HBASE-12068 [Branch-1] Avoid need to always do KeyValueUtil#ensureKeyValue for Filter transformCell.
This commit is contained in:
parent
48aa009581
commit
af35daac77
|
@ -62,6 +62,13 @@ public class ColumnCountGetFilter extends FilterBase {
|
|||
return filterAllRemaining() ? ReturnCode.NEXT_COL : ReturnCode.INCLUDE_AND_NEXT_COL;
|
||||
}
|
||||
|
||||
// Override here explicitly as the method in super class FilterBase might do a KeyValue recreate.
|
||||
// See HBASE-12068
|
||||
@Override
|
||||
public Cell transformCell(Cell v) {
|
||||
return v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
this.count = 0;
|
||||
|
|
|
@ -143,6 +143,13 @@ public class ColumnPaginationFilter extends FilterBase
|
|||
}
|
||||
}
|
||||
|
||||
// Override here explicitly as the method in super class FilterBase might do a KeyValue recreate.
|
||||
// See HBASE-12068
|
||||
@Override
|
||||
public Cell transformCell(Cell v) {
|
||||
return v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cell getNextCellHint(Cell kv) {
|
||||
return KeyValueUtil.createFirstOnRow(
|
||||
|
|
|
@ -60,6 +60,13 @@ public class ColumnPrefixFilter extends FilterBase {
|
|||
}
|
||||
}
|
||||
|
||||
// Override here explicitly as the method in super class FilterBase might do a KeyValue recreate.
|
||||
// See HBASE-12068
|
||||
@Override
|
||||
public Cell transformCell(Cell v) {
|
||||
return v;
|
||||
}
|
||||
|
||||
public ReturnCode filterColumn(byte[] buffer, int qualifierOffset, int qualifierLength) {
|
||||
if (qualifierLength < prefix.length) {
|
||||
int cmp = Bytes.compareTo(buffer, qualifierOffset, qualifierLength, this.prefix, 0,
|
||||
|
|
|
@ -151,6 +151,13 @@ public class ColumnRangeFilter extends FilterBase {
|
|||
return ReturnCode.NEXT_ROW;
|
||||
}
|
||||
|
||||
// Override here explicitly as the method in super class FilterBase might do a KeyValue recreate.
|
||||
// See HBASE-12068
|
||||
@Override
|
||||
public Cell transformCell(Cell v) {
|
||||
return v;
|
||||
}
|
||||
|
||||
public static Filter createFilterFromArguments(ArrayList<byte []> filterArguments) {
|
||||
Preconditions.checkArgument(filterArguments.size() == 4,
|
||||
"Expected 4 but got: %s", filterArguments.size());
|
||||
|
|
|
@ -21,6 +21,7 @@ package org.apache.hadoop.hbase.filter;
|
|||
|
||||
import com.google.common.base.Preconditions;
|
||||
import org.apache.hadoop.classification.InterfaceAudience;
|
||||
import org.apache.hadoop.hbase.Cell;
|
||||
import org.apache.hadoop.hbase.classification.InterfaceStability;
|
||||
import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
|
||||
import org.apache.hadoop.hbase.protobuf.generated.FilterProtos;
|
||||
|
@ -122,6 +123,13 @@ public abstract class CompareFilter extends FilterBase {
|
|||
}
|
||||
}
|
||||
|
||||
// Override here explicitly as the method in super class FilterBase might do a KeyValue recreate.
|
||||
// See HBASE-12068
|
||||
@Override
|
||||
public Cell transformCell(Cell v) {
|
||||
return v;
|
||||
}
|
||||
|
||||
// returns an array of heterogeneous objects
|
||||
public static ArrayList<Object> extractArguments(ArrayList<byte []> filterArguments) {
|
||||
Preconditions.checkArgument(filterArguments.size() == 2,
|
||||
|
|
|
@ -30,8 +30,6 @@ import org.apache.hadoop.classification.InterfaceAudience;
|
|||
import org.apache.hadoop.hbase.classification.InterfaceStability;
|
||||
import org.apache.hadoop.hbase.Cell;
|
||||
import org.apache.hadoop.hbase.CellUtil;
|
||||
import org.apache.hadoop.hbase.KeyValue;
|
||||
import org.apache.hadoop.hbase.KeyValueUtil;
|
||||
import org.apache.hadoop.hbase.exceptions.DeserializationException;
|
||||
import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
|
||||
import org.apache.hadoop.hbase.protobuf.generated.FilterProtos;
|
||||
|
@ -137,20 +135,18 @@ public class DependentColumnFilter extends CompareFilter {
|
|||
|
||||
@Override
|
||||
public ReturnCode filterKeyValue(Cell c) {
|
||||
// TODO make matching Column a cell method or CellUtil method.
|
||||
KeyValue v = KeyValueUtil.ensureKeyValue(c);
|
||||
// Check if the column and qualifier match
|
||||
if (!CellUtil.matchingColumn(v, this.columnFamily, this.columnQualifier)) {
|
||||
if (!CellUtil.matchingColumn(c, this.columnFamily, this.columnQualifier)) {
|
||||
// include non-matches for the time being, they'll be discarded afterwards
|
||||
return ReturnCode.INCLUDE;
|
||||
}
|
||||
// If it doesn't pass the op, skip it
|
||||
if (comparator != null
|
||||
&& doCompare(compareOp, comparator, v.getValueArray(), v.getValueOffset(),
|
||||
v.getValueLength()))
|
||||
&& doCompare(compareOp, comparator, c.getValueArray(), c.getValueOffset(),
|
||||
c.getValueLength()))
|
||||
return ReturnCode.SKIP;
|
||||
|
||||
stampSet.add(v.getTimestamp());
|
||||
stampSet.add(c.getTimestamp());
|
||||
if(dropDependentColumn) {
|
||||
return ReturnCode.SKIP;
|
||||
}
|
||||
|
|
|
@ -208,7 +208,14 @@ public abstract class Filter {
|
|||
*/
|
||||
abstract public boolean filterRow() throws IOException;
|
||||
|
||||
@Deprecated // use Cell GetNextKeyHint(final Cell)
|
||||
/**
|
||||
* @param currentKV
|
||||
* @return KeyValue which must be next seeked. return null if the filter is not sure which key to
|
||||
* seek to next.
|
||||
* @throws IOException
|
||||
* @Deprecated Use {@link #getNextCellHint(Cell)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
abstract public KeyValue getNextKeyHint(final KeyValue currentKV) throws IOException;
|
||||
|
||||
/**
|
||||
|
|
|
@ -24,7 +24,6 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import org.apache.hadoop.classification.InterfaceAudience;
|
||||
import org.apache.hadoop.classification.InterfaceStability;
|
||||
import org.apache.hadoop.hbase.Cell;
|
||||
import org.apache.hadoop.hbase.KeyValue;
|
||||
import org.apache.hadoop.hbase.KeyValueUtil;
|
||||
|
|
|
@ -212,7 +212,12 @@ final public class FilterList extends Filter {
|
|||
|
||||
@Override
|
||||
public Cell transformCell(Cell v) throws IOException {
|
||||
return transform(KeyValueUtil.ensureKeyValue(v));
|
||||
// transformCell() is expected to follow an inclusive filterKeyValue() immediately:
|
||||
if (!v.equals(this.referenceKV)) {
|
||||
throw new IllegalStateException("Reference Cell: " + this.referenceKV + " does not match: "
|
||||
+ v);
|
||||
}
|
||||
return this.transformedKV;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -20,11 +20,9 @@
|
|||
package org.apache.hadoop.hbase.filter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.hadoop.classification.InterfaceAudience;
|
||||
import org.apache.hadoop.classification.InterfaceStability;
|
||||
import org.apache.hadoop.hbase.Cell;
|
||||
import org.apache.hadoop.hbase.KeyValue;
|
||||
import org.apache.hadoop.hbase.KeyValueUtil;
|
||||
|
@ -105,17 +103,13 @@ final public class FilterWrapper extends Filter {
|
|||
@Override
|
||||
@Deprecated
|
||||
public KeyValue getNextKeyHint(KeyValue currentKV) throws IOException {
|
||||
// This will never get called.
|
||||
return KeyValueUtil.ensureKeyValue(this.filter.getNextCellHint((Cell)currentKV));
|
||||
}
|
||||
|
||||
/**
|
||||
* Old filter wrapper descendants will implement KV getNextKeyHint(KV) so we should call it.
|
||||
*/
|
||||
@Override
|
||||
public Cell getNextCellHint(Cell currentKV) throws IOException {
|
||||
// Old filters based off of this class will override KeyValue getNextKeyHint(KeyValue).
|
||||
// Thus to maintain compatibility we need to call the old version.
|
||||
return this.getNextKeyHint(KeyValueUtil.ensureKeyValue(currentKV));
|
||||
return this.filter.getNextCellHint(currentKV);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -130,9 +124,7 @@ final public class FilterWrapper extends Filter {
|
|||
|
||||
@Override
|
||||
public Cell transformCell(Cell v) throws IOException {
|
||||
// Old filters based off of this class will override KeyValue transform(KeyValue).
|
||||
// Thus to maintain compatibility we need to call the old version.
|
||||
return transform(KeyValueUtil.ensureKeyValue(v));
|
||||
return this.filter.transformCell(v);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -143,6 +135,7 @@ final public class FilterWrapper extends Filter {
|
|||
@Override
|
||||
@Deprecated
|
||||
public KeyValue transform(KeyValue currentKV) throws IOException {
|
||||
// This will never get called.
|
||||
return KeyValueUtil.ensureKeyValue(this.filter.transformCell(currentKV));
|
||||
}
|
||||
|
||||
|
|
|
@ -53,6 +53,13 @@ public class FirstKeyOnlyFilter extends FilterBase {
|
|||
return ReturnCode.INCLUDE;
|
||||
}
|
||||
|
||||
// Override here explicitly as the method in super class FilterBase might do a KeyValue recreate.
|
||||
// See HBASE-12068
|
||||
@Override
|
||||
public Cell transformCell(Cell v) {
|
||||
return v;
|
||||
}
|
||||
|
||||
public static Filter createFilterFromArguments(ArrayList<byte []> filterArguments) {
|
||||
Preconditions.checkArgument(filterArguments.size() == 0,
|
||||
"Expected 0 but got: %s", filterArguments.size());
|
||||
|
|
|
@ -97,6 +97,13 @@ public class FuzzyRowFilter extends FilterBase {
|
|||
return ReturnCode.NEXT_ROW;
|
||||
}
|
||||
|
||||
// Override here explicitly as the method in super class FilterBase might do a KeyValue recreate.
|
||||
// See HBASE-12068
|
||||
@Override
|
||||
public Cell transformCell(Cell v) {
|
||||
return v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Cell getNextCellHint(Cell curCell) {
|
||||
byte[] nextRowKey = null;
|
||||
|
|
|
@ -58,6 +58,13 @@ public class InclusiveStopFilter extends FilterBase {
|
|||
return ReturnCode.INCLUDE;
|
||||
}
|
||||
|
||||
// Override here explicitly as the method in super class FilterBase might do a KeyValue recreate.
|
||||
// See HBASE-12068
|
||||
@Override
|
||||
public Cell transformCell(Cell v) {
|
||||
return v;
|
||||
}
|
||||
|
||||
public boolean filterRowKey(byte[] buffer, int offset, int length) {
|
||||
if (buffer == null) {
|
||||
//noinspection RedundantIfStatement
|
||||
|
|
|
@ -71,6 +71,13 @@ public class MultipleColumnPrefixFilter extends FilterBase {
|
|||
}
|
||||
}
|
||||
|
||||
// Override here explicitly as the method in super class FilterBase might do a KeyValue recreate.
|
||||
// See HBASE-12068
|
||||
@Override
|
||||
public Cell transformCell(Cell v) {
|
||||
return v;
|
||||
}
|
||||
|
||||
public ReturnCode filterColumn(byte[] buffer, int qualifierOffset, int qualifierLength) {
|
||||
byte [] qualifier = Arrays.copyOfRange(buffer, qualifierOffset,
|
||||
qualifierLength + qualifierOffset);
|
||||
|
|
|
@ -64,7 +64,14 @@ public class PageFilter extends FilterBase {
|
|||
public ReturnCode filterKeyValue(Cell ignored) throws IOException {
|
||||
return ReturnCode.INCLUDE;
|
||||
}
|
||||
|
||||
|
||||
// Override here explicitly as the method in super class FilterBase might do a KeyValue recreate.
|
||||
// See HBASE-12068
|
||||
@Override
|
||||
public Cell transformCell(Cell v) {
|
||||
return v;
|
||||
}
|
||||
|
||||
public boolean filterAllRemaining() {
|
||||
return this.rowsAccepted >= this.pageSize;
|
||||
}
|
||||
|
|
|
@ -73,6 +73,13 @@ public class PrefixFilter extends FilterBase {
|
|||
return ReturnCode.INCLUDE;
|
||||
}
|
||||
|
||||
// Override here explicitly as the method in super class FilterBase might do a KeyValue recreate.
|
||||
// See HBASE-12068
|
||||
@Override
|
||||
public Cell transformCell(Cell v) {
|
||||
return v;
|
||||
}
|
||||
|
||||
public boolean filterRow() {
|
||||
return filterRow;
|
||||
}
|
||||
|
|
|
@ -79,6 +79,13 @@ public class RandomRowFilter extends FilterBase {
|
|||
return ReturnCode.INCLUDE;
|
||||
}
|
||||
|
||||
// Override here explicitly as the method in super class FilterBase might do a KeyValue recreate.
|
||||
// See HBASE-12068
|
||||
@Override
|
||||
public Cell transformCell(Cell v) {
|
||||
return v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean filterRow() {
|
||||
return filterOutRow;
|
||||
|
|
|
@ -28,8 +28,6 @@ import org.apache.hadoop.classification.InterfaceAudience;
|
|||
import org.apache.hadoop.hbase.classification.InterfaceStability;
|
||||
import org.apache.hadoop.hbase.Cell;
|
||||
import org.apache.hadoop.hbase.CellUtil;
|
||||
import org.apache.hadoop.hbase.KeyValue;
|
||||
import org.apache.hadoop.hbase.KeyValueUtil;
|
||||
import org.apache.hadoop.hbase.exceptions.DeserializationException;
|
||||
import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
|
||||
import org.apache.hadoop.hbase.protobuf.ProtobufUtil;
|
||||
|
@ -108,10 +106,10 @@ public class SingleColumnValueExcludeFilter extends SingleColumnValueFilter {
|
|||
public void filterRowCells(List<Cell> kvs) {
|
||||
Iterator<? extends Cell> it = kvs.iterator();
|
||||
while (it.hasNext()) {
|
||||
KeyValue kv = KeyValueUtil.ensureKeyValue(it.next());
|
||||
Cell cell = it.next();
|
||||
// If the current column is actually the tested column,
|
||||
// we will skip it instead.
|
||||
if (CellUtil.matchingColumn(kv, this.columnFamily, this.columnQualifier)) {
|
||||
if (CellUtil.matchingColumn(cell, this.columnFamily, this.columnQualifier)) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,8 +29,6 @@ import org.apache.hadoop.classification.InterfaceAudience;
|
|||
import org.apache.hadoop.hbase.classification.InterfaceStability;
|
||||
import org.apache.hadoop.hbase.Cell;
|
||||
import org.apache.hadoop.hbase.CellUtil;
|
||||
import org.apache.hadoop.hbase.KeyValue;
|
||||
import org.apache.hadoop.hbase.KeyValueUtil;
|
||||
import org.apache.hadoop.hbase.client.Scan;
|
||||
import org.apache.hadoop.hbase.exceptions.DeserializationException;
|
||||
import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
|
||||
|
@ -172,10 +170,6 @@ public class SingleColumnValueFilter extends FilterBase {
|
|||
|
||||
@Override
|
||||
public ReturnCode filterKeyValue(Cell c) {
|
||||
// TODO get rid of this.
|
||||
KeyValue keyValue = KeyValueUtil.ensureKeyValue(c);
|
||||
|
||||
// System.out.println("REMOVE KEY=" + keyValue.toString() + ", value=" + Bytes.toString(keyValue.getValue()));
|
||||
if (this.matchedColumn) {
|
||||
// We already found and matched the single column, all keys now pass
|
||||
return ReturnCode.INCLUDE;
|
||||
|
@ -183,18 +177,24 @@ public class SingleColumnValueFilter extends FilterBase {
|
|||
// We found but did not match the single column, skip to next row
|
||||
return ReturnCode.NEXT_ROW;
|
||||
}
|
||||
if (!CellUtil.matchingColumn(keyValue, this.columnFamily, this.columnQualifier)) {
|
||||
if (!CellUtil.matchingColumn(c, this.columnFamily, this.columnQualifier)) {
|
||||
return ReturnCode.INCLUDE;
|
||||
}
|
||||
foundColumn = true;
|
||||
if (filterColumnValue(keyValue.getValueArray(),
|
||||
keyValue.getValueOffset(), keyValue.getValueLength())) {
|
||||
if (filterColumnValue(c.getValueArray(), c.getValueOffset(), c.getValueLength())) {
|
||||
return this.latestVersionOnly? ReturnCode.NEXT_ROW: ReturnCode.INCLUDE;
|
||||
}
|
||||
this.matchedColumn = true;
|
||||
return ReturnCode.INCLUDE;
|
||||
}
|
||||
|
||||
// Override here explicitly as the method in super class FilterBase might do a KeyValue recreate.
|
||||
// See HBASE-12068
|
||||
@Override
|
||||
public Cell transformCell(Cell v) {
|
||||
return v;
|
||||
}
|
||||
|
||||
private boolean filterColumnValue(final byte [] data, final int offset,
|
||||
final int length) {
|
||||
int compareResult = this.comparator.compareTo(data, offset, length);
|
||||
|
|
|
@ -99,6 +99,13 @@ public class TimestampsFilter extends FilterBase {
|
|||
return ReturnCode.SKIP;
|
||||
}
|
||||
|
||||
// Override here explicitly as the method in super class FilterBase might do a KeyValue recreate.
|
||||
// See HBASE-12068
|
||||
@Override
|
||||
public Cell transformCell(Cell v) {
|
||||
return v;
|
||||
}
|
||||
|
||||
public static Filter createFilterFromArguments(ArrayList<byte []> filterArguments) {
|
||||
ArrayList<Long> timestamps = new ArrayList<Long>();
|
||||
for (int i = 0; i<filterArguments.size(); i++) {
|
||||
|
|
|
@ -138,6 +138,13 @@ class AccessControlFilter extends FilterBase {
|
|||
return ReturnCode.SKIP;
|
||||
}
|
||||
|
||||
// Override here explicitly as the method in super class FilterBase might do a KeyValue recreate.
|
||||
// See HBASE-12068
|
||||
@Override
|
||||
public Cell transformCell(Cell v) {
|
||||
return v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() throws IOException {
|
||||
this.prevFam.unset();
|
||||
|
|
|
@ -834,5 +834,12 @@ public class VisibilityController extends BaseMasterAndRegionObserver implements
|
|||
deleteCellVisTagsFormat);
|
||||
return matchFound ? ReturnCode.INCLUDE : ReturnCode.SKIP;
|
||||
}
|
||||
|
||||
// Override here explicitly as the method in super class FilterBase might do a KeyValue recreate.
|
||||
// See HBASE-12068
|
||||
@Override
|
||||
public Cell transformCell(Cell v) {
|
||||
return v;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -78,6 +78,13 @@ class VisibilityLabelFilter extends FilterBase {
|
|||
return this.expEvaluator.evaluate(cell) ? ReturnCode.INCLUDE : ReturnCode.SKIP;
|
||||
}
|
||||
|
||||
// Override here explicitly as the method in super class FilterBase might do a KeyValue recreate.
|
||||
// See HBASE-12068
|
||||
@Override
|
||||
public Cell transformCell(Cell v) {
|
||||
return v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() throws IOException {
|
||||
this.curFamily.unset();
|
||||
|
|
|
@ -32,6 +32,13 @@ public class FilterAllFilter extends FilterBase {
|
|||
return ReturnCode.SKIP;
|
||||
}
|
||||
|
||||
// Override here explicitly as the method in super class FilterBase might do a KeyValue recreate.
|
||||
// See HBASE-12068
|
||||
@Override
|
||||
public Cell transformCell(Cell v) {
|
||||
return v;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasFilterRow() {
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue