Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>HBase stores data as byte arrays (untyped). Therefore if you perform a table scan data will be displayed in a <a href="http://hbase.apache.org/apidocs/org/apache/hadoop/hbase/util/Bytes.html#toStringBinary%28byte%5B%5D,%20int,%20int%29" rel="noreferrer">common format</a> (escaped hexadecimal string), e.g:<br> "\x48\x65\x6c\x6c\x6f\x20\x48\x42\x61\x73\x65" -> Hello HBase<br></p> <p>If you want to get back the typed value from the serialized byte array you have to do this manually. You have the following options:</p> <ul> <li>Java code (Bytes.toString(...))</li> <li>hack the <strong>to_string</strong> function in <code>$HBASE/HOME/lib/ruby/hbase/table.rb</code> : replace <em>toStringBinary</em> with <em>toInt</em> for non-meta tables</li> <li>write a get/scan <em>JRuby function</em> which converts the byte array to the appropriate type</li> </ul> <p>Since you want it HBase shell, then consider the last option:<br> Create a file get_result.rb :</p> <pre><code>import org.apache.hadoop.hbase.HBaseConfiguration import org.apache.hadoop.hbase.client.HTable import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.client.ResultScanner; import org.apache.hadoop.hbase.client.Result; import java.util.ArrayList; # Simple function equivalent to scan 'test', {COLUMNS =&gt; 'c:c2'} def get_result() htable = HTable.new(HBaseConfiguration.new, "test") rs = htable.getScanner(Bytes.toBytes("c"), Bytes.toBytes("c2")) output = ArrayList.new output.add "ROW\t\t\t\t\t\tCOLUMN\+CELL" rs.each { |r| r.raw.each { |kv| row = Bytes.toString(kv.getRow) fam = Bytes.toString(kv.getFamily) ql = Bytes.toString(kv.getQualifier) ts = kv.getTimestamp val = Bytes.toInt(kv.getValue) output.add " #{row} \t\t\t\t\t\t column=#{fam}:#{ql}, timestamp=#{ts}, value=#{val}" } } output.each {|line| puts "#{line}\n"} end </code></pre> <p>load it in the HBase shell and use it:</p> <pre><code>require '/path/to/get_result' get_result </code></pre> <p>Note: modify/enhance/fix the code according to your needs</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload