HBASE-17956 Raw scan should ignore TTL

This commit is contained in:
zhangduo 2017-04-25 14:02:10 +08:00
parent 2557506415
commit 8973582bc6
2 changed files with 25 additions and 1 deletions

View File

@ -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

View File

@ -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());
}
}
}
}