You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hbase.apache.org by an...@apache.org on 2014/09/24 09:50:32 UTC

git commit: HBASE-12068 [Branch-1] Avoid need to always do KeyValueUtil#ensureKeyValue for Filter transformCell.

Repository: hbase
Updated Branches:
  refs/heads/branch-1 48aa00958 -> af35daac7


HBASE-12068 [Branch-1] Avoid need to always do KeyValueUtil#ensureKeyValue for Filter transformCell.


Project: http://git-wip-us.apache.org/repos/asf/hbase/repo
Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/af35daac
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/af35daac
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/af35daac

Branch: refs/heads/branch-1
Commit: af35daac777c06639d3eb1985def4846fda84cbb
Parents: 48aa009
Author: anoopsjohn <an...@gmail.com>
Authored: Wed Sep 24 13:17:34 2014 +0530
Committer: anoopsjohn <an...@gmail.com>
Committed: Wed Sep 24 13:17:34 2014 +0530

----------------------------------------------------------------------
 .../hadoop/hbase/filter/ColumnCountGetFilter.java |  7 +++++++
 .../hbase/filter/ColumnPaginationFilter.java      |  7 +++++++
 .../hadoop/hbase/filter/ColumnPrefixFilter.java   |  7 +++++++
 .../hadoop/hbase/filter/ColumnRangeFilter.java    |  7 +++++++
 .../apache/hadoop/hbase/filter/CompareFilter.java |  8 ++++++++
 .../hbase/filter/DependentColumnFilter.java       | 12 ++++--------
 .../org/apache/hadoop/hbase/filter/Filter.java    |  9 ++++++++-
 .../apache/hadoop/hbase/filter/FilterBase.java    |  1 -
 .../apache/hadoop/hbase/filter/FilterList.java    |  7 ++++++-
 .../apache/hadoop/hbase/filter/FilterWrapper.java | 15 ++++-----------
 .../hadoop/hbase/filter/FirstKeyOnlyFilter.java   |  7 +++++++
 .../hadoop/hbase/filter/FuzzyRowFilter.java       |  7 +++++++
 .../hadoop/hbase/filter/InclusiveStopFilter.java  |  7 +++++++
 .../hbase/filter/MultipleColumnPrefixFilter.java  |  7 +++++++
 .../apache/hadoop/hbase/filter/PageFilter.java    |  9 ++++++++-
 .../apache/hadoop/hbase/filter/PrefixFilter.java  |  7 +++++++
 .../hadoop/hbase/filter/RandomRowFilter.java      |  7 +++++++
 .../filter/SingleColumnValueExcludeFilter.java    |  6 ++----
 .../hbase/filter/SingleColumnValueFilter.java     | 18 +++++++++---------
 .../hadoop/hbase/filter/TimestampsFilter.java     |  7 +++++++
 .../security/access/AccessControlFilter.java      |  7 +++++++
 .../security/visibility/VisibilityController.java |  7 +++++++
 .../visibility/VisibilityLabelFilter.java         |  7 +++++++
 .../hadoop/hbase/filter/FilterAllFilter.java      |  7 +++++++
 24 files changed, 154 insertions(+), 36 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/af35daac/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ColumnCountGetFilter.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ColumnCountGetFilter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ColumnCountGetFilter.java
index 8f942b8..206830a 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ColumnCountGetFilter.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ColumnCountGetFilter.java
@@ -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;

http://git-wip-us.apache.org/repos/asf/hbase/blob/af35daac/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ColumnPaginationFilter.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ColumnPaginationFilter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ColumnPaginationFilter.java
index 7021420..43373f4 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ColumnPaginationFilter.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ColumnPaginationFilter.java
@@ -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(

http://git-wip-us.apache.org/repos/asf/hbase/blob/af35daac/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ColumnPrefixFilter.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ColumnPrefixFilter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ColumnPrefixFilter.java
index 78467a2..7c6f344 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ColumnPrefixFilter.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ColumnPrefixFilter.java
@@ -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,

http://git-wip-us.apache.org/repos/asf/hbase/blob/af35daac/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ColumnRangeFilter.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ColumnRangeFilter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ColumnRangeFilter.java
index 0d827ab..dc4a3db 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ColumnRangeFilter.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ColumnRangeFilter.java
@@ -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());

http://git-wip-us.apache.org/repos/asf/hbase/blob/af35daac/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/CompareFilter.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/CompareFilter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/CompareFilter.java
index f1ddebe..9dc620b 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/CompareFilter.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/CompareFilter.java
@@ -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,

http://git-wip-us.apache.org/repos/asf/hbase/blob/af35daac/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/DependentColumnFilter.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/DependentColumnFilter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/DependentColumnFilter.java
index 3eff070..7c174fc 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/DependentColumnFilter.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/DependentColumnFilter.java
@@ -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;
     }

