hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jg...@apache.org
Subject svn commit: r814098 - in /hadoop/hbase/branches/0.20: CHANGES.txt src/java/org/apache/hadoop/hbase/filter/CompareFilter.java src/test/org/apache/hadoop/hbase/client/TestClient.java
Date Sat, 12 Sep 2009 01:01:26 GMT
Author: jgray
Date: Sat Sep 12 01:01:26 2009
New Revision: 814098

URL: http://svn.apache.org/viewvc?rev=814098&view=rev
Log:
HBASE-1828  CompareFilters are broken from client-side

Modified:
    hadoop/hbase/branches/0.20/CHANGES.txt
    hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/filter/CompareFilter.java
    hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/client/TestClient.java

Modified: hadoop/hbase/branches/0.20/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/CHANGES.txt?rev=814098&r1=814097&r2=814098&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20/CHANGES.txt (original)
+++ hadoop/hbase/branches/0.20/CHANGES.txt Sat Sep 12 01:01:26 2009
@@ -8,6 +8,7 @@
    HBASE-1794  recovered log files are not inserted into the storefile map
    HBASE-1740  ICV has a subtle race condition only visible under high load
    HBASE-1808  [stargate] fix how columns are specified for scanners
+   HBASE-1828  CompareFilters are broken from client-side
 
   IMPROVEMENTS
    HBASE-1819  Update to 0.20.1 hadoop and zk 3.2.1

Modified: hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/filter/CompareFilter.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/filter/CompareFilter.java?rev=814098&r1=814097&r2=814098&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/filter/CompareFilter.java
(original)
+++ hadoop/hbase/branches/0.20/src/java/org/apache/hadoop/hbase/filter/CompareFilter.java
Sat Sep 12 01:01:26 2009
@@ -27,7 +27,6 @@
 
 import org.apache.hadoop.hbase.HBaseConfiguration;
 import org.apache.hadoop.hbase.KeyValue;
-import org.apache.hadoop.hbase.io.HbaseObjectWritable;
 import org.apache.hadoop.io.ObjectWritable;
 
 /**
@@ -127,15 +126,17 @@
     }
   }
   
+  private static final HBaseConfiguration hbc = new HBaseConfiguration();
+  
   public void readFields(DataInput in) throws IOException {
     compareOp = CompareOp.valueOf(in.readUTF());
     comparator = (WritableByteArrayComparable)
-        HbaseObjectWritable.readObject(in, null);
+        ObjectWritable.readObject(in, hbc);
   }
 
   public void write(DataOutput out) throws IOException {
     out.writeUTF(compareOp.name());
     ObjectWritable.writeObject(out, comparator,
-        WritableByteArrayComparable.class, null);
+        WritableByteArrayComparable.class, hbc);
   }
 }

Modified: hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/client/TestClient.java
URL: http://svn.apache.org/viewvc/hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/client/TestClient.java?rev=814098&r1=814097&r2=814098&view=diff
==============================================================================
--- hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/client/TestClient.java (original)
+++ hadoop/hbase/branches/0.20/src/test/org/apache/hadoop/hbase/client/TestClient.java Sat
Sep 12 01:01:26 2009
@@ -27,6 +27,10 @@
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.HTableDescriptor;
 import org.apache.hadoop.hbase.KeyValue;
+import org.apache.hadoop.hbase.filter.Filter;
+import org.apache.hadoop.hbase.filter.QualifierFilter;
+import org.apache.hadoop.hbase.filter.RegexStringComparator;
+import org.apache.hadoop.hbase.filter.CompareFilter.CompareOp;
 import org.apache.hadoop.hbase.util.Bytes;
 
 public class TestClient extends HBaseClusterTestCase {
@@ -60,6 +64,40 @@
     System.out.println("Done.");
   }
   
+  public void testFilters() throws Exception {
+    byte [] TABLE = Bytes.toBytes("testFilters");
+    HTable ht = createTable(TABLE, FAMILY);
+    byte [][] ROWS = makeN(ROW, 10);
+    byte [][] QUALIFIERS = {
+        Bytes.toBytes("col0-<d2v1>-<d3v2>"), Bytes.toBytes("col1-<d2v1>-<d3v2>"),

+        Bytes.toBytes("col2-<d2v1>-<d3v2>"), Bytes.toBytes("col3-<d2v1>-<d3v2>"),

+        Bytes.toBytes("col4-<d2v1>-<d3v2>"), Bytes.toBytes("col5-<d2v1>-<d3v2>"),

+        Bytes.toBytes("col6-<d2v1>-<d3v2>"), Bytes.toBytes("col7-<d2v1>-<d3v2>"),

+        Bytes.toBytes("col8-<d2v1>-<d3v2>"), Bytes.toBytes("col9-<d2v1>-<d3v2>")
+    };
+    for(int i=0;i<10;i++) {
+      Put put = new Put(ROWS[i]);
+      put.add(FAMILY, QUALIFIERS[i], VALUE);
+      ht.put(put);
+    }
+    Scan scan = new Scan();
+    scan.addFamily(FAMILY);
+    Filter filter = new QualifierFilter(CompareOp.EQUAL,
+        new RegexStringComparator("col[1-5]"));
+    scan.setFilter(filter);
+    ResultScanner scanner = ht.getScanner(scan);
+    int expectedIndex = 1;
+    for(Result result : ht.getScanner(scan)) {
+      assertEquals(result.size(), 1);
+      assertTrue(Bytes.equals(result.raw()[0].getRow(), ROWS[expectedIndex]));
+      assertTrue(Bytes.equals(result.raw()[0].getQualifier(), 
+          QUALIFIERS[expectedIndex]));
+      expectedIndex++;
+    }
+    assertEquals(expectedIndex, 6);
+    scanner.close();
+  }
+  
   /**
    * Test simple table and non-existent row cases.
    */



Mime
View raw message