virajjasani commented on code in PR #1848:
URL: https://github.com/apache/phoenix/pull/1848#discussion_r1516955054
##########
phoenix-core-client/src/main/java/org/apache/phoenix/iterate/BaseResultIterators.java:
##########
@@ -1005,6 +1005,43 @@ private ScansWithRegionLocations getParallelScans(byte[]
startKey, byte[] stopKe
int regionIndex = 0;
int startRegionIndex = 0;
+
+ List<HRegionLocation> regionLocations;
+ if (isSalted && !isLocalIndex) {
+ // key prefix = salt num + view index id + tenant id
+ // If salting is used with tenant or view index id, scan start and
end
+ // rowkeys will not be empty. We need to generate region locations
for
+ // all the scan range such that we cover (each salt bucket num) +
(prefix starting from
+ // index position 1 to cover view index and/or tenant id and/or
remaining prefix).
+ if (scan.getStartRow().length > 0 && scan.getStopRow().length > 0)
{
+ regionLocations = new ArrayList<>();
+ for (int i = 0; i < getTable().getBucketNum(); i++) {
+ byte[] saltStartRegionKey = new
byte[scan.getStartRow().length];
+ saltStartRegionKey[0] = (byte) i;
+ System.arraycopy(scan.getStartRow(), 1,
saltStartRegionKey, 1,
+ scan.getStartRow().length - 1);
+
+ byte[] saltStopRegionKey = new
byte[scan.getStopRow().length];
+ saltStopRegionKey[0] = (byte) i;
+ System.arraycopy(scan.getStopRow(), 1, saltStopRegionKey,
1,
+ scan.getStopRow().length - 1);
+
+ regionLocations.addAll(
+ getRegionBoundaries(scanGrouper, saltStartRegionKey,
saltStopRegionKey));
+ }
Review Comment:
`traverseAllRegions` is only used here, to use scan boundaries:
```
} else if (!traverseAllRegions) {
byte[] scanStartRow = scan.getStartRow();
if (scanStartRow.length != 0 && Bytes.compareTo(scanStartRow,
startKey) > 0) {
startRegionBoundaryKey = startKey = scanStartRow;
}
byte[] scanStopRow = scan.getStopRow();
if (stopKey.length == 0
|| (scanStopRow.length != 0 &&
Bytes.compareTo(scanStopRow, stopKey) < 0)) {
stopRegionBoundaryKey = stopKey = scanStopRow;
}
}
```
Here, with this work, we will be able to restrict the range scan for salted
table to only specific regions, given that single salt can have many more
regions as the table size grows.
Moreover, salted table with tenant id makes the restriction even narrower
for large table. Hence, with this work, we are covering optimization for large
salted tables.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]