From 5486d8df706d3fb203a8d80833f1566e442deda0 Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Thu, 14 Apr 2011 04:24:25 +0000 Subject: [PATCH] HBASE-3685 when multiple columns are combined with TimestampFilter, only one column is returned git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1091995 13f79535-47bb-0310-9956-ffa450edef68 --- CHANGES.txt | 2 + .../regionserver/ExplicitColumnTracker.java | 1 + .../hbase/client/TestTimestampsFilter.java | 46 +++++++++++++++++++ 3 files changed, 49 insertions(+) diff --git a/CHANGES.txt b/CHANGES.txt index e5621dc7e50..41779397b52 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -204,6 +204,8 @@ Release 0.90.3 - Unreleased message with more help HBASE-3722 A lot of data is lost when name node crashed (gaojinchao) HBASE-3771 All jsp pages don't clean their HBA + HBASE-3685 when multiple columns are combined with TimestampFilter, only + one column is returned (Jerry Chen) IMPROVEMENTS HBASE-3747 ReplicationSource should differanciate remote and local exceptions diff --git a/src/main/java/org/apache/hadoop/hbase/regionserver/ExplicitColumnTracker.java b/src/main/java/org/apache/hadoop/hbase/regionserver/ExplicitColumnTracker.java index 1f053683725..f48343269c8 100644 --- a/src/main/java/org/apache/hadoop/hbase/regionserver/ExplicitColumnTracker.java +++ b/src/main/java/org/apache/hadoop/hbase/regionserver/ExplicitColumnTracker.java @@ -206,6 +206,7 @@ public class ExplicitColumnTracker implements ColumnTracker { 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) { diff --git a/src/test/java/org/apache/hadoop/hbase/client/TestTimestampsFilter.java b/src/test/java/org/apache/hadoop/hbase/client/TestTimestampsFilter.java index e48e5dd32cf..9f6b28f159f 100644 --- a/src/test/java/org/apache/hadoop/hbase/client/TestTimestampsFilter.java +++ b/src/test/java/org/apache/hadoop/hbase/client/TestTimestampsFilter.java @@ -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. *