public StreamPreferredProperties withOrderSensitivity() { return new StreamPreferredProperties(distribution, false, Optional.empty(), true); }
public static StreamPreferredProperties any() { return new StreamPreferredProperties(Optional.empty(), Optional.empty(), false); }
public static StreamPreferredProperties singleStream() { return new StreamPreferredProperties(Optional.of(SINGLE), Optional.empty(), false); }
public static StreamPreferredProperties fixedParallelism() { return new StreamPreferredProperties(Optional.of(FIXED), Optional.empty(), false); }
public StreamPreferredProperties withoutPreference() { return new StreamPreferredProperties(Optional.empty(), Optional.empty(), orderSensitive); }
public StreamPreferredProperties translate(Function<Symbol, Optional<Symbol>> translator) { return new StreamPreferredProperties( distribution, partitioningColumns.flatMap(partitioning -> translateSymbols(partitioning, translator)), orderSensitive); }
public static StreamPreferredProperties exactlyPartitionedOn(Collection<Symbol> partitionSymbols) { if (partitionSymbols.isEmpty()) { return singleStream(); } // this must be the exact partitioning symbols, in the exact order return new StreamPreferredProperties(Optional.of(FIXED), true, Optional.of(ImmutableList.copyOf(partitionSymbols)), false); }
public StreamPreferredProperties withParallelism() { // do not override an existing parallel preference if (isParallelPreferred()) { return this; } return new StreamPreferredProperties(Optional.of(MULTIPLE), Optional.empty(), orderSensitive); }
public StreamPreferredProperties withPartitioning(Collection<Symbol> partitionSymbols) { if (partitionSymbols.isEmpty()) { return singleStream(); } Iterable<Symbol> desiredPartitioning = partitionSymbols; if (partitioningColumns.isPresent()) { if (exactColumnOrder) { if (partitioningColumns.get().equals(desiredPartitioning)) { return this; } } else { // If there are common columns between our requirements and the desired partitionSymbols, both can be satisfied in one shot Set<Symbol> common = Sets.intersection(ImmutableSet.copyOf(desiredPartitioning), ImmutableSet.copyOf(partitioningColumns.get())); // If we find common partitioning columns, use them, else use child's partitioning columns if (!common.isEmpty()) { desiredPartitioning = common; } } } return new StreamPreferredProperties(distribution, Optional.of(desiredPartitioning), false); }
public static StreamPreferredProperties defaultParallelism(Session session) { if (getTaskConcurrency(session) > 1 && !preferStreamingOperators(session)) { return new StreamPreferredProperties(Optional.of(MULTIPLE), Optional.empty(), false); } return any(); }
public StreamPreferredProperties constrainTo(Iterable<Symbol> symbols) { if (!partitioningColumns.isPresent()) { return this; } ImmutableSet<Symbol> availableSymbols = ImmutableSet.copyOf(symbols); if (exactColumnOrder) { if (availableSymbols.containsAll(partitioningColumns.get())) { return this; } return any(); } List<Symbol> common = partitioningColumns.get().stream() .filter(availableSymbols::contains) .collect(toImmutableList()); if (common.isEmpty()) { return any(); } return new StreamPreferredProperties(distribution, Optional.of(common), false); } }