bg
BangDBDatabase – Embedded Java – BangDB = NoSQL + AI + Stream

BangDBDatabase – Embedded Java

chevron

BangDBDatabase

Embedded, Java

public BangDBDatabase(String dbName, DBParam dbparam)
Given a dbname and dbparam, this will create the BangDBDatabase object. DBParam is defined below for reference.
public BangDBTable getTable(String tableName, TableEnv tenv, OpenType openType)
Returns BangDBTable object for given tableName, tenv. OpenType when null, then OPENCREATE is used as default
public void beginTransaction(Transaction txn)
To begin transaction, pass the Transaction object. Txn cannot be null
public long commitTransaction(Transaction txn)
To commit transaction, pass the Transaction object. Txn cannot be null. It returns txn number for success or -1 for error
public void abortTransaction(Transaction txn)
To abort transaction, pass the Transaction object. Txn cannot be null
public int dumpData()
To dump data on the file system, syncing all data from memory to filesystem, this api can be called. It returns 0 for success else -1 for error
public int dropTable(BangDBTable tbl)
Given a BangDBTable, this api will drop the table from the database, which would erase all data and other information for the given table. It returns 0 for success else -1 for error
public boolean doesTableExist(String tblName, long tblId)
Given tblName or tblId, this can check if the table is existing. If tblId is less than 0 then tblName would be used, else tblId is used. It returns true if exists else false
// flag = 1 for open, 2 for closed, 3 for all
public int getNumTables(int flag)
This will return number of tables in the database. Flag set as 1 would return count for open tables only, whereas if set to 2 then it will return count for closed tables only. Flag set as 3 would return for both open and close. For error it returns -1.
public String getTableList()
This will return list of table in json format, else null for error
public String getStats(boolean verbose) This api would return json string containing the statistics of the database. If verbose then it will returns lots of details. It may return null for error
public String getTableStats(String tblName, boolean verbose)
This api would return json string containing the statistics of the given table. If verbose then it will returns lots of details. It may return null for error
public String describeDatabase()
This api would return json string describing the database. It may return null for error
public DBParam getParam()
This returns dbParam used to create the DB object
public String getName()
This returns name of the database or null for error
public TableType getTableType(String tblName, long tblId)
This returns table type for the given tblName or tblId. If tblId is positive then it will be used else for negative value tblName will be used
public TableEnv getTableEnv(String tblName, long tblId)
This returns table environment for the given tblName or tblId. If tblId is positive then it will be used else for negative value tblName will be used. For error, null may be returned
public long getTableId(String tblName)
Given a tblName, this will return table id, else -1 for error
public String add_udf(String udf_json)
This will add udf to the database which could be later used for computation. Here is the format of the udf_json;
{"name":"mylib", "base_class":"baseclass", "create_func":"maker","type":1, "src":"src_loc", "srctype":1, "bucket_info":{}}
it will return json string containing errcode, 0 for success and -1 for error
public String del_udf(String udf_name)
Given a udf_name this api will delete the udf from the database. it will return json string containing errcode, 0 for success and -1 for error
public String exec_udf(String req_json)
This will allow user to execute udf given the request json. req_json looks like following;
{"name":, "id", "argv":["a", 1, 0.3], "exp-type"}
and the return value is also a json and it looks like;
{"ret-val":"abc"}
public void closeDatabase(CloseType dbclose)
To close database, call this function. Dbclose when null, Default option is used