Index with BangDB

BangDB supports primary and secondary indexes on the data which may be structured (json data) or unstructured (string or opaque). The primary index is always created when data is stored using put. The way primary index (or key) is stored in determined by how the index type was defined while creating the table. There are two ways of defining the primary index type;

  • Btree
  • Hash

The index type can be defined explictly by using table_env or by defalut it reads the value from the bangdb.config file for param BANGDB_INDEX_TYPE. However, BangDB also supports secondary indexes and user can create or drop as required using the simple APIs. The secondary indexes can be created on both opaque or json data, but since BangDB can't look inside the opaque data hence user has to specify the index name and value explicitly during put. Currently only single index can be created on opaque data but this will be extended to support any number of index as required in coming minor release

With structured data, user can create as many indexes as required and there is no theoretical limit to it. Once created user may then just simply put data and the db would add all necessary indexes apart from storing the data. The user doesn't need to define the index explicitly during put here as db can look into the json data. There are separate APIs for dealing with unstructured and structured data for indexes for simplicity and user should use appropriate API based on data type. Scan can be used to retrieve the data based on index values. Scan returns result set which can further be used for combining results from two different scans.

Here are the highlights of indexing with BangDB

  • Index - BangDB allows user to create index in unstructured data (like opaque value or string) or structured data(json data). With unstructured data user needs to tell the index name and value for each put, whereas for structured data (json data) user can just create index on field and db implicitly will add index for every put
  • Multi Index - With BangDB, user may create as many indexes as required
  • Nested Index - For json data, user may create nested index
  • Retrieve data using index - With BangDB user can get data for a given index name and value. Get returns ResultSet for such get and user may get as many ResultSets as needed and then do various operations on the ResultSets (ex; add, append, intersect etc...)
  • The index can be created using Btree or ExtHash (primary only) methods depending upon various need
  • User can create index or drop index whenever they like using the simple API

For detailed discussion see the next sections