You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@phoenix.apache.org by GitBox <gi...@apache.org> on 2020/06/09 21:54:39 UTC

[GitHub] [phoenix] swaroopak commented on a change in pull request #789: PHOENIX-5783: Implement starttime in IndexTool for rebuild and verifi…

swaroopak commented on a change in pull request #789:
URL: https://github.com/apache/phoenix/pull/789#discussion_r437744234



##########
File path: phoenix-core/src/main/java/org/apache/phoenix/coprocessor/IndexRebuildRegionScanner.java
##########
@@ -1398,7 +1410,64 @@ public boolean next(List<Cell> results) throws IOException {
                     SINGLE_COLUMN, AGG_TIMESTAMP, rowCountBytes, 0, rowCountBytes.length);
         }
         results.add(aggKeyValue);
-        return hasMore;
+        return hasMore || hasMoreIncr;
+    }
+
+    private RegionScanner getLocalScanner() throws IOException {
+        // override the filter to skip scan and open new scanner
+        // when lower bound of timerange is passed or newStartKey was populated
+        // from previous call to next()
+        if(minTimestamp!= 0) {
+            Scan incrScan = new Scan(scan);
+            incrScan.setTimeRange(minTimestamp, scan.getTimeRange().getMax());
+            incrScan.setRaw(true);
+            incrScan.setMaxVersions();
+            incrScan.getFamilyMap().clear();
+            incrScan.setCacheBlocks(false);
+            for (byte[] family : scan.getFamilyMap().keySet()) {
+                incrScan.addFamily(family);
+            }
+            if(nextStartKey != null) {
+                incrScan.setStartRow(nextStartKey);
+            }
+            List<KeyRange> keys = new ArrayList<>();
+            try(RegionScanner scanner = region.getScanner(incrScan)) {
+                List<Cell> row = new ArrayList<>();
+                int rowCount = 0;
+                // collect row keys that have been modified in the given time-range
+                // up to the size of page to build skip scan filter
+                do {
+                    hasMoreIncr = scanner.nextRaw(row);
+                    if (!row.isEmpty()) {
+                        keys.add(PVarbinary.INSTANCE.getKeyRange(CellUtil.cloneRow(row.get(0))));
+                        rowCount++;
+                    }
+                    row.clear();
+                } while (hasMoreIncr && rowCount < pageSizeInRows);
+            }
+            if (!hasMoreIncr && keys.isEmpty()) {
+                return null;
+            }
+            if (!keys.isEmpty()) {
+                nextStartKey = ByteUtil.calculateTheClosestNextRowKeyForPrefix(keys.get(keys.size() - 1).getLowerRange());
+            }
+            try {
+                ScanRanges scanRanges = ScanRanges.createPointLookup(keys);
+                scanRanges.initializeScan(incrScan);
+                SkipScanFilter skipScanFilter = scanRanges.getSkipScanFilter();
+                incrScan.setFilter(new SkipScanFilter(skipScanFilter, true));

Review comment:
       Yes, I will add a test for view index




----------------------------------------------------------------
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:
users@infra.apache.org