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/23 19:38:11 UTC

git commit: HBASE-12048 Remove deprecated APIs from Filter.

Repository: hbase
Updated Branches:
  refs/heads/master a94f7b140 -> 564b3d8bc


HBASE-12048 Remove deprecated APIs from Filter.


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

Branch: refs/heads/master
Commit: 564b3d8bc2a2a9277fb8b99ace288f47a9186c6b
Parents: a94f7b1
Author: anoopsjohn <an...@gmail.com>
Authored: Tue Sep 23 23:07:38 2014 +0530
Committer: anoopsjohn <an...@gmail.com>
Committed: Tue Sep 23 23:07:38 2014 +0530

----------------------------------------------------------------------
 .../org/apache/hadoop/hbase/filter/Filter.java  | 20 +++---------
 .../apache/hadoop/hbase/filter/FilterBase.java  | 26 +--------------
 .../apache/hadoop/hbase/filter/FilterList.java  | 26 ---------------
 .../hadoop/hbase/filter/FilterWrapper.java      | 33 ++------------------
 .../hadoop/hbase/filter/TestFilterList.java     | 22 ++++++-------
 5 files changed, 18 insertions(+), 109 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/564b3d8b/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 0c63c98..0a0164e 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
@@ -25,7 +25,6 @@ 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.exceptions.DeserializationException;
 
 /**
@@ -36,10 +35,10 @@ import org.apache.hadoop.hbase.exceptions.DeserializationException;
  *   <li> {@link #reset()} : reset the filter state before filtering a new row. </li>
  *   <li> {@link #filterAllRemaining()}: true means row scan is over; false means keep going. </li>
  *   <li> {@link #filterRowKey(byte[],int,int)}: true means drop this row; false means include.</li>
- *   <li> {@link #filterKeyValue(Cell)}: decides whether to include or exclude this KeyValue.
+ *   <li> {@link #filterKeyValue(Cell)}: decides whether to include or exclude this Cell.
  *        See {@link ReturnCode}. </li>
- *   <li> {@link #transform(KeyValue)}: if the KeyValue is included, let the filter transform the
- *        KeyValue. </li>
+ *   <li> {@link #transformCell(Cell)}: if the Cell is included, let the filter transform the
+ *        Cell. </li>
  *   <li> {@link #filterRowCells(List)}: allows direct modification of the final list to be submitted
  *   <li> {@link #filterRow()}: last chance to drop entire row based on the sequence of
  *        filter calls. Eg: filter a row if it doesn't contain a specified column. </li>
@@ -123,7 +122,7 @@ public abstract class Filter {
    * @see org.apache.hadoop.hbase.KeyValue#shallowCopy()
    *      The transformed KeyValue is what is eventually returned to the client. Most filters will
    *      return the passed KeyValue unchanged.
-   * @see org.apache.hadoop.hbase.filter.KeyOnlyFilter#transform(KeyValue) for an example of a
+   * @see org.apache.hadoop.hbase.filter.KeyOnlyFilter#transformCell(Cell) for an example of a
    *      transformation.
    * 
    *      Concrete implementers can signal a failure condition in their code by throwing an
@@ -136,14 +135,6 @@ public abstract class Filter {
   abstract public Cell transformCell(final Cell v) throws IOException;
 
   /**
-   * WARNING: please to not override this method.  Instead override {@link #transformCell(Cell)}.
-   * This is for transition from 0.94 -> 0.96
-   **/
-  @Deprecated // use Cell transformCell(final Cell)
-  abstract public KeyValue transform(final KeyValue currentKV) throws IOException;
- 
-  
-  /**
    * Return codes for filterValue().
    */
   @InterfaceAudience.Public
