bg
Helper types – Embedded – BangDB = NoSQL + AI + Stream

Helper types – Embedded

chevron

BangDB helper types

db_param

C++

Selected

Java

Selected

b_param helps set the various configuration for the BangDB. It has following configurable parameter;

host : sets the host ip of the server, not relevant for embedded>
port : sets the port id of the server, not relevant for embedded
userid : BangDB uses default id as of now, will change in future
password : BangDB used default password as of now, will change in future
init_sock_conn : boolean to specify if we need to init the socket connection, not relevant for embedded
tls_conn : whether to use ssl/tls based secure channel or not, not relevant for BangDB embedded
tran_type : Whether the db should be opened in transaction mode or not, following trantypes are available;

enum db_transaction_type { DB_TRANSACTION_NONE, DB_OPTIMISTIC_TRANSACTION, DB_PESSIMISTIC_TRANSACTION, };
Only DB_OPTIMISTIC_TRANSACTION is supported

config_path : path to the bangdb.config file
dbPath : path for db to keep files
dbLogPath : path for db to keep log files
dbArchivePath : in case of archival, this path should be used to keep archived data

DBParam helps set the various configuration for the BangDB. It has following configurable parameter;

host : sets the host ip of the server, not relevant for embedded
port : sets the port id of the server, not relevant for embedded
userid : BangDB uses default id as of now, will change in future
password : BangDB used default password as of now, will change in future
init_sock_conn : boolean to specify if we need to init the socket connection, not relevant for embedded
tls_conn : whether to use ssl/tls based secure channel or not, not relevant for BangDB embedded
tran_type : Whether the db should be opened in transaction mode or not, following trantypes are available;

enum DBTransactionType { DB_TRANSACTION_NONE, DB_OPTIMISTIC_TRANSACTION, DB_PESSIMISTIC_TRANSACTION, };
Only DB_OPTIMISTIC_TRANSACTION is supported

config_path : path to the bangdb.config file
dbPath : path for db to keep files
dbLogPath : path for db to keep log files
dbArchivePath : in case of archival, this path should be used to keep archived data

table_env

C++

Selected

Java

Selected

Table environment defines the way table should be created. This is very important helper type and should be used carefully and in right manner to create a table
Here are the parameter for the table environment;
db_type : type of db, in-memory or persistent as well. Default is persistent.

It is selected from following enum;

//types of db enum bangdb_persist_type { INMEM_ONLY, //only RAM based, cache enabled (no overflow to disk, ideally overflow to other RAM) INMEM_PERSIST, //disked backed, cache enabled (over flow to disk) PERSIST_ONLY, //cache disabled, direct file IO INVALID_PERSIST_TYPE };
Most of the time user is not required to set this, default is fine

idx_type : type of index for primary key, how primary keys would be stored.
It is driven from following enum;
//types of pk arrangement enum bangdb_index_type { HASH, EXTHASH, BTREE, HEAP, INVALID_INDEX_TYPE, };
Default is BTREE, and it’s good for most of the cases.

key_sz : in case of string key, what’s the maximum size of the primary key. Please note large size is not good for performance reasons, typically it should be less than 64 bytes, but if it has to be more, please set it accordingly, but not good from efficiency perspective. Note than if key is tried to be inserted, and size of key is more than key_sz, then operation will be rejected, hence set it carefully. Default is 24 or 32 bytes

table_sz_hint : this is optional, and it helps tell the db how large this table is going to be in case it’s created. Good for db optimization. Please note this only affects the db in run time, therefore it could be reset while db restarts etc.

log_sz_mb : Usually default is good, however you may use to reset it. This tells what the size of a single log file is. This log file is write ahead log, where db writes metadata and/or data for atomicity, transction and data recovery perspective.

table_log_type : BangDB can create write ahead log in shared and in private mode. Shared mode will have a log structure shared by all tables, whereas private log will be created for each table. It’s always good to use shared (default) log type unless there is a security or other reason to use private.
Here are the options;
//log type enum bangdb_log_type { SHARED_LOG, PRIVATE_LOG, };
table_type : The type of the table. Default is NORMAL_TABLE, but user must change this as per requirement. This is a must specified parameter and user must define it properly. Here are the options;
enum bangdb_table_type { NORMAL_TABLE, WIDE_TABLE, INDEX_TABLE, PRIMITIVE_TABLE_INT, PRIMITIVE_TABLE_LONG, PRIMITIVE_TABLE_STRING, LARGE_TABLE, BANGDB_TABLE_INVALID };
wal_enabled : this tells if write ahead log is enabled or not. User can switch on or off it using this. Default is ON.

Autocommit : this is always on

