[
https://issues.apache.org/jira/browse/HBASE-6750?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Andrew Kyle Purtell resolved HBASE-6750.
----------------------------------------
Resolution: Won't Fix
> 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: 2.0.0
> Environment: All
> Reporter: David Witten
> Priority: Minor
> Labels: beginner
> Original Estimate: 24h
> Remaining Estimate: 24h
>
> 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 was sent by Atlassian Jira
(v8.20.7#820007)