@@ -208,9 +199,6 @@ public abstract class Filter {
    */
   abstract public boolean filterRow() throws IOException;
 
-  @Deprecated // use Cell GetNextKeyHint(final Cell)
-  abstract public KeyValue getNextKeyHint(final KeyValue currentKV) throws IOException;
-
   /**
    * If the filter returns the match code SEEK_NEXT_USING_HINT, then it should also tell which is
    * the next key it must seek to. After receiving the match code SEEK_NEXT_USING_HINT, the

http://git-wip-us.apache.org/repos/asf/hbase/blob/564b3d8b/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 0418020..b321d52 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
@@ -25,8 +25,6 @@ import java.util.List;
 
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.hbase.Cell;
-import org.apache.hadoop.hbase.KeyValue;
-import org.apache.hadoop.hbase.KeyValueUtil;
 
 /**
  * Abstract base class to help you implement new Filters.  Common "ignore" or NOOP type
@@ -78,20 +76,7 @@ public abstract class FilterBase 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));
-  }
-
-  /**
-   * WARNING: please to not override this method.  Instead override {@link #transformCell(Cell)}.
-   *
-   * This is for transition from 0.94 -> 0.96
-   */
-  @Override
-  @Deprecated
-  public KeyValue transform(KeyValue currentKV) throws IOException {
-    return currentKV;
+    return v;
   }
 
   /**
@@ -128,15 +113,6 @@ public abstract class FilterBase extends Filter {
   }
 
   /**
-   * This method is deprecated and you should override Cell getNextKeyHint(Cell) instead.
-   */
-  @Override
-  @Deprecated
-  public KeyValue getNextKeyHint(KeyValue currentKV) throws IOException {
-    return null;
-  }
-  
-  /**
    * Filters that are not sure which key must be next seeked to, can inherit
    * this implementation that, by default, returns a null Cell.
    *

http://git-wip-us.apache.org/repos/asf/hbase/blob/564b3d8b/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 019ede7..0775e9c 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
@@ -28,7 +28,6 @@ import org.apache.hadoop.classification.InterfaceStability;
 import org.apache.hadoop.hbase.Cell;
 import org.apache.hadoop.hbase.CellComparator;
 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;
@@ -220,25 +219,6 @@ final public class FilterList extends Filter {
     return this.transformedCell;
   }
 
-  /**
-   * WARNING: please to not override this method.  Instead override {@link #transformCell(Cell)}.
-   *
-   * When removing this, its body should be placed in transformCell.
-   *
-   * This is for transition from 0.94 -> 0.96
-   */
-  @Deprecated
-  @Override
-  public KeyValue transform(KeyValue v) throws IOException {
-    // transform() is expected to follow an inclusive filterKeyValue() immediately:
-    if (!v.equals(this.referenceCell)) {
-      throw new IllegalStateException(
-          "Reference Cell: " + this.referenceCell + " does not match: " + v);
-     }
-    return KeyValueUtil.ensureKeyValue(this.transformedCell);
-  }
-
-  
   @Override
   @edu.umd.cs.findbugs.annotations.SuppressWarnings(value="SF_SWITCH_FALLTHROUGH",
     justification="Intentional")
@@ -400,12 +380,6 @@ final public class FilterList extends Filter {
   }
 
   @Override
-  @Deprecated
-  public KeyValue getNextKeyHint(KeyValue currentKV) throws IOException {
-    return KeyValueUtil.ensureKeyValue(getNextCellHint((Cell)currentKV));
-  }
-
-  @Override
   public Cell getNextCellHint(Cell currentCell) throws IOException {
     Cell keyHint = null;
     if (operator == Operator.MUST_PASS_ALL) {

http://git-wip-us.apache.org/repos/asf/hbase/blob/564b3d8b/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 57e3e41..06a2415 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
@@ -24,8 +24,6 @@ import java.util.List;
 
 import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.hbase.Cell;
-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;
@@ -97,23 +95,9 @@ final public class FilterWrapper extends Filter {
     return this.filter.filterRow();
   }
 
-  /**
-   * This method is deprecated and you should override Cell getNextKeyHint(Cell) instead.
-   */
-  @Override
-  @Deprecated
-  public KeyValue getNextKeyHint(KeyValue currentKV) throws IOException {
-    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 currentCell) 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(currentCell));
+    return this.filter.getNextCellHint(currentCell);
   }
 
   @Override
@@ -128,20 +112,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));
-  }
-
-  /**
-   * WARNING: please to not override this method.  Instead override {@link #transformCell(Cell)}.
-   *
-   * This is for transition from 0.94 -> 0.96
-   */
-  @Override
-  @Deprecated
-  public KeyValue transform(KeyValue currentKV) throws IOException {
-    return KeyValueUtil.ensureKeyValue(this.filter.transformCell(currentKV));
+    return this.filter.transformCell(v);
   }
 
   @Override

