hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jingchen...@apache.org
Subject hbase git commit: HBASE-17688 MultiRowRangeFilter not working correctly if given same start and stop RowKey
Date Tue, 28 Feb 2017 04:36:46 GMT
Repository: hbase
Updated Branches:
  refs/heads/branch-1.1 1a81a27ac -> 5dd170b20


HBASE-17688 MultiRowRangeFilter not working correctly if given same start and stop RowKey


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

Branch: refs/heads/branch-1.1
Commit: 5dd170b204cbbd3b7be935f2025c632fface6f90
Parents: 1a81a27
Author: Jingcheng Du <jingchengdu@apache.org>
Authored: Tue Feb 28 12:30:02 2017 +0800
Committer: Jingcheng Du <jingchengdu@apache.org>
Committed: Tue Feb 28 12:30:02 2017 +0800

----------------------------------------------------------------------
 .../hbase/filter/MultiRowRangeFilter.java       | 15 +++++-----
 .../hbase/filter/TestMultiRowRangeFilter.java   | 31 ++++++++++++++++++++
 2 files changed, 38 insertions(+), 8 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/5dd170b2/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultiRowRangeFilter.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultiRowRangeFilter.java
b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultiRowRangeFilter.java
index 4bcf430..01bdb04 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultiRowRangeFilter.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/MultiRowRangeFilter.java
@@ -117,7 +117,9 @@ public class MultiRowRangeFilter extends FilterBase {
       } else {
         if (range.contains(buffer, offset, length)) {
           currentReturnCode = ReturnCode.INCLUDE;
-        } else currentReturnCode = ReturnCode.SEEK_NEXT_USING_HINT;
+        } else {
+          currentReturnCode = ReturnCode.SEEK_NEXT_USING_HINT;
+        }
       }
     } else {
       currentReturnCode = ReturnCode.INCLUDE;
@@ -151,7 +153,6 @@ public class MultiRowRangeFilter extends FilterBase {
         if (range.stopRow != null)
           rangebuilder.setStopRow(ByteStringer.wrap(range.stopRow));
         rangebuilder.setStopRowInclusive(range.stopRowInclusive);
-        range.isScan = Bytes.equals(range.startRow, range.stopRow) ? 1 : 0;
         builder.addRowRangeList(rangebuilder.build());
       }
     }
@@ -422,7 +423,6 @@ public class MultiRowRangeFilter extends FilterBase {
     private boolean startRowInclusive = true;
     private byte[] stopRow;
     private boolean stopRowInclusive = false;
-    private int isScan = 0;
 
     public RowRange() {
     }
@@ -445,7 +445,6 @@ public class MultiRowRangeFilter extends FilterBase {
       this.startRowInclusive = startRowInclusive;
       this.stopRow = (stopRow == null) ? HConstants.EMPTY_BYTE_ARRAY :stopRow;
       this.stopRowInclusive = stopRowInclusive;
-      isScan = Bytes.equals(startRow, stopRow) ? 1 : 0;
     }
 
     public byte[] getStartRow() {
@@ -479,21 +478,21 @@ public class MultiRowRangeFilter extends FilterBase {
         if(stopRowInclusive) {
           return Bytes.compareTo(buffer, offset, length, startRow, 0, startRow.length) >=
0
               && (Bytes.equals(stopRow, HConstants.EMPTY_BYTE_ARRAY) ||
-                  Bytes.compareTo(buffer, offset, length, stopRow, 0, stopRow.length) <=
isScan);
+                  Bytes.compareTo(buffer, offset, length, stopRow, 0, stopRow.length) <=
0);
         } else {
           return Bytes.compareTo(buffer, offset, length, startRow, 0, startRow.length) >=
0
               && (Bytes.equals(stopRow, HConstants.EMPTY_BYTE_ARRAY) ||
-                  Bytes.compareTo(buffer, offset, length, stopRow, 0, stopRow.length) <
isScan);
+                  Bytes.compareTo(buffer, offset, length, stopRow, 0, stopRow.length) <
0);
         }
       } else {
         if(stopRowInclusive) {
           return Bytes.compareTo(buffer, offset, length, startRow, 0, startRow.length) >
0
               && (Bytes.equals(stopRow, HConstants.EMPTY_BYTE_ARRAY) ||
-                  Bytes.compareTo(buffer, offset, length, stopRow, 0, stopRow.length) <=
isScan);
+                  Bytes.compareTo(buffer, offset, length, stopRow, 0, stopRow.length) <=
0);
         } else {
           return Bytes.compareTo(buffer, offset, length, startRow, 0, startRow.length) >
0
               && (Bytes.equals(stopRow, HConstants.EMPTY_BYTE_ARRAY) ||
-                  Bytes.compareTo(buffer, offset, length, stopRow, 0, stopRow.length) <
isScan);
+                  Bytes.compareTo(buffer, offset, length, stopRow, 0, stopRow.length) <
0);
         }
       }
     }

http://git-wip-us.apache.org/repos/asf/hbase/blob/5dd170b2/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestMultiRowRangeFilter.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestMultiRowRangeFilter.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestMultiRowRangeFilter.java
index 8e2daa5..fe5fc29 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestMultiRowRangeFilter.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestMultiRowRangeFilter.java
@@ -457,6 +457,35 @@ public class TestMultiRowRangeFilter {
     ht.close();
   }
 
+  @Test
+  public void testOneRowRange() throws IOException {
+    tableName = Bytes.toBytes("testOneRowRange");
+    HTable ht = TEST_UTIL.createTable(tableName, family, Integer.MAX_VALUE);
+    generateRows(numRows, ht, family, qf, value);
+    ArrayList<MultiRowRangeFilter.RowRange> rowRangesList = new ArrayList<>();
+    rowRangesList
+        .add(new MultiRowRangeFilter.RowRange(Bytes.toBytes(50), true, Bytes.toBytes(50),
true));
+    Scan scan = new Scan();
+    scan.setFilter(new MultiRowRangeFilter(rowRangesList));
+    int resultsSize = getResultsSize(ht, scan);
+    assertEquals(1, resultsSize);
+    rowRangesList.clear();
+    rowRangesList
+        .add(new MultiRowRangeFilter.RowRange(Bytes.toBytes(50), true, Bytes.toBytes(51),
false));
+    scan = new Scan();
+    scan.setFilter(new MultiRowRangeFilter(rowRangesList));
+    resultsSize = getResultsSize(ht, scan);
+    assertEquals(1, resultsSize);
+    rowRangesList.clear();
+    rowRangesList
+        .add(new MultiRowRangeFilter.RowRange(Bytes.toBytes(50), true, Bytes.toBytes(51),
true));
+    scan = new Scan();
+    scan.setFilter(new MultiRowRangeFilter(rowRangesList));
+    resultsSize = getResultsSize(ht, scan);
+    assertEquals(2, resultsSize);
+    ht.close();
+  }
+
   private void generateRows(int numberOfRows, HTable ht, byte[] family, byte[] qf, byte[]
value)
       throws IOException {
     for (int i = 0; i < numberOfRows; i++) {
@@ -485,6 +514,7 @@ public class TestMultiRowRangeFilter {
         kvList.add(kv);
       }
     }
+    scanner.close();
     return kvList;
   }
 
@@ -497,6 +527,7 @@ public class TestMultiRowRangeFilter {
         results.add(kv);
       }
     }
+    scanner.close();
     return results.size();
   }
 }


Mime
View raw message