private static void handleDistinct(OSelectExecutionPlan result, QueryPlanningInfo info, OCommandContext ctx, boolean profilingEnabled) { if (info.distinct) { result.chain(new DistinctExecutionStep(ctx, profilingEnabled)); } }
private void fetchNext(int nRecords) { while (true) { if (nextValue != null) { return; } if (lastResult == null || !lastResult.hasNext()) { lastResult = getPrev().get().syncPull(ctx, nRecords); } if (lastResult == null || !lastResult.hasNext()) { return; } long begin = profilingEnabled ? System.nanoTime() : 0; try { nextValue = lastResult.next(); if (alreadyVisited(nextValue)) { nextValue = null; } else { markAsVisited(nextValue); } } finally { if (profilingEnabled) { cost += (System.nanoTime() - begin); } } } }
@Override public String prettyPrint(int depth, int indent) { String result = OExecutionStepInternal.getIndent(depth, indent) + "+ DISTINCT"; if (profilingEnabled) { result += " (" + getCostFormatted() + ")"; } return result; }
result.add(new DistinctExecutionStep(ctx, profilingEnabled));
private OExecutionStepInternal createParallelIndexFetch(List<IndexSearchDescriptor> indexSearchDescriptors, Set<String> filterClusters, OCommandContext ctx, boolean profilingEnabled) { List<OInternalExecutionPlan> subPlans = new ArrayList<>(); for (IndexSearchDescriptor desc : indexSearchDescriptors) { OSelectExecutionPlan subPlan = new OSelectExecutionPlan(ctx); subPlan.chain(new FetchFromIndexStep(desc.idx, desc.keyCondition, desc.additionalRangeCondition, ctx, profilingEnabled)); int[] filterClusterIds = null; if (filterClusters != null) { filterClusterIds = filterClusters.stream().map(name -> ctx.getDatabase().getClusterIdByName(name)).mapToInt(i -> i) .toArray(); } subPlan.chain(new GetValueFromIndexEntryStep(ctx, filterClusterIds, profilingEnabled)); if (requiresMultipleIndexLookups(desc.keyCondition)) { subPlan.chain(new DistinctExecutionStep(ctx, profilingEnabled)); } if (desc.remainingCondition != null && !desc.remainingCondition.isEmpty()) { subPlan.chain(new FilterStep(createWhereFrom(desc.remainingCondition), ctx, profilingEnabled)); } subPlans.add(subPlan); } return new ParallelExecStep(subPlans, ctx, profilingEnabled); }
result.chain(new DistinctExecutionStep(context, enableProfiling));
subPlan.chain(new DistinctExecutionStep(ctx, profilingEnabled)); plan.chain(new ParallelExecStep(resultSubPlans, ctx, profilingEnabled)); plan.chain(new FilterByClustersStep(filterClusters, ctx, profilingEnabled)); plan.chain(new DistinctExecutionStep(ctx, profilingEnabled));