/leveldb-CompositeIndex

Stand Alone Secondary Index on top of LevelDB based on composite prefix based key.

Primary LanguageC++BSD 3-Clause "New" or "Revised" LicenseBSD-3-Clause

leveldb_standalone-index with composite prefix index.
Authors: Mohiuddin Abdul Qader (mabdu002@cs.ucr.edu)
leveldb version: 1.14.0

The code under this directory implements a system for maintaining a
persistent key/value store with stand alone index support for secondary attribute where secondary index is composite <seckey+primarykey> index. 



The Public APIs:

1. static Status Open(const Options& options, const std::string& name, DB** dbptr);

This API creates/open a database. The new addition to original leveldb option is that primary attribute and secondary attribute name has to be set in database options. Here, options.isSecondaryDB has to be set to false.
Options{
 bool using_s_index;
 std::string primary_key;
 std::string secondary_key;
}

2. Status Put(const WriteOptions& o, const Slice& val);

This API writes a record in database. It will parse the the primary key and secondary key from the val argument by checking primary and secondary attribute that has been set when the database was created.


3. Status Delete(const WriteOptions& options, const Slice& key);

This API deletes a record from database with the specified primary key. This is same as original leveldb Delete API.


4. Status Get(const ReadOptions& options, const Slice& key, std::string* value);

This API reads a record from database with the specified primary key. This is same as original leveldb Get API.


5. virtual Status Get(const ReadOptions& options, const Slice& skey, std::vector<RangeKeyValuePair>* value);

This API is the new LOOKUP procedure which takes a secondary key and ReadOptions as input argument. A new field in ReadOptions (num_records) has been added which has to be set to the number of K outputs that has to be  returned. This API then returns the most recent top-K a record from database containing the specified secondary key.


6. virtual Status RangeLookUp(const ReadOptions& options, const Slice& startSkey, const Slice& endSkey,
                   std::vector<RangeKeyValuePair>* value);
                   
This API is the new Range LOOKUP procedure which takes a secondary start key and end key and ReadOptions as input argument. A new field in ReadOptions (num_records) has been added which has to be set to the number of K outputs that has to be  returned. This API then returns the most recent top-K a record from database containing the specified secondary key range.
                   

The return value KeyValuePair contains key and value of the resulting records.

struct RangeKeyValuePair {
  std::string key;
  std::string value;
  uint64_t sequence_number; 
}

Implementation Details:


See doc/index.html for more explanation on original leveldb.
See doc/impl.html for a brief overview of the implementation of original leveldb.
See doc/Header files.txt for the guide to header files.