Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
HBase, mail # user - Modifying SingleColumnValueFilter to not include matched KV


Copy link to this message
-
Modifying SingleColumnValueFilter to not include matched KV
David Koch 2013-01-23, 23:47
Hello,

As part of some custom filter building I took the source
of SingleColumnValueFilter (HBase 0.92.1) [1] and wanted to tweak it to NOT
return the matched column - thus essentially make it
equivalent SingleColumnValueExcludeFilter. I thought it must be trivial but
for some reason I cannot get it to work. The filter always includes the
matched KV pair.

The only change I made is in the filterKeyValue(<KeyValue>) method by
editing the last statement (see below):

public ReturnCode filterKeyValue(KeyValue keyValue) {
    if (this.matchedColumn) {
      // We already found and matched the single column, all keys now pass
      return ReturnCode.INCLUDE;
    } else if (this.latestVersionOnly && this.foundColumn) {
      // We found but did not match the single column, skip to next row
      return ReturnCode.NEXT_ROW;
    }
    if (!keyValue.matchingColumn(this.columnFamily, this.columnQualifier)) {
      return ReturnCode.INCLUDE;
    }
    foundColumn = true;
    if (filterColumnValue(keyValue.getBuffer(),
        keyValue.getValueOffset(), keyValue.getValueLength())) {
      return this.latestVersionOnly? ReturnCode.NEXT_ROW:
ReturnCode.INCLUDE;
    }
    this.matchedColumn = true;
    // Commented line below to NOT include matched column
    // return ReturnCode.INCLUDE;
    return ReturnCode.SKIP;
 }

Is this expected behavior? What am I overlooking here? By the way - how can
I sensibly debug filters. I tried using the Log instance but the output
does not show up in the region server's output.

Thank you,

/David

[1]
http://grepcode.com/file_/repo1.maven.org/maven2/org.apache.hbase/hbase/0.92.1/org/apache/hadoop/hbase/filter/SingleColumnValueFilter.java/?v=source