hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From apurt...@apache.org
Subject hbase git commit: HBASE-17297 Single Filter in parenthesis cannot be parsed correctly (Xuesen Liang)
Date Tue, 20 Dec 2016 00:41:30 GMT
Repository: hbase
Updated Branches:
  refs/heads/0.98 a1ca72344 -> ecdcb2281


HBASE-17297 Single Filter in parenthesis cannot be parsed correctly (Xuesen Liang)


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

Branch: refs/heads/0.98
Commit: ecdcb2281f75daa2d797af3aa4df5582a0dc4821
Parents: a1ca723
Author: tedyu <yuzhihong@gmail.com>
Authored: Mon Dec 12 12:09:22 2016 -0800
Committer: Andrew Purtell <apurtell@apache.org>
Committed: Mon Dec 19 15:17:17 2016 -0800

----------------------------------------------------------------------
 .../org/apache/hadoop/hbase/filter/ParseFilter.java |  7 +++++++
 .../apache/hadoop/hbase/filter/TestParseFilter.java | 16 ++++++++++++++++
 2 files changed, 23 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/hbase/blob/ecdcb228/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ParseFilter.java
----------------------------------------------------------------------
diff --git a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ParseFilter.java b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ParseFilter.java
index 9d6bd3c..4ba675b 100644
--- a/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ParseFilter.java
+++ b/hbase-client/src/main/java/org/apache/hadoop/hbase/filter/ParseFilter.java
@@ -162,6 +162,10 @@ public class ParseFilter {
           throw new IllegalArgumentException("Mismatched parenthesis");
         }
         ByteBuffer argumentOnTopOfStack = operatorStack.peek();
+        if (argumentOnTopOfStack.equals(ParseConstants.LPAREN_BUFFER)) {
+          operatorStack.pop();
+          continue;
+        }
         while (!(argumentOnTopOfStack.equals(ParseConstants.LPAREN_BUFFER))) {
           filterStack.push(popArguments(operatorStack, filterStack));
           if (operatorStack.empty()) {
@@ -182,6 +186,9 @@ public class ParseFilter {
     while (!operatorStack.empty()) {
       filterStack.push(popArguments(operatorStack, filterStack));
     }
+    if (filterStack.empty()) {
+        throw new IllegalArgumentException("Incorrect Filter String");
+    }
     filter = filterStack.pop();
     if (!filterStack.empty()) {
       throw new IllegalArgumentException("Incorrect Filter String");

http://git-wip-us.apache.org/repos/asf/hbase/blob/ecdcb228/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestParseFilter.java
----------------------------------------------------------------------
diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestParseFilter.java
b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestParseFilter.java
index 9a4b386..91c80bd 100644
--- a/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestParseFilter.java
+++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/filter/TestParseFilter.java
@@ -508,6 +508,22 @@ public class TestParseFilter {
   }
 
   @Test
+  public void testCompoundFilter5() throws IOException {
+    String filterStr = "(ValueFilter(!=, 'substring:pre'))";
+    ValueFilter valueFilter = doTestFilter(filterStr, ValueFilter.class);
+    assertTrue(valueFilter.getComparator() instanceof SubstringComparator);
+
+    filterStr = "(ValueFilter(>=,'binary:x') AND (ValueFilter(<=,'binary:y')))"
+            + " OR ValueFilter(=,'binary:ab')";
+    filter = f.parseFilterString(filterStr);
+    assertTrue(filter instanceof FilterList);
+    List<Filter> list = ((FilterList) filter).getFilters();
+    assertEquals(2, list.size());
+    assertTrue(list.get(0) instanceof FilterList);
+    assertTrue(list.get(1) instanceof ValueFilter);
+  }
+
+  @Test
   public void testIncorrectCompareOperator() throws IOException {
     String filterString = "RowFilter ('>>' , 'binary:region')";
     try {


Mime
View raw message