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++
Java

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();

To create the database object

public BangDBDatabase(String dbName, BangDBEnv env, DBParam dbparam)

It returns null for error or json describing the database. To get the table or create a new table

public BangDBTable getTable(String tableName, TableEnv tenv, OpenType openType)

Before creating new table, we should set the table_env 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 
JUSTOPEN, // open only if exists, else fail

It returns null for error. To get the table stats, the details of the table

public String getTableStats(String tblName, boolean verbose)

It returns null for error or json describing the table and it's stats. To get database stats

public String getStats(boolean verbose)

It returns null for error or json describing the database and it's stats. To get table reference (for already created or opened table)

public TableEnv getTableEnv(String tblName, long tblId)

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

public int dropTable(BangDBTable tbl)

It returns -1 for error BangDB supports transaction for set of operations. To get the transaction reference

public void beginTransaction(Transaction txn)

To commit the transaction

public long commitTransaction(Transaction txn)

To abort the transaction

public void abortTransaction(Transaction txn)

Please see "bangdb Transaction" for details to dumpdata on the disk

public 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 exists or not

public boolean doesTableExist(String tblName, long tblId)

To get number of tables in the db

public int getNumTables(int flag)

To get the table list

public String getTableList()

To get the DBParam for the db

public DBParam getParam()

To get the name of the db

public String getName()

To get the table type of the given table

public TableType getTableType(String tblName, long tblId)

To get the id of the table

public long getTableId(String tblName)

BangDB stream processing supports UDFs (user defined functions), to deal with UDFs

String add_udf(String udf_json)
String del_udf(String udf_name)
String exec_udf(String req_json)

The arguments for all these methods are json, these are described in detail in UDF section.