From a34a37985f43b9101a3921aa54b0e7b0e58ba377 Mon Sep 17 00:00:00 2001 From: Michael Stack Date: Mon, 21 Jul 2008 15:47:35 +0000 Subject: [PATCH] HBASE-756 In HBase shell, the put command doesn't process the timestamp git-svn-id: https://svn.apache.org/repos/asf/hadoop/hbase/trunk@678454 13f79535-47bb-0310-9956-ffa450edef68 --- bin/HBase.rb | 2 +- .../org/apache/hadoop/hbase/regionserver/HStore.java | 10 ++-------- .../hadoop/hbase/regionserver/TestCompaction.java | 12 ++++++++++-- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/bin/HBase.rb b/bin/HBase.rb index c860f151e23..4f5c6e703fa 100644 --- a/bin/HBase.rb +++ b/bin/HBase.rb @@ -251,7 +251,7 @@ module HBase now = Time.now bu = nil if timestamp - bu = BatchUpdate.new(row) + bu = BatchUpdate.new(row, timestamp) else bu = BatchUpdate.new(row) end diff --git a/src/java/org/apache/hadoop/hbase/regionserver/HStore.java b/src/java/org/apache/hadoop/hbase/regionserver/HStore.java index 35c699dc3a4..b8304ea4f7e 100644 --- a/src/java/org/apache/hadoop/hbase/regionserver/HStore.java +++ b/src/java/org/apache/hadoop/hbase/regionserver/HStore.java @@ -840,8 +840,7 @@ public class HStore implements HConstants { int timesSeen = 0; byte [] lastRow = null; byte [] lastColumn = null; - // Map of a row deletes keyed by column with a list of timestamps for value - Map> deletes = null; + while (numDone < done.length) { // Find the reader with the smallest key. If two files have same key // but different values -- i.e. one is delete and other is non-delete @@ -869,14 +868,9 @@ public class HStore implements HConstants { timesSeen++; } else { timesSeen = 0; - // We are on to a new row. Create a new deletes list. - deletes = new TreeMap>(Bytes.BYTES_COMPARATOR); } - byte [] value = (vals[smallestKey] == null)? - null: vals[smallestKey].get(); - if (!isDeleted(sk, value, false, deletes) && - timesSeen <= family.getMaxVersions()) { + if (timesSeen <= family.getMaxVersions()) { // Keep old versions until we have maxVersions worth. // Then just skip them. if (sk.getRow().length != 0 && sk.getColumn().length != 0) { diff --git a/src/test/org/apache/hadoop/hbase/regionserver/TestCompaction.java b/src/test/org/apache/hadoop/hbase/regionserver/TestCompaction.java index 2a128631b85..164337ca96b 100644 --- a/src/test/org/apache/hadoop/hbase/regionserver/TestCompaction.java +++ b/src/test/org/apache/hadoop/hbase/regionserver/TestCompaction.java @@ -144,16 +144,24 @@ public class TestCompaction extends HBaseTestCase { // Assert that the first row is still deleted. cellValues = r.get(STARTROW, COLUMN_FAMILY_TEXT, 100 /*Too many*/); assertNull(cellValues); - // Assert the store files do not have the first record 'aaa' keys in them. + // Make sure the store files do have some 'aaa' keys in them. + boolean containsStartRow = false; for (MapFile.Reader reader: this.r.stores. get(Bytes.mapKey(COLUMN_FAMILY_TEXT_MINUS_COLON)).getReaders()) { reader.reset(); HStoreKey key = new HStoreKey(); ImmutableBytesWritable val = new ImmutableBytesWritable(); while(reader.next(key, val)) { - assertFalse(Bytes.equals(key.getRow(), STARTROW)); + if (Bytes.equals(key.getRow(), STARTROW)) { + containsStartRow = true; + break; + } + } + if (containsStartRow) { + break; } } + assertTrue(containsStartRow); } private void createStoreFile(final HRegion region) throws IOException {