【问题标题】:HBASE/MR - Map called despite filter, but no outputHBASE/MR - 尽管过滤器调用了映射,但没有输出
【发布时间】:2016-12-30 12:34:56
【问题描述】:

问题

我想确认以下几点:

如果过滤器过滤掉了一行,映射器应该被调用。

目标

尝试将meta:uuid 列添加到还没有此类列的行。

奇怪的是,尽管日志显示并非如此,但似乎一切正常。

代码

过滤器:

new SingleColumnValueFilter( 
    Bytes.toBytes( "meta" ), 
    Bytes.toBytes( "uuid" ), 
    CompareFilter.CompareOp.NOT_EQUAL, 
    new NullComparator()
);

地图:

@Override
public void map( ImmutableBytesWritable row, Result columns, Context context ) throws IOException, InterruptedException {
    Put put = new Put( row.get() );

    String uuid = UUID.randomUUID().toString();
    put.add( META_COLUMNFAMILY, UUID_QUALIFIER, uuid.getBytes() );


    System.out.println( uuid.toString() );
    context.write( row, put );
}

行为

首次运行

它将meta:uuid 列添加到所有行。

第二次运行

我们仍然得到带有新 UUID 的 System.out.println( uuid.toString() ) 输出 - 这表明映射器已被调用。

但 UUID(或时间戳)在 HBASE 中不会改变。

【问题讨论】:

    标签: java mapreduce hbase


    【解决方案1】:

    好的,就像docs say

    您还必须指定族和限定符。仅测试此列的值。在具有指定输入的 CellScanner 上使用此过滤器时,还应将要测试的列添加为输入(否则过滤器会将列视为缺失)。

    所以我不得不补充:

    scan.addColumn( Bytes.toBytes( "meta" ), Bytes.toBytes( "uuid" ) );
    

    (至于为什么 UUID 没有改变 - 这似乎与 HBase 的一些问题有关,该问题在重新启动后得到纠正。)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-03-31
      • 2019-12-20
      • 2015-02-18
      • 2014-02-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多