Repository: hbase Updated Branches: refs/heads/master 255750641 -> 8973582bc
HBASE-17956 Raw scan should ignore TTL Project: http://git-wip-us.apache.org/repos/asf/hbase/repo Commit: http://git-wip-us.apache.org/repos/asf/hbase/commit/8973582b Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/8973582b Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/8973582b Branch: refs/heads/master Commit: 8973582bc67a8a759310876e41a0348a1e26c89c Parents: 2557506 Author: zhangduo <zhang...@apache.org> Authored: Tue Apr 25 14:02:10 2017 +0800 Committer: zhangduo <zhang...@apache.org> Committed: Wed Apr 26 15:03:53 2017 +0800 ---------------------------------------------------------------------- .../hadoop/hbase/regionserver/StoreScanner.java | 2 +- .../client/TestScannersFromClientSide.java | 24 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/hbase/blob/8973582b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java index 3bc6a0f..e42979e 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/StoreScanner.java @@ -158,7 +158,7 @@ public class StoreScanner extends NonReversedNonLazyKeyValueScanner this.scan = scan; this.columns = columns; this.now = EnvironmentEdgeManager.currentTime(); - this.oldestUnexpiredTS = now - scanInfo.getTtl(); + this.oldestUnexpiredTS = scan.isRaw() ? 0L : now - scanInfo.getTtl(); this.minVersions = scanInfo.getMinVersions(); // We look up row-column Bloom filters for multi-column queries as part of http://git-wip-us.apache.org/repos/asf/hbase/blob/8973582b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestScannersFromClientSide.java ---------------------------------------------------------------------- diff --git a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestScannersFromClientSide.java b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestScannersFromClientSide.java index e5c19ac..1b18ee2 100644 --- a/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestScannersFromClientSide.java +++ b/hbase-server/src/test/java/org/apache/hadoop/hbase/client/TestScannersFromClientSide.java @@ -16,9 +16,12 @@ */ package org.apache.hadoop.hbase.client; +import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; @@ -30,6 +33,7 @@ import org.apache.commons.logging.LogFactory; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.hbase.Cell; import org.apache.hadoop.hbase.HBaseTestingUtility; +import org.apache.hadoop.hbase.HColumnDescriptor; import org.apache.hadoop.hbase.HConstants; import org.apache.hadoop.hbase.HRegionInfo; import org.apache.hadoop.hbase.HRegionLocation; @@ -795,4 +799,24 @@ public class TestScannersFromClientSide { assertEquals(expKvList.size(), result.size()); } + + @Test + public void testReadExpiredDataForRawScan() throws IOException { + TableName tableName = TableName.valueOf(name.getMethodName()); + long ts = System.currentTimeMillis() - 10000; + byte[] value = Bytes.toBytes("expired"); + try (Table table = TEST_UTIL.createTable(tableName, FAMILY)) { + table.put(new Put(ROW).addColumn(FAMILY, QUALIFIER, ts, value)); + assertArrayEquals(value, table.get(new Get(ROW)).getValue(FAMILY, QUALIFIER)); + TEST_UTIL.getAdmin().modifyColumnFamily(tableName, + new HColumnDescriptor(FAMILY).setTimeToLive(5)); + try (ResultScanner scanner = table.getScanner(FAMILY)) { + assertNull(scanner.next()); + } + try (ResultScanner scanner = table.getScanner(new Scan().setRaw(true))) { + assertArrayEquals(value, scanner.next().getValue(FAMILY, QUALIFIER)); + assertNull(scanner.next()); + } + } + } }