Skip to content

Commit 243e861

Browse files
committed
Revert "HBASE-26122: Implement an optional maximum size for Gets, after which a partial result is returned (#3532)"
This reverts commit 8f16e34.
1 parent 8f16e34 commit 243e861

File tree

8 files changed

+13
-202
lines changed

8 files changed

+13
-202
lines changed

hbase-client/src/main/java/org/apache/hadoop/hbase/client/Get.java

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ public class Get extends Query implements Row {
7676
private boolean checkExistenceOnly = false;
7777
private boolean closestRowBefore = false;
7878
private Map<byte [], NavigableSet<byte []>> familyMap = new TreeMap<>(Bytes.BYTES_COMPARATOR);
79-
private long maxResultSize = -1;
8079

8180
/**
8281
* Create a Get operation for the specified row.
@@ -340,21 +339,6 @@ public Get setFilter(Filter filter) {
340339
return this;
341340
}
342341

343-
/**
344-
* Set the maximum result size. The default is -1; this means that no specific
345-
* maximum result size will be set for this Get.
346-
*
347-
* If set to a value greater than zero, the server may respond with a Result where
348-
* {@link Result#mayHaveMoreCellsInRow()} is true. The user is required to handle
349-
* this case.
350-
*
351-
* @param maxResultSize The maximum result size in bytes
352-
*/
353-
public Get setMaxResultSize(long maxResultSize) {
354-
this.maxResultSize = maxResultSize;
355-
return this;
356-
}
357-
358342
/* Accessors */
359343

360344
/**
@@ -474,13 +458,6 @@ public Map<String, Object> getFingerprint() {
474458
return map;
475459
}
476460

477-
/**
478-
* @return the maximum result size in bytes. See {@link #setMaxResultSize(long)}
479-
*/
480-
public long getMaxResultSize() {
481-
return maxResultSize;
482-
}
483-
484461
/**
485462
* Compile the details beyond the scope of getFingerprint (row, columns,
486463
* timestamps, etc.) into a Map along with the fingerprinted information.

hbase-client/src/main/java/org/apache/hadoop/hbase/protobuf/ProtobufUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1382,7 +1382,7 @@ public static Result toResult(final ClientProtos.Result proto, final CellScanner
13821382

13831383
return (cells == null || cells.isEmpty())
13841384
? (proto.getStale() ? EMPTY_RESULT_STALE : EMPTY_RESULT)
1385-
: Result.create(cells, null, proto.getStale(), proto.getPartial());
1385+
: Result.create(cells, null, proto.getStale());
13861386
}
13871387

13881388

hbase-client/src/main/java/org/apache/hadoop/hbase/shaded/protobuf/ProtobufUtil.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -592,9 +592,6 @@ public static Get toGet(final ClientProtos.Get proto) throws IOException {
592592
if (proto.hasLoadColumnFamiliesOnDemand()) {
593593
get.setLoadColumnFamiliesOnDemand(proto.getLoadColumnFamiliesOnDemand());
594594
}
595-
if (proto.hasMaxResultSize()) {
596-
get.setMaxResultSize(proto.getMaxResultSize());
597-
}
598595
return get;
599596
}
600597

@@ -1259,9 +1256,6 @@ public static ClientProtos.Get toGet(
12591256
if (loadColumnFamiliesOnDemand != null) {
12601257
builder.setLoadColumnFamiliesOnDemand(loadColumnFamiliesOnDemand);
12611258
}
1262-
if (get.getMaxResultSize() > 0) {
1263-
builder.setMaxResultSize(get.getMaxResultSize());
1264-
}
12651259
return builder.build();
12661260
}
12671261

@@ -1463,7 +1457,6 @@ public static ClientProtos.Result toResultNoData(final Result result) {
14631457
ClientProtos.Result.Builder builder = ClientProtos.Result.newBuilder();
14641458
builder.setAssociatedCellCount(size);
14651459
builder.setStale(result.isStale());
1466-
builder.setPartial(result.mayHaveMoreCellsInRow());
14671460
return builder.build();
14681461
}
14691462

@@ -1554,7 +1547,7 @@ public static Result toResult(final ClientProtos.Result proto, final CellScanner
15541547

15551548
return (cells == null || cells.isEmpty())
15561549
? (proto.getStale() ? EMPTY_RESULT_STALE : EMPTY_RESULT)
1557-
: Result.create(cells, null, proto.getStale(), proto.getPartial());
1550+
: Result.create(cells, null, proto.getStale());
15581551
}
15591552

15601553

hbase-protocol-shaded/src/main/protobuf/Client.proto

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,6 @@ message Get {
9090
optional Consistency consistency = 12 [default = STRONG];
9191
repeated ColumnFamilyTimeRange cf_time_range = 13;
9292
optional bool load_column_families_on_demand = 14; /* DO NOT add defaults to load_column_families_on_demand. */
93-
94-
optional uint64 max_result_size = 15;
9593
}
9694

