0

我在 Pig Latin 中使用 org.apache.pig.backend.hadoop.hbase.HBaseStorage()。是否可以获得一个值的所有版本?

在 HBase Shell 中,命令是:

get 'table', 'cf:column', {COLUMN => 'cf:column', VERSIONS => 5}

猪也可以吗?

输入样本:

我的 HBase 表如下所示:

hbase(main):019:0> put 'mytable', 'mykey1', 'cf:onlyoneclumn', 'value 1'
0 row(s) in 0.0070 seconds

hbase(main):020:0> put 'mytable', 'mykey1', 'cf:onlyoneclumn', 'value 2'
0 row(s) in 0.0070 seconds

hbase(main):021:0> put 'mytable', 'mykey1', 'cf:onlyoneclumn', 'value 3'
0 row(s) in 0.0050 seconds

hbase(main):022:0> put 'mytable', 'mykey1', 'cf:onlyoneclumn', 'value 4'
0 row(s) in 0.0050 seconds

hbase(main):023:0> get 'mytable', 'mykey1'
COLUMN                CELL                                                      
 cf:onlyoneclumn      timestamp=1376470137654, value=value 4                    
1 row(s) in 0.0370 seconds

hbase(main):024:0> get 'mytable', 'mykey1',  {COLUMN => 'cf:onlyoneclumn', VERSIONS => 5}
COLUMN                CELL                                                      
 cf:onlyoneclumn      timestamp=1376470137654, value=value 4                    
 cf:onlyoneclumn      timestamp=1376470136632, value=value 3                    
 cf:onlyoneclumn      timestamp=1376470135411, value=value 2                    
3 row(s) in 0.0140 seconds
4

1 回答 1

1

当前(0.11.1)HBaseStorage 是 pig 附带的用于读取 HBase 表的类,它不支持它。它只支持以下

optString - Loader options. Known options:
-loadKey=(true|false) Load the row key as the first column
-gt=minKeyVal
-lt=maxKeyVal
-gte=minKeyVal
-lte=maxKeyVal
-limit=numRowsPerRegion max number of rows to retrieve per region
-delim=char delimiter to use when parsing column names (default is space or comma)
-ignoreWhitespace=(true|false) ignore spaces when parsing column names (default true)
-caching=numRows number of rows to cache (faster scans, more memory).
-noWAL=(true|false) Sets the write ahead to false for faster loading.
-minTimestamp= Scan's timestamp for min timeRange
-maxTimestamp= Scan's timestamp for max timeRange
-timestamp= Scan's specified timestamp
-caster=(HBaseBinaryConverter|Utf8StorageConverter) Utf8StorageConverter is the default To be used with extreme caution,

因为这可能会导致数据丢失(请参阅 http://hbase.apache.org/book.html#perf.hbase.client.putwal)。

您可以做的是获取HBaseStorage 代码,并构建您自己的支持它的加载器

于 2013-08-14T07:00:39.793 回答