【问题标题】:Using pig with HBase to get timestamp of records使用 pig 和 HBase 来获取记录的时间戳
【发布时间】:2013-06-14 11:49:44
【问题描述】:

我的任务是获取 HBase 表中数据的时间戳。如果我在 hbase shell 的表上执行scan,我可以看到给定行的时间戳,例如,

scan 'mytable', {LIMIT => 1}
ROW                          COLUMN+CELL                                                                       
 00001000715ce3d569ee256153d column=0:, timestamp=1326362691000, value=1320073315600x600                       
 f31db629b                                                                                                     
1 row(s) in 1.9800 seconds

如果我尝试在 grunt shell 中从这个表中加载一些数据,那么我看不到时间戳,只有值。

tableinput = LOAD 'hbase://imagestore-new' 
USING org.apache.pig.backend.hadoop.hbase.HBaseStorage('0: ', '-loadKey true')
AS (id:bytearray, thingy:chararray);
illustrate tableinput;

这给了我:

--------------------------------------------------------------------------------
| tableinput     | id:bytearray                         | thingy:chararray     | 
--------------------------------------------------------------------------------
|                | 0000bizrad8156b98bffa60d8968fba0f326 | {=1348461029160x130} | 
--------------------------------------------------------------------------------

我严重缺乏关于如何将 HBaseStorage 与 pig 一起使用的信息;我唯一能找到的是 API 条目 (http://pig.apache.org/docs/r0.9.1/api/org/apache/pig/backend/hadoop/hbase/HBaseStorage.html)。我怀疑有一种方法可以在对 HBaseStorage 的调用中将其添加为配置,可能类似于'-loadKey true',但我不知道在哪里可以找到此信息。请帮忙!

【问题讨论】:

    标签: hbase apache-pig


    【解决方案1】:

    你现在实际上不能这样做。这是当前可用键的列表(您可以在 HBaseStorage 的构造函数 javadoc 中看到它们):

    /**
     * Constructor. Construct a HBase Table LoadFunc and StoreFunc to load or store.
     * @param columnList
     * @param optString Loader options. Known options:<ul>
     * <li>-loadKey=(true|false)  Load the row key as the first column
     * <li>-gt=minKeyVal
     * <li>-lt=maxKeyVal
     * <li>-gte=minKeyVal
     * <li>-lte=maxKeyVal
     * <li>-limit=numRowsPerRegion max number of rows to retrieve per region
     * <li>-delim=char delimiter to use when parsing column names (default is space or comma)
     * <li>-ignoreWhitespace=(true|false) ignore spaces when parsing column names (default true)
     * <li>-caching=numRows  number of rows to cache (faster scans, more memory).
     * <li>-noWAL=(true|false) Sets the write ahead to false for faster loading.
     * <li>-minTimestamp= Scan's timestamp for min timeRange
     * <li>-maxTimestamp= Scan's timestamp for max timeRange
     * <li>-timestamp= Scan's specified timestamp
     * <li>-caster=(HBaseBinaryConverter|Utf8StorageConverter) Utf8StorageConverter is the default
     * To be used with extreme caution, since this could result in data loss
     * (see http://hbase.apache.org/book.html#perf.hbase.client.putwal).
     * </ul>
     * @throws ParseException
     * @throws IOException
     */
    

    如您所见,已添加通过时间戳限制扫描,但实际上不需要返回它。我认为实施起来并不难。打开一个 Jira?也许甚至发布补丁? :)

    【讨论】:

    • 谢谢。我开始得出这个结论,但留下这个问题以防万一我错了。更糟糕的是,我们使用的先前版本甚至不包含 -min/max/timestamp 标志,因此我们甚至无法按值过滤。 :(
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-11-28
    • 2012-12-04
    • 1970-01-01
    • 2014-04-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多