Source:
<code>protected Grouper<ByteBuffer> newGrouper() { Grouper grouper = null; final DefaultLimitSpec limitSpec = query.isApplyLimitPushDown() && querySpecificConfig.isApplyLimitPushDownToSegment() ? (DefaultLimitSpec) query.getLimitSpec() : null; <START> boolean canDoPushdown = false; <END> if (limitSpec != null) { canDoPushdown = canPushdownLimit(query.getDimensions().stream().map(DimensionSpec::getDimension)); canDoPushdown &= canPushdownLimit(limitSpec.getColumns().stream().map(OrderByColumnSpec::getDimension)); } if (canDoPushdown) { LimitedBufferHashGrouper limitGrouper = new LimitedBufferHashGrouper<>( Suppliers.ofInstance(buffer), keySerde, AggregatorAdapters.factorizeBuffered( cursor.getColumnSelectorFactory(), query.getAggregatorSpecs() ), querySpecificConfig.getBufferGrouperMaxSize(), querySpecificConfig.getBufferGrouperMaxLoadFactor(), querySpecificConfig.getBufferGrouperInitialBuckets(), limitSpec.getLimit(), DefaultLimitSpec.sortingOrderHasNonGroupingFields( limitSpec, query.getDimensions() ) ); if (limitGrouper.validateBufferCapacity(buffer.capacity())) { grouper = limitGrouper; } else { LOGGER.warn( "Limit is not applied in segment scan phase due to limited buffer capacity for query [%s].", query.getId() ); } } if (grouper == null) { grouper = new BufferHashGrouper<>( Suppliers.ofInstance(buffer), keySerde, AggregatorAdapters.factorizeBuffered( cursor.getColumnSelectorFactory(), query.getAggregatorSpecs() ), querySpecificConfig.getBufferGrouperMaxSize(), querySpecificConfig.getBufferGrouperMaxLoadFactor(), querySpecificConfig.getBufferGrouperInitialBuckets(), true ); } return grouper; }</code><technical_language>canDoLimitPushDown a name for reasons: 1. other stuff pushed down, in general, other limits. 2. Spelling of PushDown is more consistent methods GroupByQuery itself</technical_language>

Target:
protected Grouper<ByteBuffer> newGrouper() { Grouper<ByteBuffer> grouper = null; final ColumnSelectorFactory selectorFactory = cursor.getColumnSelectorFactory(); final DefaultLimitSpec limitSpec = query.isApplyLimitPushDown() && querySpecificConfig.isApplyLimitPushDownToSegment() ? (DefaultLimitSpec) query.getLimitSpec() : null; final boolean canDoLimitPushdown; if (limitSpec != null) { canDoLimitPushdown = Stream.concat( query.getDimensions().stream().map(DimensionSpec::getDimension), limitSpec.getColumns().stream().map(OrderByColumnSpec::getDimension) ).allMatch(col -> GroupByQueryEngineV2.canPushDownLimit(selectorFactory, col)); } else { canDoLimitPushdown = false; } if (canDoLimitPushdown) { LimitedBufferHashGrouper<ByteBuffer> limitGrouper = new LimitedBufferHashGrouper<>( Suppliers.ofInstance(buffer), keySerde, AggregatorAdapters.factorizeBuffered( selectorFactory, query.getAggregatorSpecs() ), querySpecificConfig.getBufferGrouperMaxSize(), querySpecificConfig.getBufferGrouperMaxLoadFactor(), querySpecificConfig.getBufferGrouperInitialBuckets(), limitSpec.getLimit(), DefaultLimitSpec.sortingOrderHasNonGroupingFields( limitSpec, query.getDimensions() ) ); if (limitGrouper.validateBufferCapacity(buffer.capacity())) { grouper = limitGrouper; } else { LOGGER.warn( "Limit is not applied in segment scan phase due to limited buffer capacity for query [%s].", query.getId() ); } } if (grouper == null) { grouper = new BufferHashGrouper<>( Suppliers.ofInstance(buffer), keySerde, AggregatorAdapters.factorizeBuffered( selectorFactory, query.getAggregatorSpecs() ), querySpecificConfig.getBufferGrouperMaxSize(), querySpecificConfig.getBufferGrouperMaxLoadFactor(), querySpecificConfig.getBufferGrouperInitialBuckets(), true ); } return grouper; }