BangDB ML Helper offers several APIs to help simplify the ML related activities. The type offers features from Training model, prediction, versioning of model, deployment to managing large files and binary objects related to ML. Check out the few real world examples for to learn more or try them out on BangDB.
The key is the id of the file fpath takes the path to the file including the file name.
It returns -1 for error.
This is to train a model we should call trainModel API. This API returns immediately and if successful then it schedules training of the model. User should call getModelStaus() for sometime until it returns the end status.
inttrainModel(constchar*req)
It takes a training request and returns status of the training request. It returns -1 for error.
To get status of the model when training request is fired
The above is true for ML related model status. For IE (Information Extraction) related model status use following:
It returns NULL for error or errcode as -1, else errcode for success. User should free the memory using delete[].
To delete the mode
intdelModel(constchar*req)
This delete model by passing req parameter. req = {"schema_name":,"model_name":} It returns -1 for error.
To delete training request
intdelTrainRequest(constchar*req)
This is to delete the training request. Helpful when training got stuck for some reasons and the status was not updated properly. It returns -1 for error.
It gets the object(binary or otherwise) from the given bucket, key. It fills data with the object and sets the datlen as length or size of the object. It returns -1 for error.
To delete a file from a bucket
intdelFile(constchar*bucket_info,constchar*key)
It returns -1 for error.
To delete a bucket
intdelBucket(constchar*bucket_info)
It returns -1 for error.
To count the number of buckets
longcountBuckets()
It returns -1 for error or count for success.
To get number of slices are there for the given file
Since BRS (bangdb resource server) stores large files and objects in chunks, therefore we can count how many slices are there for the given file (key) by calling this function. It returns -1 for error for count for success.
To count object in a given bucket
longcountObjects(constchar*bucket_info)
It returns -1 for error.
To get details of all the objects in a given bucket
char*countObjectsDetails(constchar*bucket_info)
It returns NULL for error else the details. User should free memory using delete[].
This returns json string with the list of objects in a given bucket for a given key or for all keys It returns NULL for error else the object list. User should free the memory of returned data using delete[].
To get list of buckets present
char*listBuckets(constchar*user_info)
This returns the list of all buckets for the user given by user_info which looks like following:
{"access_key":"akey","secret_key":"skey"}
It returns NULL for error else the object list. User should free the memory of returned data using delete[].
This is to train a model we should call trainModel API. This API returns immediately and if successful then it schedules training of the model. User should call getModelStaus() for sometime until it returns the end status.
publicinttrainModel(String req)
It takes a training request and returns the status of the training request. The training request looks like following:
The train_state actually tells the status of the model. The value for train_state are as following:
The above is true for ML related model status. For IE (Information Extraction) related model status use following:
To set the status of a model
publicintsetModelStatus(String req)
This sets the status for a particular train request. The req is as follows:
req ={"schema-name":,"model_name":, “status”:}
Upon success it returns 0 else -1 for error.
To delete a model
publicintdelModel(String req)
This is used to delete the model by passing req parameter
req ={"schema_name":,"model_name":}
To delete the training request
publicintdelTrainRequest(String req)
This is to delete the training request. Helpful when training got stuck for some reasons and the status was not updated properly. Here is how req looks like:
Given a request get the prediction status. The req is as follows:
req ={"schema-name":,"model_name":}
It returns NULL for error or errcode as -1 else errcode.
To delete prediction request
publicintdelPredRequest(String req)
Deletes the request. The input param req is as follows:
req ={"schema-name":,"model_name": “file_name”:}
It returns 0 for success and -1 for error.
To get list of all the training request
publicResultSetgetTrainRequests(String req)
This returns all the training requests made so far for a schema. The prev_rs should be NULL for the first call and for subsequent calls, just pass the previous rs. Upon success it returns 0 else -1 for error.
To get training request from the ml housekeeping
publicStringgetRequestDetail(String req)
It returns response with status or NULL for error or if req not found.
To get the buckets list for a user
publicStringlistBuckets(String req)
This returns the list of all buckets for the user given by req which looks like following:
This returns a json string with the list of objects in a given bucket for a given key or for all keys (in case of skey is NULL). It may return NULL for error as well. list_size_mb defines the max size of the list, by default it would return 2MB of data or less.
To count number of models for a given schema
publiclonggetModelCount(String req)
This counts the models for a given schema else returns -1 for error.
For admin settings
publicintreinitMDM(String req)
To check if the BRS is local or its a distributed system
publicbooleanisBRSLocal()
Returns if BRS is local, useful for distributed mode or server.
The key is the name/id of the file to be downloaded and bucketinfo details information about the bucket from which the file has to be downloaded and fpath is the location on the local system where to download the file with name of the file as fname. It returns 0 for success else -1 for error.
BRS stores large files and objects in chunks, therefore we can count how many slices are there for the given file (key) by calling this function. It returns count of slices else -1 for error.