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.sakaiproject.nakamura.lite.storage.jdbc.WideColumnIndexer.java
public WideColumnIndexer(JDBCStorageClient jdbcStorageClient, Map<String, String> indexColumnsNames, Set<String> indexColumnTypes, Map<String, Object> sqlConfig) { super(indexColumnsNames.keySet()); this.client = jdbcStorageClient; this.indexColumnsNames = indexColumnsNames; Builder<String, String> b = ImmutableMap.builder(); for (String k : Sets.union(indexColumnTypes, JDBCStorageClient.AUTO_INDEX_COLUMNS_TYPES)) { String[] type = StringUtils.split(k, "=", 2); b.put(type[0], type[1]);//from w w w .j av a 2 s .c o m } this.indexColumnsTypes = b.build(); }
From source file:com.google.javascript.jscomp.DeadPropertyAssignmentElimination.java
@Override public void process(Node externs, Node root) { // GatherExternProperties must be enabled for this pass to safely know what property writes are // eligible for removal. if (compiler.getExternProperties() == null) { return;/* ww w .j a v a2s . c o m*/ } GetterSetterCollector getterSetterCollector = new GetterSetterCollector(); NodeTraversal.traverse(compiler, root, getterSetterCollector); // If there's any potentially unknown getter/setter property, back off of the optimization. if (getterSetterCollector.unknownGetterSetterPresent) { return; } Set<String> blacklistedPropNames = Sets.union(getterSetterCollector.propNames, compiler.getExternProperties()); NodeTraversal.traverseChangedFunctions(compiler, new FunctionVisitor(blacklistedPropNames)); }
From source file:cern.entwined.TransactionalMap.java
@Override public int size() { this.markGloballyAccessed(); Set<K> keys = Sets.union(this.sourceMap.keySet(), this.pendingModifications.keySet()); return keys.size() - this.pendingDeletions.size(); }
From source file:com.viadeo.kasper.core.interceptor.tags.TagsInterceptor.java
@SuppressWarnings("unchecked") private Map newContextMapWithAdditionalTags(Map initialContextMap, Set<String> additionalTags) { final String initialTags = Strings.nullToEmpty((String) initialContextMap.get(Context.TAGS_SHORTNAME)); final Set<String> allTags = Sets.union(Tags.valueOf(initialTags), additionalTags); final Map contextMap = Maps.newHashMap(initialContextMap); contextMap.put(Context.TAGS_SHORTNAME, Tags.toString(allTags)); return contextMap; }
From source file:org.sosy_lab.cpachecker.cfa.ast.c.CIdExpressionCollectingVisitor.java
@Override public Set<CIdExpression> visit(CFunctionCallAssignmentStatement pS) throws RuntimeException { Set<CIdExpression> result = Sets.union(pS.getLeftHandSide().accept(this), pS.getRightHandSide().getFunctionNameExpression().accept(this)); for (CExpression expr : pS.getRightHandSide().getParameterExpressions()) { result = Sets.union(result, expr.accept(this)); }/*from w ww .ja v a 2 s . c o m*/ return result; }
From source file:org.dita.dost.reader.DitaValReader.java
@VisibleForTesting DitaValReader(Set<QName> filterAttributes, Set<QName> flagAttributes) { this();//from w w w .j a v a 2 s . co m this.filterAttributes = Sets.union(this.filterAttributes, filterAttributes); this.flagAttributes = Sets.union(this.flagAttributes, flagAttributes); }
From source file:org.sosy_lab.cpachecker.cfa.ast.c.FileLocationCollectingVisitor.java
@Override public Set<FileLocation> visit(CExpressionStatement pS) throws RuntimeException { return Sets.union(Collections.singleton(pS.getFileLocation()), pS.getExpression().accept(this)); }
From source file:org.dllearner.learningproblems.PosNegLP.java
@Override public void init() throws ComponentInitException { // check if some positive examples have been set if (positiveExamples.isEmpty()) { throw new ComponentInitException("No positive examples have been set."); }//from w w w. ja va2 s . c o m // check if some negative examples have been set and give warning if not if (negativeExamples.isEmpty()) { logger.warn("No negative examples have been set, but you decided to use the positive-negative learning" + "problem. We recommend to use the positive-only learning problem for the case of no negative examples instead."); } // check if there is some overlap between positive and negative examples and give warning // in that case SetView<OWLIndividual> overlap = Sets.intersection(positiveExamples, negativeExamples); if (!overlap.isEmpty()) { logger.warn("You declared some individuals as both positive and negative examples."); } allExamples = Sets.union(positiveExamples, negativeExamples); if (accuracyMethod == null) { accuracyMethod = new AccMethodPredAcc(true); } if (accuracyMethod instanceof AccMethodApproximate) { ((AccMethodApproximate) accuracyMethod).setReasoner(reasoner); } // sanity check whether examples are contained in KB if (reasoner != null && !reasoner.getIndividuals().containsAll(allExamples) && !reasoner.getClass().isAssignableFrom(SPARQLReasoner.class)) { Set<OWLIndividual> missing = Sets.difference(allExamples, reasoner.getIndividuals()); double percentage = missing.size() / allExamples.size(); percentage = Math.round(percentage * 1000) / 1000; String str = "The examples (" + (percentage * 100) + " % of total) below are not contained in the knowledge base (check spelling and prefixes)\n"; str += missing.toString(); if (missing.size() == allExamples.size()) { throw new ComponentInitException(str); } if (percentage < 0.10) { logger.warn(str); } else { logger.error(str); } } }
From source file:org.opennms.newts.api.query.ResultDescriptor.java
public Set<String> getLabels() { return Sets.union(m_datasources.keySet(), m_calculations.keySet()); }
From source file:com.streamsets.pipeline.lib.fuzzy.FuzzyMatch.java
public static int getRatio(String s1, String s2) { if (s1.length() >= s2.length()) { // We need to swap s1 and s2 String temp = s2;//ww w .j av a2 s .co m s2 = s1; s1 = temp; } // Get alpha numeric characters Set<String> set1 = tokenizeString(escapeString(s1)); Set<String> set2 = tokenizeString(escapeString(s2)); SetView<String> intersection = Sets.intersection(set1, set2); TreeSet<String> sortedIntersection = Sets.newTreeSet(intersection); if (LOG.isTraceEnabled()) { StringBuilder sortedSb = new StringBuilder(); for (String s : sortedIntersection) { sortedSb.append(s).append(" "); } LOG.trace("Sorted intersection --> {}", sortedSb.toString()); } // Find out difference of sets set1 and intersection of set1,set2 SetView<String> restOfSet1 = Sets.symmetricDifference(set1, intersection); // Sort it TreeSet<String> sortedRestOfSet1 = Sets.newTreeSet(restOfSet1); SetView<String> restOfSet2 = Sets.symmetricDifference(set2, intersection); TreeSet<String> sortedRestOfSet2 = Sets.newTreeSet(restOfSet2); if (LOG.isTraceEnabled()) { StringBuilder sb1 = new StringBuilder(); for (String s : sortedRestOfSet1) { sb1.append(s).append(" "); } LOG.trace("Sorted rest of 1 --> {}", sb1.toString()); StringBuilder sb2 = new StringBuilder(); for (String s : sortedRestOfSet1) { sb2.append(s).append(" "); } LOG.trace("Sorted rest of 2 --> {}", sb2.toString()); } StringBuilder t0Builder = new StringBuilder(""); StringBuilder t1Builder = new StringBuilder(""); StringBuilder t2Builder = new StringBuilder(""); for (String s : sortedIntersection) { t0Builder.append(" ").append(s); } String t0 = t0Builder.toString().trim(); Set<String> setT1 = Sets.union(sortedIntersection, sortedRestOfSet1); for (String s : setT1) { t1Builder.append(" ").append(s); } String t1 = t1Builder.toString().trim(); Set<String> setT2 = Sets.union(intersection, sortedRestOfSet2); for (String s : setT2) { t2Builder.append(" ").append(s); } String t2 = t2Builder.toString().trim(); int amt1 = calculateLevenshteinDistance(t0, t1); int amt2 = calculateLevenshteinDistance(t0, t2); int amt3 = calculateLevenshteinDistance(t1, t2); LOG.trace("t0 = {} --> {}", t0, amt1); LOG.trace("t1 = {} --> {}", t1, amt2); LOG.trace("t2 = {} --> {}", t2, amt3); return Math.max(Math.max(amt1, amt2), amt3); }