HBASE-22710 Wrong result in one case of scan that use raw and version… (#767)

Signed-off-by: stack <stack@apache.org>
Signed-off-by: Duo Zhang <zhangduo@apache.org>
Signed-off-by: Viraj Jasani <vjasani@apache.org>
This commit is contained in:
bsglz 2020-04-30 16:21:37 +08:00 committed by GitHub
parent e26a2b5bf3
commit b810c9bb91
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 1 deletions

View File

@ -372,11 +372,12 @@ public abstract class ScanQueryMatcher implements ShipperListener {
if (userScan != null) { if (userScan != null) {
if (userScan.isRaw()) { if (userScan.isRaw()) {
resultMaxVersion = userScan.getMaxVersions(); resultMaxVersion = userScan.getMaxVersions();
maxVersionToCheck = userScan.hasFilter() ? Integer.MAX_VALUE : resultMaxVersion;
} else { } else {
resultMaxVersion = Math.min(userScan.getMaxVersions(), scanInfo.getMaxVersions()); resultMaxVersion = Math.min(userScan.getMaxVersions(), scanInfo.getMaxVersions());
}
maxVersionToCheck = userScan.hasFilter() ? scanInfo.getMaxVersions() : resultMaxVersion; maxVersionToCheck = userScan.hasFilter() ? scanInfo.getMaxVersions() : resultMaxVersion;
} }
}
DeleteTracker deleteTracker; DeleteTracker deleteTracker;
if (scanInfo.isNewVersionBehavior() && (userScan == null || !userScan.isRaw())) { if (scanInfo.isNewVersionBehavior() && (userScan == null || !userScan.isRaw())) {

View File

@ -36,6 +36,7 @@ import org.apache.hadoop.hbase.Cell;
import org.apache.hadoop.hbase.CellBuilderType; import org.apache.hadoop.hbase.CellBuilderType;
import org.apache.hadoop.hbase.CellComparator; import org.apache.hadoop.hbase.CellComparator;
import org.apache.hadoop.hbase.CellUtil; import org.apache.hadoop.hbase.CellUtil;
import org.apache.hadoop.hbase.CompareOperator;
import org.apache.hadoop.hbase.ExtendedCellBuilderFactory; import org.apache.hadoop.hbase.ExtendedCellBuilderFactory;
import org.apache.hadoop.hbase.HBaseClassTestRule; import org.apache.hadoop.hbase.HBaseClassTestRule;
import org.apache.hadoop.hbase.HBaseConfiguration; import org.apache.hadoop.hbase.HBaseConfiguration;
@ -46,7 +47,10 @@ import org.apache.hadoop.hbase.KeyValue;
import org.apache.hadoop.hbase.PrivateCellUtil; import org.apache.hadoop.hbase.PrivateCellUtil;
import org.apache.hadoop.hbase.client.Get; import org.apache.hadoop.hbase.client.Get;
import org.apache.hadoop.hbase.client.Scan; import org.apache.hadoop.hbase.client.Scan;
import org.apache.hadoop.hbase.filter.BinaryComparator;
import org.apache.hadoop.hbase.filter.ColumnCountGetFilter; import org.apache.hadoop.hbase.filter.ColumnCountGetFilter;
import org.apache.hadoop.hbase.filter.Filter;
import org.apache.hadoop.hbase.filter.QualifierFilter;
import org.apache.hadoop.hbase.testclassification.RegionServerTests; import org.apache.hadoop.hbase.testclassification.RegionServerTests;
import org.apache.hadoop.hbase.testclassification.SmallTests; import org.apache.hadoop.hbase.testclassification.SmallTests;
import org.apache.hadoop.hbase.util.Bytes; import org.apache.hadoop.hbase.util.Bytes;
@ -1022,4 +1026,30 @@ public class TestStoreScanner {
assertFalse(storeScanner.isScanUsePread()); assertFalse(storeScanner.isScanUsePread());
} }
} }
@Test
public void testReadVersionWithRawAndFilter() throws IOException {
ScanInfo scanInfo = new ScanInfo(CONF, CF, 0, 1, Long.MAX_VALUE,
KeepDeletedCells.FALSE, HConstants.DEFAULT_BLOCKSIZE, 0
, CellComparator.getInstance(), false);
KeyValue [] kvs = new KeyValue[] {
create("R1", "cf", "a", 3, KeyValue.Type.Put, "dont-care"),
create("R1", "cf", "a", 2, KeyValue.Type.Put, "dont-care"),
create("R1", "cf", "a", 1, KeyValue.Type.Put, "dont-care")
};
List<KeyValueScanner> scanners = Arrays.asList(
new KeyValueScanner[]{
new KeyValueScanFixture(CellComparator.getInstance(), kvs)
});
BinaryComparator comp = new BinaryComparator(Bytes.toBytes("a"));
Filter filter = new QualifierFilter(CompareOperator.EQUAL, comp);
Scan scanSpec = new Scan().withStartRow(Bytes.toBytes("R1")).readVersions(2).setRaw(true);
scanSpec.setFilter(filter);
try (StoreScanner scan = new StoreScanner(scanSpec, scanInfo, null, scanners)) {
List<Cell> results = new ArrayList<>();
assertEquals(true, scan.next(results));
assertEquals(2, results.size());
}
}
} }