hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From te...@apache.org
Subject hbase git commit: HBASE-17297 Single Filter in parenthesis cannot be parsed correctly (Xuesen Liang)
Date Mon, 12 Dec 2016 20:07:40 GMT
Repository: hbase
Updated Branches:
  refs/heads/master 1615f45b3 -> adb319f5c


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/adb319f5
Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/adb319f5
Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/adb319f5

Branch: refs/heads/master
Commit: adb319f5c23e8813ac8cc5a27a483caf825dfdda
Parents: 1615f45
Author: tedyu <yuzhihong@gmail.com>
Authored: Mon Dec 12 12:07:34 2016 -0800
Committer: tedyu <yuzhihong@gmail.com>
Committed: Mon Dec 12 12:07:34 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/adb319f5/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 5089308..f59ddb5 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
@@ -161,6 +161,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()) {
@@ -181,6 +185,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/adb319f5/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 4b2df33..b6d8bc1 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
@@ -509,6 +509,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