David Witten created HBASE-6750:
-----------------------------------
Summary: Provide a variant of ValueFilter that only accepts the
latest value (like SingleColumnValueFilter.setLatestVersionOnly)
Key: HBASE-6750
URL: https://issues.apache.org/jira/browse/HBASE-6750
Project: HBase
Issue Type: New Feature
Components: filters
Affects Versions: 0.90.5
Environment: All
Reporter: David Witten
Currently ValueFilter will return an old value that matches if the latest value
does not. I recommend providing an option on ValueFilter, like
setLastestVersionOnly, or creating a subclass of ValueFilter that always has
this behavior.
Below is a custom filter that seems to work, though you may want to copy and
frob ValueFilter to just return NEXT_COL where it returns SKIP:
package dummy.hbasesvr;
import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.filter.ValueFilter;
import org.apache.hadoop.hbase.filter.WritableByteArrayComparable;
/**
* The same as {@link ValueFilter} except it will only look at the latest value
for a given column.
*/
public class LatestValueFilter extends ValueFilter
{
/**
* Writable constructor, do not use.
*/
public LatestValueFilter()
{
}
/**
* Constructor.
* @param valueCompareOp the compare op for value matching
* @param valueComparator the comparator for value matching
*/
public LatestValueFilter(CompareOp valueCompareOp,
WritableByteArrayComparable valueComparator)
{
super(valueCompareOp, valueComparator);
}
@Override
public ReturnCode filterKeyValue( KeyValue v)
{
// This assumes that given several KeyValues with the same
row+fam+qual+val the one with
// the latest value will be given first.
ReturnCode superReturnCode = super.filterKeyValue(v);
if ( superReturnCode == ReturnCode.SKIP)
{
return ReturnCode.NEXT_COL;
}
return superReturnCode;
}
}
Note I am a novice HBase user.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira