Skip to content

Commit f6739e2

Browse files
committed
remove incorrect early return of MatchCode.SKIP
1 parent 202ea7d commit f6739e2

File tree

3 files changed

+18
-44
lines changed

3 files changed

+18
-44
lines changed

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

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,6 @@ public MatchCode match(ExtendedCell cell, ExtendedCell prevCell, boolean visibil
8282
if (includeDeleteMarker) {
8383
this.deletes.add(cell);
8484
}
85-
// optimization for delete markers
86-
if ((returnCode = checkCanSeekNextCol(cell, prevCell, visibilityLabelEnabled)) != null) {
87-
return returnCode;
88-
}
89-
return MatchCode.SKIP;
9085
}
9186
// optimization when prevCell is Delete or DeleteFamilyVersion
9287
if ((returnCode = checkDeletedEffectively(cell, prevCell, visibilityLabelEnabled)) != null) {
@@ -98,28 +93,15 @@ public MatchCode match(ExtendedCell cell, ExtendedCell prevCell, boolean visibil
9893
return matchColumn(cell, timestamp, typeByte);
9994
}
10095

101-
private MatchCode checkCanSeekNextCol(ExtendedCell cell, ExtendedCell prevCell,
102-
boolean visibilityLabelEnabled) {
103-
// optimization for DeleteFamily and DeleteColumn(only for empty qualifier)
104-
if (
105-
canOptimizeReadDeleteMarkers(visibilityLabelEnabled) && (PrivateCellUtil.isDeleteFamily(cell)
106-
|| PrivateCellUtil.isDeleteColumns(cell) && cell.getQualifierLength() > 0)
107-
) {
108-
return MatchCode.SEEK_NEXT_COL;
109-
}
110-
// optimization for duplicate Delete and DeleteFamilyVersion
111-
return checkDeletedEffectively(cell, prevCell, visibilityLabelEnabled);
112-
}
113-
114-
// If prevCell is a delete marker and cell is a Put or delete marker,
96+
// If prevCell is a delete marker and cell is a delete marked Put or delete marker,
11597
// it means the cell is deleted effectively.
11698
// And we can do SEEK_NEXT_COL.
11799
private MatchCode checkDeletedEffectively(ExtendedCell cell, ExtendedCell prevCell,
118100
boolean visibilityLabelEnabled) {
119101
if (
120102
prevCell != null && canOptimizeReadDeleteMarkers(visibilityLabelEnabled)
121103
&& CellUtil.matchingRowColumn(prevCell, cell) && CellUtil.matchingTimestamp(prevCell, cell)
122-
&& (PrivateCellUtil.isDeleteType(prevCell) && cell.getQualifierLength() > 0
104+
&& (PrivateCellUtil.isDeleteType(prevCell)
123105
|| PrivateCellUtil.isDeleteFamilyVersion(prevCell))
124106
) {
125107
return MatchCode.SEEK_NEXT_COL;

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -224,13 +224,13 @@ public void testKeepDeletedCells() throws IOException {
224224
kvs.add(create("r", CF, "q", 1, Type.Put, "v"));
225225
kvs.add(create("r", CF, "q1", 1, Type.Put, "v"));
226226

227-
// optimization works only for KeepDeletedCells.FALSE
227+
// optimization does not work. optimization works only for KeepDeletedCells.FALSE
228228
result = scanAll(KeepDeletedCells.TRUE, 1);
229229
assertEquals(1, result.getFirst().size());
230230
assertEquals(kvs.get(4), result.getFirst().get(0));
231231
assertEquals(kvs.size(), result.getSecond().longValue());
232232

233-
// optimization works only for KeepDeletedCells.FALSE
233+
// optimization does not work. optimization works only for KeepDeletedCells.FALSE
234234
result = scanAll(KeepDeletedCells.TTL, 1);
235235
assertEquals(1, result.getFirst().size());
236236
assertEquals(kvs.get(4), result.getFirst().get(0));
@@ -239,16 +239,16 @@ public void testKeepDeletedCells() throws IOException {
239239

240240
@Test
241241
public void testScanMaxVersions() throws IOException {
242-
kvs.add(create("r", CF, "q", 4, Type.DeleteColumn, ""));
243-
kvs.add(create("r", CF, "q", 3, Type.DeleteColumn, ""));
244-
kvs.add(create("r", CF, "q", 2, Type.DeleteColumn, ""));
242+
kvs.add(create("r", CF, "q", 2, Type.Delete, ""));
243+
kvs.add(create("r", CF, "q", 2, Type.Put, "v"));
244+
kvs.add(create("r", CF, "q", 1, Type.Delete, ""));
245245
kvs.add(create("r", CF, "q", 1, Type.Put, "v"));
246246

247247
// optimization works only for maxVersions = 1
248248
result = scanAll(KeepDeletedCells.FALSE, 1);
249249
assertEquals(0, result.getFirst().size());
250-
// kvs0
251-
assertEquals(1, result.getSecond().longValue());
250+
// kvs0, kvs1
251+
assertEquals(2, result.getSecond().longValue());
252252

253253
// optimization does not work
254254
result = scanAll(KeepDeletedCells.FALSE, 2);

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

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,8 @@ public void testNotDuplicatDelete() throws IOException {
108108

109109
@Test
110110
public void testEffectiveDelete() throws IOException {
111+
pairs.add(new Pair<>(createKV(null, 2, Type.Delete), MatchCode.SKIP));
112+
pairs.add(new Pair<>(createKV(null, 2, Type.Put), MatchCode.SEEK_NEXT_COL));
111113
pairs.add(new Pair<>(createKV(col1, 2, Type.Delete), MatchCode.SKIP));
112114
pairs.add(new Pair<>(createKV(col1, 2, Type.Put), MatchCode.SEEK_NEXT_COL));
113115
verify(pairs);
@@ -213,20 +215,6 @@ public void testDeleteFamilyAfterPut() throws IOException {
213215
verify(pairs);
214216
}
215217

216-
@Test
217-
public void testEmptyQualifierDeleteShouldNotSeekNextColumn() throws IOException {
218-
// The empty qualifier is used for DeleteFamily and DeleteFamilyVersion markers only.
219-
// So we should not seek to next column for any other type.
220-
pairs.add(new Pair<>(createKV(null, 4, Type.Delete), MatchCode.SKIP));
221-
pairs.add(new Pair<>(createKV(null, 4, Type.Delete), MatchCode.SKIP));
222-
pairs.add(new Pair<>(createKV(null, 3, Type.DeleteColumn), MatchCode.SKIP));
223-
pairs.add(new Pair<>(createKV(null, 3, Type.DeleteColumn), MatchCode.SKIP));
224-
pairs.add(new Pair<>(createKV(null, 2, Type.DeleteFamilyVersion), MatchCode.SKIP));
225-
pairs.add(new Pair<>(createKV(null, 2, Type.DeleteFamilyVersion), MatchCode.SEEK_NEXT_COL));
226-
pairs.add(new Pair<>(createKV(null, 1, Type.DeleteFamily), MatchCode.SEEK_NEXT_COL));
227-
verify(pairs);
228-
}
229-
230218
@Test
231219
public void testKeyForNextColumnForDeleteFamily() throws IOException {
232220
long now = EnvironmentEdgeManager.currentTime();
@@ -262,18 +250,22 @@ public void testNoDelete() throws IOException {
262250
}
263251

264252
@Test
265-
public void testDeleteFamilyWithVisibilityLabelEnabled() throws IOException {
253+
public void testVisibilityLabelEnabled() throws IOException {
266254
Configuration conf = HBaseConfiguration.create();
267255
enableVisiblityLabels(conf);
268-
pairs.add(new Pair<>(createKV(null, 2, Type.DeleteFamily), MatchCode.SKIP));
256+
pairs.add(new Pair<>(createKV(col1, 3, Type.Delete), MatchCode.SKIP));
257+
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));
269259
pairs.add(new Pair<>(createKV(col1, 1, Type.Put), MatchCode.SEEK_NEXT_COL));
270260
verify(pairs, 1, VisibilityUtils.isVisibilityLabelEnabled(conf));
271261
}
272262

273263
@Test
274264
public void testScanWithFilter() throws IOException {
275265
scan.setFilter(new FilterList());
276-
pairs.add(new Pair<>(createKV(null, 2, Type.DeleteFamily), MatchCode.SKIP));
266+
pairs.add(new Pair<>(createKV(col1, 3, Type.Delete), MatchCode.SKIP));
267+
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));
277269
pairs.add(new Pair<>(createKV(col1, 1, Type.Put), MatchCode.SEEK_NEXT_COL));
278270
verify(pairs);
279271
}

0 commit comments

Comments
 (0)