Skip to content
This repository was archived by the owner on May 8, 2026. It is now read-only.

Commit 2da37ec

Browse files
committed
make bounded endkey more clear
1 parent 072d21b commit 2da37ec

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

  • google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/internal

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/internal/RowSetUtil.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,11 @@ private static List<RowRange> splitOnLargeRowKey(RowRange range, ByteString larg
162162
ByteString startKey = StartPoint.extract(range).value;
163163
ByteString endKey = EndPoint.extract(range).value;
164164

165-
// if end key is on the left of large row key, don't split. Empty endKey means it's unbounded
166-
// so it's always on the right of the large key
167-
if (!endKey.isEmpty() && ByteStringComparator.INSTANCE.compare(endKey, largeRowKey) < 0) {
165+
// Empty endKey means it's unbounded
166+
boolean boundedEnd = !endKey.isEmpty();
167+
168+
// if end key is on the left of large row key, don't split.
169+
if (boundedEnd && ByteStringComparator.INSTANCE.compare(endKey, largeRowKey) < 0) {
168170
rowRanges.add(range);
169171
return rowRanges;
170172
}
@@ -182,8 +184,8 @@ private static List<RowRange> splitOnLargeRowKey(RowRange range, ByteString larg
182184
}
183185

184186
// if the end key is on the right of the large row key, set the start key to be large row key
185-
// open. Empty end key is unbounded so it's always on the right of the large key
186-
if (endKey.isEmpty() || ByteStringComparator.INSTANCE.compare(endKey, largeRowKey) > 0) {
187+
// open.
188+
if (!boundedEnd|| ByteStringComparator.INSTANCE.compare(endKey, largeRowKey) > 0) {
187189
// handle the edge case where (key, key\0) is an empty range and should be excluded
188190
ByteString nextKey = largeRowKey.concat(ByteString.copyFrom(new byte[] {0}));
189191
EndPoint endPoint = EndPoint.extract(range);

0 commit comments

Comments
 (0)