List of usage examples for com.google.common.collect ImmutableSet.Builder addAll
boolean addAll(Collection<? extends E> c);
From source file:com.spotify.dns.AggregatingChangeNotifier.java
private Set<T> aggregateSet() { ImmutableSet.Builder<T> records = ImmutableSet.builder(); for (final ChangeNotifier<T> changeNotifier : changeNotifiers) { records.addAll(changeNotifier.current()); }//from ww w. ja va 2s.co m return records.build(); }
From source file:com.facebook.presto.connector.system.SystemSplitManager.java
@Override public ConnectorSplitSource getSplits(ConnectorSession session, ConnectorTableLayoutHandle layout) { SystemTableLayoutHandle layoutHandle = checkType(layout, SystemTableLayoutHandle.class, "layout"); SystemTableHandle tableHandle = layoutHandle.getTable(); TupleDomain<ColumnHandle> constraint = layoutHandle.getConstraint(); SystemTable systemTable = tables.get(tableHandle.getSchemaTableName()); Distribution tableDistributionMode = systemTable.getDistribution(); if (tableDistributionMode == SINGLE_COORDINATOR) { HostAddress address = nodeManager.getCurrentNode().getHostAndPort(); ConnectorSplit split = new SystemSplit(tableHandle, address, constraint); return new FixedSplitSource(SystemConnector.NAME, ImmutableList.of(split)); }/* w ww. ja v a 2 s .co m*/ ImmutableList.Builder<ConnectorSplit> splits = ImmutableList.builder(); ImmutableSet.Builder<Node> nodes = ImmutableSet.builder(); if (tableDistributionMode == ALL_COORDINATORS) { nodes.addAll(nodeManager.getCoordinators()); } else if (tableDistributionMode == ALL_NODES) { nodes.addAll(nodeManager.getActiveNodes()); } Set<Node> nodeSet = nodes.build(); for (Node node : nodeSet) { splits.add(new SystemSplit(tableHandle, node.getHostAndPort(), constraint)); } return new FixedSplitSource(SystemConnector.NAME, splits.build()); }
From source file:me.yanaga.winter.data.jpa.cdi.SimpleRepositoryBean.java
public Set<Type> getTypes() { ImmutableSet.Builder<Type> builder = ImmutableSet.builder(); builder.add(repositoryType);//from w w w . ja va2s . c o m builder.addAll(Arrays.asList(repositoryType.getInterfaces())); return builder.build(); }
From source file:com.twitter.aurora.scheduler.http.Maintenance.java
private Multimap<String, String> getTasksByHosts(StoreProvider provider, Iterable<String> hosts) { ImmutableSet.Builder<IScheduledTask> drainingTasks = ImmutableSet.builder(); for (String host : hosts) { drainingTasks.addAll(provider.getTaskStore().fetchTasks(Query.slaveScoped(host).active())); }//w w w . j ava2s. c o m return Multimaps.transformValues(Multimaps.index(drainingTasks.build(), TASK_TO_HOST), Tasks.SCHEDULED_TO_ID); }
From source file:org.sosy_lab.cpachecker.core.algorithm.termination.lasso_analysis.construction.InOutVariablesCollector.java
public Set<Formula> getInVariables() { ImmutableSet.Builder<Formula> allInVariables = ImmutableSet.builder(); allInVariables.addAll(inVariables); ufs.values().stream().map(m -> m.get(m.firstKey())).forEach(allInVariables::add); return allInVariables.build(); }
From source file:org.sosy_lab.cpachecker.cpa.edgeexclusion.EdgeExclusionPrecision.java
/** * Returns a precision that excludes all edges excluded by this precision * plus all given edges./*ww w . j a v a 2 s . c o m*/ * * @param pAdditionalExcludedEdges the additional edges to exclude. * * @return a precision that excludes all edges excluded by this precision * plus all given edges. */ public EdgeExclusionPrecision excludeMoreEdges(Collection<CFAEdge> pAdditionalExcludedEdges) { if (excludedEdges.containsAll(pAdditionalExcludedEdges)) { return this; } ImmutableSet.Builder<CFAEdge> setBuilder = ImmutableSet.<CFAEdge>builder(); setBuilder.addAll(excludedEdges); Queue<CFAEdge> waitlist = new ArrayDeque<>(pAdditionalExcludedEdges); while (!waitlist.isEmpty()) { CFAEdge current = waitlist.poll(); if (current instanceof MultiEdge) { for (CFAEdge edge : (MultiEdge) current) { waitlist.offer(edge); } } setBuilder.add(current); } return new EdgeExclusionPrecision(setBuilder.build()); }
From source file:io.prestosql.connector.system.SystemSplitManager.java
@Override public ConnectorSplitSource getSplits(ConnectorTransactionHandle transactionHandle, ConnectorSession session, ConnectorTableLayoutHandle layout, SplitSchedulingStrategy splitSchedulingStrategy) { SystemTableLayoutHandle layoutHandle = (SystemTableLayoutHandle) layout; SystemTableHandle tableHandle = layoutHandle.getTable(); TupleDomain<ColumnHandle> constraint = layoutHandle.getConstraint(); SystemTable systemTable = tables.getSystemTable(session, tableHandle.getSchemaTableName()) // table might disappear in the meantime .orElseThrow(() -> new PrestoException(NOT_FOUND, format("Table %s not found", tableHandle.getSchemaTableName()))); Distribution tableDistributionMode = systemTable.getDistribution(); if (tableDistributionMode == SINGLE_COORDINATOR) { HostAddress address = nodeManager.getCurrentNode().getHostAndPort(); ConnectorSplit split = new SystemSplit(tableHandle.getConnectorId(), tableHandle, address, constraint); return new FixedSplitSource(ImmutableList.of(split)); }//from ww w . j av a 2 s .co m ImmutableList.Builder<ConnectorSplit> splits = ImmutableList.builder(); ImmutableSet.Builder<Node> nodes = ImmutableSet.builder(); if (tableDistributionMode == ALL_COORDINATORS) { nodes.addAll(nodeManager.getCoordinators()); } else if (tableDistributionMode == ALL_NODES) { nodes.addAll(nodeManager.getNodes(ACTIVE)); } Set<Node> nodeSet = nodes.build(); for (Node node : nodeSet) { splits.add( new SystemSplit(tableHandle.getConnectorId(), tableHandle, node.getHostAndPort(), constraint)); } return new FixedSplitSource(splits.build()); }
From source file:org.sosy_lab.cpachecker.core.algorithm.termination.lasso_analysis.construction.InOutVariablesCollector.java
public Set<Formula> getOutVariables() { ImmutableSet.Builder<Formula> allOutVariables = ImmutableSet.builder(); allOutVariables.addAll(outVariables); ufs.values().stream().map(m -> m.get(m.lastKey())).forEach(allOutVariables::add); return allOutVariables.build(); }
From source file:org.apache.flex.compiler.internal.css.semantics.ActivatedStyleSheets.java
/** * @return All activated CSS models./* ww w.j ava 2 s . co m*/ */ public Set<ICSSDocument> all() { final ImmutableSet.Builder<ICSSDocument> builder = new ImmutableSet.Builder<ICSSDocument>(); builder.addAll(defaults); builder.addAll(libraries.keySet()); builder.addAll(themes); return builder.build(); }
From source file:com.google.devtools.build.lib.analysis.RunfilesSupplierImpl.java
@Override public Iterable<Artifact> getArtifacts() { ImmutableSet.Builder<Artifact> builder = ImmutableSet.builder(); for (Entry<PathFragment, Runfiles> entry : inputRunfiles.entrySet()) { builder.addAll(Iterables.filter(entry.getValue().getAllArtifacts(), Artifact.MIDDLEMAN_FILTER)); }/* w w w . j a v a2 s .com*/ return builder.build(); }