Index: src/test/java/org/apache/hadoop/hbase/filter/CustomIncludeAndNextUsingHintFilter.java =================================================================== --- src/test/java/org/apache/hadoop/hbase/filter/CustomIncludeAndNextUsingHintFilter.java (revision 0) +++ src/test/java/org/apache/hadoop/hbase/filter/CustomIncludeAndNextUsingHintFilter.java (revision 0) @@ -0,0 +1,54 @@ +package org.apache.hadoop.hbase.filter; + +import java.io.DataInput; +import java.io.DataOutput; +import java.io.IOException; + +import org.apache.hadoop.hbase.KeyValue; +import org.apache.hadoop.hbase.util.Bytes; + +public class CustomIncludeAndNextUsingHintFilter extends FilterBase { + private byte[][] seekHints; + transient private int count = 0; + + public CustomIncludeAndNextUsingHintFilter(byte[][] hints) { + this.seekHints = hints; + } + + @Override + public ReturnCode filterKeyValue(KeyValue kv) { + if (Bytes.equals(kv.getRow(), seekHints[count++])) { + return ReturnCode.INCLUDE_AND_SEEK_NEXT_USING_HINT; + } else { + return ReturnCode.SEEK_NEXT_USING_HINT; + } + } + + @Override + public boolean filterAllRemaining() { + return count >= seekHints.length; + } + + @Override + public KeyValue getNextKeyHint(KeyValue kv) { + byte[] hint = seekHints[count-1]; + return KeyValue.createFirstOnRow(hint); + } + + @Override + public void write(DataOutput out) throws IOException { + out.writeInt(seekHints.length); + for (byte [] hint : seekHints) { + Bytes.writeByteArray(out, hint); + } + } + + @Override + public void readFields(DataInput in) throws IOException { + int count = in.readInt(); + this.seekHints = new byte[count][]; + for (int i=0; i