【问题标题】:Hbase filter rows based on column and timestampHbase 根据列和时间戳过滤行
【发布时间】:2014-12-03 21:11:21
【问题描述】:

我想使用 hbase shell 根据列值时间戳过滤列。例如:

f:my_qualifier  timestamp=1417542508438,  value=some value

我想返回时间戳为 > 特定时间戳的所有列值。这可以使用 hbase shell 吗?看起来 TimestampsFilter 需要一个特定的时间戳,我认为不可能使用比较器。

提前致谢!

【问题讨论】:

    标签: hbase filtering


    【解决方案1】:

    使用 TIMERANGE 选项:

    scan 't1', {COLUMNS => 'c1', TIMERANGE => [1303668804, 1303668904]}
    

    查看扫描命令帮助以获取更多选项:

    hbase(main):001:0> scan
    
    Here is some help for this command:
    Scan a table; pass table name and optionally a dictionary of scanner
    specifications.  Scanner specifications may include one or more of:
    TIMERANGE, FILTER, LIMIT, STARTROW, STOPROW, TIMESTAMP, MAXLENGTH,
    or COLUMNS, CACHE
    
    Some examples:
    
      hbase> scan '.META.'
      hbase> scan '.META.', {COLUMNS => 'info:regioninfo'}
      hbase> scan 't1', {COLUMNS => ['c1', 'c2'], LIMIT => 10, STARTROW => 'xyz'}
      hbase> scan 't1', {COLUMNS => 'c1', TIMERANGE => [1303668804, 1303668904]}
      hbase> scan 't1', {FILTER => "(PrefixFilter ('row2') AND (QualifierFilter (>=, 'binary:xyz'))) AND (TimestampsFilter ( 123, 456))"}
      hbase> scan 't1', {FILTER => org.apache.hadoop.hbase.filter.ColumnPaginationFilter.new(1, 0)}
    

    【讨论】:

    • 为了让 TIMERANGE 为我工作,我必须使用毫秒时间戳。例如:上面的时间戳后面三个零:TIMERANGE => [1303668804000, 1303668904000]
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-10-14
    • 2018-09-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多