sort_method : When BTREE for index is used then we have to define the sort method. Here are options;
enum bangdb_key_sort_method { LEXICOGRAPH = 1, QUASI_LEXICOGRAPH = 2, };
default is QUASI_LEXICOGRAPH = 2
sort_direction : user can define if sort is in increasing or decreasing order. Here are options;
enum bangdb_key_sort_direction { SORT_ASCENDING = 3, SORT_DESCENDING = 4, SORT_INVALID };
default is SORT_ASCENDING
key_type : user may override key type as well. Here are options;
enum bangdb_key_type { NORMAL_KEY = 1, COMPOSITE_KEY = 3, NORMAL_KEY_LONG = 10, };
defaut is NORMAL_KEY
table_sub_type : to set sub type of the table. Here are the options;
enum bangdb_table_subtype { BANGDB_SW_TABLE, BANGDB_TOPK_TABLE, NON_ANALYTICAL_TABLE, INDEXBTREE_TABLE, DUPLINDEX_TABLE_NOLOG, BANGDB_SW_INVALID, };
Default is NON_ANALYTICAL_TABLE
allow_duplicate : Sets if duplicate keys are allowed.
version_type : When duplicate keys are set for primary or secondary, then to have data version defined for proper retrieval of data, we should set this. The options are;
enum bangdb_version_value { BANGDB_DATA_VERSION_INVALID = 0, BANGDB_DATA_VERSION_VALID = 1, };
Default is BANGDB_DATA_VERSION_INVALID
allow_rev_idx : set to allow reverse indexing. Note that it can only be done for WIDE_TABLE

Table environment defines the way table should be created. This is very important helper type and should be used carefully and in right manner to create a table
Here are the parameter for the table environment;

db_type : type of db, in-memory or persistent as well. Default is persistent.

It is selected from following enum;

//types of db BangDBPersistType { INMEM_ONLY, //only RAM based, cache enabled (no overflow to disk, ideally overflow to other RAM) INMEM_PERSIST, //disked backed, cache enabled (over flow to disk) PERSIST_ONLY, //cache disabled, direct file IO INVALID_PERSIST_TYPE };
Most of the time user is not required to set this, default is fine
idx_type : type of index for primary key, how primary keys would be stored.
It is driven from following enum;
//types of pk arrangement BangDBIndexType { HASH, EXTHASH, BTREE, HEAP, INVALID_INDEX_TYPE, };
Default is BTREE, and it’s good for most of the cases.

key_sz : in case of string key, what’s the maximum size of the primary key. Please note large size is not good for performance reasons, typically it should be less than 64 bytes, but if it has to be more, please set it accordingly, but not good from efficiency perspective. Note than if key is tried to be inserted, and size of key is more than key_sz, then operation will be rejected, hence set it carefully. Default is 24 or 32 bytes

table_sz_hint : this is optional, and it helps tell the db how large this table is going to be in case it’s created. Good for db optimization. Please note this only affects the db in run time, therefore it could be reset while db restarts etc.

log_sz_mb : Usually default is good, however you may use to reset it. This tells what the size of a single log file is. This log file is write ahead log, where db writes metadata and/or data for atomicity, transction and data recovery perspective.

table_log_type : BangDB can create write ahead log in shared and in private mode. Shared mode will have a log structure shared by all tables, whereas private log will be created for each table. It’s always good to use shared (default) log type unless there is a security or other reason to use private.
Here are the options;
//log type BangDBLogType { SHARED_LOG, PRIVATE_LOG, };
table_type : The type of the table. Default is NORMAL_TABLE, but user must change this as per requirement. This is a must specified parameter and user must define it properly. Here are the options;
BangDBTableType { NORMAL_TABLE, WIDE_TABLE, INDEX_TABLE, PRIMITIVE_TABLE_INT, PRIMITIVE_TABLE_LONG, PRIMITIVE_TABLE_STRING, LARGE_TABLE,
BANGDB_TABLE_INVALID };
wal_enabled : this tells if write ahead log is enabled or not. User can switch on or off it using this. Default is ON.

Autocommit : this is always on

sort_method : When BTREE for index is used then we have to define the sort method. Here are options;
BangDBSortMethod { LEXICOGRAPH = 1, QUASI_LEXICOGRAPH = 2, };
default is QUASI_LEXICOGRAPH = 2
sort_direction : user can define if sort is in increasing or decreasing order. Here are options;
BangDBSortDirection { SORT_ASCENDING = 3, SORT_DESCENDING = 4, SORT_INVALID };
default is SORT_ASCENDING
key_type : user may override key type as well. Here are options;
BangDBKeyType { NORMAL_KEY = 1, COMPOSITE_KEY = 3, NORMAL_KEY_LONG = 10, };
defaut is NORMAL_KEY
table_sub_type : to set sub type of the table. Here are the options;
BangDBSubType { BANGDB_SW_TABLE, BANGDB_TOPK_TABLE, NON_ANALYTICAL_TABLE, INDEXBTREE_TABLE, DUPLINDEX_TABLE_NOLOG, BANGDB_SW_INVALID, };
Default is NON_ANALYTICAL_TABLE
allow_duplicate : Sets if duplicate keys are allowed.
version_type : When duplicate keys are set for primary or secondary, then to have data version defined for proper retrieval of data, we should set this. The options are;
BangDBVersionValue { BANGDB_DATA_VERSION_INVALID = 0, BANGDB_DATA_VERSION_VALID = 1, };
Default is BANGDB_DATA_VERSION_INVALID
allow_rev_idx : set to allow reverse indexing. Note that it can only be done for WIDE_TABLE