我正在寻找一个 Hbase put 命令,它可以将值插入到 Hbase 表中同一行键的同一列族的多个列中。 假设我有一个名为“employee”的 hbase 表,其中包含 1 个列族“data”
我正在应用下面的命令,但它抛出错误。
PUT 'employee' 'data:column1', 'column1_val', 'data:column2', 'column_val2'
ERROR: no method 'add' for arguments (org.jruby.java.proxies.ArrayJavaProxy,org.jruby.RubyNil,org.jruby.RubyString,org.jruby.java.proxies.ArrayJavaProxy) on Java::OrgApacheHadoopHbaseClient::Put available overloads:
但是,如果我为每个列值插入尝试单独的 put 命令,它工作正常。
PUT 'employee' 'data:column1', 'column1_val'
PUT 'employee' 'data:column2', 'column2_val'
有没有办法在单个 put 命令中将值插入属于同一列族的多个列?
最佳答案
HBase shell 不支持一条语句中的多列
hbase(main):002:0> help "put"
Put a cell 'value' at specified table/row/column and optionally
timestamp coordinates. To put a cell value into table 'ns1:t1' or 't1'
at row 'r1' under column 'c1' marked with the time 'ts1', do:
hbase> put 'ns1:t1', 'r1', 'c1', 'value'
hbase> put 't1', 'r1', 'c1', 'value'
hbase> put 't1', 'r1', 'c1', 'value', ts1
hbase> put 't1', 'r1', 'c1', 'value', {ATTRIBUTES=>{'mykey'=>'myvalue'}}
hbase> put 't1', 'r1', 'c1', 'value', ts1, {ATTRIBUTES=>{'mykey'=>'myvalue'}}
hbase> put 't1', 'r1', 'c1', 'value', ts1, {VISIBILITY=>'PRIVATE|SECRET'}
The same commands also can be run on a table reference. Suppose you had a reference
t to table 't1', the corresponding command would be:
hbase> t.put 'r1', 'c1', 'value', ts1, {ATTRIBUTES=>{'mykey'=>'myvalue'}}
不过,您可以创建多个具有相同时间戳的 put,这没问题。
关于hadoop - 将值放在 Hbase 中同一系列的多个列中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47325944/