List of usage examples for com.google.common.collect Sets union
public static <E> SetView<E> union(final Set<? extends E> set1, final Set<? extends E> set2)
From source file:natlab.toolkits.analysis.core.ReachingDefs.java
@Override public Map<String, Set<Def>> merge(Map<String, Set<Def>> in1, Map<String, Set<Def>> in2) { return MergeUtil.unionMerge(in1, in2, (a, b) -> new HashSet<>(Sets.union(a, b))); }
From source file:org.diqube.consensus.internal.DiqubeCatalystSerializer.java
@PostConstruct public void initialize() { // register all the operation classes in the serializer so they can be serialized (we need to whitelist them). // Register all additional classes, too. this.resolve((registry) -> { Set<Class<?>> allSerializationClasses = Sets.union( consensusStateMachineManager.getAllOperationClasses(), consensusStateMachineManager.getAllAdditionalSerializationClasses()); List<Class<?>> serializationClassesSorted = allSerializationClasses.stream() .sorted((c1, c2) -> c1.getName().compareTo(c2.getName())).collect(Collectors.toList()); serializationClassesSorted.addAll(Arrays.asList(ADDITIONAL_SERIALIZATION_CLASSES)); // start suing IDs at an arbitrary, but fixed point, so we do not overwrite IDs used internally by copycat. int nextId = BASE_SERIALIZATION_ID; for (Class<?> opClass : serializationClassesSorted) { registry.register(opClass, nextId++, DiqubeJavaSerializableSerializer.class); }/* w w w . j a va 2 s . c o m*/ }); }
From source file:org.apache.beam.runners.core.construction.graph.FusedPipeline.java
/** * Returns the {@link RunnerApi.Pipeline} representation of this {@link FusedPipeline}. * * <p>The {@link Components} of the returned pipeline will contain all of the {@link PTransform * PTransforms} present in the original Pipeline that this {@link FusedPipeline} was created from, * plus all of the {@link ExecutableStage ExecutableStages} contained within this {@link * FusedPipeline}. The {@link Pipeline#getRootTransformIdsList()} will contain all of the runner * executed transforms and all of the {@link ExecutableStage execuable stages} contained within * the Pipeline./*from w ww. ja v a 2 s . c om*/ */ public RunnerApi.Pipeline toPipeline() { Map<String, PTransform> executableStageTransforms = getEnvironmentExecutedTransforms(); Set<String> executableTransformIds = Sets.union(executableStageTransforms.keySet(), getRunnerExecutedTransforms().stream().map(PTransformNode::getId).collect(Collectors.toSet())); // Augment the initial transforms with all of the executable transforms. Components fusedComponents = getComponents().toBuilder().putAllTransforms(executableStageTransforms) .build(); List<String> rootTransformIds = StreamSupport .stream(QueryablePipeline.forTransforms(executableTransformIds, fusedComponents) .getTopologicallyOrderedTransforms().spliterator(), false) .map(PTransformNode::getId).collect(Collectors.toList()); Pipeline res = Pipeline.newBuilder().setComponents(fusedComponents).addAllRootTransformIds(rootTransformIds) .build(); // Validate that fusion didn't produce a malformed pipeline. PipelineValidator.validate(res); return res; }
From source file:org.apache.lens.server.query.collect.IntersectingWaitingQueriesSelector.java
@VisibleForTesting Set<WaitingQueriesSelectionPolicy> prepareAllSelectionPolicies(final FinishedLensQuery finishedQuery) { /* Get the selection policies of driver on which this query was run */ ImmutableSet<WaitingQueriesSelectionPolicy> driverSelectionPolicies = finishedQuery .getDriverSelectionPolicies(); return Sets.union(this.selectionPolicies, driverSelectionPolicies); }
From source file:springfox.documentation.spring.web.plugins.CombinedRequestHandler.java
@Override public Set<NameValueExpression<String>> headers() { return Sets.union(first.headers(), second.headers()); }
From source file:de.topobyte.osm4j.extra.extracts.query.ComplexRelationsQuery.java
public void execute(RelationQueryBag queryBag) throws IOException { RelationGraph relationGraph = new RelationGraph(true, true); relationGraph.build(dataRelations.getRelations()); List<Group> groups = relationGraph.buildGroups(); logger.debug(String.format("This batch has %d groups and %d simple relations", groups.size(), relationGraph.getIdsSimpleRelations().size())); Set<OsmRelation> foundSimple = new HashSet<>(); Set<OsmRelation> foundComplex = new HashSet<>(); if (!relationGraph.getIdsSimpleRelations().isEmpty()) { executeSimple(queryBag, relationGraph.getIdsSimpleRelations(), foundSimple); }//from www. j a v a 2 s .com if (!groups.isEmpty()) { executeGroups(queryBag, groups, foundComplex); } SetView<OsmRelation> found = Sets.union(foundSimple, foundComplex); TLongObjectMap<OsmRelation> relations = new TLongObjectHashMap<>(); for (OsmRelation relation : found) { relations.put(relation.getId(), relation); } logger.debug(String.format("writing %d relations", relations.size())); QueryUtil.writeRelations(relations, queryBag.outRelations.getOsmOutput()); }
From source file:org.tensorics.core.function.operations.AbstractDiscreteFunctionBinaryOperation.java
@Override public DiscreteFunction<X, Y> perform(DiscreteFunction<X, Y> left, DiscreteFunction<X, Y> right) { @SuppressWarnings("unchecked") InterpolationStrategy<Y> strategy = environment.options().get(InterpolationStrategy.class); InterpolatedFunction<X, Y> rigthInterpolated = MathFunctions.interpolated(right, strategy, conversion, comparator);//from w w w. j a va 2 s . c o m InterpolatedFunction<X, Y> leftInterpolated = MathFunctions.interpolated(left, strategy, conversion, comparator); MapBackedDiscreteFunction.Builder<X, Y> builder = MapBackedDiscreteFunction.builder(); for (X x : Sets.union(left.definedXValues(), right.definedXValues())) { Y y1 = leftInterpolated.apply(x); Y y2 = rigthInterpolated.apply(x); Y result = operation.perform(y1, y2); builder.put(x, result); } return builder.build(); }
From source file:bullet.impl.ComponentProcessingStep.java
@Override public void process(SetMultimap<Class<? extends Annotation>, Element> elementsByAnnotation) { Set<Element> componentElements = Sets.union(elementsByAnnotation.get(Component.class), elementsByAnnotation.get(Subcomponent.class)); for (Element element : componentElements) { TypeElement componentElement = MoreElements.asType(element); generateObjectGraph(componentElement); }// w w w . j a v a2 s .c o m }
From source file:com.google.devtools.moe.client.dvcs.AbstractDvcsWriter.java
private DraftRevision putCodebase(Codebase incomingChangeCodebase) { incomingChangeCodebase.checkProjectSpace(revClone.getConfig().getProjectSpace()); Set<String> codebaseFiles = incomingChangeCodebase.getRelativeFilenames(); Set<String> writerRepoFiles = Utils.filterByRegEx( Utils.makeFilenamesRelative(Injector.INSTANCE.fileSystem().findFiles(getRoot()), getRoot()), getIgnoreFilePatterns());// www . jav a 2 s . c om Set<String> filesToUpdate = Sets.union(codebaseFiles, writerRepoFiles); for (String filename : filesToUpdate) { try { putFile(filename, incomingChangeCodebase); } catch (CommandException e) { StringBuilder sb = new StringBuilder("Problem occurred while running '"); sb.append(e.cmd); for (String arg : e.args) { sb.append(" ").append(arg); } sb.append("': ").append(e.stderr); throw new MoeProblem(sb.toString()); } } return new DvcsDraftRevision(revClone); }
From source file:org.eclipse.sirius.diagram.business.internal.metamodel.helper.ContainerMappingHelper.java
/** * Helper for {@link ContainerMapping#getAllContainerMappings()}. The result * should be wrapped in an appropriate EList by users. * /* w w w . j a va2 s . c om*/ * @param self * the container mapping. * @return the container mappings. */ public static Collection<ContainerMapping> getAllContainerMappings(ContainerMapping self) { return Sets.union(Sets.newLinkedHashSet(self.getSubContainerMappings()), Sets.newLinkedHashSet(self.getReusedContainerMappings())); }