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:org.eclipse.sw360.portal.tags.TagUtils.java
private static <U extends TFieldIdEnum, T extends TBase<T, U>> void displaySet(StringBuilder display, Set<String> oldFieldValue, Set<String> updateFieldValue, Set<String> deletedFieldValue, U field, String prefix, String key) { String oldDisplay = null;//from ww w. ja v a2 s. c o m String deleteDisplay = "n.a. (modified list)"; String updateDisplay = null; if (oldFieldValue != null) { oldDisplay = getDisplayString(TType.SET, oldFieldValue); } if (updateFieldValue != null) { updateDisplay = getDisplayString(TType.SET, Sets.difference(Sets.union(nullToEmptySet(oldFieldValue), nullToEmptySet(updateFieldValue)), nullToEmptySet(deletedFieldValue))); } if (isNullOrEmpty(updateDisplay) && isNullOrEmpty(oldDisplay)) { return; } if (isNullOrEmpty(updateDisplay)) { updateDisplay = NOT_SET; } if (isNullOrEmpty(oldDisplay)) { oldDisplay = NOT_SET; } String keyString = isNullOrEmpty(key) ? "" : " [" + key + "]"; display.append(String.format("<tr><td>%s:</td>", prefix + field.getFieldName() + keyString)); display.append(String.format("<td>%s</td>", oldDisplay, prefix + field.getFieldName() + keyString)); display.append(String.format("<td>%s</td>", deleteDisplay, prefix + field.getFieldName() + keyString)); display.append( String.format("<td>%s</td></tr> ", updateDisplay, prefix + field.getFieldName() + keyString)); }
From source file:com.nearinfinity.honeycomb.mysql.Util.java
/** * Retrieve from a list of indices which ones have been changed. * * @param indices Table indices// www .j ava 2 s .co m * @param oldRecords Old MySQL row * @param newRecords New MySQL row * @return List of changed indices */ public static ImmutableList<IndexSchema> getChangedIndices(Collection<IndexSchema> indices, Map<String, ByteBuffer> oldRecords, Map<String, ByteBuffer> newRecords) { if (indices.isEmpty()) { return ImmutableList.of(); } MapDifference<String, ByteBuffer> diff = Maps.difference(oldRecords, newRecords); Set<String> changedColumns = Sets.difference(Sets.union(newRecords.keySet(), oldRecords.keySet()), diff.entriesInCommon().keySet()); ImmutableList.Builder<IndexSchema> changedIndices = ImmutableList.builder(); for (IndexSchema index : indices) { Set<String> indexColumns = ImmutableSet.copyOf(index.getColumns()); if (!Sets.intersection(changedColumns, indexColumns).isEmpty()) { changedIndices.add(index); } } return changedIndices.build(); }
From source file:mvm.rya.indexing.accumulo.entity.StarQuery.java
public Set<String> getBindingNames() { Set<String> bindingNames = Sets.newHashSet(); for (StatementPattern sp : nodes) { if (bindingNames.size() == 0) { bindingNames = sp.getBindingNames(); } else {//from w w w . j ava2 s.c o m bindingNames = Sets.union(bindingNames, sp.getBindingNames()); } } return bindingNames; }
From source file:org.debian.dependency.builders.EmbeddedAntBuilder.java
private float jarSimilarity(final File jarFile1, final File jarFile2) throws IOException { Set<String> files1 = createFileList(jarFile1); Set<String> files2 = createFileList(jarFile2); Set<String> union = Sets.union(files1, files2); Set<String> difference = Sets.symmetricDifference(files1, files2); return (union.size() - difference.size()) / union.size(); }
From source file:org.apache.rya.indexing.accumulo.entity.StarQuery.java
public Set<String> getBindingNames() { Set<String> bindingNames = Sets.newHashSet(); for (final StatementPattern sp : nodes) { if (bindingNames.size() == 0) { bindingNames = sp.getBindingNames(); } else {// www . j av a 2s .c o m bindingNames = Sets.union(bindingNames, sp.getBindingNames()); } } return bindingNames; }
From source file:com.continuuity.loom.layout.Solver.java
/** * Validate whether or not a set of services are allowed to be added to a cluster. * * @param cluster Cluster to check addition of services to. * @param servicesToAdd Services to add to the cluster * @throws IOException/*from ww w.j a v a 2 s. c o m*/ */ public void validateServicesToAdd(Cluster cluster, Set<String> servicesToAdd) throws IOException { EntityStoreView entityStore = entityStoreService.getView(cluster.getAccount()); Map<String, Service> serviceMap = getServiceMap(Sets.union(cluster.getServices(), servicesToAdd), entityStore); validateServicesToAdd(cluster, servicesToAdd, serviceMap); }
From source file:org.diqube.execution.steps.OverwritingRowIdOrStep.java
@Override protected void execute() { int leftRowIdsSize = leftRowIds.size(); int rightRowIdsSize = rightRowIds.size(); Set<Long> res = Sets.union(leftRowIds, rightRowIds); Long[] resArray = res.toArray(new Long[res.size()]); ExecutionEnvironment activeEnv;// ww w .j a v a 2 s . c o m synchronized (latestEnvSync) { activeEnv = latestEnv; } if (activeEnv != null) forEachOutputConsumerOfType(OverwritingRowIdConsumer.class, c -> c.consume(activeEnv, resArray)); if (leftSourceIsDone.get() && rightSourceIsDone.get() && leftRowIds.size() == leftRowIdsSize && rightRowIds.size() == rightRowIdsSize) { forEachOutputConsumerOfType(GenericConsumer.class, c -> c.sourceIsDone()); doneProcessing(); } }
From source file:org.apache.metron.stellar.common.utils.ConcatMap.java
@Override public Set<String> keySet() { Set<String> ret = null; for (Map m : variableMappings) { if (ret == null) { ret = m.keySet();//from www . ja v a 2 s. c om } else { ret = Sets.union(ret, m.keySet()); } } return ret; }
From source file:com.facebook.buck.core.model.targetgraph.impl.AbstractImmutableTargetNode.java
/** @return all targets which must be built before this one can be. */ @Override//from w ww.j av a 2 s . c o m public Set<BuildTarget> getBuildDeps() { return Sets.union(getDeclaredDeps(), getExtraDeps()); }
From source file:org.apache.beam.runners.core.construction.graph.FusedPipeline.java
/** * Return a map of IDs to {@link PTransform} which are executed by an SDK Harness. * * <p>The transforms that are present in the returned map are the {@link RunnerApi.PTransform} * versions of the {@link ExecutableStage ExecutableStages} returned in {@link #getFusedStages()}. * The IDs of the returned transforms will not collide with any transform ID present in {@link * #getComponents()}.// w ww .j a v a2s .c om */ private Map<String, PTransform> getEnvironmentExecutedTransforms() { Map<String, PTransform> topLevelTransforms = new HashMap<>(); for (ExecutableStage stage : getFusedStages()) { String baseName = String.format("%s/%s", stage.getInputPCollection().getPCollection().getUniqueName(), stage.getEnvironment().getUrn()); Set<String> usedNames = Sets.union(topLevelTransforms.keySet(), getComponents().getTransformsMap().keySet()); String uniqueId = SyntheticComponents.uniqueId(baseName, usedNames::contains); topLevelTransforms.put(uniqueId, stage.toPTransform(uniqueId)); } return topLevelTransforms; }