List<HRegionLocation> regionLocations = getRegionBoundaries(scanGrouper); List<byte[]> regionBoundaries = toBoundaries(regionLocations); ScanRanges scanRanges = context.getScanRanges(); PTable table = getTable(); boolean isSalted = table.getBucketNum() != null; boolean isLocalIndex = table.getIndexType() == IndexType.LOCAL; GuidePostsInfo gps = getGuidePosts(); prefixScanRanges = computePrefixScanRanges(dataPlan.getContext().getScanRanges(), columnsInCommon=computeColumnsInCommon()); KeyRange prefixRange = prefixScanRanges.getScanRange(); if (!prefixRange.lowerUnbound()) { int stopIndex = regionBoundaries.size(); if (startRegionBoundaryKey.length > 0) { startRegionIndex = regionIndex = getIndexContainingInclusive(regionBoundaries, startRegionBoundaryKey); stopIndex = Math.min(stopIndex, regionIndex + getIndexContainingExclusive(regionBoundaries.subList(regionIndex, stopIndex), stopRegionBoundaryKey)); if (isLocalIndex) { stopKey = regionLocations.get(stopIndex).getRegion().getEndKey(); byte[] regionStartKey = regionInfo.getStartKey(); ImmutableBytesWritable ptr = context.getTempPtr(); clipKeyRangeBytes(prefixScanRanges.getSchema(), 0, columnsInCommon, regionStartKey, ptr, false); regionStartKey = ByteUtil.copyKeyBytesIfNecessary(ptr); updateEstimates(gps, guideIndex-1, estimates); updateEstimates(gps, guideIndex, estimates);
int queryTimeOut = context.getStatement().getQueryTimeoutInMillis(); try { submitWork(scan, futures, allIterators, splitSize, isReverse, scanGrouper); boolean clearedCache = false; for (List<Pair<Scan,Future<PeekingResultIterator>>> future : reverseIfNecessary(futures,isReverse)) { List<PeekingResultIterator> concatIterators = Lists.newArrayListWithExpectedSize(future.size()); Iterator<Pair<Scan, Future<PeekingResultIterator>>> scanPairItr = reverseIfNecessary(future,isReverse).iterator(); while (scanPairItr.hasNext()) { Pair<Scan,Future<PeekingResultIterator>> scanPair = scanPairItr.next(); recreateIterators(services, isLocalIndex, allIterators, iterators, isReverse, maxQueryEndTime, previousScan, clearedCache, concatIterators, scanPairItr, scanPair, retryCount-1); Thread.sleep(1000); concatIterators = recreateIterators(services, isLocalIndex, allIterators, iterators, isReverse, maxQueryEndTime, previousScan, clearedCache, concatIterators, scanPairItr, scanPair, retryCount); addIterator(iterators, concatIterators); if (!success) { try { close(); } catch (Exception e) { if (toThrow == null) {
if (cq != null) { int qualifier = table.getEncodingScheme().decode(cq); adjustQualifierRange(qualifier, minMaxQualifiers); if (cq != null) { int qualifier = table.getEncodingScheme().decode(cq); adjustQualifierRange(qualifier, minMaxQualifiers); familyMap.put(familyBytes, qualifierSet); if (qualifierRangeForFamily != null) { adjustQualifierRange(qualifierRangeForFamily.getFirst(), minMaxQualifiers); adjustQualifierRange(qualifierRangeForFamily.getSecond(), minMaxQualifiers);
private List<PeekingResultIterator> recreateIterators(ConnectionQueryServices services, boolean isLocalIndex, Queue<PeekingResultIterator> allIterators, List<PeekingResultIterator> iterators, boolean isReverse, long maxQueryEndTime, ScanWrapper previousScan, boolean clearedCache, List<PeekingResultIterator> concatIterators, Iterator<Pair<Scan, Future<PeekingResultIterator>>> scanPairItr, Pair<Scan, Future<PeekingResultIterator>> scanPair, int retryCount) throws SQLException { scanPairItr.remove(); // Resubmit just this portion of work again Scan oldScan = scanPair.getFirst(); byte[] startKey = oldScan.getAttribute(SCAN_ACTUAL_START_ROW); byte[] endKey = oldScan.getStopRow(); List<List<Scan>> newNestedScans = this.getParallelScans(startKey, endKey); // Add any concatIterators that were successful so far // as we need these to be in order addIterator(iterators, concatIterators); concatIterators = Lists.newArrayList(); getIterators(newNestedScans, services, isLocalIndex, allIterators, iterators, isReverse, maxQueryEndTime, newNestedScans.size(), previousScan, retryCount); return concatIterators; }
List<HRegionLocation> regionLocations = getRegionBoundaries(scanGrouper); List<byte[]> regionBoundaries = toBoundaries(regionLocations); int regionIndex = 0; int stopIndex = regionBoundaries.size(); if (scan.getStartRow().length > 0) { regionIndex = getIndexContainingInclusive(regionBoundaries, scan.getStartRow()); stopIndex = Math.min(stopIndex, regionIndex + getIndexContainingExclusive(regionBoundaries.subList(regionIndex, stopIndex), scan.getStopRow())); scans = addNewScan(parallelScans, scans, newScan, endKey, true, regionLocation); regionIndex++;
@Test public void test() { ScanRanges scanRanges = ScanRanges.create(schema, Collections.<List<KeyRange>>singletonList(Collections.<KeyRange>singletonList(input)), new int[] {schema.getFieldCount()-1}, null, false, -1); ScanRanges clippedRange = BaseResultIterators.computePrefixScanRanges(scanRanges, clipTo); assertEquals(expectedOutput, clippedRange.getScanRange()); }
range = clipRange(dataScanRanges.getSchema(), offset, rangeSpan, range);
byte[] lowerRange = range.getLowerRange(); if (!lowerUnbound && lowerRange.length > 0) { if (clipKeyRangeBytes(schema, fieldIndex, rangeSpan, lowerRange, ptr, true)) { byte[] upperRange = range.getUpperRange(); if (!upperUnbound && upperRange.length > 0) { if (clipKeyRangeBytes(schema, fieldIndex, rangeSpan, upperRange, ptr, false)) {
List<HRegionLocation> regionLocations = getRegionBoundaries(scanGrouper); List<byte[]> regionBoundaries = toBoundaries(regionLocations); int regionIndex = 0; int stopIndex = regionBoundaries.size(); if (scan.getStartRow().length > 0) { regionIndex = getIndexContainingInclusive(regionBoundaries, scan.getStartRow()); stopIndex = Math.min(stopIndex, regionIndex + getIndexContainingExclusive(regionBoundaries.subList(regionIndex, stopIndex), scan.getStopRow())); scans = addNewScan(parallelScans, scans, newScan, endKey, true, regionLocation); regionIndex++;
private List<PeekingResultIterator> recreateIterators(ConnectionQueryServices services, boolean isLocalIndex, Queue<PeekingResultIterator> allIterators, List<PeekingResultIterator> iterators, boolean isReverse, long maxQueryEndTime, ScanWrapper previousScan, boolean clearedCache, List<PeekingResultIterator> concatIterators, Iterator<Pair<Scan, Future<PeekingResultIterator>>> scanPairItr, Pair<Scan, Future<PeekingResultIterator>> scanPair, int retryCount) throws SQLException { scanPairItr.remove(); // Resubmit just this portion of work again Scan oldScan = scanPair.getFirst(); byte[] startKey = oldScan.getAttribute(SCAN_ACTUAL_START_ROW); byte[] endKey = oldScan.getStopRow(); List<List<Scan>> newNestedScans = this.getParallelScans(startKey, endKey); // Add any concatIterators that were successful so far // as we need these to be in order addIterator(iterators, concatIterators); concatIterators = Lists.newArrayList(); getIterators(newNestedScans, services, isLocalIndex, allIterators, iterators, isReverse, maxQueryEndTime, newNestedScans.size(), previousScan, retryCount); return concatIterators; }
range = clipRange(dataScanRanges.getSchema(), offset, rangeSpan, range);
byte[] lowerRange = range.getLowerRange(); if (!lowerUnbound && lowerRange.length > 0) { if (clipKeyRangeBytes(schema, fieldIndex, rangeSpan, lowerRange, ptr, true)) { byte[] upperRange = range.getUpperRange(); if (!upperUnbound && upperRange.length > 0) { if (clipKeyRangeBytes(schema, fieldIndex, rangeSpan, upperRange, ptr, false)) {
List<HRegionLocation> regionLocations = getRegionBoundaries(scanGrouper); List<byte[]> regionBoundaries = toBoundaries(regionLocations); ScanRanges scanRanges = context.getScanRanges(); PTable table = getTable(); boolean isSalted = table.getBucketNum() != null; boolean isLocalIndex = table.getIndexType() == IndexType.LOCAL; GuidePostsInfo gps = getGuidePosts(); prefixScanRanges = computePrefixScanRanges(dataPlan.getContext().getScanRanges(), columnsInCommon=computeColumnsInCommon()); KeyRange prefixRange = prefixScanRanges.getScanRange(); if (!prefixRange.lowerUnbound()) { int stopIndex = regionBoundaries.size(); if (startRegionBoundaryKey.length > 0) { startRegionIndex = regionIndex = getIndexContainingInclusive(regionBoundaries, startRegionBoundaryKey); stopIndex = Math.min(stopIndex, regionIndex + getIndexContainingExclusive(regionBoundaries.subList(regionIndex, stopIndex), stopRegionBoundaryKey)); if (isLocalIndex) { stopKey = regionLocations.get(stopIndex).getRegion().getEndKey(); byte[] regionStartKey = regionInfo.getStartKey(); ImmutableBytesWritable ptr = context.getTempPtr(); clipKeyRangeBytes(prefixScanRanges.getSchema(), 0, columnsInCommon, regionStartKey, ptr, false); regionStartKey = ByteUtil.copyKeyBytesIfNecessary(ptr); updateEstimates(gps, guideIndex-1, estimates); updateEstimates(gps, guideIndex, estimates);
List<HRegionLocation> regionLocations = getRegionBoundaries(scanGrouper); List<byte[]> regionBoundaries = toBoundaries(regionLocations); int regionIndex = 0; int stopIndex = regionBoundaries.size(); if (scan.getStartRow().length > 0) { regionIndex = getIndexContainingInclusive(regionBoundaries, scan.getStartRow()); stopIndex = Math.min(stopIndex, regionIndex + getIndexContainingExclusive(regionBoundaries.subList(regionIndex, stopIndex), scan.getStopRow())); scans = addNewScan(parallelScans, scans, newScan, endKey, true, regionLocation); regionIndex++;
int queryTimeOut = context.getStatement().getQueryTimeoutInMillis(); try { submitWork(scan, futures, allIterators, splitSize, isReverse, scanGrouper); boolean clearedCache = false; for (List<Pair<Scan,Future<PeekingResultIterator>>> future : reverseIfNecessary(futures,isReverse)) { List<PeekingResultIterator> concatIterators = Lists.newArrayListWithExpectedSize(future.size()); Iterator<Pair<Scan, Future<PeekingResultIterator>>> scanPairItr = reverseIfNecessary(future,isReverse).iterator(); while (scanPairItr.hasNext()) { Pair<Scan,Future<PeekingResultIterator>> scanPair = scanPairItr.next(); recreateIterators(services, isLocalIndex, allIterators, iterators, isReverse, maxQueryEndTime, previousScan, clearedCache, concatIterators, scanPairItr, scanPair, retryCount-1); Thread.sleep(1000); concatIterators = recreateIterators(services, isLocalIndex, allIterators, iterators, isReverse, maxQueryEndTime, previousScan, clearedCache, concatIterators, scanPairItr, scanPair, retryCount); addIterator(iterators, concatIterators); if (!success) { try { close(); } catch (Exception e) { if (toThrow == null) {
private List<PeekingResultIterator> recreateIterators(ConnectionQueryServices services, boolean isLocalIndex, Queue<PeekingResultIterator> allIterators, List<PeekingResultIterator> iterators, boolean isReverse, long maxQueryEndTime, ScanWrapper previousScan, boolean clearedCache, List<PeekingResultIterator> concatIterators, Iterator<Pair<Scan, Future<PeekingResultIterator>>> scanPairItr, Pair<Scan, Future<PeekingResultIterator>> scanPair, int retryCount) throws SQLException { scanPairItr.remove(); // Resubmit just this portion of work again Scan oldScan = scanPair.getFirst(); byte[] startKey = oldScan.getAttribute(SCAN_ACTUAL_START_ROW); byte[] endKey = oldScan.getStopRow(); List<List<Scan>> newNestedScans = this.getParallelScans(startKey, endKey); // Add any concatIterators that were successful so far // as we need these to be in order addIterator(iterators, concatIterators); concatIterators = Lists.newArrayList(); getIterators(newNestedScans, services, isLocalIndex, allIterators, iterators, isReverse, maxQueryEndTime, newNestedScans.size(), previousScan, retryCount); return concatIterators; }
range = clipRange(dataScanRanges.getSchema(), offset, rangeSpan, range); clipRange(dataScanRanges.getSchema(), 0, nColumnsInCommon, dataScanRanges.getMinMaxRange()); slotSpan = slotSpan.length == cnf.size() ? slotSpan : Arrays.copyOf(slotSpan, cnf.size()); ScanRanges commonScanRanges = ScanRanges.create(dataScanRanges.getSchema(), cnf, slotSpan, minMaxRange, null, useSkipScan, -1);