我想确认以下内容:
如果过滤器已过滤掉一行,那么映射器应该不随之调用。
尝试将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() )
输出 - 这表明已经调用了映射器。
但是UUCID(或时间戳)在HBASE中不会改变。
答案 0 :(得分:0)
好的,docs say:
您还必须指定系列和限定符。仅测试此列的值。在具有指定输入的CellScanner上使用此过滤器时,还应将要测试的列添加为输入(否则过滤器会将该列视为缺失)。
所以我不得不补充:
scan.addColumn( Bytes.toBytes( "meta" ), Bytes.toBytes( "uuid" ) );
(至于为什么UUID没有改变 - 这似乎与HBase在重启后纠正的一些问题有关。)