http://git-wip-us.apache.org/repos/asf/hbase/blob/af35daac/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/Filter.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/Filter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/Filter.java
index 8ca7667..0761106 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/Filter.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/Filter.java
@@ -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;
 
   /**

http://git-wip-us.apache.org/repos/asf/hbase/blob/af35daac/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FilterBase.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FilterBase.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FilterBase.java
index 4988dc8..54ec40d 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FilterBase.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FilterBase.java
@@ -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;

http://git-wip-us.apache.org/repos/asf/hbase/blob/af35daac/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java
index e8beac4..ead0d6a 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FilterList.java
@@ -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;
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/hbase/blob/af35daac/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FilterWrapper.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FilterWrapper.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FilterWrapper.java
index 51b2a66..9a2a818 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FilterWrapper.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FilterWrapper.java
@@ -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));
   }
 

http://git-wip-us.apache.org/repos/asf/hbase/blob/af35daac/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FirstKeyOnlyFilter.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FirstKeyOnlyFilter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FirstKeyOnlyFilter.java
index 08d04b4..12c7f55 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FirstKeyOnlyFilter.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FirstKeyOnlyFilter.java
@@ -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());

http://git-wip-us.apache.org/repos/asf/hbase/blob/af35daac/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FuzzyRowFilter.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FuzzyRowFilter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FuzzyRowFilter.java
index 5bd44d4..0925bb2 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FuzzyRowFilter.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/FuzzyRowFilter.java
@@ -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;

http://git-wip-us.apache.org/repos/asf/hbase/blob/af35daac/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/InclusiveStopFilter.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/InclusiveStopFilter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/InclusiveStopFilter.java
index dc2bab3..bea0f79 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/InclusiveStopFilter.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/InclusiveStopFilter.java
@@ -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

http://git-wip-us.apache.org/repos/asf/hbase/blob/af35daac/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultipleColumnPrefixFilter.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultipleColumnPrefixFilter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultipleColumnPrefixFilter.java
index 1c85b85..94267ae 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultipleColumnPrefixFilter.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultipleColumnPrefixFilter.java
@@ -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);

http://git-wip-us.apache.org/repos/asf/hbase/blob/af35daac/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/PageFilter.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/PageFilter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/PageFilter.java
index bc54d59..6aa2d70 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/PageFilter.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/PageFilter.java
@@ -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;
   }

http://git-wip-us.apache.org/repos/asf/hbase/blob/af35daac/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/PrefixFilter.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/PrefixFilter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/PrefixFilter.java
index c07c343..72ad178 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/PrefixFilter.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/PrefixFilter.java
@@ -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;
   }

http://git-wip-us.apache.org/repos/asf/hbase/blob/af35daac/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/RandomRowFilter.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/RandomRowFilter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/RandomRowFilter.java
index 83d1de8..28e4f7b 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/RandomRowFilter.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/RandomRowFilter.java
@@ -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;

http://git-wip-us.apache.org/repos/asf/hbase/blob/af35daac/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/SingleColumnValueExcludeFilter.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/SingleColumnValueExcludeFilter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/SingleColumnValueExcludeFilter.java
index 88873ba..3796061 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/SingleColumnValueExcludeFilter.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/SingleColumnValueExcludeFilter.java
@@ -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();
       }
     }

http://git-wip-us.apache.org/repos/asf/hbase/blob/af35daac/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/SingleColumnValueFilter.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/SingleColumnValueFilter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/SingleColumnValueFilter.java
index 0e9414e..4d6db7c 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/SingleColumnValueFilter.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/SingleColumnValueFilter.java
@@ -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);

http://git-wip-us.apache.org/repos/asf/hbase/blob/af35daac/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/TimestampsFilter.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/TimestampsFilter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/TimestampsFilter.java
index 18b43bb..3025445 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/TimestampsFilter.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/TimestampsFilter.java
@@ -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++) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/af35daac/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessControlFilter.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessControlFilter.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessControlFilter.java
index 1fbe06f..265aa91 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessControlFilter.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/access/AccessControlFilter.java
@@ -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();

http://git-wip-us.apache.org/repos/asf/hbase/blob/af35daac/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityController.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityController.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityController.java
index f2afa76..859b55f 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityController.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityController.java
@@ -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;
+    }
   }
 }

http://git-wip-us.apache.org/repos/asf/hbase/blob/af35daac/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityLabelFilter.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityLabelFilter.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityLabelFilter.java
index 3241fa5..527e47c 100644
--- a/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityLabelFilter.java
+++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/security/visibility/VisibilityLabelFilter.java
@@ -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();

http://git-wip-us.apache.org/repos/asf/hbase/blob/af35daac/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/FilterAllFilter.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/FilterAllFilter.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/FilterAllFilter.java
index a104def..27b6590 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/FilterAllFilter.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/FilterAllFilter.java
@@ -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;