hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nspiegelb...@apache.org
Subject svn commit: r1181514 - in /hbase/branches/0.89/src: main/java/org/apache/hadoop/hbase/regionserver/ExplicitColumnTracker.java test/java/org/apache/hadoop/hbase/client/TestTimestampsFilter.java
Date Tue, 11 Oct 2011 02:15:39 GMT
Author: nspiegelberg
Date: Tue Oct 11 02:15:39 2011
New Revision: 1181514

URL: http://svn.apache.org/viewvc?rev=1181514&view=rev
Log:
fix missing column when multiple columns w TimestampsFilter

Summary:
Fix missing column problem with multiple columns are combined with
TimestampsFilter.

Test Plan:
unit tests

Reviewed By: kannan
Reviewers: kannan
Commenters: jgray
CC: jgray, kannan, hbase@lists
Tasks:
column is returned

Revert Plan:
OK.

Differential Revision: 232037

Modified:
    hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/regionserver/ExplicitColumnTracker.java
    hbase/branches/0.89/src/test/java/org/apache/hadoop/hbase/client/TestTimestampsFilter.java

Modified: hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/regionserver/ExplicitColumnTracker.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/regionserver/ExplicitColumnTracker.java?rev=1181514&r1=1181513&r2=1181514&view=diff
==============================================================================
--- hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/regionserver/ExplicitColumnTracker.java
(original)
+++ hbase/branches/0.89/src/main/java/org/apache/hadoop/hbase/regionserver/ExplicitColumnTracker.java
Tue Oct 11 02:15:39 2011
@@ -206,6 +206,7 @@ public class ExplicitColumnTracker imple
     while (this.column != null) {
       int compare = Bytes.compareTo(column.getBuffer(), column.getOffset(),
           column.getLength(), bytes, offset, length);
+      resetTS();
       if (compare == 0) {
         this.columns.remove(this.index);
         if (this.columns.size() == this.index) {

Modified: hbase/branches/0.89/src/test/java/org/apache/hadoop/hbase/client/TestTimestampsFilter.java
URL: http://svn.apache.org/viewvc/hbase/branches/0.89/src/test/java/org/apache/hadoop/hbase/client/TestTimestampsFilter.java?rev=1181514&r1=1181513&r2=1181514&view=diff
==============================================================================
--- hbase/branches/0.89/src/test/java/org/apache/hadoop/hbase/client/TestTimestampsFilter.java
(original)
+++ hbase/branches/0.89/src/test/java/org/apache/hadoop/hbase/client/TestTimestampsFilter.java
Tue Oct 11 02:15:39 2011
@@ -163,6 +163,52 @@ public class TestTimestampsFilter {
     }
   }
 
+  @Test
+  public void testMultiColumns() throws Exception {
+    byte [] TABLE = Bytes.toBytes("testTimestampsFilterMultiColumns");
+    byte [] FAMILY = Bytes.toBytes("event_log");
+    byte [][] FAMILIES = new byte[][] { FAMILY };
+    KeyValue kvs[];
+
+    // create table; set versions to max...
+    HTable ht = TEST_UTIL.createTable(TABLE, FAMILIES, Integer.MAX_VALUE);
+
+    Put p = new Put(Bytes.toBytes("row"));
+    p.add(FAMILY, Bytes.toBytes("column0"), 3, Bytes.toBytes("value0-3"));
+    p.add(FAMILY, Bytes.toBytes("column1"), 3, Bytes.toBytes("value1-3"));
+    p.add(FAMILY, Bytes.toBytes("column2"), 1, Bytes.toBytes("value2-1"));
+    p.add(FAMILY, Bytes.toBytes("column2"), 2, Bytes.toBytes("value2-2"));
+    p.add(FAMILY, Bytes.toBytes("column2"), 3, Bytes.toBytes("value2-3"));
+    p.add(FAMILY, Bytes.toBytes("column3"), 2, Bytes.toBytes("value3-2"));
+    p.add(FAMILY, Bytes.toBytes("column4"), 1, Bytes.toBytes("value4-1"));
+    p.add(FAMILY, Bytes.toBytes("column4"), 2, Bytes.toBytes("value4-2"));
+    p.add(FAMILY, Bytes.toBytes("column4"), 3, Bytes.toBytes("value4-3"));
+    ht.put(p);
+
+    ArrayList timestamps = new ArrayList();
+    timestamps.add(new Long(3));
+    TimestampsFilter filter = new TimestampsFilter(timestamps);
+
+    Get g = new Get(Bytes.toBytes("row"));
+    g.setFilter(filter);
+    g.setMaxVersions();
+    g.addColumn(FAMILY, Bytes.toBytes("column2"));
+    g.addColumn(FAMILY, Bytes.toBytes("column4"));
+
+    Result result = ht.get(g);
+    for (KeyValue kv : result.list()) {
+      System.out.println("found row " + Bytes.toString(kv.getRow()) +
+          ", column " + Bytes.toString(kv.getQualifier()) + ", value "
+          + Bytes.toString(kv.getValue()));
+    }
+
+    assertEquals(result.list().size(), 2);
+    assertEquals(Bytes.toString(result.list().get(0).getValue()),
+        "value2-3");
+    assertEquals(Bytes.toString(result.list().get(1).getValue()),
+        "value4-3");
+  }
+
   /**
    * Test TimestampsFilter in the presence of version deletes.
    *



Mime
View raw message