On this page

BRS Commands

BRS Commands / Queries using CLI

BangDB Resource Server Commands – 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

create bucket mybucket bucket [ mybucket ] 
//created

To see the buckets in the db

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

putfile /home/sachin/Documents/abc.txt into mybucket where filekey = "abc_file_key"

successfully put the file

Show the files in the bucket

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 see 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”

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

count from mybucket total num of files = 1

To delete the file

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

To drop the bucket

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

 

Was this article helpful to you? Yes No