tkhurana commented on code in PR #1736:
URL: https://github.com/apache/phoenix/pull/1736#discussion_r1479088010
##########
phoenix-core-server/src/main/java/org/apache/phoenix/coprocessor/GroupedAggregateRegionObserver.java:
##########
@@ -436,36 +622,79 @@ public boolean next(List<Cell> resultsToReturn) throws
IOException {
hasMore = delegate.nextRaw(results);
if (!results.isEmpty()) {
if (isDummy(results)) {
- getDummyResult(resultsToReturn);
- return true;
+ return getDummyResult(resultsToReturn);
}
result.setKeyValues(results);
ImmutableBytesPtr key =
TupleUtil.getConcatenatedValue(result,
expressions);
+ ImmutableBytesPtr originalRowKey = new
ImmutableBytesPtr();
+ result.getKey(originalRowKey);
+ currentRowKey = originalRowKey;
Aggregator[] rowAggregators =
groupByCache.cache(key);
+ groupByCache.cacheAggregateRowKey(key,
originalRowKey);
// Aggregate values here
aggregators.aggregate(rowAggregators, result);
}
now = EnvironmentEdgeManager.currentTimeMillis();
- } while (hasMore && groupByCache.size() < limit && (now -
startTime) < pageSizeMs);
- if (hasMore && groupByCache.size() < limit && (now -
startTime) >= pageSizeMs) {
- // Return a dummy result as we have processed a page
worth of rows
- // but we are not ready to aggregate
- getDummyResult(resultsToReturn);
- return true;
- }
+ if (hasMore && groupByCache.size() < limit &&
+ (now - startTime) >= pageSizeMs) {
+ return getDummyResult(resultsToReturn);
+ }
+ } while (hasMore && groupByCache.size() < limit);
regionScanner = groupByCache.getScanner(delegate);
// Do not sort here, but sort back on the client instead
// The reason is that if the scan ever extends beyond a
region
// (which can happen if we're basing our parallelization
split
// points on old metadata), we'll get incorrect query
results.
return regionScanner.next(resultsToReturn);
}
+ } catch (Exception e) {
+ LOGGER.error("Unordered group-by scanner next encountered
error.", e);
+ if (e instanceof IOException) {
+ throw e;
+ } else {
+ throw new IOException(e);
+ }
} finally {
if (acquiredLock) region.closeRegionOperation();
}
}
+ /**
+ * Retrieve dummy rowkey and return to the client.
+ *
+ * @param resultsToReturn dummy cell.
+ * @return true if more rows exist after this one, false if scanner is
done.
Review Comment:
This comment can be updated since we are always returning true
--
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]