int limit = this.query.getLimit(parameters); Collection mergedResults = coalesceOrderedResults(resultCollector, context, cs, limit); resultCollector.clear();
private void executeSequentially(Collection<Collection> resultCollector, List buckets) throws QueryException, InterruptedException, ForceReattemptException { ExecutionContext context = new QueryExecutionContext(this.parameters, this.pr.getCache(), this.query); CompiledSelect cs = this.query.getSimpleSelect(); int limit = this.query.getLimit(parameters); if (cs != null && cs.isOrderBy()) { for (Integer bucketID : this._bucketsToQuery) { List<Integer> singleBucket = Collections.singletonList(bucketID); context.setBucketList(singleBucket); executeQueryOnBuckets(resultCollector, context); } Collection mergedResults = coalesceOrderedResults(resultCollector, context, cs, limit); resultCollector.clear(); resultCollector.add(mergedResults); } else { context.setBucketList(buckets); executeQueryOnBuckets(resultCollector, context); } }
@Before public void setup() throws Exception { localNode = new InternalDistributedMember("localhost", 8888); remoteNodeA = new InternalDistributedMember("localhost", 8889); remoteNodeB = new InternalDistributedMember("localhost", 8890); cache = Fakes.cache(); system = (InternalDistributedSystem) cache.getDistributedSystem(); allNodes.add(localNode); allNodes.add(remoteNodeA); allNodes.add(remoteNodeB); pr = mock(PartitionedRegion.class); dataStore = new ExtendedPartitionedRegionDataStore(); CompiledSelect select = mock(CompiledSelect.class); when(select.getType()).thenReturn(CompiledValue.COMPARISON); when(select.getElementTypeForOrderByQueries()).thenReturn(new ObjectTypeImpl(String.class)); query = mock(DefaultQuery.class); when(query.getSimpleSelect()).thenReturn(select); when(query.getLimit(any())).thenReturn(-1); when(pr.getCachePerfStats()).thenReturn(mock(CachePerfStats.class)); when(pr.getMyId()).thenReturn(localNode); when(pr.getDataStore()).thenReturn(dataStore); when(pr.getCache()).thenReturn(cache); }
limit = this.query.getLimit(parameters); isDistinct = (cs != null) ? cs.isDistinct() : true; isCount = (cs != null) ? cs.isCount() : false;