private Map<DecoderColumnHandle, JsonFieldDecoder> chooseFieldDecoders(Set<DecoderColumnHandle> columns) { return columns.stream() .collect(toImmutableMap(identity(), this::chooseFieldDecoder)); }
public Visitor(Collection<PlanFragment> fragments, DirectedGraph<PlanFragmentId, DefaultEdge> graph) { this.fragments = fragments.stream() .collect(toImmutableMap(PlanFragment::getId, identity())); this.graph = graph; }
public RawRowDecoder(Set<DecoderColumnHandle> columnHandles) { requireNonNull(columnHandles, "columnHandles is null"); columnDecoders = columnHandles.stream() .collect(toImmutableMap(identity(), this::createColumnDecoder)); }
private static <K, V1, V2> Map<K, V2> map(Map<K, V1> input, Function<V1, V2> mapper) { return input.entrySet() .stream() .collect(toImmutableMap(Map.Entry::getKey, entry -> mapper.apply(entry.getValue()))); }
SymbolMapper getCorrelatedSymbolMapper() { return new SymbolMapper(correlatedSymbolsMapping.asMap().entrySet().stream() .collect(toImmutableMap(Map.Entry::getKey, symbols -> Iterables.getLast(symbols.getValue())))); }
private static Map<Expression, Symbol> symbolsForExpressions(PlanBuilder builder, Iterable<? extends Expression> expressions) { return stream(expressions) .distinct() .collect(toImmutableMap(expression -> expression, builder::translate)); }
private Map<String, HiveColumnStatistics> groupStatisticsByColumn(List<ColumnStatisticsObj> statistics, OptionalLong rowCount) { return statistics.stream() .collect(toImmutableMap(ColumnStatisticsObj::getColName, statisticsObj -> ThriftMetastoreUtil.fromMetastoreApiColumnStatistics(statisticsObj, rowCount))); }
public void validateMetadata(OrcDataSourceId orcDataSourceId, Map<String, Slice> actualMetadata) throws OrcCorruptionException { // Filter out metadata value statically added by the DWRF writer Map<String, Slice> filteredMetadata = actualMetadata.entrySet().stream() .filter(entry -> !STATIC_METADATA.containsKey(entry.getKey())) .collect(toImmutableMap(Entry::getKey, Entry::getValue)); if (!metadata.equals(filteredMetadata)) { throw new OrcCorruptionException(orcDataSourceId, "Unexpected metadata"); } }
public StageInfo getStageInfo() { Map<StageId, StageInfo> stageInfos = stages.values().stream() .map(SqlStageExecution::getStageInfo) .collect(toImmutableMap(StageInfo::getStageId, identity())); return buildStageInfo(rootStageId, stageInfos); }
public static Map<List<String>, ComputedStatistics> createComputedStatisticsToPartitionMap( Collection<ComputedStatistics> computedStatistics, List<String> partitionColumns, Map<String, Type> columnTypes) { List<Type> partitionColumnTypes = partitionColumns.stream() .map(columnTypes::get) .collect(toImmutableList()); return computedStatistics.stream() .collect(toImmutableMap(statistics -> getPartitionValues(statistics, partitionColumns, partitionColumnTypes), statistics -> statistics)); }
public PhasedExecutionSchedule(Collection<SqlStageExecution> stages) { List<Set<PlanFragmentId>> phases = extractPhases(stages.stream().map(SqlStageExecution::getFragment).collect(toImmutableList())); Map<PlanFragmentId, SqlStageExecution> stagesByFragmentId = stages.stream().collect(toImmutableMap(stage -> stage.getFragment().getId(), identity())); // create a mutable list of mutable sets of stages, so we can remove completed stages schedulePhases = new ArrayList<>(); for (Set<PlanFragmentId> phase : phases) { schedulePhases.add(phase.stream() .map(stagesByFragmentId::get) .collect(Collectors.toCollection(HashSet::new))); } }
@Override public Map<String, ColumnHandle> getColumnHandles(ConnectorSession session, ConnectorTableHandle tableHandle) { return getTableMetadata(session, tableHandle).getColumns().stream().collect(toImmutableMap(ColumnMetadata::getName, ThriftColumnHandle::new)); }
private static Map<Symbol, Symbol> getInputSymbolMapping(UnionNode node, int source) { return node.getSymbolMapping() .keySet() .stream() .collect(toImmutableMap(key -> key, key -> node.getSymbolMapping().get(key).get(source))); } }
private void storePartitionColumnStatistics(String databaseName, String tableName, String partitionName, PartitionWithStatistics partitionWithStatistics) { PartitionStatistics statistics = partitionWithStatistics.getStatistics(); Map<String, HiveColumnStatistics> columnStatistics = statistics.getColumnStatistics(); if (columnStatistics.isEmpty()) { return; } Map<String, HiveType> columnTypes = partitionWithStatistics.getPartition().getColumns().stream() .collect(toImmutableMap(Column::getName, Column::getType)); setPartitionColumnStatistics(databaseName, tableName, partitionName, columnTypes, columnStatistics, statistics.getBasicStatistics().getRowCount()); }
public void testToImmutableMap_exceptionOnDuplicateKey() { Collector<Entry<String, Integer>, ?, ImmutableMap<String, Integer>> collector = ImmutableMap.toImmutableMap(Entry::getKey, Entry::getValue); try { Stream.of(mapEntry("one", 1), mapEntry("one", 11)).collect(collector); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { } }
private <E extends TpchEntity> Map<TpchColumn<E>, ColumnStatisticsRecorder> createStatisticsRecorders(List<TpchColumn<E>> columns) { return columns.stream() .collect(toImmutableMap(identity(), (column) -> new ColumnStatisticsRecorder(column.getType()))); }
private PlanNodeCostEstimate calculateCumulativeCost(PlanNode node, CostCalculator costCalculator, StatsCalculator statsCalculator, Map<String, Type> types) { TypeProvider typeProvider = TypeProvider.copyOf(types.entrySet().stream() .collect(ImmutableMap.toImmutableMap(entry -> new Symbol(entry.getKey()), Map.Entry::getValue))); StatsProvider statsProvider = new CachingStatsProvider(statsCalculator, session, typeProvider); CostProvider costProvider = new CachingCostProvider(costCalculator, statsProvider, Optional.empty(), session, typeProvider); return costProvider.getCumulativeCost(node); }
private PlanNodeCostEstimate calculateCumulativeCostFragmentedPlan(PlanNode node, StatsCalculator statsCalculator, Map<String, Type> types) { TypeProvider typeProvider = TypeProvider.copyOf(types.entrySet().stream() .collect(ImmutableMap.toImmutableMap(entry -> new Symbol(entry.getKey()), Map.Entry::getValue))); StatsProvider statsProvider = new CachingStatsProvider(statsCalculator, session, typeProvider); CostProvider costProvider = new CachingCostProvider(costCalculatorUsingExchanges, statsProvider, Optional.empty(), session, typeProvider); SubPlan subPlan = fragment(new Plan(node, typeProvider, StatsAndCosts.create(node, statsProvider, costProvider))); return subPlan.getFragment().getStatsAndCosts().getCosts().getOrDefault(node.getId(), PlanNodeCostEstimate.unknown()); }
public void testToImmutableMap() { Collector<Entry<String, Integer>, ?, ImmutableMap<String, Integer>> collector = ImmutableMap.toImmutableMap(Entry::getKey, Entry::getValue); Equivalence<ImmutableMap<String, Integer>> equivalence = Equivalence.equals() .<Entry<String, Integer>>pairwise() .onResultOf(ImmutableMap::entrySet); CollectorTester.of(collector, equivalence) .expectCollects( ImmutableMap.of("one", 1, "two", 2, "three", 3), mapEntry("one", 1), mapEntry("two", 2), mapEntry("three", 3)); }
public void testToImmutableMapMerging() { Collector<Entry<String, Integer>, ?, ImmutableMap<String, Integer>> collector = ImmutableMap.toImmutableMap(Entry::getKey, Entry::getValue, Integer::sum); Equivalence<ImmutableMap<String, Integer>> equivalence = Equivalence.equals() .<Entry<String, Integer>>pairwise() .onResultOf(ImmutableMap::entrySet); CollectorTester.of(collector, equivalence) .expectCollects( ImmutableMap.of("one", 1, "two", 4, "three", 3), mapEntry("one", 1), mapEntry("two", 2), mapEntry("three", 3), mapEntry("two", 2)); } }