9795
message Result {

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

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@
146146
import org.apache.hadoop.hbase.regionserver.MultiVersionConcurrencyControl.WriteEntry;
147147
import org.apache.hadoop.hbase.regionserver.compactions.CompactionContext;
148148
import org.apache.hadoop.hbase.regionserver.compactions.CompactionLifeCycleTracker;
149-
import org.apache.hadoop.hbase.regionserver.ScannerContext.LimitScope;
150149
import org.apache.hadoop.hbase.regionserver.throttle.CompactionThroughputControllerFactory;
151150
import org.apache.hadoop.hbase.regionserver.throttle.NoLimitThroughputController;
152151
import org.apache.hadoop.hbase.regionserver.throttle.StoreHotnessProtector;
@@ -3865,7 +3864,8 @@ public void prepareMiniBatchOperations(MiniBatchOperationInProgress<Mutation> mi
38653864
Result result;
38663865
if (returnResults) {
38673866
// convert duplicate increment/append to get
3868-
result = region.get(toGet(mutation), false, nonceGroup, nonce);
3867+
List<Cell> results = region.get(toGet(mutation), false, nonceGroup, nonce);
3868+
result = Result.create(results);
38693869
} else {
38703870
result = Result.EMPTY_RESULT;
38713871
}
@@ -7497,7 +7497,9 @@ public static boolean rowIsInRange(RegionInfo info, final byte [] row, final int
74977497
@Override
74987498
public Result get(final Get get) throws IOException {
74997499
prepareGet(get);
7500-
return get(get, true, HConstants.NO_NONCE, HConstants.NO_NONCE);
7500+
List<Cell> results = get(get, true);
7501+
boolean stale = this.getRegionInfo().getReplicaId() != 0;
7502+
return Result.create(results, get.isCheckExistenceOnly() ? !results.isEmpty() : null, stale);
75017503
}
75027504

75037505
void prepareGet(final Get get) throws IOException {
@@ -7516,31 +7518,11 @@ void prepareGet(final Get get) throws IOException {
75167518

75177519
@Override
75187520
public List<Cell> get(Get get, boolean withCoprocessor) throws IOException {
7519-
return getInternal(get, null, withCoprocessor, HConstants.NO_NONCE, HConstants.NO_NONCE);
7520-
}
7521-
7522-
private Result get(Get get, boolean withCoprocessor, long nonceGroup, long nonce)
7523-
throws IOException {
7524-
ScannerContext scannerContext = get.getMaxResultSize() > 0
7525-
? ScannerContext.newBuilder()
7526-
.setSizeLimit(LimitScope.BETWEEN_CELLS, get.getMaxResultSize(), get.getMaxResultSize())
7527-
.build()
7528-
: null;
7529-
7530-
List<Cell> result = getInternal(get, scannerContext, withCoprocessor, nonceGroup, nonce);
7531-
boolean stale = this.getRegionInfo().getReplicaId() != 0;
7532-
boolean mayHaveMoreCellsInRow =
7533-
scannerContext != null && scannerContext.mayHaveMoreCellsInRow();
7534-
7535-
return Result.create(
7536-
result,
7537-
get.isCheckExistenceOnly() ? !result.isEmpty() : null,
7538-
stale,
7539-
mayHaveMoreCellsInRow);
7521+
return get(get, withCoprocessor, HConstants.NO_NONCE, HConstants.NO_NONCE);
75407522
}
75417523

7542-
private List<Cell> getInternal(Get get, ScannerContext scannerContext, boolean withCoprocessor,
7543-
long nonceGroup, long nonce) throws IOException {
7524+
private List<Cell> get(Get get, boolean withCoprocessor, long nonceGroup, long nonce)
7525+
throws IOException {
75447526
List<Cell> results = new ArrayList<>();
75457527
long before = EnvironmentEdgeManager.currentTime();
75467528

@@ -7557,7 +7539,7 @@ private List<Cell> getInternal(Get get, ScannerContext scannerContext, boolean w
75577539
}
75587540
try (RegionScanner scanner = getScanner(scan, null, nonceGroup, nonce)) {
75597541
List<Cell> tmp = new ArrayList<>();
7560-
scanner.next(tmp, scannerContext);
7542+
scanner.next(tmp);
75617543
// Copy EC to heap, then close the scanner.
75627544
// This can be an EXPENSIVE call. It may make an extra copy from offheap to onheap buffers.
75637545
// See more details in HBASE-26036.

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

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2668,15 +2668,10 @@ private Result get(Get get, HRegion region, RegionScannersCloseCallBack closeCal
26682668
if (scan.getLoadColumnFamiliesOnDemandValue() == null) {
26692669
scan.setLoadColumnFamiliesOnDemand(region.isLoadingCfsOnDemandDefault());
26702670
}
2671-
2672-
ScannerContext scannerContext = ScannerContext.newBuilder()
2673-
.setSizeLimit(LimitScope.BETWEEN_CELLS, get.getMaxResultSize(), get.getMaxResultSize())
2674-
.build();
2675-
26762671
RegionScannerImpl scanner = null;
26772672
try {
26782673
scanner = region.getScanner(scan);
2679-
scanner.next(results, scannerContext);
2674+
scanner.next(results);
26802675
} finally {
26812676
if (scanner != null) {
26822677
if (closeCallBack == null) {
@@ -2701,8 +2696,7 @@ private Result get(Get get, HRegion region, RegionScannersCloseCallBack closeCal
27012696
}
27022697
region.metricsUpdateForGet(results, before);
27032698

2704-
return Result.create(results, get.isCheckExistenceOnly() ? !results.isEmpty() : null, stale,
2705-
scannerContext.mayHaveMoreCellsInRow());
2699+
return Result.create(results, get.isCheckExistenceOnly() ? !results.isEmpty() : null, stale);
27062700
}
27072701

27082702
private void checkBatchSizeAndLogLargeSize(MultiRequest request) throws ServiceException {

hbase-server/src/test/java/org/apache/hadoop/hbase/TestPartialResultsFromClientSide.java

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -31,26 +31,18 @@
3131
import java.util.Set;
3232
import org.apache.hadoop.hbase.client.ClientScanner;
3333
import org.apache.hadoop.hbase.client.Delete;
34-
import org.apache.hadoop.hbase.client.Get;
3534
import org.apache.hadoop.hbase.client.Put;
3635
import org.apache.hadoop.hbase.client.RegionInfo;
3736
import org.apache.hadoop.hbase.client.Result;
3837
import org.apache.hadoop.hbase.client.ResultScanner;
3938
import org.apache.hadoop.hbase.client.Scan;
4039
import org.apache.hadoop.hbase.client.Table;
41-
import org.apache.hadoop.hbase.filter.BinaryComparator;
42-
import org.apache.hadoop.hbase.filter.ByteArrayComparable;
4340
import org.apache.hadoop.hbase.filter.ColumnPrefixFilter;
4441
import org.apache.hadoop.hbase.filter.ColumnRangeFilter;
45-
import org.apache.hadoop.hbase.filter.FamilyFilter;
4642
import org.apache.hadoop.hbase.filter.Filter;
47-
import org.apache.hadoop.hbase.filter.FilterList;
48-
import org.apache.hadoop.hbase.filter.FilterListWithAND;
4943
import org.apache.hadoop.hbase.filter.FirstKeyOnlyFilter;
5044
import org.apache.hadoop.hbase.filter.FirstKeyValueMatchingQualifiersFilter;
51-
import org.apache.hadoop.hbase.filter.PageFilter;
5245
import org.apache.hadoop.hbase.filter.RandomRowFilter;
53-
import org.apache.hadoop.hbase.protobuf.generated.FilterProtos;
5446
import org.apache.hadoop.hbase.testclassification.LargeTests;
5547
import org.apache.hadoop.hbase.util.Bytes;
5648
import org.apache.hadoop.hbase.util.ClassSize;
@@ -144,46 +136,6 @@ public static void tearDownAfterClass() throws Exception {
144136
TEST_UTIL.shutdownMiniCluster();
145137
}
146138

147-
@Test
148-
public void testGetPartialResults() throws Exception {
149-
byte[] row = ROWS[0];
150-
151-
Result result;
152-
int cf = 0;
153-
int qf = 0;
154-
int total = 0;
155-
156-
do {
157-
// this will ensure we always return only 1 result
158-
Get get = new Get(row)
159-
.setMaxResultSize(1);
160-
161-
// we want to page through the entire row, this will ensure we always get the next
162-
if (total > 0) {
163-
get.setFilter(new FilterList(FilterList.Operator.MUST_PASS_ALL,
164-
new ColumnRangeFilter(QUALIFIERS[qf], true, null, false),
165-
new FamilyFilter(CompareOperator.GREATER_OR_EQUAL, new BinaryComparator(FAMILIES[cf]))));
166-
}
167-
168-
// all values are the same, but there should be a value
169-
result = TABLE.get(get);
170-
assertTrue(String.format("Value for family %s (# %s) and qualifier %s (# %s)",
171-
Bytes.toStringBinary(FAMILIES[cf]), cf, Bytes.toStringBinary(QUALIFIERS[qf]), qf),
172-
Bytes.equals(VALUE, result.getValue(FAMILIES[cf], QUALIFIERS[qf])));
173-
174-
total++;
175-
if (++qf >= NUM_QUALIFIERS) {
176-
cf++;
177-
qf = 0;
178-
}
179-
} while (result.mayHaveMoreCellsInRow());
180-
181-
// ensure we iterated all cells in row
182-
assertEquals(NUM_COLS, total);
183-
assertEquals(NUM_FAMILIES, cf);
184-
assertEquals(0, qf);
185-
}
186-
187139
/**
188140
* Ensure that the expected key values appear in a result returned from a scanner that is
189141
* combining partial results into complete results

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

Lines changed: 0 additions & 85 deletions
Original file line numberDiff line numberDiff line change
@@ -7861,89 +7861,4 @@ public void run() {
78617861
assertFalse("Region lock holder should not have been interrupted", holderInterrupted.get());
78627862
}
78637863

7864-
@Test
7865-
public void testOversizedGetsReturnPartialResult() throws IOException {
7866-
HRegion region = initHRegion(tableName, name.getMethodName(), CONF, fam1);
7867-
7868-
Put p = new Put(row)
7869-
.addColumn(fam1, qual1, value1)
7870-
.addColumn(fam1, qual2, value2);
7871-
7872-
region.put(p);
7873-
7874-
Get get = new Get(row)
7875-
.addColumn(fam1, qual1)
7876-
.addColumn(fam1, qual2)
7877-
.setMaxResultSize(1); // 0 doesn't count as a limit, according to HBase
7878-
7879-
Result r = region.get(get);
7880-
7881-
assertTrue("Expected partial result, but result was not marked as partial", r.mayHaveMoreCellsInRow());
7882-
}
7883-
7884-
@Test
7885-
public void testGetsWithoutResultSizeLimitAreNotPartial() throws IOException {
7886-
HRegion region = initHRegion(tableName, name.getMethodName(), CONF, fam1);
7887-
7888-
Put p = new Put(row)
7889-
.addColumn(fam1, qual1, value1)
7890-
.addColumn(fam1, qual2, value2);
7891-
7892-
region.put(p);
7893-
7894-
Get get = new Get(row)
7895-
.addColumn(fam1, qual1)
7896-
.addColumn(fam1, qual2);
7897-
7898-
Result r = region.get(get);
7899-
7900-
assertFalse("Expected full result, but it was marked as partial", r.mayHaveMoreCellsInRow());
7901-
assertTrue(Bytes.equals(value1, r.getValue(fam1, qual1)));
7902-
assertTrue(Bytes.equals(value2, r.getValue(fam1, qual2)));
7903-
}
7904-
7905-
@Test
7906-
public void testGetsWithinResultSizeLimitAreNotPartial() throws IOException {
7907-
HRegion region = initHRegion(tableName, name.getMethodName(), CONF, fam1);
7908-
7909-
Put p = new Put(row)
7910-
.addColumn(fam1, qual1, value1)
7911-
.addColumn(fam1, qual2, value2);
7912-
7913-
region.put(p);
7914-
7915-
Get get = new Get(row)
7916-
.addColumn(fam1, qual1)
7917-
.addColumn(fam1, qual2)
7918-
.setMaxResultSize(Long.MAX_VALUE);
7919-
7920-
Result r = region.get(get);
7921-
7922-
assertFalse("Expected full result, but it was marked as partial", r.mayHaveMoreCellsInRow());
7923-
assertTrue(Bytes.equals(value1, r.getValue(fam1, qual1)));
7924-
assertTrue(Bytes.equals(value2, r.getValue(fam1, qual2)));
7925-
}
7926-
7927-
@Test
7928-
public void testGetsWithResultSizeLimitReturnPartialResults() throws IOException {
7929-
HRegion region = initHRegion(tableName, name.getMethodName(), CONF, fam1);
7930-
7931-
Put p = new Put(row)
7932-
.addColumn(fam1, qual1, value1)
7933-
.addColumn(fam1, qual2, value2);
7934-
7935-
region.put(p);
7936-
7937-
Get get = new Get(row)
7938-
.addColumn(fam1, qual1)
7939-
.addColumn(fam1, qual2)
7940-
.setMaxResultSize(10);
7941-
7942-
Result r = region.get(get);
7943-
7944-
assertTrue("Expected partial result, but it was marked as complete", r.mayHaveMoreCellsInRow());
7945-
assertTrue(Bytes.equals(value1, r.getValue(fam1, qual1)));
7946-
assertEquals("Got more results than expected", 1, r.size());
7947-
}
7948-
79497864
}

0 commit comments

Comments
 (0)