Repository: hbase Updated Branches: refs/heads/branch-1 9d1deeec8 -> cbae65763
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/cbae6576 Tree: http://git-wip-us.apache.org/repos/asf/hbase/tree/cbae6576 Diff: http://git-wip-us.apache.org/repos/asf/hbase/diff/cbae6576 Branch: refs/heads/branch-1 Commit: cbae657632ba25575700f06b8ff3308269ec164b Parents: 9d1deee Author: zhangduo <zhang...@apache.org> Authored: Wed Apr 26 15:34:14 2017 +0800 Committer: zhangduo <zhang...@apache.org> Committed: Wed Apr 26 15:34:14 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/cbae6576/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 c98af00..28d9ef2 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 @@ -155,7 +155,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/cbae6576/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 4e356e4..17c8b92 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; @@ -27,6 +30,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; @@ -675,4 +679,24 @@ public class TestScannersFromClientSide { assertEquals(expKvList.size(), result.size()); } + + @Test + public void testReadExpiredDataForRawScan() throws IOException { + TableName tableName = TableName.valueOf("testReadExpiredDataForRawScan"); + 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.getHBaseAdmin().modifyColumn(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()); + } + } + } }