Skip to content

Commit 6390115

Browse files
committed
make visibilityLabelEnabled a instance variable
1 parent 74ecf71 commit 6390115

6 files changed

Lines changed: 48 additions & 45 deletions

File tree

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ public StoreScanner(HStore store, ScanInfo scanInfo, Scan scan, NavigableSet<byt
249249
throw new DoNotRetryIOException("Cannot specify any column for a raw scan");
250250
}
251251
matcher = UserScanQueryMatcher.create(scan, scanInfo, columns, oldestUnexpiredTS, now,
252-
store.getCoprocessorHost());
252+
store.getCoprocessorHost(), visibilityLabelEnabled);
253253

254254
store.addChangedReaderObserver(this);
255255

@@ -363,8 +363,8 @@ public StoreScanner(ScanInfo scanInfo, ScanType scanType,
363363
this(null, scan, scanInfo, columns != null ? columns.size() : 0, 0L, scan.getCacheBlocks(),
364364
scanType);
365365
if (scanType == ScanType.USER_SCAN) {
366-
this.matcher =
367-
UserScanQueryMatcher.create(scan, scanInfo, columns, oldestUnexpiredTS, now, null);
366+
this.matcher = UserScanQueryMatcher.create(scan, scanInfo, columns, oldestUnexpiredTS, now,
367+
null, visibilityLabelEnabled);
368368
} else {
369369
this.matcher = CompactionScanQueryMatcher.create(scanInfo, scanType, Long.MAX_VALUE,
370370
PrivateConstants.OLDEST_TIMESTAMP, oldestUnexpiredTS, now, null, null, null);
@@ -378,8 +378,8 @@ public StoreScanner(ScanInfo scanInfo, ScanType scanType,
378378
// 0 is passed as readpoint because the test bypasses Store
379379
this(null, scan, scanInfo, columns != null ? columns.size() : 0, 0L, scan.getCacheBlocks(),
380380
ScanType.USER_SCAN);
381-
this.matcher =
382-
UserScanQueryMatcher.create(scan, scanInfo, columns, oldestUnexpiredTS, now, null);
381+
this.matcher = UserScanQueryMatcher.create(scan, scanInfo, columns, oldestUnexpiredTS, now,
382+
null, visibilityLabelEnabled);
383383
seekAllScanner(scanInfo, scanners);
384384
}
385385

@@ -641,7 +641,7 @@ public boolean next(List<? super ExtendedCell> outResult, ScannerContext scanner
641641

642642
scannerContext.setLastPeekedCell(cell);
643643
topChanged = false;
644-
ScanQueryMatcher.MatchCode qcode = matcher.match(cell, prevCell, visibilityLabelEnabled);
644+
ScanQueryMatcher.MatchCode qcode = matcher.match(cell, prevCell);
645645
LOG.trace("next - cell={}, prevCell={}, qCode={}", cell, prevCell, qcode);
646646
prevCell = cell;
647647
switch (qcode) {

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

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,17 @@ public abstract class NormalUserScanQueryMatcher extends UserScanQueryMatcher {
4343

4444
private final int scanMaxVersions;
4545

46+
private final boolean visibilityLabelEnabled;
47+
4648
protected NormalUserScanQueryMatcher(Scan scan, ScanInfo scanInfo, ColumnTracker columns,
47-
boolean hasNullColumn, DeleteTracker deletes, long oldestUnexpiredTS, long now) {
49+
boolean hasNullColumn, DeleteTracker deletes, long oldestUnexpiredTS, long now,
50+
boolean visibilityLabelEnabled) {
4851
super(scan, scanInfo, columns, hasNullColumn, oldestUnexpiredTS, now);
4952
this.deletes = deletes;
5053
this.get = scan.isGetScan();
5154
this.seePastDeleteMarkers = scanInfo.getKeepDeletedCells() != KeepDeletedCells.FALSE;
5255
this.scanMaxVersions = Math.max(scan.getMaxVersions(), scanInfo.getMaxVersions());
56+
this.visibilityLabelEnabled = visibilityLabelEnabled;
5357
}
5458

5559
@Override
@@ -60,13 +64,11 @@ public void beforeShipped() throws IOException {
6064

6165
@Override
6266
public MatchCode match(ExtendedCell cell) throws IOException {
63-
// set visibilityLabelEnabled to true pessimistically if it cannot be determined
64-
return match(cell, null, true);
67+
return match(cell, null);
6568
}
6669

6770
@Override
68-
public MatchCode match(ExtendedCell cell, ExtendedCell prevCell, boolean visibilityLabelEnabled)
69-
throws IOException {
71+
public MatchCode match(ExtendedCell cell, ExtendedCell prevCell) throws IOException {
7072
if (filter != null && filter.filterAllRemaining()) {
7173
return MatchCode.DONE_SCAN;
7274
}
@@ -83,12 +85,12 @@ public MatchCode match(ExtendedCell cell, ExtendedCell prevCell, boolean visibil
8385
this.deletes.add(cell);
8486
}
8587
// In some cases, optimization can not be done
86-
if (!canOptimizeReadDeleteMarkers(visibilityLabelEnabled)) {
88+
if (!canOptimizeReadDeleteMarkers()) {
8789
return MatchCode.SKIP;
8890
}
8991
}
9092
// optimization when prevCell is Delete or DeleteFamilyVersion
91-
if ((returnCode = checkDeletedEffectively(cell, prevCell, visibilityLabelEnabled)) != null) {
93+
if ((returnCode = checkDeletedEffectively(cell, prevCell)) != null) {
9294
return returnCode;
9395
}
9496
if ((returnCode = checkDeleted(deletes, cell)) != null) {
@@ -100,10 +102,9 @@ public MatchCode match(ExtendedCell cell, ExtendedCell prevCell, boolean visibil
100102
// If prevCell is a delete marker and cell is a delete marked Put or delete marker,
101103
// it means the cell is deleted effectively.
102104
// And we can do SEEK_NEXT_COL.
103-
private MatchCode checkDeletedEffectively(ExtendedCell cell, ExtendedCell prevCell,
104-
boolean visibilityLabelEnabled) {
105+
private MatchCode checkDeletedEffectively(ExtendedCell cell, ExtendedCell prevCell) {
105106
if (
106-
prevCell != null && canOptimizeReadDeleteMarkers(visibilityLabelEnabled)
107+
prevCell != null && canOptimizeReadDeleteMarkers()
107108
&& CellUtil.matchingRowColumn(prevCell, cell) && CellUtil.matchingTimestamp(prevCell, cell)
108109
&& (PrivateCellUtil.isDeleteType(prevCell)
109110
|| PrivateCellUtil.isDeleteFamilyVersion(prevCell))
@@ -113,7 +114,7 @@ private MatchCode checkDeletedEffectively(ExtendedCell cell, ExtendedCell prevCe
113114
return null;
114115
}
115116

116-
private boolean canOptimizeReadDeleteMarkers(boolean visibilityLabelEnabled) {
117+
private boolean canOptimizeReadDeleteMarkers() {
117118
// for simplicity, optimization works only for these cases
118119
return !seePastDeleteMarkers && scanMaxVersions == 1 && !visibilityLabelEnabled
119120
&& getFilter() == null && !(deletes instanceof NewVersionBehaviorTracker);
@@ -131,11 +132,11 @@ protected boolean isGet() {
131132

132133
public static NormalUserScanQueryMatcher create(Scan scan, ScanInfo scanInfo,
133134
ColumnTracker columns, DeleteTracker deletes, boolean hasNullColumn, long oldestUnexpiredTS,
134-
long now) throws IOException {
135+
long now, boolean visibilityLabelEnabled) throws IOException {
135136
if (scan.isReversed()) {
136137
if (scan.includeStopRow()) {
137138
return new NormalUserScanQueryMatcher(scan, scanInfo, columns, hasNullColumn, deletes,
138-
oldestUnexpiredTS, now) {
139+
oldestUnexpiredTS, now, visibilityLabelEnabled) {
139140

140141
@Override
141142
protected boolean moreRowsMayExistsAfter(int cmpToStopRow) {
@@ -144,7 +145,7 @@ protected boolean moreRowsMayExistsAfter(int cmpToStopRow) {
144145
};
145146
} else {
146147
return new NormalUserScanQueryMatcher(scan, scanInfo, columns, hasNullColumn, deletes,
147-
oldestUnexpiredTS, now) {
148+
oldestUnexpiredTS, now, visibilityLabelEnabled) {
148149

149150
@Override
150151
protected boolean moreRowsMayExistsAfter(int cmpToStopRow) {
@@ -155,7 +156,7 @@ protected boolean moreRowsMayExistsAfter(int cmpToStopRow) {
155156
} else {
156157
if (scan.includeStopRow()) {
157158
return new NormalUserScanQueryMatcher(scan, scanInfo, columns, hasNullColumn, deletes,
158-
oldestUnexpiredTS, now) {
159+
oldestUnexpiredTS, now, visibilityLabelEnabled) {
159160

160161
@Override
161162
protected boolean moreRowsMayExistsAfter(int cmpToStopRow) {
@@ -164,7 +165,7 @@ protected boolean moreRowsMayExistsAfter(int cmpToStopRow) {
164165
};
165166
} else {
166167
return new NormalUserScanQueryMatcher(scan, scanInfo, columns, hasNullColumn, deletes,
167-
oldestUnexpiredTS, now) {
168+
oldestUnexpiredTS, now, visibilityLabelEnabled) {
168169

169170
@Override
170171
protected boolean moreRowsMayExistsAfter(int cmpToStopRow) {

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -247,15 +247,13 @@ protected final MatchCode checkDeleted(DeleteTracker deletes, ExtendedCell cell)
247247
* <li>ignore the current KeyValue (MatchCode.SKIP)</li>
248248
* <li>got to the next row (MatchCode.DONE)</li>
249249
* </ul>
250-
* @param cell KeyValue to check
251-
* @param prevCell KeyValue checked previously
252-
* @param visibilityLabelEnabled Whether visibility labels are enabled
250+
* @param cell KeyValue to check
251+
* @param prevCell KeyValue checked previously
253252
* @return The match code instance.
254253
* @throws IOException in case there is an internal consistency problem caused by a data
255254
* corruption.
256255
*/
257-
public MatchCode match(ExtendedCell cell, ExtendedCell prevCell, boolean visibilityLabelEnabled)
258-
throws IOException {
256+
public MatchCode match(ExtendedCell cell, ExtendedCell prevCell) throws IOException {
259257
return match(cell);
260258
}
261259

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,8 @@ public boolean moreRowsMayExistAfter(ExtendedCell cell) {
287287

288288
public static UserScanQueryMatcher create(Scan scan, ScanInfo scanInfo,
289289
NavigableSet<byte[]> columns, long oldestUnexpiredTS, long now,
290-
RegionCoprocessorHost regionCoprocessorHost) throws IOException {
290+
RegionCoprocessorHost regionCoprocessorHost, boolean visibilityLabelEnabled)
291+
throws IOException {
291292
boolean hasNullColumn =
292293
!(columns != null && columns.size() != 0 && columns.first().length != 0);
293294
Pair<DeleteTracker, ColumnTracker> trackers =
@@ -299,7 +300,7 @@ public static UserScanQueryMatcher create(Scan scan, ScanInfo scanInfo,
299300
oldestUnexpiredTS, now);
300301
} else {
301302
return NormalUserScanQueryMatcher.create(scan, scanInfo, columnTracker, deleteTracker,
302-
hasNullColumn, oldestUnexpiredTS, now);
303+
hasNullColumn, oldestUnexpiredTS, now, visibilityLabelEnabled);
303304
}
304305
}
305306
}

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

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ public void testNeverIncludeFakeCell() throws IOException {
6464
UserScanQueryMatcher qm = UserScanQueryMatcher.create(scan,
6565
new ScanInfo(this.conf, fam2, 10, 1, ttl, KeepDeletedCells.FALSE,
6666
HConstants.DEFAULT_BLOCKSIZE, 0, rowComparator, false),
67-
get.getFamilyMap().get(fam2), now - ttl, now, null);
67+
get.getFamilyMap().get(fam2), now - ttl, now, null, false);
6868
ExtendedCell kv = new KeyValue(row1, fam2, col2, 1, data);
6969
ExtendedCell cell = PrivateCellUtil.createLastOnRowCol(kv);
7070
qm.setToNewRow(kv);
@@ -91,7 +91,7 @@ public void testMatchExplicitColumns() throws IOException {
9191
UserScanQueryMatcher qm = UserScanQueryMatcher.create(
9292
scan, new ScanInfo(this.conf, fam2, 0, 1, ttl, KeepDeletedCells.FALSE,
9393
HConstants.DEFAULT_BLOCKSIZE, 0, rowComparator, false),
94-
get.getFamilyMap().get(fam2), now - ttl, now, null);
94+
get.getFamilyMap().get(fam2), now - ttl, now, null, false);
9595

9696
List<KeyValue> memstore = new ArrayList<>(6);
9797
memstore.add(new KeyValue(row1, fam2, col1, 1, data));
@@ -132,9 +132,11 @@ public void testMatch_Wildcard() throws IOException {
132132
expected.add(ScanQueryMatcher.MatchCode.DONE);
133133

134134
long now = EnvironmentEdgeManager.currentTime();
135-
UserScanQueryMatcher qm = UserScanQueryMatcher.create(scan, new ScanInfo(this.conf, fam2, 0, 1,
136-
ttl, KeepDeletedCells.FALSE, HConstants.DEFAULT_BLOCKSIZE, 0, rowComparator, false), null,
137-
now - ttl, now, null);
135+
UserScanQueryMatcher qm =
136+
UserScanQueryMatcher.create(scan,
137+
new ScanInfo(this.conf, fam2, 0, 1, ttl, KeepDeletedCells.FALSE,
138+
HConstants.DEFAULT_BLOCKSIZE, 0, rowComparator, false),
139+
null, now - ttl, now, null, false);
138140

139141
List<KeyValue> memstore = new ArrayList<>(6);
140142
memstore.add(new KeyValue(row1, fam2, col1, 1, data));
@@ -179,7 +181,7 @@ public void testMatch_ExpiredExplicit() throws IOException {
179181
UserScanQueryMatcher qm = UserScanQueryMatcher.create(scan,
180182
new ScanInfo(this.conf, fam2, 0, 1, testTTL, KeepDeletedCells.FALSE,
181183
HConstants.DEFAULT_BLOCKSIZE, 0, rowComparator, false),
182-
get.getFamilyMap().get(fam2), now - testTTL, now, null);
184+
get.getFamilyMap().get(fam2), now - testTTL, now, null, false);
183185

184186
KeyValue[] kvs = new KeyValue[] { new KeyValue(row1, fam2, col1, now - 100, data),
185187
new KeyValue(row1, fam2, col2, now - 50, data),
@@ -218,9 +220,10 @@ public void testMatch_ExpiredWildcard() throws IOException {
218220
ScanQueryMatcher.MatchCode.SEEK_NEXT_COL, ScanQueryMatcher.MatchCode.DONE };
219221

220222
long now = EnvironmentEdgeManager.currentTime();
221-
UserScanQueryMatcher qm = UserScanQueryMatcher.create(scan, new ScanInfo(this.conf, fam2, 0, 1,
222-
testTTL, KeepDeletedCells.FALSE, HConstants.DEFAULT_BLOCKSIZE, 0, rowComparator, false), null,
223-
now - testTTL, now, null);
223+
UserScanQueryMatcher qm = UserScanQueryMatcher.create(scan,
224+
new ScanInfo(this.conf, fam2, 0, 1, testTTL, KeepDeletedCells.FALSE,
225+
HConstants.DEFAULT_BLOCKSIZE, 0, rowComparator, false),
226+
null, now - testTTL, now, null, false);
224227

225228
KeyValue[] kvs = new KeyValue[] { new KeyValue(row1, fam2, col1, now - 100, data),
226229
new KeyValue(row1, fam2, col2, now - 50, data),
@@ -264,7 +267,7 @@ public void testMatchWhenFilterReturnsIncludeAndSeekNextRow() throws IOException
264267
UserScanQueryMatcher qm = UserScanQueryMatcher.create(
265268
scanWithFilter, new ScanInfo(this.conf, fam2, 0, 1, ttl, KeepDeletedCells.FALSE,
266269
HConstants.DEFAULT_BLOCKSIZE, 0, rowComparator, false),
267-
get.getFamilyMap().get(fam2), now - ttl, now, null);
270+
get.getFamilyMap().get(fam2), now - ttl, now, null, false);
268271

269272
List<KeyValue> memstore = new ArrayList<>();
270273
// ColumnTracker will return INCLUDE_AND_SEEK_NEXT_COL , and filter will return
@@ -314,7 +317,7 @@ public void testMergeFilterResponseCase1() throws IOException {
314317
UserScanQueryMatcher qm = UserScanQueryMatcher.create(
315318
scanWithFilter, new ScanInfo(this.conf, fam2, 0, 3, ttl, KeepDeletedCells.FALSE,
316319
HConstants.DEFAULT_BLOCKSIZE, 0, rowComparator, false),
317-
get.getFamilyMap().get(fam2), now - ttl, now, null);
320+
get.getFamilyMap().get(fam2), now - ttl, now, null, false);
318321

319322
List<KeyValue> memstore = new ArrayList<>();
320323
memstore.add(new KeyValue(row1, fam1, col5, 1, data)); // match code will be INCLUDE
@@ -334,7 +337,7 @@ scanWithFilter, new ScanInfo(this.conf, fam2, 0, 3, ttl, KeepDeletedCells.FALSE,
334337
qm = UserScanQueryMatcher.create(
335338
scanWithFilter, new ScanInfo(this.conf, fam2, 0, 2, ttl, KeepDeletedCells.FALSE,
336339
HConstants.DEFAULT_BLOCKSIZE, 0, rowComparator, false),
337-
get.getFamilyMap().get(fam2), now - ttl, now, null);
340+
get.getFamilyMap().get(fam2), now - ttl, now, null, false);
338341

339342
List<KeyValue> memstore2 = new ArrayList<>();
340343
memstore2.add(new KeyValue(row2, fam1, col2, 1, data)); // match code will be INCLUDE
@@ -374,7 +377,7 @@ public void testMergeFilterResponseCase2() throws Exception {
374377
UserScanQueryMatcher qm = UserScanQueryMatcher.create(
375378
scanWithFilter, new ScanInfo(this.conf, fam2, 0, 5, ttl, KeepDeletedCells.FALSE,
376379
HConstants.DEFAULT_BLOCKSIZE, 0, rowComparator, false),
377-
get.getFamilyMap().get(fam2), now - ttl, now, null);
380+
get.getFamilyMap().get(fam2), now - ttl, now, null, false);
378381

379382
List<KeyValue> memstore = new ArrayList<>();
380383

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ private void verify(List<Pair<KeyValue, MatchCode>> pairs, int maxVersions,
6565
UserScanQueryMatcher qm = UserScanQueryMatcher.create(scan,
6666
new ScanInfo(this.conf, fam1, 0, maxVersions, ttl, KeepDeletedCells.FALSE,
6767
HConstants.DEFAULT_BLOCKSIZE, 0, rowComparator, newVersionBehavior),
68-
get.getFamilyMap().get(fam1), now - ttl, now, null);
68+
get.getFamilyMap().get(fam1), now - ttl, now, null, visibilityEnabled);
6969

7070
List<KeyValue> storedKVs = new ArrayList<>();
7171
for (Pair<KeyValue, MatchCode> Pair : pairs) {
@@ -78,7 +78,7 @@ private void verify(List<Pair<KeyValue, MatchCode>> pairs, int maxVersions,
7878
ExtendedCell prevCell = null;
7979

8080
for (KeyValue kv : storedKVs) {
81-
MatchCode matchCode = qm.match(kv, prevCell, visibilityEnabled);
81+
MatchCode matchCode = qm.match(kv, prevCell);
8282
prevCell = kv;
8383
scannedKVs.add(matchCode);
8484
}
@@ -221,7 +221,7 @@ public void testKeyForNextColumnForDeleteFamily() throws IOException {
221221
UserScanQueryMatcher qm = UserScanQueryMatcher.create(
222222
scan, new ScanInfo(this.conf, fam1, 0, 1, ttl, KeepDeletedCells.FALSE,
223223
HConstants.DEFAULT_BLOCKSIZE, 0, rowComparator, false),
224-
get.getFamilyMap().get(fam1), now - ttl, now, null);
224+
get.getFamilyMap().get(fam1), now - ttl, now, null, false);
225225

226226
KeyValue kv;
227227
ExtendedCell nextColumnKey;

0 commit comments

Comments
 (0)