We plan to use hbase rest api to perform inserts into a hbase table and would like to know if there is a way to insert multiple columns into a single column family or even multiple column families in a single call .
If not , as we plan to insert about 100+ columns for a particular record(row), this is causing us to make 100+ calls for a single row entry
You can insert multiple columns for a single/multiple column family in a single PUT operation. --data
payload contains the key
and CellSet
, CellSet contains base64 encoded value of cf:columnname
and $
contains the base64 encoded value of column value.
For example :
{ "Row":[
{
"key":"d3d3LnNvbWVzaXRlLmNvbQ==",
"Cell":[
{
"column":"QXV0aG9yczp0ZXN0MQ==", // It can be cf1:name
"$":"c29tZURhdGE="
},
{
"column":"QXV0aG9yczp0ZXN0Mg==", // It can be cf2:address
"$":"bW9yZURhdGE="
}
]
}
]
}
The final curl command will look like this:
curl -vi -X PUT \
-H "Accept: text/json" \
-H "Content-Type: text/json" \
-d '{"Row":[{"key":"d3d3LnNvbWVzaXRlLmNvbQ==","Cell":[{"column":"QXV0aG9yczp0ZXN0MQ==","$":"c29tZURhdGE="},{"column":"QXV0aG9yczp0ZXN0Mg==","$":"bW9yZURhdGE="}]}]}' \
"localhost:20550/table/rowkey"