Index – BangDB 2.0 supports several indexing methods to be able to query them efficiently at run time
BangDB supports primary and secondary index 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 is determined by how the index type was defined while creating the table. There are two ways of defining the primary index type;
The index type can be defined explicitly by using TableEnv type or by default it reads the default value from the bangdb.config file for param BANGDB_INDEX_TYPE. However, BangDB also supports many kinds of other 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 indexes name and value explicitly during put. 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 indexes 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 many different scans.
Following indexing techniques could be used depending upon the use cases;
Let’s discuss all these in detail different subsections.