BinShi-SecularBird commented on a change in pull request #463: Phoenix stats
Initial Commit
URL: https://github.com/apache/phoenix/pull/463#discussion_r265830442
##########
File path:
phoenix-core/src/main/java/org/apache/phoenix/iterate/BaseResultIterators.java
##########
@@ -550,6 +550,76 @@ public BaseResultIterators(QueryPlan plan, Integer
perScanLimit, Integer offset,
}
return ranges;
}
+
+ private List<KeyRange> getRegionRowKeyRanges() throws SQLException {
+ List<HRegionLocation> regionLocations =
getRegionBoundaries(scanGrouper); //Load the region information
+
+ List<KeyRange> regionKeyRanges =
Lists.newArrayListWithExpectedSize(regionLocations.size());
+
+ //Map each HRegionLocation to a KeyRange - no Java 8
+ for(HRegionLocation regionLocation : regionLocations){
+ HRegionInfo regionInfo = regionLocation.getRegionInfo();
+
+ //Region is upperInclusive false by definition
+ KeyRange range = KeyRange.getKeyRange(regionInfo.getStartKey(),
true, regionInfo.getEndKey(), false);
+ regionKeyRanges.add(range);
+ }
+ return regionKeyRanges;
+ }
+
+ List<List<KeyRange>> getQueryRowKeyRanges(List<KeyRange> regionKeyRanges) {
+ ScanRanges scanRanges = context.getScanRanges();
+
+ RowKeySchema schema = scanRanges.getSchema();
+
+ PTable table = getTable();
+ boolean isLocalIndex = table.getIndexType() == IndexType.LOCAL;
+
+ //Use the dataplan to build the queryRowKeyRanges
+ if (isLocalIndex) {
+ // should always have a data plan when a local index is being used.
+ if (dataPlan != null && dataPlan.getTableRef().getTable().getType()
+ != PTableType.INDEX) { // Sanity check
+ scanRanges =
+
computePrefixScanRanges(dataPlan.getContext().getScanRanges(),
+ computeColumnsInCommon());
+ }
+ }
+
+ List<KeyRange> queryRowKeyRanges = scanRanges.getRowKeyRanges();
+
+ if(isLocalIndex){
+ List<KeyRange> newQueryRowKeyRanges =
Lists.newArrayListWithExpectedSize(queryRowKeyRanges.size() *
regionKeyRanges.size());
+
+ for(KeyRange regionKeyRange : regionKeyRanges) {
+ for (KeyRange queryRowKeyRange : queryRowKeyRanges) {
+ KeyRange
+ newQueryRowKeyRange =
queryRowKeyRange.prependRange(regionKeyRange.getLowerRange(),0,regionKeyRange.getLowerRange().length);
+ newQueryRowKeyRanges.add(newQueryRowKeyRange);
+ }
+ }
+ queryRowKeyRanges = newQueryRowKeyRanges;
+ }
+
+ // Filter the region list based on the queryKeyRanges
+ // Assumed Regions are in ascending key order
+ // Note that regions KeyRanges to scan KeyRanges are a many to many
relationship
+ // That is a scan range can cross multiple regions or multiple scan
ranges may be in a single region
+ List<List<KeyRange>> scanRowKeyRanges =
Lists.newArrayListWithExpectedSize(regionKeyRanges.size());
+
+ for (KeyRange regionKeyRange : regionKeyRanges) {
+ List<KeyRange> regionQueryIntersections =
KeyRange.intersect(Lists.newArrayList(regionKeyRange), queryRowKeyRanges);
+ if((regionQueryIntersections.size() == 1 &&
regionQueryIntersections.get(0).equals(KeyRange.EMPTY_RANGE))) {
+ scanRowKeyRanges.add(new ArrayList<KeyRange>());
+ }
+ else
+ {
Review comment:
(Coding Style) Should it be "else {"?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services