On this page

BangDBDatabase

BangDB Database Type

API for client application development

BangDB Database represents the database within BangDB. The database contains rest of the entities within BangDB, for example: table, stream, ML etc.
We need to create the database object to be able to do anything within the database

C++

Selected

Java

Selected

To create the database object

 BangDBDatabase(const char *dbName, BangDBEnv *env, DBParam *dbParam = NULL); 
To get the table or create a new table
 BangDBTable *getTable(const char *tblName, TableEnv *tblenv = NULL, OpenType openflag = OPENCREATE); 
Before creating new table, we should set the TableEnv object properly based on what kind of table we wish to create. There are several properties that we could set for the table. Please see the section on “table_env” OpenType has following options;
 OPENCREATE, // to create new or open if table is not existing TRUNCOPEN, // hardly used (truncate and open) JUSTOPEN // open only if exists, else fail 
It returns NULL for error To get the table stats, the details of the table
 const char *getTableStats(const char *tblName, bool verbose); 
It returns NULL for error or json describing the table and it’s stats To get database stats
 const char *getStats(bool verbose = true); 
It returns NULL for error or json describing the database and it’s stats To get table reference (for already created or opened table)
 TableEnv *getTableEnv(const char *tblName, long tblId = 0); 
It returns NULL if table doesn’t exist. Please note this is the reference to the table and should not be deleted To drop a table
 int dropTable(BangDBTable **tbl); 
It returns -1 for error BangDB supports transaction for set of operations. To get the transaction reference
 void beginTransaction(Transaction *txn); long commitTransaction(Transaction *txn); void abortTransaction(Transaction *txn); 
Please see “bangdb transaction” for details to dumpdata on the disk
 int dumpData(); 
This may be required when you simply want to force table contents on disk for copying the files etc. It returns -1 for error To check if table exist or not
 short doesTableExist(const char *tblName, long tblId = 0); 
To get number of tables
 long getNumTables(int flag = 1); 
To get the list of the table names
 const char *getTableList(); 
To get the db param
 DBParam *getParam(); 
To get the name of the table
 const char *getName(); 
To get the type of the table
 TableType getTableType(const char *tblName, long tblId = 0); 
To get the table id
 long getTableId(const char *tblName); 
To check if table is valid
 bool isValid(); 

 

 

Was this article helpful to you? Yes No