BRS Commands – Cli – BangDB = NoSQL + AI + Stream

BRS Commands – Cli


BRS Commands

Queries for BRS using cli

BRS is short form for BangDB Resource Server. BRS is for dealing with large files or objects, where the file / object size could go from few KBs to several GBs.
BRS allows users to create buckets and then put the files or objects in these buckets. There are two default buckets that BangDB creates when it creates a db, namely "ml_bucket_info" and "udf_bucket_info". These are for storing ML related files and user defined functions respectively.

We can interact with BRS using the commands from cli as follows.

Create buckets

bangdb> create bucket mybucket bucket [ mybucket ] created

To see the buckets in the db

bangdb> show buckets +-----------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+ |key |val | +-----------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+ |mybucket |{"bucket_name":"mybucket","access_key":"brs_access_key","secret_key":"secret_key", | | |"num_objects":" 0","create_time":1611991680677004,"ttl":0,"_pk":"mybucket","_v":1} | +-----------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+ |ml_bucket_info |{"bucket_name":"ml_bucket_info","access_key":"brs_access_key","secret_key":"brs_secret_key", | | |"ttl":604800,"num_objects":" 0","create_time":1611919352456474,"_pk":"ml_bucket_info","_v":1} | +-----------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+ |bangdb_udf_bucket |{"bucket_name":"bangdb_udf_bucket","access_key":"brs_access_key","secret_key": | | |"brs_secret_key","ttl":604800,"num_objects":" 0","create_time":1611919352512129," | | |_pk":"bangdb_udf_bucket","_v":1} | +-----------------------------+------------------------------------------------------------------------------------------------------------------------------------------------+

To put file in the buckets

Let's say we wish to upload a file name abc.txt, present at /home/sachin/Documents
Size of the file is around 17MB
bangdb> putfile /home/sachin/Documents/abc.txt into mybucket where filekey = "abc_file_key" successfully put the file

Show the files in the bucket

bangdb> show from mybucket { "total_keys" : 1, "key_list" : [ { "key" : "abc_file_key:0:17:17254154:1612102871582854" } ] } success
The file is stored in BRS in slices and if we read the key returned by the command "show from mybucket", we will se that the file has been sliced into 17 parts and stored in the db. When we retrieve the file, db combines all these slices and returns the entire file

To get the file from the BRS

Here we call the getfile command for the given file key and store the retrieved file at "/home/sachin/Document/xyz.txt"
bangdb> getfile /home/sachin/Documents/xyz.txt from mybucket where filekey = "abc_file_key" success in getting the file

To count the number of items in the bucket

bangdb> count from mybucket total num of files = 1

To delete the file

bangdb> delfile from mybucket where filekey = "abc_file_key" file deleted successfully

To drop the bucket

bangdb> drop bucket mybucket do you wish to delete the bucket and all its files? [ yes | no ]: yes bucket [ mybucket ] successfully dropped