private static void checkDependencies(Collection<Symbol> inputs, Collection<Symbol> required, String message, Object... parameters) { checkArgument(ImmutableSet.copyOf(inputs).containsAll(required), message, parameters); } }
@Override public boolean contains(@Nullable Object obj) { if (obj instanceof Set) { Set<?> set = (Set<?>) obj; return inputSet.keySet().containsAll(set); } return false; }
public boolean isPartitionedOn(Iterable<Symbol> columns) { if (!partitioningColumns.isPresent()) { return false; } // partitioned on (k_1, k_2, ..., k_n) => partitioned on (k_1, k_2, ..., k_n, k_n+1, ...) // can safely ignore all constant columns when comparing partition properties return ImmutableSet.copyOf(columns).containsAll(partitioningColumns.get()); }
@Override public boolean contains(@Nullable Object o) { if (o instanceof Set) { Set<?> s = (Set<?>) o; return s.size() == size && index.keySet().containsAll(s); } return false; }
@Override public boolean contains(@NullableDecl Object o) { if (o instanceof Set) { Set<?> s = (Set<?>) o; return s.size() == size && index.keySet().containsAll(s); } return false; }
@Override public boolean contains(@NullableDecl Object obj) { if (obj instanceof Set) { Set<?> set = (Set<?>) obj; return inputSet.keySet().containsAll(set); } return false; }
@Override public boolean contains(@NullableDecl Object o) { if (o instanceof Set) { Set<?> s = (Set<?>) o; return s.size() == size && index.keySet().containsAll(s); } return false; }
@Override public boolean contains(@NullableDecl Object obj) { if (obj instanceof Set) { Set<?> set = (Set<?>) obj; return inputSet.keySet().containsAll(set); } return false; }
@JsonCreator public PartitioningScheme( @JsonProperty("partitioning") Partitioning partitioning, @JsonProperty("outputLayout") List<Symbol> outputLayout, @JsonProperty("hashColumn") Optional<Symbol> hashColumn, @JsonProperty("replicateNullsAndAny") boolean replicateNullsAndAny, @JsonProperty("bucketToPartition") Optional<int[]> bucketToPartition) { this.partitioning = requireNonNull(partitioning, "partitioning is null"); this.outputLayout = ImmutableList.copyOf(requireNonNull(outputLayout, "outputLayout is null")); Set<Symbol> columns = partitioning.getColumns(); checkArgument(ImmutableSet.copyOf(outputLayout).containsAll(columns), "Output layout (%s) don't include all partition columns (%s)", outputLayout, columns); this.hashColumn = requireNonNull(hashColumn, "hashColumn is null"); hashColumn.ifPresent(column -> checkArgument(outputLayout.contains(column), "Output layout (%s) don't include hash column (%s)", outputLayout, column)); checkArgument(!replicateNullsAndAny || columns.size() <= 1, "Must have at most one partitioning column when nullPartition is REPLICATE."); this.replicateNullsAndAny = replicateNullsAndAny; this.bucketToPartition = requireNonNull(bucketToPartition, "bucketToPartition is null"); }
private static List<Type> toTypes(Map<Symbol, Integer> layout, LocalExecutionPlanContext context) { // verify layout covers all values int channelCount = layout.values().stream().mapToInt(Integer::intValue).max().orElse(-1) + 1; checkArgument( layout.size() == channelCount && ImmutableSet.copyOf(layout.values()).containsAll(ContiguousSet.create(closedOpen(0, channelCount), integers())), "Layout does not have a symbol for every output channel: %s", layout); Map<Integer, Symbol> channelLayout = ImmutableBiMap.copyOf(layout).inverse(); return range(0, channelCount) .mapToObj(channelLayout::get) .map(context.getTypes()::get) .collect(toImmutableList()); }
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); } }
checkArgument(ImmutableSet.copyOf(root.getOutputSymbols()).containsAll(partitioningScheme.getOutputLayout()), "Root node outputs (%s) does not include all fragment outputs (%s)", root.getOutputSymbols(), partitioningScheme.getOutputLayout());
/** * Given a list of partition fields, checks if all the fields requested are single-valued. If all * the fields are single-valued returns list of equivalent MPartition fieldnames * which can be used in the setResult clause of a JDO query * * @param partitionFields List of partitionFields in the projection * @return List of JDO field names which can be used in setResult clause * of a JDO query. Returns null if input partitionFields cannot be used in a setResult clause */ public static List<String> getMPartitionFieldNames(List<String> partitionFields) throws MetaException { // if there are no partitionFields requested, it means all the fields are requested which include // multi-valued fields. if (partitionFields == null || partitionFields.isEmpty()) { return null; } // throw exception if there are invalid field names PartitionProjectionEvaluator.validate(partitionFields); // else, check if all the fields are single-valued. In case there are multi-valued fields requested // return null since setResult in JDO doesn't support multi-valued fields if (!allPartitionSingleValuedFields.keySet().containsAll(partitionFields)) { return null; } List<String> jdoFields = new ArrayList<>(partitionFields.size()); for (String partitionField : partitionFields) { jdoFields.add(allPartitionSingleValuedFields.get(partitionField)); } return jdoFields; } }
checkArgument(inputs.size() == sources.size(), "Must have same number of input lists as sources"); for (int i = 0; i < inputs.size(); i++) { checkArgument(ImmutableSet.copyOf(sources.get(i).getOutputSymbols()).containsAll(inputs.get(i)), "Source does not supply all required input symbols");
@Override public List<Partition> getPartitionsByNames(String dbName, String tableName, List<String> names) throws TException { accessCount.incrementAndGet(); if (throwException) { throw new RuntimeException(); } if (!dbName.equals(TEST_DATABASE) || !tableName.equals(TEST_TABLE) || !ImmutableSet.of(TEST_PARTITION1, TEST_PARTITION2).containsAll(names)) { throw new NoSuchObjectException(); } return Lists.transform(names, name -> { try { return new Partition(ImmutableList.copyOf(Warehouse.getPartValuesFromPartName(name)), TEST_DATABASE, TEST_TABLE, 0, 0, DEFAULT_STORAGE_DESCRIPTOR, ImmutableMap.of()); } catch (MetaException e) { throw new RuntimeException(e); } }); }
if (!ImmutableSet.copyOf(columnNames).containsAll(layout.getPartitionColumns())) { throw new PrestoException(NOT_SUPPORTED, "INSERT must write all distribution columns: " + layout.getPartitionColumns());
(PlaceholderUnificationVisitor.State<? extends JCExpression> state) -> { if (ImmutableSet.copyOf(state.seenParameters()) .containsAll(placeholder().requiredParameters())) { Unifier resultUnifier = state.unifier(); JCExpression prevBinding = resultUnifier.getBinding(placeholder().exprKey());
.getPropertyDescriptors()); check(propertyDescriptors.transform(p -> p.getName()).toSet().containsAll(rwProperties));
(State<ConsumptionState> consumptionState) -> { if (ImmutableSet.copyOf(consumptionState.seenParameters()) .containsAll(placeholder().requiredParameters())) { Unifier resultUnifier = consumptionState.unifier().fork(); int nConsumedStatements = consumptionState.result().consumedStatements();
@Test public void testCollectionMethods() throws Exception { getMetastore().createProject(PROJECT_NAME); ImmutableSet<SchemaField> schema = ImmutableSet.of(new SchemaField("test1", STRING), new SchemaField("test2", STRING)); getMetastore().getOrCreateCollectionFields(PROJECT_NAME, "testcollection1", schema); getMetastore().getOrCreateCollectionFields(PROJECT_NAME, "testcollection2", schema); assertEquals(ImmutableSet.of("testcollection1", "testcollection2"), ImmutableSet.copyOf(getMetastore().getCollectionNames(PROJECT_NAME))); Map<String, List<SchemaField>> testing = getMetastore().getCollections(PROJECT_NAME); assertEquals(testing.size(), 2); assertTrue(ImmutableSet.copyOf(testing.get("testcollection1")).containsAll(schema)); assertTrue(ImmutableSet.copyOf(testing.get("testcollection2")).containsAll(schema)); }