http://git-wip-us.apache.org/repos/asf/hbase/blob/564b3d8b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterList.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterList.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterList.java
index b8a3b05..759435b 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterList.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestFilterList.java
@@ -458,22 +458,22 @@ public class TestFilterList {
     // Should take the min if given two hints
     FilterList filterList = new FilterList(Operator.MUST_PASS_ONE,
         Arrays.asList(new Filter [] { filterMinHint, filterMaxHint } ));
-    assertEquals(0, KeyValue.COMPARATOR.compare(filterList.getNextKeyHint(null),
+    assertEquals(0, KeyValue.COMPARATOR.compare(filterList.getNextCellHint(null),
         minKeyValue));
 
     // Should have no hint if any filter has no hint
     filterList = new FilterList(Operator.MUST_PASS_ONE,
         Arrays.asList(
             new Filter [] { filterMinHint, filterMaxHint, filterNoHint } ));
-    assertNull(filterList.getNextKeyHint(null));
+    assertNull(filterList.getNextCellHint(null));
     filterList = new FilterList(Operator.MUST_PASS_ONE,
         Arrays.asList(new Filter [] { filterNoHint, filterMaxHint } ));
-    assertNull(filterList.getNextKeyHint(null));
+    assertNull(filterList.getNextCellHint(null));
 
     // Should give max hint if its the only one
     filterList = new FilterList(Operator.MUST_PASS_ONE,
         Arrays.asList(new Filter [] { filterMaxHint, filterMaxHint } ));
-    assertEquals(0, KeyValue.COMPARATOR.compare(filterList.getNextKeyHint(null),
+    assertEquals(0, KeyValue.COMPARATOR.compare(filterList.getNextCellHint(null),
         maxKeyValue));
 
     // MUST PASS ALL
@@ -482,13 +482,13 @@ public class TestFilterList {
     filterList = new FilterList(Operator.MUST_PASS_ALL,
         Arrays.asList(new Filter [] { filterMinHint, filterMaxHint } ));
     filterList.filterKeyValue(null);
-    assertEquals(0, KeyValue.COMPARATOR.compare(filterList.getNextKeyHint(null),
+    assertEquals(0, KeyValue.COMPARATOR.compare(filterList.getNextCellHint(null),
         minKeyValue));
 
     filterList = new FilterList(Operator.MUST_PASS_ALL,
         Arrays.asList(new Filter [] { filterMaxHint, filterMinHint } ));
     filterList.filterKeyValue(null);
-    assertEquals(0, KeyValue.COMPARATOR.compare(filterList.getNextKeyHint(null),
+    assertEquals(0, KeyValue.COMPARATOR.compare(filterList.getNextCellHint(null),
         maxKeyValue));
 
     // Should have first hint even if a filter has no hint
@@ -496,17 +496,17 @@ public class TestFilterList {
         Arrays.asList(
             new Filter [] { filterNoHint, filterMinHint, filterMaxHint } ));
     filterList.filterKeyValue(null);
-    assertEquals(0, KeyValue.COMPARATOR.compare(filterList.getNextKeyHint(null),
+    assertEquals(0, KeyValue.COMPARATOR.compare(filterList.getNextCellHint(null),
         minKeyValue));
     filterList = new FilterList(Operator.MUST_PASS_ALL,
         Arrays.asList(new Filter [] { filterNoHint, filterMaxHint } ));
     filterList.filterKeyValue(null);
-    assertEquals(0, KeyValue.COMPARATOR.compare(filterList.getNextKeyHint(null),
+    assertEquals(0, KeyValue.COMPARATOR.compare(filterList.getNextCellHint(null),
         maxKeyValue));
     filterList = new FilterList(Operator.MUST_PASS_ALL,
         Arrays.asList(new Filter [] { filterNoHint, filterMinHint } ));
     filterList.filterKeyValue(null);
-    assertEquals(0, KeyValue.COMPARATOR.compare(filterList.getNextKeyHint(null),
+    assertEquals(0, KeyValue.COMPARATOR.compare(filterList.getNextCellHint(null),
         minKeyValue));
   }
 
@@ -539,12 +539,12 @@ public class TestFilterList {
 
     // Value for fam:qual1 should be stripped:
     assertEquals(Filter.ReturnCode.INCLUDE, flist.filterKeyValue(kvQual1));
-    final KeyValue transformedQual1 = KeyValueUtil.ensureKeyValue(flist.transform(kvQual1));
+    final KeyValue transformedQual1 = KeyValueUtil.ensureKeyValue(flist.transformCell(kvQual1));
     assertEquals(0, transformedQual1.getValue().length);
 
     // Value for fam:qual2 should not be stripped:
     assertEquals(Filter.ReturnCode.INCLUDE, flist.filterKeyValue(kvQual2));
-    final KeyValue transformedQual2 = KeyValueUtil.ensureKeyValue(flist.transform(kvQual2));
+    final KeyValue transformedQual2 = KeyValueUtil.ensureKeyValue(flist.transformCell(kvQual2));
     assertEquals("value", Bytes.toString(transformedQual2.getValue()));
 
     // Other keys should be skipped: