【问题标题】:Put values inside multiple columns in same family in Hbase将值放在 Hbase 中同一族的多个列中
【发布时间】:2017-11-16 09:29:01
【问题描述】:

我正在寻找一个 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 命令中将值插入到属于同一列族的多个列中?

【问题讨论】:

    标签: hadoop hbase


    【解决方案1】:

    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,这很好。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-15
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多