private ComputedStatistics( List<String> groupingColumns, List<Block> groupingValues, Map<TableStatisticType, Block> tableStatistics, Map<ColumnStatisticMetadata, Block> columnStatistics) { this.groupingColumns = unmodifiableList(new ArrayList<>(requireNonNull(groupingColumns, "groupingColumns is null"))); this.groupingValues = unmodifiableList(new ArrayList<>(requireNonNull(groupingValues, "groupingValues is null"))); if (!groupingValues.stream().allMatch(ComputedStatistics::isSingleValueBlock)) { throw new IllegalArgumentException("grouping value blocks are expected to be single value blocks"); } this.tableStatistics = unmodifiableMap(new HashMap<>(requireNonNull(tableStatistics, "tableStatistics is null"))); if (!tableStatistics.values().stream().allMatch(ComputedStatistics::isSingleValueBlock)) { throw new IllegalArgumentException("computed table statistics blocks are expected to be single value blocks"); } this.columnStatistics = unmodifiableMap(new HashMap<>(requireNonNull(columnStatistics, "columnStatistics is null"))); if (!columnStatistics.values().stream().allMatch(ComputedStatistics::isSingleValueBlock)) { throw new IllegalArgumentException("computed column statistics blocks are expected to be single value blocks"); } }
private ComputedStatistics( List<String> groupingColumns, List<Block> groupingValues, Map<TableStatisticType, Block> tableStatistics, Map<ColumnStatisticMetadata, Block> columnStatistics) { this.groupingColumns = unmodifiableList(new ArrayList<>(requireNonNull(groupingColumns, "groupingColumns is null"))); this.groupingValues = unmodifiableList(new ArrayList<>(requireNonNull(groupingValues, "groupingValues is null"))); if (!groupingValues.stream().allMatch(ComputedStatistics::isSingleValueBlock)) { throw new IllegalArgumentException("grouping value blocks are expected to be single value blocks"); } this.tableStatistics = unmodifiableMap(new HashMap<>(requireNonNull(tableStatistics, "tableStatistics is null"))); if (!tableStatistics.values().stream().allMatch(ComputedStatistics::isSingleValueBlock)) { throw new IllegalArgumentException("computed table statistics blocks are expected to be single value blocks"); } this.columnStatistics = unmodifiableMap(new HashMap<>(requireNonNull(columnStatistics, "columnStatistics is null"))); if (!columnStatistics.values().stream().allMatch(ComputedStatistics::isSingleValueBlock)) { throw new IllegalArgumentException("computed column statistics blocks are expected to be single value blocks"); } }
public static ResettableRandomizedIterator<Node> randomizedNodes(NodeMap nodeMap, boolean includeCoordinator, Set<Node> excludedNodes) { ImmutableList<Node> nodes = nodeMap.getNodesByHostAndPort().values().stream() .filter(node -> includeCoordinator || !nodeMap.getCoordinatorNodeIds().contains(node.getNodeIdentifier())) .filter(node -> !excludedNodes.contains(node)) .collect(toImmutableList()); return new ResettableRandomizedIterator<>(nodes); }
@Override public Result apply(AggregationNode aggregationNode, Captures captures, Context context) { Set<Symbol> requiredInputs = Streams.concat( aggregationNode.getGroupingKeys().stream(), aggregationNode.getHashSymbol().map(Stream::of).orElse(Stream.empty()), aggregationNode.getAggregations().values().stream() .flatMap(PruneAggregationSourceColumns::getAggregationInputs)) .collect(toImmutableSet()); return restrictChildOutputs(context.getIdAllocator(), aggregationNode, requiredInputs) .map(Result::ofPlanNode) .orElse(Result.empty()); }