|New fast key-value storage library|
|Written by Kay Ewbank|
|Thursday, 04 August 2011|
A fast and lightweight key/value database library that supports ordered data has been released by Google. LevelDB is being made available as open source under a BSD-style license.
According to a blog post from Google’s open source blogspot, LevelDB is a C++ library that is suitable for use in contexts such as by a web browser to store a cache of recently accessed web pages, or by an operating system to store the list of installed packages and package dependencies, or by an application to store user preference settings. LevelDB is also being used in forthcoming versions of the Chrome browser, which includes an implementation of the IndexedDB HTML5 API that is built on top of LevelDB. LevelDB has already been ported to a variety of Unix based systems, Mac OS X, Windows, and Android.
The Google team says that LevelDB differs from similar systems like SQLite and Kyoto Cabinet by being optimized for batch updates that modify many keys scattered across a large key space and point out that this is an important requirement for efficiently updating an inverted index that does not fit in memory.
The keys and values in LevelDB are arbitrary byte arrays, and data values are stored by key. The basic operations you can make use of are Put(key,value), Get(key), and Delete(key). You can make multiple changes in one atomic batch, and create a transient snapshot to get a consistent view of data. Forward and backward iteration is supported over the data, and data is automatically compressed using the Snappy compression library.
External activity (file system operations etc.) is relayed through a virtual interface so users can customize the operating system interactions, and callers can provide a custom comparison function to override the sort order.
You shouldn't think of LevelDB as a database in the way that a SQL database would be used. It doesn't have a relational data model, it doesn't support SQL queries, and it has no support for indexes. Only a single process (possibly multi-threaded) can access a particular database at a time, and there’s no client-server support built in to the library. An application that needs such support will have to wrap its own server around the library.
LevelDB is available on Google Code: http://code.google.com/p/leveldb
|Last Updated ( Thursday, 04 August 2011 )|