List of usage examples for com.google.common.collect Sets difference
public static <E> SetView<E> difference(final Set<E> set1, final Set<?> set2)
From source file:io.druid.client.cache.HybridCache.java
@Override public Map<NamedKey, byte[]> getBulk(Iterable<NamedKey> keys) { Set<NamedKey> remaining = Sets.newHashSet(keys); Map<NamedKey, byte[]> res = level1.getBulk(keys); hitCount.addAndGet(res.size());//from w ww . j a v a 2 s . c om remaining = Sets.difference(remaining, res.keySet()); if (!remaining.isEmpty()) { Map<NamedKey, byte[]> res2 = level2.getBulk(remaining); for (Map.Entry<NamedKey, byte[]> entry : res2.entrySet()) { level1.put(entry.getKey(), entry.getValue()); } int size = res2.size(); hitCount.addAndGet(size); missCount.addAndGet(remaining.size() - size); if (size != 0) { res = Maps.newHashMap(res); res.putAll(res2); } } return res; }
From source file:com.facebook.buck.skylark.io.impl.NativeGlobber.java
/** * @param include File patterns that should be included in the resulting set. * @param exclude File patterns that should be excluded from the resulting set. * @param excludeDirectories Whether directories should be excluded from the resulting set. * @return The set of paths resolved using include patterns minus paths excluded by exclude * patterns./*from w w w.j a v a2s . c om*/ */ @Override public Set<String> run(Collection<String> include, Collection<String> exclude, boolean excludeDirectories) throws IOException { ImmutableSet<String> includePaths = resolvePathsMatchingGlobPatterns(include, basePath, excludeDirectories); ImmutableSet<String> excludePaths = resolvePathsMatchingGlobPatterns(exclude, basePath, excludeDirectories); return Sets.difference(includePaths, excludePaths); }
From source file:com.getbase.android.schema.MigrationsHelper.java
public void performMigrations(SQLiteDatabase db, TableMigration... migrations) { for (TableMigration migration : migrations) { final String tempTable = "tmp_" + tempTableIndex++; db.execSQL("ALTER TABLE " + migration.tableName + " RENAME TO " + tempTable); ImmutableSet<String> oldColumns = getColumns(db, tempTable); db.execSQL(migration.createTableStatement); final String tempNewTable = "tmp_" + tempTableIndex++; db.execSQL("ALTER TABLE " + migration.tableName + " RENAME TO " + tempNewTable); ImmutableSet<String> newColumns = getColumns(db, tempNewTable); db.execSQL("ALTER TABLE " + tempNewTable + " RENAME TO " + migration.tableName); Set<String> commonColumns = Sets.intersection(oldColumns, newColumns); Set<String> droppedColumns = Sets.difference(oldColumns, newColumns); if (!droppedColumns.isEmpty()) { Log.w(TAG, "Dropping columns " + Joiner.on(",").join(droppedColumns) + " during migration of " + migration.tableName); }/*from www .j a v a2s.c o m*/ Set<String> addedColumns = Sets.difference(Sets.difference(newColumns, oldColumns), migration.mappings.keySet()); if (!addedColumns.isEmpty()) { Log.w(TAG, "Will try to add new columns " + Joiner.on(",").join(addedColumns) + " during migration of " + migration.tableName); } SetView<String> unmappedColumns = Sets.difference(commonColumns, migration.mappings.keySet()); String insertColumnsString = Joiner.on(",") .join(Iterables.concat(unmappedColumns, migration.mappings.keySet())); String selectColumnsString = Joiner.on(",") .join(Iterables.concat(unmappedColumns, migration.mappings.values())); db.execSQL("INSERT INTO " + migration.tableName + "(" + insertColumnsString + ") SELECT " + selectColumnsString + " FROM " + tempTable); db.execSQL("DROP TABLE " + tempTable); } }
From source file:com.siemens.sw360.moderation.db.ModerationRequestGenerator.java
private void dealWithStringSets(U field) { documentDeletions.setFieldValue(field, Sets.difference((Set<String>) actualDocument.getFieldValue(field), (Set<String>) updateDocument.getFieldValue(field))); documentAdditions.setFieldValue(field, Sets.difference((Set<String>) updateDocument.getFieldValue(field), (Set<String>) actualDocument.getFieldValue(field))); }
From source file:com.google.javascript.jscomp.fuzzing.WhileFuzzer.java
@Override protected Node fuzz(AbstractFuzzer fuzzer, int budget) { if (fuzzer instanceof ExpressionFuzzer) { /*//from www . j a va 2 s. c o m * someLabel: while(void(xxx)) {} often causes compiler to crash when * compiling from AST. Because while(undefined) {} only produce dead code, * we could safely remove it. */ Set<Type> types = Sets .immutableEnumSet(Sets.difference(fuzzer.supportedTypes(), EnumSet.of(Type.UNDEFINED))); return fuzzer.generate(budget, types); } else { return fuzzer.generate(budget); } }
From source file:xml.entity.serilalize.transform.AddNamespacesTransformation.java
@Override @Nonnull/* ww w . j a va 2s. c om*/ public ImmutableElement apply(@Nonnull final ImmutableElement input) { final ImmutableSet<String> declaredNamespaces = input.select().from("/*/*/").where(isNamespaceDecl) .iterable().transform(toName()).transform(namespaceDeclToPrefix).toSet(); final SetView<String> missingNamespaces = Sets.difference(prefixToUrl.keySet(), declaredNamespaces); ImmutableElement result = input; for (final String missing : missingNamespaces) { final String attrName = "xmlns:" + missing; final String url = prefixToUrl.get(missing); result = result.update().from("/*/").setAttr(attrName, url).element(); } return result; }
From source file:hu.bme.mit.incqueryd.engine.rete.nodes.TypeInputNode.java
public ChangeSet filter(Predicate<Tuple> predicate) { Set<Tuple> remainingTuples = Sets.newHashSet(Sets.filter(tuples, predicate)); Set<Tuple> removedTuples = Sets.newHashSet(Sets.difference(tuples, remainingTuples)); tuples = remainingTuples;// w w w . ja va 2s .c om return new ChangeSet(removedTuples, ChangeType.NEGATIVE); }
From source file:org.fenixedu.bennu.oauth.domain.ExternalApplication.java
public void setScopeList(List<ExternalApplicationScope> newScopes) { Set<ExternalApplicationScope> oldScopes = getScopesSet(); Set<ExternalApplicationScope> result = Sets.difference(Sets.newHashSet(newScopes), Sets.newHashSet(oldScopes)); if (result.size() > 0) { deleteAuthorizations();/* w w w .jav a 2 s. c o m*/ } oldScopes.clear(); oldScopes.addAll(newScopes); }
From source file:org.sonar.java.se.AlwaysTrueOrFalseExpressionCollector.java
public Set<Tree> alwaysFalse() { return Sets.difference(falseEvaluations.keySet(), trueEvaluations.keySet()); }
From source file:com.thinkbiganalytics.cluster.DefaultMessageDeliveryStatus.java
@Override public Set<String> getNodesAwaitingMessage() { return Sets.difference(sentTo, receivedFrom); }