Skip to content

Commit 74ecf71

Browse files
committed
handle failed test cases
1 parent f6739e2 commit 74ecf71

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/querymatcher/NormalUserScanQueryMatcher.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ public MatchCode match(ExtendedCell cell, ExtendedCell prevCell, boolean visibil
8282
if (includeDeleteMarker) {
8383
this.deletes.add(cell);
8484
}
85+
// In some cases, optimization can not be done
86+
if (!canOptimizeReadDeleteMarkers(visibilityLabelEnabled)) {
87+
return MatchCode.SKIP;
88+
}
8589
}
8690
// optimization when prevCell is Delete or DeleteFamilyVersion
8791
if ((returnCode = checkDeletedEffectively(cell, prevCell, visibilityLabelEnabled)) != null) {
@@ -112,7 +116,7 @@ private MatchCode checkDeletedEffectively(ExtendedCell cell, ExtendedCell prevCe
112116
private boolean canOptimizeReadDeleteMarkers(boolean visibilityLabelEnabled) {
113117
// for simplicity, optimization works only for these cases
114118
return !seePastDeleteMarkers && scanMaxVersions == 1 && !visibilityLabelEnabled
115-
&& getFilter() == null;
119+
&& getFilter() == null && !(deletes instanceof NewVersionBehaviorTracker);
116120
}
117121

118122
@Override

hbase-server/src/test/java/org/apache/hadoop/hbase/regionserver/querymatcher/TestUserScanQueryMatcherDeleteMarkerOptimization.java

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,16 @@ public class TestUserScanQueryMatcherDeleteMarkerOptimization extends AbstractTe
5555
private List<Pair<KeyValue, MatchCode>> pairs;
5656

5757
private void verify(List<Pair<KeyValue, MatchCode>> pairs) throws IOException {
58-
verify(pairs, 1, false);
58+
verify(pairs, 1, false, false);
5959
}
6060

6161
private void verify(List<Pair<KeyValue, MatchCode>> pairs, int maxVersions,
62-
boolean visibilityEnabled) throws IOException {
62+
boolean visibilityEnabled, boolean newVersionBehavior) throws IOException {
6363
long now = EnvironmentEdgeManager.currentTime();
6464
scan.readVersions(maxVersions);
6565
UserScanQueryMatcher qm = UserScanQueryMatcher.create(scan,
6666
new ScanInfo(this.conf, fam1, 0, maxVersions, ttl, KeepDeletedCells.FALSE,
67-
HConstants.DEFAULT_BLOCKSIZE, 0, rowComparator, false),
67+
HConstants.DEFAULT_BLOCKSIZE, 0, rowComparator, newVersionBehavior),
6868
get.getFamilyMap().get(fam1), now - ttl, now, null);
6969

7070
List<KeyValue> storedKVs = new ArrayList<>();
@@ -121,7 +121,7 @@ public void testDeleteWithMaxVersions() throws IOException {
121121
pairs.add(new Pair<>(createKV(col1, 2, Type.Delete), MatchCode.SKIP));
122122
pairs.add(new Pair<>(createKV(col1, 2, Type.Put), MatchCode.SKIP));
123123
pairs.add(new Pair<>(createKV(col1, 1, Type.Put), MatchCode.INCLUDE));
124-
verify(pairs, 2, false);
124+
verify(pairs, 2, false, false);
125125
}
126126

127127
@Test
@@ -255,18 +255,27 @@ public void testVisibilityLabelEnabled() throws IOException {
255255
enableVisiblityLabels(conf);
256256
pairs.add(new Pair<>(createKV(col1, 3, Type.Delete), MatchCode.SKIP));
257257
pairs.add(new Pair<>(createKV(col1, 3, Type.Put), MatchCode.SKIP));
258-
pairs.add(new Pair<>(createKV(null, 2, Type.DeleteFamily), MatchCode.SEEK_NEXT_COL));
258+
pairs.add(new Pair<>(createKV(null, 2, Type.DeleteFamily), MatchCode.SKIP));
259259
pairs.add(new Pair<>(createKV(col1, 1, Type.Put), MatchCode.SEEK_NEXT_COL));
260-
verify(pairs, 1, VisibilityUtils.isVisibilityLabelEnabled(conf));
260+
verify(pairs, 1, VisibilityUtils.isVisibilityLabelEnabled(conf), false);
261261
}
262262

263263
@Test
264264
public void testScanWithFilter() throws IOException {
265265
scan.setFilter(new FilterList());
266266
pairs.add(new Pair<>(createKV(col1, 3, Type.Delete), MatchCode.SKIP));
267267
pairs.add(new Pair<>(createKV(col1, 3, Type.Put), MatchCode.SKIP));
268-
pairs.add(new Pair<>(createKV(null, 2, Type.DeleteFamily), MatchCode.SEEK_NEXT_COL));
268+
pairs.add(new Pair<>(createKV(null, 2, Type.DeleteFamily), MatchCode.SKIP));
269269
pairs.add(new Pair<>(createKV(col1, 1, Type.Put), MatchCode.SEEK_NEXT_COL));
270270
verify(pairs);
271271
}
272+
273+
@Test
274+
public void testNewVersionBehavior() throws IOException {
275+
pairs.add(new Pair<>(createKV(col1, 3, Type.Delete), MatchCode.SKIP));
276+
pairs.add(new Pair<>(createKV(col1, 3, Type.Put), MatchCode.SKIP));
277+
pairs.add(new Pair<>(createKV(null, 2, Type.DeleteFamily), MatchCode.SKIP));
278+
pairs.add(new Pair<>(createKV(col1, 1, Type.Put), MatchCode.SKIP));
279+
verify(pairs, 2, false, true);
280+
}
272281
}

0 commit comments

Comments
 (0)