How to add a column to a column family in hbase

I am new to hbase. Can you show me how to add a column to a column family. I have the following data:

{ name: abc addres: xyz } 

I have a test table with a group character. How can I add a name and address as a column for this person. Please show me on the hbase command line as well as in java.

+6
source share
2 answers

HBase Shell:

From the Hbase shell wiki: http://hbase.apache.org/book.html#shell

Place the cell value in the specified table / row / column and, if necessary, the coordinates of the timestamp. To put the cell value in the table 't1' in the row 'r1' under the column 'c1' marked by the time 'ts1', do:

 hbase> put 't1', 'r1', 'c1', 'value', ts1 

something like this in your case:

 hbase> put 'test', 'yourRow', 'person:name', 'abc' hbase> put 'test', 'yourRow', 'person:address', 'xyz' 

In Java:

 Configuration config = HBaseConfiguration.create(); HTable table = new HTable(config, "test"); Put p = new Put(Bytes.toBytes("yourRow")); p.add(Bytes.toBytes("person"), Bytes.toBytes("name"), Bytes.toBytes("abc")); table.put(p); 
+15
source

JP Bond gave you an example of the code you need - I just wanted to add that one of the nice things about HBase is that it is sparse (i.e. does not reserve column space for rows with values). One of the features of this design decision is that you can create a new column (column family + qualifier) ​​just by writing for it.

+6
source

Source: https://habr.com/ru/post/925253/


All Articles