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);
}