@Override public Expression visitUnion(UnionNode node, Void context) { Expression firstUnderlyingPredicate = node.getSources().get(0).accept(this, context); // Rewrite in terms of output symbols Expression firstOutputPredicate = ExpressionTreeRewriter.rewriteWith( new ExpressionSymbolInliner(node.outputSymbolMap(0)), firstUnderlyingPredicate); Set<Expression> conjuncts = ImmutableSet.copyOf(extractConjuncts(firstOutputPredicate)); // Find the intersection of all predicates for (int i = 1; i < node.getSources().size(); i++) { Expression underlyingPredicate = node.getSources().get(i).accept(this, context); // Rewrite in terms of output symbols Expression outputPredicate = ExpressionTreeRewriter.rewriteWith( new ExpressionSymbolInliner(node.outputSymbolMap(i)), underlyingPredicate); // TODO: use a more precise way to determine overlapping conjuncts (e.g. commutative // predicates) conjuncts = Sets.intersection(conjuncts, ImmutableSet.copyOf(extractConjuncts(outputPredicate))); } return combineConjuncts(conjuncts); }
@SuppressWarnings("unchecked") @Test public void testFoldLeftValueComparator() { List<Tuple2<Integer, TimeValue>> pairs = Lists.newArrayList( tuple2(5, new TimeValue(2, 0.5)), tuple2(1, new TimeValue(1, 1.2)), tuple2(5, new TimeValue(1, 1.0)), tuple2(1, new TimeValue(2, 2.0)), tuple2(1, new TimeValue(3, 3.0))); JavaPairRDD<Integer, TimeValue> p = jsc().parallelizePairs(pairs); GroupSorted<Integer, TimeValue> gs = new GroupSorted(p, new HashPartitioner(2), new TimeValueComparator()); JavaPairRDD<Integer, Double> emas = gs.foldLeftByKey( 0.0, new Function2<Double, TimeValue, Double>() { public Double call(Double acc, TimeValue tv) { return 0.8 * acc + 0.2 * tv.getValue(); } }); System.out.println(ImmutableSet.copyOf(emas.collect())); Assert.assertTrue( ImmutableSet.copyOf(emas.collect()) .equals(ImmutableSet.of(tuple2(1, 1.0736), tuple2(5, 0.26)))); }
@SuppressWarnings("unchecked") private static void initializeSets() throws FieldAccessException { if (serverPackets == null || clientPackets == null) { List<Field> sets = getPacketRegistry().getFieldListByType(Set.class); try { if (sets.size() > 1) { serverPackets = (Set<Integer>) FieldUtils.readStaticField(sets.get(0), true); clientPackets = (Set<Integer>) FieldUtils.readStaticField(sets.get(1), true); // Impossible if (serverPackets == null || clientPackets == null) throw new FieldAccessException("Packet sets are in an illegal state."); // NEVER allow callers to modify the underlying sets serverPackets = ImmutableSet.copyOf(serverPackets); clientPackets = ImmutableSet.copyOf(clientPackets); } else { throw new FieldAccessException("Cannot retrieve packet client/server sets."); } } catch (IllegalAccessException e) { throw new FieldAccessException("Cannot access field.", e); } } }
/** * Helper to add srcs and deps Soy files to a SoyFileSet builder. Also does sanity checks. * * @param sfsBuilder The SoyFileSet builder to add to. * @param inputPrefix The input path prefix to prepend to all the file paths. * @param srcs The srcs from the --srcs flag. Exactly one of 'srcs' and 'args' must be nonempty. * @param args The old-style srcs from the command line (that's how they were specified before we * added the --srcs flag). Exactly one of 'srcs' and 'args' must be nonempty. * @param deps The deps from the --deps flag, or empty list if not applicable. * @param exitWithErrorFn A function that exits with an error message followed by a usage message. */ static void addSoyFilesToBuilder( Builder sfsBuilder, String inputPrefix, Collection<String> srcs, Collection<String> args, Collection<String> deps, Collection<String> indirectDeps, Function<String, Void> exitWithErrorFn) { if (srcs.isEmpty() && args.isEmpty()) { exitWithErrorFn.apply("Must provide list of source Soy files (--srcs)."); } if (!srcs.isEmpty() && !args.isEmpty()) { exitWithErrorFn.apply( "Found source Soy files from --srcs and from args (please use --srcs only)."); } // Create Set versions of each of the arguments, and de-dupe. If something is included as // multiple file kinds, we'll keep the strongest one; a file in both srcs and deps will be a // src, and one in both deps and indirect_deps will be a dep. // TODO(gboyer): Maybe stop supporting old style (srcs from command line args) at some point. Set<String> srcsSet = ImmutableSet.<String>builder().addAll(srcs).addAll(args).build(); Set<String> depsSet = Sets.difference(ImmutableSet.copyOf(deps), srcsSet); Set<String> indirectDepsSet = Sets.difference(ImmutableSet.copyOf(indirectDeps), Sets.union(srcsSet, depsSet)); for (String src : srcsSet) { sfsBuilder.addWithKind(new File(inputPrefix + src), SoyFileKind.SRC); } for (String dep : depsSet) { sfsBuilder.addWithKind(new File(inputPrefix + dep), SoyFileKind.DEP); } for (String dep : indirectDepsSet) { sfsBuilder.addWithKind(new File(inputPrefix + dep), SoyFileKind.INDIRECT_DEP); } }
@Test public void testUnresolvedCatalogItemParameters() { // Insert template which is not instantiatable during catalog addition due to // missing dependencies, but the spec can be created (the // dependencies are already parsed). addCatalogItems( "brooklyn.catalog:", " version: " + TEST_VERSION, " items:", " - id: " + SYMBOLIC_NAME, " itemType: template", " item:", " services:", " - type: basic-app", " - id: basic-app", " itemType: entity", " item:", " type: " + ConfigAppForTest.class.getName()); EntitySpec<? extends Application> spec = createAppSpec("services:", "- type: " + ver(SYMBOLIC_NAME)); List<SpecParameter<?>> params = spec.getParameters(); assertEquals( params.size(), 4, "Wrong number of params: " + params); // sample + defaultDisplayName + destroy_on_stop + start.latch assertEquals( ImmutableSet.copyOf(params), ImmutableSet.copyOf(BasicSpecParameter.fromClass(mgmt(), ConfigAppForTest.class))); }
private List<ARGState> chooseIfArbitrary( ARGState parent, List<ARGState> pRelevantChildrenOfElement) { if (pRelevantChildrenOfElement.size() <= 1) { return pRelevantChildrenOfElement; } List<ARGState> result = new ArrayList<>(2); for (ARGState candidate : pRelevantChildrenOfElement) { boolean valid = true; if (!result.isEmpty()) { Set<ARGState> candidateParents = ImmutableSet.copyOf(candidate.getParents()); Set<ARGState> candidateChildren = ImmutableSet.copyOf(candidate.getChildren()); for (ARGState chosen : result) { if (parent.getEdgesToChild(chosen).equals(parent.getEdgesToChild(candidate))) { Set<ARGState> chosenParents = ImmutableSet.copyOf(chosen.getParents()); Set<ARGState> chosenChildren = ImmutableSet.copyOf(chosen.getChildren()); if (candidateParents.equals(chosenParents) && candidateChildren.equals(chosenChildren)) { valid = false; break; } } } } if (valid) { result.add(candidate); } } return result; }
/** * @return Pair of dep-file rule key and the members of possibleDepFileSourcePaths that actually * appeared in the dep file * @throws IOException */ public Optional<Pair<RuleKey, ImmutableSet<SourcePath>>> build( Optional<ImmutableSet<SourcePath>> possibleDepFileSourcePaths) throws IOException { ImmutableSet<SourcePath> inputs = builder.getInputsSoFar(); ImmutableSet<SourcePath> depFileInputs = inputs; if (possibleDepFileSourcePaths.isPresent()) { // possibleDepFileSourcePaths is an ImmutableSortedSet which implements contains() via // binary search rather than via hashing. Thus taking the intersection/difference // is O(n*log(n)). Here, we make a hash-based copy of the set, so that intersection // will be reduced to O(N). ImmutableSet<SourcePath> possibleDepFileSourcePathsUnsorted = ImmutableSet.copyOf(possibleDepFileSourcePaths.get()); Sets.SetView<SourcePath> nonDepFileInputs = Sets.difference(inputs, possibleDepFileSourcePathsUnsorted); builder.addToRuleKey(nonDepFileInputs); depFileInputs = ImmutableSet.copyOf(Sets.intersection(inputs, possibleDepFileSourcePathsUnsorted)); } Optional<RuleKey> ruleKey = builder.build(); if (ruleKey.isPresent()) { return Optional.of(new Pair<>(ruleKey.get(), depFileInputs)); } else { return Optional.empty(); } }
private DocumentRelation( IType relationType, ImmutableSet<RelationMention> provenances, ImmutableSet<DocumentRelationArgument> arguments, ImmutableMap<IType, Float> attributes, float confidence) { this.relationType = checkNotNull(relationType); this.provenances = ImmutableSet.copyOf(provenances); for (final RelationMention arg : provenances) { checkArgument( relationType.equals(arg.getRelationType()), "A document relation's provenance's relation type must match its own, " + "but got argument of type %s for relation of type %s", arg.getRelationType(), relationType); } this.arguments = ImmutableSet.copyOf(arguments); this.attributes = ImmutableMap.copyOf(attributes); // no null check because it's optional this.confidence = confidence; }
@ConstructorProperties({ "id", "creationTimestamp", "selfLink", "name", "description", "status", "maintenanceWindows", "availableMachineTypes" }) private Zone( String id, Date creationTimestamp, URI selfLink, String name, String description, Status status, Set<MaintenanceWindow> maintenanceWindows, Set<String> availableMachineTypes) { super(Kind.ZONE, id, creationTimestamp, selfLink, name, description); this.status = checkNotNull(status, "status of %name", name); this.maintenanceWindows = maintenanceWindows == null ? ImmutableSet.<MaintenanceWindow>of() : ImmutableSet.copyOf(maintenanceWindows); this.availableMachineTypes = availableMachineTypes == null ? ImmutableSet.<String>of() : ImmutableSet.copyOf(availableMachineTypes); }
@Test public void testListTables() { // all schemas assertEquals( ImmutableSet.copyOf(metadata.listTables(SESSION, null)), ImmutableSet.of( new SchemaTableName("example", "numbers"), new SchemaTableName("example", "view_source"), new SchemaTableName("example", "view"), new SchemaTableName("tpch", "orders"), new SchemaTableName("tpch", "lineitem"), new SchemaTableName("exa_ple", "num_ers"))); // specific schema assertEquals( ImmutableSet.copyOf(metadata.listTables(SESSION, "example")), ImmutableSet.of( new SchemaTableName("example", "numbers"), new SchemaTableName("example", "view_source"), new SchemaTableName("example", "view"))); assertEquals( ImmutableSet.copyOf(metadata.listTables(SESSION, "tpch")), ImmutableSet.of( new SchemaTableName("tpch", "orders"), new SchemaTableName("tpch", "lineitem"))); assertEquals( ImmutableSet.copyOf(metadata.listTables(SESSION, "exa_ple")), ImmutableSet.of(new SchemaTableName("exa_ple", "num_ers"))); // unknown schema assertEquals(ImmutableSet.copyOf(metadata.listTables(SESSION, "unknown")), ImmutableSet.of()); }
public JoinLeafPredicateInfo( SqlKind comparisonType, List<List<RexNode>> joinKeyExprs, List<Set<Integer>> projsJoinKeysInChildSchema, List<Set<Integer>> projsJoinKeysInJoinSchema) { this.comparisonType = comparisonType; ImmutableList.Builder<ImmutableList<RexNode>> joinKeyExprsBuilder = ImmutableList.builder(); for (int i = 0; i < joinKeyExprs.size(); i++) { joinKeyExprsBuilder.add(ImmutableList.copyOf(joinKeyExprs.get(i))); } this.joinKeyExprs = joinKeyExprsBuilder.build(); ImmutableList.Builder<ImmutableSet<Integer>> projsJoinKeysInChildSchemaBuilder = ImmutableList.builder(); for (int i = 0; i < projsJoinKeysInChildSchema.size(); i++) { projsJoinKeysInChildSchemaBuilder.add( ImmutableSet.copyOf(projsJoinKeysInChildSchema.get(i))); } this.projsJoinKeysInChildSchema = projsJoinKeysInChildSchemaBuilder.build(); ImmutableList.Builder<ImmutableSet<Integer>> projsJoinKeysInJoinSchemaBuilder = ImmutableList.builder(); for (int i = 0; i < projsJoinKeysInJoinSchema.size(); i++) { projsJoinKeysInJoinSchemaBuilder.add(ImmutableSet.copyOf(projsJoinKeysInJoinSchema.get(i))); } this.projsJoinKeysInJoinSchema = projsJoinKeysInJoinSchemaBuilder.build(); }
ConcreteAspect( Set<Class<? extends Component>> all, Set<Class<? extends Component>> any, Set<Class<? extends Component>> none) { this.all = ImmutableSet.copyOf(all); this.any = ImmutableSet.copyOf(any); this.none = ImmutableSet.copyOf(none); }
@Test public void testForMultimap_related() { Navigator<String> navigator = Navigators.forMultimap(ImmutableSetMultimap.of("a", "a1", "a", "a2", "b", "b")); assertEquals(ImmutableSet.of("a1", "a2"), ImmutableSet.copyOf(navigator.related("a"))); assertEquals(ImmutableSet.of("b"), ImmutableSet.copyOf(navigator.related("b"))); assertEquals(ImmutableSet.of(), ImmutableSet.copyOf(navigator.related("c"))); }
@Test public void testClosureAlwaysIncludesStart() { Navigator<String> navigator = Navigators.forMultimap(ImmutableSetMultimap.<String, String>of()); assertEquals(ImmutableSet.of("A"), ImmutableSet.copyOf(Navigators.closure(navigator, "A"))); assertEquals( ImmutableSet.of("A"), ImmutableSet.copyOf(Navigators.closureOfMany(navigator, ImmutableList.of("A")))); }
public OwnersReport( SetMultimap<TargetNode<?>, Path> owners, Set<Path> inputsWithNoOwners, Set<String> nonExistentInputs, Set<String> nonFileInputs) { this.owners = ImmutableSetMultimap.copyOf(owners); this.inputsWithNoOwners = ImmutableSet.copyOf(inputsWithNoOwners); this.nonExistentInputs = ImmutableSet.copyOf(nonExistentInputs); this.nonFileInputs = ImmutableSet.copyOf(nonFileInputs); }
protected QueryPipeline( final String name, final Set<String> servicePathPrefixes, final Set<TemporaryKeyType> allowedTemporaryCredentials, final Set<RequiredQueryParams> requiredQueryParams) { this.auth = new HmacUserAuthenticationStage(allowedTemporaryCredentials); this.name = name; this.servicePathPrefixes = ImmutableSet.copyOf(servicePathPrefixes); this.requiredQueryParams = ImmutableSet.copyOf(requiredQueryParams); }
private ContentQuery( Iterable<String> uris, Iterable<String> ids, Iterable<Annotation> annotations, Optional<Selection> selection) { this.publisher = Optional.absent(); this.uris = ImmutableSet.copyOf(uris); this.ids = ImmutableSet.copyOf(ids); this.annotations = ImmutableSet.copyOf(annotations); this.selection = selection; }
@Test public void testForFunction_Serializable() { Navigator<Integer> navigator = SerializationUtils.serializedCopy( Navigators.forFunction(ImmutableSet.of(1, 2, 3), new MyFun())); assertEquals(ImmutableSet.of(1, 2, 3), ImmutableSet.copyOf(navigator.domain())); assertEquals(ImmutableSet.of(2, 2), ImmutableSet.copyOf(navigator.related(1))); assertEquals(ImmutableSet.of(4, 3), ImmutableSet.copyOf(navigator.related(2))); assertEquals(ImmutableSet.of(6, 4), ImmutableSet.copyOf(navigator.related(3))); }
@Override public ImmutableSet<JSType> getTypesToSkipForType(JSType type) { type = type.restrictByNotNullOrUndefined(); if (type instanceof UnionType) { Set<JSType> types = Sets.newHashSet(type); for (JSType alt : ((UnionType) type).getAlternates()) { types.addAll(getTypesToSkipForTypeNonUnion(type)); } return ImmutableSet.copyOf(types); } return ImmutableSet.copyOf(getTypesToSkipForTypeNonUnion(type)); }
@Override public StyleInfo apply(StyleMirror input) { return ImmutableStyleInfo.of( input.get(), input.init(), input.with(), input.add(), input.addAll(), input.put(), input.putAll(), input.copyOf(), input.of(), input.instance(), input.builder(), input.newBuilder(), input.from(), input.build(), input.buildOrThrow(), input.isInitialized(), input.isSet(), input.set(), input.unset(), input.clear(), input.create(), input.toImmutable(), input.typeBuilder(), input.typeInnerBuilder(), input.typeAbstract(), input.typeImmutable(), input.typeImmutableEnclosing(), input.typeImmutableNested(), input.typeModifiable(), ToImmutableInfo.FUNCTION.apply(input.defaults()), input.strictBuilder(), input.allParameters(), input.defaultAsDefault(), input.headerComments(), input.jdkOnly(), ImmutableSet.copyOf(input.passAnnotationsName()), ImmutableSet.copyOf(input.additionalJsonAnnotationsName()), input.visibility(), input.optionalAcceptNullable(), input.generateSuppressAllWarnings(), input.privateNoargConstructor(), input.attributelessSingleton(), input.unsafeDefaultAndDerived(), input.clearBuilder(), input.deepImmutablesDetection(), input.overshadowImplementation(), input.implementationNestedInBuilder(), input.builderVisibility(), input.throwForInvalidImmutableStateName()); }
@Test public void testClosure() { TransitiveRelation<String> relation = Relations.newTransitiveRelation(); relation.relate("A", "B"); relation.relate("B", "C"); Navigator<String> direct = relation.direct(); assertEquals( ImmutableSet.of("A", "B", "C"), ImmutableSet.copyOf(Navigators.closure(direct, "A"))); assertEquals(ImmutableSet.of("B", "C"), ImmutableSet.copyOf(Navigators.closure(direct, "B"))); assertEquals(ImmutableSet.of("C"), ImmutableSet.copyOf(Navigators.closure(direct, "C"))); }
public WindowOperatorFactory( int operatorId, List<? extends Type> sourceTypes, List<Integer> outputChannels, List<WindowFunctionDefinition> windowFunctionDefinitions, List<Integer> partitionChannels, List<Integer> preGroupedChannels, List<Integer> sortChannels, List<SortOrder> sortOrder, int preSortedChannelPrefix, FrameInfo frameInfo, int expectedPositions) { requireNonNull(sourceTypes, "sourceTypes is null"); requireNonNull(outputChannels, "outputChannels is null"); requireNonNull(windowFunctionDefinitions, "windowFunctionDefinitions is null"); requireNonNull(partitionChannels, "partitionChannels is null"); requireNonNull(preGroupedChannels, "preGroupedChannels is null"); checkArgument( partitionChannels.containsAll(preGroupedChannels), "preGroupedChannels must be a subset of partitionChannels"); requireNonNull(sortChannels, "sortChannels is null"); requireNonNull(sortOrder, "sortOrder is null"); checkArgument( sortChannels.size() == sortOrder.size(), "Must have same number of sort channels as sort orders"); checkArgument( preSortedChannelPrefix <= sortChannels.size(), "Cannot have more pre-sorted channels than specified sorted channels"); checkArgument( preSortedChannelPrefix == 0 || ImmutableSet.copyOf(preGroupedChannels) .equals(ImmutableSet.copyOf(partitionChannels)), "preSortedChannelPrefix can only be greater than zero if all partition channels are pre-grouped"); requireNonNull(frameInfo, "frameInfo is null"); this.operatorId = operatorId; this.sourceTypes = ImmutableList.copyOf(sourceTypes); this.outputChannels = ImmutableList.copyOf(outputChannels); this.windowFunctionDefinitions = ImmutableList.copyOf(windowFunctionDefinitions); this.partitionChannels = ImmutableList.copyOf(partitionChannels); this.preGroupedChannels = ImmutableList.copyOf(preGroupedChannels); this.sortChannels = ImmutableList.copyOf(sortChannels); this.sortOrder = ImmutableList.copyOf(sortOrder); this.preSortedChannelPrefix = preSortedChannelPrefix; this.frameInfo = frameInfo; this.expectedPositions = expectedPositions; this.types = Stream.concat( outputChannels.stream().map(sourceTypes::get), windowFunctionDefinitions.stream().map(WindowFunctionDefinition::getType)) .collect(toImmutableList()); }
public SessionInfo( InetAddress peer, InetAddress connecting, Collection<StreamSummary> receivingSummaries, Collection<StreamSummary> sendingSummaries, StreamSession.State state) { this.peer = peer; this.connecting = connecting; this.receivingSummaries = ImmutableSet.copyOf(receivingSummaries); this.sendingSummaries = ImmutableSet.copyOf(sendingSummaries); this.receivingFiles = new ConcurrentHashMap<>(); this.sendingFiles = new ConcurrentHashMap<>(); this.state = state; }
@Override public PlanNode visitDistinctLimit( DistinctLimitNode node, RewriteContext<Set<Symbol>> context) { Set<Symbol> expectedInputs; if (node.getHashSymbol().isPresent()) { expectedInputs = ImmutableSet.copyOf( concat(node.getOutputSymbols(), ImmutableList.of(node.getHashSymbol().get()))); } else { expectedInputs = ImmutableSet.copyOf(node.getOutputSymbols()); } PlanNode source = context.rewrite(node.getSource(), expectedInputs); return new DistinctLimitNode(node.getId(), source, node.getLimit(), node.getHashSymbol()); }
private ImmutableUndirectedGraph(Builder<N, E> builder) { UndirectedGraph<N, E> undirectedGraph = builder.undirectedGraph; ImmutableMap.Builder<N, ImmutableSet<E>> nodeToEdgesBuilder = ImmutableMap.builder(); for (N node : undirectedGraph.nodes()) { nodeToEdgesBuilder.put(node, ImmutableSet.copyOf(undirectedGraph.incidentEdges(node))); } nodeToIncidentEdges = nodeToEdgesBuilder.build(); ImmutableMap.Builder<E, ImmutableSet<N>> edgeToNodesBuilder = ImmutableMap.builder(); for (E edge : undirectedGraph.edges()) { edgeToNodesBuilder.put(edge, ImmutableSet.copyOf(undirectedGraph.incidentNodes(edge))); } edgeToIncidentNodes = edgeToNodesBuilder.build(); config = undirectedGraph.config(); }
public UpdateSubnetOptions( String name, String gatewayIp, Boolean enableDhcp, Set<String> dnsNameServers, Set<HostRoute> hostRoutes) { this.name = name; this.gatewayIp = gatewayIp; this.enableDhcp = enableDhcp; this.dnsNameServers = dnsNameServers != null ? ImmutableSet.copyOf(dnsNameServers) : Sets.<String>newHashSet(); this.hostRoutes = hostRoutes != null ? ImmutableSet.copyOf(hostRoutes) : Sets.<HostRoute>newHashSet(); }
@Test public void testForFunction() { Navigator<Integer> navigator = Navigators.forFunction( ImmutableSet.of(1, 2, 3), new Function<Integer, Set<Integer>>() { public Set<Integer> apply(Integer value) { return ImmutableSet.of(value * 2, value + 1); } }); assertEquals(ImmutableSet.of(1, 2, 3), ImmutableSet.copyOf(navigator.domain())); assertEquals(ImmutableSet.of(2, 2), ImmutableSet.copyOf(navigator.related(1))); assertEquals(ImmutableSet.of(4, 3), ImmutableSet.copyOf(navigator.related(2))); assertEquals(ImmutableSet.of(6, 4), ImmutableSet.copyOf(navigator.related(3))); }
private static <K, V> ImmutableSetMultimap<K, V> copyOf( Multimap<? extends K, ? extends V> multimap, Comparator<? super V> valueComparator) { checkNotNull(multimap); // eager for GWT if (multimap.isEmpty() && valueComparator == null) { return of(); } if (multimap instanceof ImmutableSetMultimap) { @SuppressWarnings("unchecked") // safe since multimap is not writable ImmutableSetMultimap<K, V> kvMultimap = (ImmutableSetMultimap<K, V>) multimap; if (!kvMultimap.isPartialView()) { return kvMultimap; } } ImmutableMap.Builder<K, ImmutableSet<V>> builder = ImmutableMap.builder(); int size = 0; for (Entry<? extends K, ? extends Collection<? extends V>> entry : multimap.asMap().entrySet()) { K key = entry.getKey(); Collection<? extends V> values = entry.getValue(); ImmutableSet<V> set = (valueComparator == null) ? ImmutableSet.copyOf(values) : ImmutableSortedSet.copyOf(valueComparator, values); if (!set.isEmpty()) { builder.put(key, set); size += set.size(); } } return new ImmutableSetMultimap<K, V>(builder.build(), size, valueComparator); }
@Test public void testShowSchemasFromOther() throws Exception { MaterializedResult result = computeActual("SHOW SCHEMAS FROM tpch"); ImmutableSet<String> schemaNames = ImmutableSet.copyOf(transform(result.getMaterializedRows(), onlyColumnGetter())); assertTrue(schemaNames.containsAll(ImmutableSet.of(INFORMATION_SCHEMA, "sys", "tiny"))); }
@Override public Map<Symbol, Symbol> visitProject(ProjectNode node, Set<Symbol> lookupSymbols) { // Map from output Symbols to source Symbols Map<Symbol, Symbol> directSymbolTranslationOutputMap = Maps.transformValues( Maps.filterValues(node.getAssignments(), SymbolReference.class::isInstance), Symbol::from); Map<Symbol, Symbol> outputToSourceMap = lookupSymbols .stream() .filter(directSymbolTranslationOutputMap.keySet()::contains) .collect(toImmutableMap(identity(), directSymbolTranslationOutputMap::get)); checkState( !outputToSourceMap.isEmpty(), "No lookup symbols were able to pass through the projection"); // Map from source Symbols to underlying index source Symbols Map<Symbol, Symbol> sourceToIndexMap = node.getSource().accept(this, ImmutableSet.copyOf(outputToSourceMap.values())); // Generate the Map the connects lookup symbols to underlying index source symbols Map<Symbol, Symbol> outputToIndexMap = Maps.transformValues( Maps.filterValues(outputToSourceMap, in(sourceToIndexMap.keySet())), Functions.forMap(sourceToIndexMap)); return ImmutableMap.copyOf(outputToIndexMap); }