@SuppressWarnings("deprecation") private static ParallelIteratorFactory buildResultIteratorFactory(StatementContext context, FilterableStatement statement, TableRef tableRef, OrderBy orderBy, Integer limit,Integer offset, boolean allowPageFilter) throws SQLException { if ((isSerial(context, statement, tableRef, orderBy, getEstimateOfDataSizeToScanIfWithinThreshold(context, tableRef.getTable(), QueryUtil.getOffsetLimit(limit, offset)) != null) || isRoundRobinPossible(orderBy, context) || isPacingScannersPossible(context))) { return ParallelIteratorFactory.NOOP_FACTORY; } ParallelIteratorFactory spoolingResultIteratorFactory = new SpoolingResultIterator.SpoolingResultIteratorFactory( context.getConnection().getQueryServices()); // If we're doing an order by then we need the full result before we can do anything, // so we don't bother chunking it. If we're just doing a simple scan then we chunk // the scan to have a quicker initial response. if (!orderBy.getOrderByExpressions().isEmpty()) { return spoolingResultIteratorFactory; } else { return new ChunkedResultIterator.ChunkedResultIteratorFactory( spoolingResultIteratorFactory, context.getConnection().getMutationState(), tableRef); } }
private ScanPlan(StatementContext context, FilterableStatement statement, TableRef table, RowProjector projector, Integer limit, Integer offset, OrderBy orderBy, ParallelIteratorFactory parallelIteratorFactory, boolean allowPageFilter, Expression dynamicFilter, QueryPlan dataPlan) throws SQLException { super(context, statement, table, projector, context.getBindManager().getParameterMetaData(), limit,offset, orderBy, GroupBy.EMPTY_GROUP_BY, parallelIteratorFactory != null ? parallelIteratorFactory : buildResultIteratorFactory(context, statement, table, orderBy, limit, offset, allowPageFilter), dynamicFilter, dataPlan); this.allowPageFilter = allowPageFilter; boolean isOrdered = !orderBy.getOrderByExpressions().isEmpty(); if (isOrdered) { // TopN int thresholdBytes = context.getConnection().getQueryServices().getProps().getInt( QueryServices.SPOOL_THRESHOLD_BYTES_ATTRIB, QueryServicesOptions.DEFAULT_SPOOL_THRESHOLD_BYTES); ScanRegionObserver.serializeIntoScan(context.getScan(), thresholdBytes, limit == null ? -1 : QueryUtil.getOffsetLimit(limit, offset), orderBy.getOrderByExpressions(), projector.getEstimatedRowByteSize()); } Integer perScanLimit = !allowPageFilter || isOrdered ? null : limit; perScanLimit = QueryUtil.getOffsetLimit(perScanLimit, offset); Pair<Long, Long> estimate = getEstimateOfDataSizeToScanIfWithinThreshold(context, table.getTable(), perScanLimit); this.isDataToScanWithinThreshold = estimate != null; this.isSerial = isSerial(context, statement, tableRef, orderBy, isDataToScanWithinThreshold); if (isSerial) { serialBytesEstimate = estimate.getFirst(); serialRowsEstimate = estimate.getSecond(); serialEstimateInfoTs = StatisticsUtil.NOT_STATS_BASED_TS; } }
@SuppressWarnings("deprecation") private static ParallelIteratorFactory buildResultIteratorFactory(StatementContext context, FilterableStatement statement, TableRef tableRef, OrderBy orderBy, Integer limit,Integer offset, boolean allowPageFilter) throws SQLException { if ((isSerial(context, statement, tableRef, orderBy, getEstimateOfDataSizeToScanIfWithinThreshold(context, tableRef.getTable(), QueryUtil.getOffsetLimit(limit, offset)) != null) || isRoundRobinPossible(orderBy, context) || isPacingScannersPossible(context))) { return ParallelIteratorFactory.NOOP_FACTORY; } ParallelIteratorFactory spoolingResultIteratorFactory = new SpoolingResultIterator.SpoolingResultIteratorFactory( context.getConnection().getQueryServices()); // If we're doing an order by then we need the full result before we can do anything, // so we don't bother chunking it. If we're just doing a simple scan then we chunk // the scan to have a quicker initial response. if (!orderBy.getOrderByExpressions().isEmpty()) { return spoolingResultIteratorFactory; } else { return new ChunkedResultIterator.ChunkedResultIteratorFactory( spoolingResultIteratorFactory, context.getConnection().getMutationState(), tableRef); } }
@SuppressWarnings("deprecation") private static ParallelIteratorFactory buildResultIteratorFactory(StatementContext context, FilterableStatement statement, TableRef tableRef, OrderBy orderBy, Integer limit,Integer offset, boolean allowPageFilter) throws SQLException { if ((isSerial(context, statement, tableRef, orderBy, getEstimateOfDataSizeToScanIfWithinThreshold(context, tableRef.getTable(), QueryUtil.getOffsetLimit(limit, offset)) != null) || isRoundRobinPossible(orderBy, context) || isPacingScannersPossible(context))) { return ParallelIteratorFactory.NOOP_FACTORY; } ParallelIteratorFactory spoolingResultIteratorFactory = new SpoolingResultIterator.SpoolingResultIteratorFactory( context.getConnection().getQueryServices()); // If we're doing an order by then we need the full result before we can do anything, // so we don't bother chunking it. If we're just doing a simple scan then we chunk // the scan to have a quicker initial response. if (!orderBy.getOrderByExpressions().isEmpty()) { return spoolingResultIteratorFactory; } else { return new ChunkedResultIterator.ChunkedResultIteratorFactory( spoolingResultIteratorFactory, context.getConnection().getMutationState(), tableRef); } }
private ScanPlan(StatementContext context, FilterableStatement statement, TableRef table, RowProjector projector, Integer limit, Integer offset, OrderBy orderBy, ParallelIteratorFactory parallelIteratorFactory, boolean allowPageFilter, Expression dynamicFilter, QueryPlan dataPlan) throws SQLException { super(context, statement, table, projector, context.getBindManager().getParameterMetaData(), limit,offset, orderBy, GroupBy.EMPTY_GROUP_BY, parallelIteratorFactory != null ? parallelIteratorFactory : buildResultIteratorFactory(context, statement, table, orderBy, limit, offset, allowPageFilter), dynamicFilter, dataPlan); this.allowPageFilter = allowPageFilter; boolean isOrdered = !orderBy.getOrderByExpressions().isEmpty(); if (isOrdered) { // TopN int thresholdBytes = context.getConnection().getQueryServices().getProps().getInt( QueryServices.SPOOL_THRESHOLD_BYTES_ATTRIB, QueryServicesOptions.DEFAULT_SPOOL_THRESHOLD_BYTES); ScanRegionObserver.serializeIntoScan(context.getScan(), thresholdBytes, limit == null ? -1 : QueryUtil.getOffsetLimit(limit, offset), orderBy.getOrderByExpressions(), projector.getEstimatedRowByteSize()); } Integer perScanLimit = !allowPageFilter || isOrdered ? null : limit; perScanLimit = QueryUtil.getOffsetLimit(perScanLimit, offset); Pair<Long, Long> estimate = getEstimateOfDataSizeToScanIfWithinThreshold(context, table.getTable(), perScanLimit); this.isDataToScanWithinThreshold = estimate != null; this.isSerial = isSerial(context, statement, tableRef, orderBy, isDataToScanWithinThreshold); if (isSerial) { serialBytesEstimate = estimate.getFirst(); serialRowsEstimate = estimate.getSecond(); serialEstimateInfoTs = StatisticsUtil.NOT_STATS_BASED_TS; } }
private ScanPlan(StatementContext context, FilterableStatement statement, TableRef table, RowProjector projector, Integer limit, Integer offset, OrderBy orderBy, ParallelIteratorFactory parallelIteratorFactory, boolean allowPageFilter, Expression dynamicFilter, QueryPlan dataPlan) throws SQLException { super(context, statement, table, projector, context.getBindManager().getParameterMetaData(), limit,offset, orderBy, GroupBy.EMPTY_GROUP_BY, parallelIteratorFactory != null ? parallelIteratorFactory : buildResultIteratorFactory(context, statement, table, orderBy, limit, offset, allowPageFilter), dynamicFilter, dataPlan); this.allowPageFilter = allowPageFilter; boolean isOrdered = !orderBy.getOrderByExpressions().isEmpty(); if (isOrdered) { // TopN int thresholdBytes = context.getConnection().getQueryServices().getProps().getInt( QueryServices.SPOOL_THRESHOLD_BYTES_ATTRIB, QueryServicesOptions.DEFAULT_SPOOL_THRESHOLD_BYTES); ScanRegionObserver.serializeIntoScan(context.getScan(), thresholdBytes, limit == null ? -1 : QueryUtil.getOffsetLimit(limit, offset), orderBy.getOrderByExpressions(), projector.getEstimatedRowByteSize()); } Integer perScanLimit = !allowPageFilter || isOrdered ? null : limit; perScanLimit = QueryUtil.getOffsetLimit(perScanLimit, offset); Pair<Long, Long> estimate = getEstimateOfDataSizeToScanIfWithinThreshold(context, table.getTable(), perScanLimit); this.isDataToScanWithinThreshold = estimate != null; this.isSerial = isSerial(context, statement, tableRef, orderBy, isDataToScanWithinThreshold); if (isSerial) { serialBytesEstimate = estimate.getFirst(); serialRowsEstimate = estimate.getSecond(); serialEstimateInfoTs = StatisticsUtil.NOT_STATS_BASED_TS; } }