use of io.trino.sql.planner.plan.JoinNode in project trino by trinodb.
the class LocalDynamicFilterConsumer method create.
public static LocalDynamicFilterConsumer create(JoinNode planNode, List<Type> buildSourceTypes, int partitionCount, Set<DynamicFilterId> collectedFilters) {
checkArgument(!planNode.getDynamicFilters().isEmpty(), "Join node dynamicFilters is empty.");
checkArgument(!collectedFilters.isEmpty(), "Collected dynamic filters set is empty");
checkArgument(planNode.getDynamicFilters().keySet().containsAll(collectedFilters), "Collected dynamic filters set is not subset of join dynamic filters");
PlanNode buildNode = planNode.getRight();
Map<DynamicFilterId, Integer> buildChannels = planNode.getDynamicFilters().entrySet().stream().filter(entry -> collectedFilters.contains(entry.getKey())).collect(toImmutableMap(// Dynamic filter ID
Map.Entry::getKey, // Build-side channel index
entry -> {
Symbol buildSymbol = entry.getValue();
int buildChannelIndex = buildNode.getOutputSymbols().indexOf(buildSymbol);
verify(buildChannelIndex >= 0);
return buildChannelIndex;
}));
Map<DynamicFilterId, Type> filterBuildTypes = buildChannels.entrySet().stream().collect(toImmutableMap(Map.Entry::getKey, entry -> buildSourceTypes.get(entry.getValue())));
return new LocalDynamicFilterConsumer(buildChannels, filterBuildTypes, partitionCount);
}
Aggregations