hbase-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "stack (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (HBASE-6750) Provide a variant of ValueFilter that only accepts the latest value (like SingleColumnValueFilter.setLatestVersionOnly)
Date Wed, 16 Nov 2016 22:17:58 GMT

     [ https://issues.apache.org/jira/browse/HBASE-6750?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

stack updated HBASE-6750:
-------------------------
    Affects Version/s:     (was: 0.90.5)
                       2.0.0

> 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
(v6.3.4#6332)

Mime
View raw message