virajjasani commented on code in PR #1736:
URL: https://github.com/apache/phoenix/pull/1736#discussion_r1451598604


##########
phoenix-core-server/src/main/java/org/apache/phoenix/coprocessor/IndexerRegionScanner.java:
##########
@@ -435,12 +437,33 @@ public boolean next(List<Cell> results) throws 
IOException {
                 mutations.clear();
             }
         }
-        byte[] rowCountBytes = PLong.INSTANCE.toBytes(Long.valueOf(rowCount));
+        byte[] rowCountBytes = PLong.INSTANCE.toBytes((long) rowCount);
         final Cell aggKeyValue;
         if (lastCell == null) {
-            aggKeyValue = 
PhoenixKeyValueUtil.newKeyValue(UNGROUPED_AGG_ROW_KEY,
-                SINGLE_COLUMN_FAMILY,
-                    SINGLE_COLUMN, AGG_TIMESTAMP, rowCountBytes,0, 
rowCountBytes.length);
+            byte[] rowKey;
+            byte[] startKey = scan.getStartRow().length > 0 ? 
scan.getStartRow() :
+                    region.getRegionInfo().getStartKey();
+            byte[] endKey = scan.getStopRow().length > 0 ? scan.getStopRow() :
+                    region.getRegionInfo().getEndKey();
+            final boolean isIncompatibleClient =
+                    
ScanUtil.isIncompatibleClientForServerReturnValidRowKey(scan);
+            if (!isIncompatibleClient) {
+                rowKey = ByteUtil.getLargestPossibleRowKeyInRange(startKey, 
endKey);
+                if (rowKey == null) {
+                    if (scan.includeStartRow()) {

Review Comment:
   This is because if `getLargestPossibleRowKeyInRange()` is not able to figure 
out previous largest possible rowkey, it returns null and most likely that 
happens when either start or end key are empty.
   
   So, we try to find [startKey, endKey) and if we can't, then if startKey is 
included, we return scan startkey (or region start key if scan startKey is 
empty), if stopKey is included (very rare case), we return endKey, otherwise we 
return empty rowKey (none of our scan boundary changes have both exclusive 
start and stop keys).



-- 
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]

Reply via email to