Java Code Examples for java.util.Set#containsAll()
The following examples show how to use
java.util.Set#containsAll() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LazyFetchStrategy.java From binaryprefs with Apache License 2.0 | 6 votes |
private Map<String, Object> getAllInternal() { readLock.lock(); try { Set<String> candidates = candidateProvider.keys(); Set<String> cachedKeys = cacheProvider.keys(); Map<String, Object> allCache = cacheProvider.getAll(); if (cachedKeys.containsAll(candidates)) { return Collections.unmodifiableMap(allCache); } Map<String, Object> fetched = fetchDeltaTask(candidates, cachedKeys); Map<String, Object> merged = mergeCache(fetched, allCache); return Collections.unmodifiableMap(merged); } finally { readLock.unlock(); } }
Example 2
Source File: BlockSplitter.java From jadx with Apache License 2.0 | 6 votes |
private static void collectSuccessors(BlockNode startBlock, Set<BlockNode> toRemove) { Deque<BlockNode> stack = new ArrayDeque<>(); stack.add(startBlock); while (!stack.isEmpty()) { BlockNode block = stack.pop(); if (!toRemove.contains(block)) { toRemove.add(block); for (BlockNode successor : block.getSuccessors()) { if (toRemove.containsAll(successor.getPredecessors())) { stack.push(successor); } } } } }
Example 3
Source File: Planner.java From quetzal with Eclipse Public License 2.0 | 5 votes |
@Override void getApplicableNodesForNotExists(Pattern p, final Set<Variable> availableVars, final Set<Variable> liveVars, final Walker walker, List<Pattern> region, Set<Node> result) { final Set<Variable> neededVars = getDependentVariables(region, ((FilterNotExistsPattern)p).getPatterns().get(1)); if (availableVars.containsAll(neededVars)) { result.add(new FilterExistsNotExistsNode(p, true, walker, availableVars, neededVars)); result.add(new FilterExistsNotExistsNode(p, true, walker, Collections.<Variable>emptySet(), neededVars)); } }
Example 4
Source File: PlanValidator.java From quantumdb with Apache License 2.0 | 5 votes |
private static void verifyThatIdentityColumnsAreMigratedFirst(Plan plan) { for (Step step : plan.getSteps()) { Operation operation = step.getOperation(); if (operation.getType() != Type.COPY) { continue; } Table table = operation.getTables().iterator().next(); List<Column> identityColumns = table.getIdentityColumns(); Set<Column> columns = operation.getColumns().stream() .map(table::getColumn) .collect(Collectors.toSet()); if (!columns.containsAll(identityColumns)) { Set<Step> dependencies = step.getTransitiveDependencies(); boolean migratesIdentities = false; for (Step dependency : dependencies) { Operation dependencyOperation = dependency.getOperation(); if (dependencyOperation.getType() != Type.COPY) { continue; } Table other = dependencyOperation.getTables().iterator().next(); Set<Column> dependencyColumns = dependencyOperation.getColumns().stream() .map(other::getColumn) .collect(Collectors.toSet()); if (other.equals(table) && dependencyColumns.containsAll(identityColumns)) { migratesIdentities = true; break; } } checkState(migratesIdentities, "Identities are not migrated first: " + table.getName()); } } }
Example 5
Source File: GraknClientIT.java From grakn with GNU Affero General Public License v3.0 | 5 votes |
private boolean explanationConsistentWithAnswer(ConceptMap ans) { Pattern queryPattern = ans.queryPattern(); Set<Variable> vars = new HashSet<>(); if (queryPattern != null) { queryPattern.statements().forEach(s -> vars.addAll(s.variables())); } return vars.containsAll(ans.map().keySet()); }
Example 6
Source File: KuduCatalog.java From bahir-flink with Apache License 2.0 | 5 votes |
@Override public void createTable(ObjectPath tablePath, CatalogBaseTable table, boolean ignoreIfExists) throws TableAlreadyExistException { Map<String, String> tableProperties = table.getProperties(); TableSchema tableSchema = table.getSchema(); Set<String> optionalProperties = new HashSet<>(Arrays.asList(KUDU_REPLICAS)); Set<String> requiredProperties = new HashSet<>(Arrays.asList(KUDU_HASH_COLS)); if (!tableSchema.getPrimaryKey().isPresent()) { requiredProperties.add(KUDU_PRIMARY_KEY_COLS); } if (!tableProperties.keySet().containsAll(requiredProperties)) { throw new CatalogException("Missing required property. The following properties must be provided: " + requiredProperties.toString()); } Set<String> permittedProperties = Sets.union(requiredProperties, optionalProperties); if (!permittedProperties.containsAll(tableProperties.keySet())) { throw new CatalogException("Unpermitted properties were given. The following properties are allowed:" + permittedProperties.toString()); } String tableName = tablePath.getObjectName(); KuduTableInfo tableInfo = KuduTableUtils.createTableInfo(tableName, tableSchema, tableProperties); createTable(tableInfo, ignoreIfExists); }
Example 7
Source File: RCAFramework.java From incubator-pinot with Apache License 2.0 | 5 votes |
static boolean isValidDAG(Collection<Pipeline> pipelines) { Set<String> visited = new HashSet<>(); visited.add(INPUT); int prevSize = 0; while(prevSize < visited.size()) { prevSize = visited.size(); for (Pipeline p : pipelines) { if (visited.containsAll(p.getInputNames())) visited.add(p.getOutputName()); } } return visited.contains(OUTPUT); }
Example 8
Source File: AbstractTableConfigHelper.java From datawave with Apache License 2.0 | 5 votes |
/** * Is the specified configuration already included in the current table configuration for locality groups. * * @param tableName * @param newLocalityGroups * @param tops * @return true if the new configuration is already included in the current configuration * @throws AccumuloException * @throws TableNotFoundException * @throws AccumuloSecurityException */ protected boolean areLocalityGroupsConfigured(String tableName, Map<String,Set<Text>> newLocalityGroups, TableOperations tops) throws AccumuloException, TableNotFoundException, AccumuloSecurityException { Map<String,Set<Text>> localityGroups = tops.getLocalityGroups(tableName); for (Map.Entry<String,Set<Text>> entry : newLocalityGroups.entrySet()) { Set<Text> families = localityGroups.get(entry.getKey()); if (families == null) { return false; } if (!families.containsAll(entry.getValue())) { return false; } } return true; }
Example 9
Source File: RankingExpressionTypeResolver.java From vespa with Apache License 2.0 | 5 votes |
/** * Resolves the types of all functions in the given profile * * @throws IllegalArgumentException if validate is true and the given rank profile does not produce valid types */ private void resolveTypesIn(RankProfile profile, boolean validate, Set<Reference> warnedAbout) { MapEvaluationTypeContext context = profile.typeContext(queryProfiles); for (Map.Entry<String, RankProfile.RankingExpressionFunction> function : profile.getFunctions().entrySet()) { ExpressionFunction expressionFunction = function.getValue().function(); if (hasUntypedArguments(expressionFunction)) continue; // Add any missing inputs for type resolution for (String argument : expressionFunction.arguments()) { Reference ref = Reference.fromIdentifier(argument); if (context.getType(ref).equals(TensorType.empty)) { context.setType(ref, expressionFunction.argumentTypes().get(argument)); } } context.forgetResolvedTypes(); TensorType type = resolveType(expressionFunction.getBody(), "function '" + function.getKey() + "'", context); function.getValue().setReturnType(type); } if (validate) { profile.getSummaryFeatures().forEach(f -> resolveType(f, "summary feature " + f, context)); ensureValidDouble(profile.getFirstPhaseRanking(), "first-phase expression", context); ensureValidDouble(profile.getSecondPhaseRanking(), "second-phase expression", context); if ( context.tensorsAreUsed() && ! context.queryFeaturesNotDeclared().isEmpty() && ! warnedAbout.containsAll(context.queryFeaturesNotDeclared())) { deployLogger.log(Level.WARNING, "The following query features used in '" + profile.getName() + "' are not declared in query profile " + "types and will be interpreted as scalars, not tensors: " + context.queryFeaturesNotDeclared()); warnedAbout.addAll(context.queryFeaturesNotDeclared()); } } }
Example 10
Source File: BewareOfBoxModelCheck.java From sonar-css-plugin with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void visitRuleset(RulesetTree tree) { Set<Combinations> combinations = EnumSet.noneOf(Combinations.class); for (PropertyDeclarationTree propertyDeclarationTree : tree.block().propertyDeclarations()) { PropertyTree propertyTree = propertyDeclarationTree.property(); if (isBoxSizing(propertyTree)) { combinations.clear(); combinations.add(Combinations.IS_BOX_SIZING); } if (!combinations.contains(Combinations.IS_BOX_SIZING)) { if (!combinations.contains(Combinations.WIDTH_FOUND) && isWidth(propertyTree)) { combinations.add(Combinations.WIDTH_FOUND); } else if (!combinations.contains(Combinations.HEIGHT_FOUND) && isHeight(propertyTree)) { combinations.add(Combinations.HEIGHT_FOUND); } if (isWidthSizing(propertyDeclarationTree)) { combinations.add(Combinations.WIDTH_SIZING); } if (isHeightSizing(propertyDeclarationTree)) { combinations.add(Combinations.HEIGHT_SIZING); } } } if (combinations.containsAll(Arrays.asList(Combinations.WIDTH_FOUND, Combinations.WIDTH_SIZING)) || combinations.containsAll(Arrays.asList(Combinations.HEIGHT_FOUND, Combinations.HEIGHT_SIZING))) { addPreciseIssue(CheckUtils.rulesetIssueLocation(tree), "Check this potential box model size issue."); } super.visitRuleset(tree); }
Example 11
Source File: FontPackage.java From fontster with Apache License 2.0 | 5 votes |
public static boolean validFontPackFolder(String path) { final File folder = new File(path); if (!folder.exists() || !folder.isDirectory()) return false; final String[] fileList = folder.list(); if (fileList == null) return false; final Set<String> fileNameSet = new HashSet<>(Arrays.asList(fileList)); return fileNameSet.containsAll(Style.REMOTE_STYLE_NAMES); }
Example 12
Source File: ImmutableDescriptorSerialTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static void main(String[] args) throws Exception { System.out.println("Test that ImmutableDescriptor.EMPTY_DESCRIPTOR " + "deserializes identically"); if (serialize(ImmutableDescriptor.EMPTY_DESCRIPTOR) != ImmutableDescriptor.EMPTY_DESCRIPTOR) { throw new Exception("ImmutableDescriptor.EMPTY_DESCRIPTOR did not " + "deserialize identically"); } System.out.println("...OK"); System.out.println("Test that serialization preserves case and " + "that deserialized object is case-insensitive"); Descriptor d = new ImmutableDescriptor("a=aval", "B=Bval", "cC=cCval"); Descriptor d1 = serialize(d); Set<String> keys = new HashSet(Arrays.asList(d1.getFieldNames())); if (keys.size() != 3 || !keys.containsAll(Arrays.asList("a", "B", "cC"))) { throw new Exception("Keys don't match: " + keys); } for (String key : keys) { String value = (String) d.getFieldValue(key); for (String t : Arrays.asList(key, key.toLowerCase(), key.toUpperCase())) { String tvalue = (String) d1.getFieldValue(t); if (!tvalue.equals(value)) { throw new Exception("Value of " + key + " for " + "deserialized object does not match: " + tvalue + " should be " + value); } } } System.out.println("...OK"); }
Example 13
Source File: RangerDefaultPolicyResourceMatcher.java From ranger with Apache License 2.0 | 5 votes |
private List<RangerResourceDef> getMatchingHierarchy(RangerAccessResource resource) { if (LOG.isDebugEnabled()) { LOG.debug("==> RangerDefaultPolicyResourceMatcher.getMatchingHierarchy(" + resource + ")"); } final List<RangerResourceDef> ret; Set<String> policyResourcesKeySet = policyResources.keySet(); Set<String> resourceKeySet = resource.getKeys(); if (CollectionUtils.isNotEmpty(resourceKeySet)) { List<RangerResourceDef> aValidHierarchy = null; if (validResourceHierarchy != null && serviceDefHelper != null) { if (serviceDefHelper.hierarchyHasAllResources(validResourceHierarchy, resourceKeySet)) { aValidHierarchy = validResourceHierarchy; } } else { if (policyResourcesKeySet.containsAll(resourceKeySet)) { aValidHierarchy = getMatchingHierarchy(policyResourcesKeySet); } else if (resourceKeySet.containsAll(policyResourcesKeySet)) { aValidHierarchy = getMatchingHierarchy(resourceKeySet); } } ret = isHierarchyValidForResources(aValidHierarchy, resource.getAsMap()) ? aValidHierarchy : null; } else { ret = validResourceHierarchy != null ? validResourceHierarchy : getMatchingHierarchy(policyResourcesKeySet); } if (LOG.isDebugEnabled()) { LOG.debug("<== RangerDefaultPolicyResourceMatcher.getMatchingHierarchy(" + resource + "): " + ret); } return ret; }
Example 14
Source File: BindPattern.java From quetzal with Eclipse Public License 2.0 | 4 votes |
public boolean isUnscopedBind() { Set<Variable> scope = getGroup() != null ? getGroup().inScopeVars() : Collections.<Variable>emptySet(); return !scope.containsAll(expr.gatherVariables()); }
Example 15
Source File: PlanValidator.java From quantumdb with Apache License 2.0 | 4 votes |
private static void verifyThatNotNullableForeignKeysAreSatisfiedBeforeInitialCopy(Plan plan) { for (Step step : plan.getSteps()) { Operation operation = step.getOperation(); if (operation.getType() != Type.COPY) { continue; } Table table = operation.getTables().iterator().next(); Set<Table> requiresTables = table.getForeignKeys().stream() .filter(ForeignKey::isNotNullable) .map(ForeignKey::getReferredTable) .distinct() .collect(Collectors.toSet()); for (Table requiresTable : requiresTables) { if (!plan.getGhostTables().contains(requiresTable)) { continue; } Set<String> requiredIdentityColumns = table.getForeignKeys().stream() .filter(ForeignKey::isNotNullable) .filter(fk -> fk.getReferredTable().equals(requiresTable)) .flatMap(fk -> fk.getReferredColumns().stream()) .collect(Collectors.toSet()); Set<Step> dependencies = step.getTransitiveDependencies(); boolean satisfied = false; for (Step dependency : dependencies) { Operation dependencyOperation = dependency.getOperation(); Set<Table> others = dependencyOperation.getTables(); if (!others.contains(requiresTable)) { continue; } if (dependencyOperation.getType() == Type.ADD_NULL) { satisfied = true; break; } else if (dependencyOperation.getType() == Type.COPY) { Set<String> dependencyColumns = dependencyOperation.getColumns().stream() .map(requiresTable::getColumn) .map(Column::getName) .collect(Collectors.toSet()); if (dependencyColumns.containsAll(requiredIdentityColumns)) { satisfied = true; break; } } } checkState(satisfied, "Identities of parent table: " + requiresTable.getName() + " should be migrated before copying records of: " + table.getName()); } } }
Example 16
Source File: VirtualMachineScaleSetMsiHandler.java From azure-libraries-for-java with MIT License | 4 votes |
/** * Method that handle the case where user request indicates all it want to do is remove all identities associated * with the virtual machine. * * @param vmssUpdate the vm update payload model * @return true if user indented to remove all the identities. */ private boolean handleRemoveAllExternalIdentitiesCase(VirtualMachineScaleSetUpdate vmssUpdate) { if (!this.userAssignedIdentities.isEmpty()) { int rmCount = 0; for (VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue v : this.userAssignedIdentities.values()) { if (v == null) { rmCount++; } else { break; } } boolean containsRemoveOnly = rmCount > 0 && rmCount == this.userAssignedIdentities.size(); // Check if user request contains only request for removal of identities. if (containsRemoveOnly) { Set<String> currentIds = new HashSet<>(); VirtualMachineScaleSetIdentity currentIdentity = this.scaleSet.inner().identity(); if (currentIdentity != null && currentIdentity.userAssignedIdentities() != null) { for (String id : currentIdentity.userAssignedIdentities().keySet()) { currentIds.add(id.toLowerCase()); } } Set<String> removeIds = new HashSet<>(); for (Map.Entry<String, VirtualMachineScaleSetIdentityUserAssignedIdentitiesValue> entrySet : this.userAssignedIdentities.entrySet()) { if (entrySet.getValue() == null) { removeIds.add(entrySet.getKey().toLowerCase()); } } // If so check user want to remove all the identities boolean removeAllCurrentIds = currentIds.size() == removeIds.size() && currentIds.containsAll(removeIds); if (removeAllCurrentIds) { // If so adjust the identity type [Setting type to SYSTEM_ASSIGNED orNONE will remove all the identities] if (currentIdentity == null || currentIdentity.type() == null) { vmssUpdate.withIdentity(new VirtualMachineScaleSetIdentity().withType(ResourceIdentityType.NONE)); } else if (currentIdentity.type().equals(ResourceIdentityType.SYSTEM_ASSIGNED_USER_ASSIGNED)) { vmssUpdate.withIdentity(currentIdentity); vmssUpdate.identity().withType(ResourceIdentityType.SYSTEM_ASSIGNED); } else if (currentIdentity.type().equals(ResourceIdentityType.USER_ASSIGNED)) { vmssUpdate.withIdentity(currentIdentity); vmssUpdate.identity().withType(ResourceIdentityType.NONE); } // and set identities property in the payload model to null so that it won't be sent vmssUpdate.identity().withUserAssignedIdentities(null); return true; } else { // Check user is asking to remove identities though there is no identities currently associated if (currentIds.size() == 0 && removeIds.size() != 0 && currentIdentity == null) { // If so we are in a invalid state but we want to send user input to service and let service // handle it (ignore or error). vmssUpdate.withIdentity(new VirtualMachineScaleSetIdentity().withType(ResourceIdentityType.NONE)); vmssUpdate.identity().withUserAssignedIdentities(null); return true; } } } } return false; }
Example 17
Source File: SubjectNullTests.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
@Override public boolean execCollection(Set<?> subjSet, Collection<?> actorData) { return subjSet.containsAll(actorData); }
Example 18
Source File: TargetAnnoCombo.java From hottub with GNU General Public License v2.0 | 4 votes |
private boolean isValidSubSet() { /* * RULE 1: conAnnoTarget should be a subset of baseAnnoTarget * RULE 2: For empty @Target ({}) - annotation cannot be applied anywhere * - Empty sets for both is valid * - Empty baseTarget set is invalid with non-empty conTarget set * - Non-empty baseTarget set is valid with empty conTarget set * RULE 3: For no @Target specified - annotation can be applied to any JDK 7 targets * - No @Target for both is valid * - No @Target for baseTarget set with @Target conTarget set is valid * - @Target for baseTarget set with no @Target for conTarget is invalid */ /* If baseAnno has no @Target, Foo can be either applied to @Target specified * for container annotation else will be applicable for all default targets * if no @Target is present for container annotation. * In both cases, the set will be a valid set with no @Target for base annotation */ if (baseAnnotations == null) { if (containerAnnotations == null) { return true; } return !(containerAnnotations.contains(TYPE_USE) || containerAnnotations.contains(TYPE_PARAMETER)); } Set<ElementType> tempBaseSet = EnumSet.noneOf(ElementType.class); tempBaseSet.addAll(baseAnnotations); // If BaseAnno has TYPE, then ANNOTATION_TYPE is allowed by default. if (baseAnnotations.contains(TYPE)) { tempBaseSet.add(ANNOTATION_TYPE); } // If BaseAnno has TYPE_USE, then add the extra allowed types if (baseAnnotations.contains(TYPE_USE)) { tempBaseSet.add(ANNOTATION_TYPE); tempBaseSet.add(TYPE); tempBaseSet.add(TYPE_PARAMETER); } // If containerAnno has no @Target, only valid case if baseAnnoTarget has // all targets defined else invalid set. if (containerAnnotations == null) { return tempBaseSet.containsAll(jdk7); } // At this point, neither conAnnoTarget or baseAnnoTarget are null. if (containerAnnotations.isEmpty()) { return true; } // At this point, conAnnoTarget is non-empty. if (baseAnnotations.isEmpty()) { return false; } // At this point, neither conAnnoTarget or baseAnnoTarget are empty. return tempBaseSet.containsAll(containerAnnotations); }
Example 19
Source File: AbstractValue.java From radon with GNU General Public License v3.0 | 4 votes |
private static <E> boolean containsAll(final Set<E> self, final Set<E> other) { if (self.size() < other.size()) { return false; } return self.containsAll(other); }
Example 20
Source File: DeletedBlockLogImpl.java From hadoop-ozone with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} * * @param transactionResults - transaction IDs. * @param dnID - Id of Datanode which has acknowledged * a delete block command. * @throws IOException */ @Override public void commitTransactions( List<DeleteBlockTransactionResult> transactionResults, UUID dnID) { lock.lock(); try { Set<UUID> dnsWithCommittedTxn; for (DeleteBlockTransactionResult transactionResult : transactionResults) { if (isTransactionFailed(transactionResult)) { continue; } try { long txID = transactionResult.getTxID(); // set of dns which have successfully committed transaction txId. dnsWithCommittedTxn = transactionToDNsCommitMap.get(txID); final ContainerID containerId = ContainerID.valueof( transactionResult.getContainerID()); if (dnsWithCommittedTxn == null) { LOG.warn("Transaction txId={} commit by dnId={} for containerID={} " + "failed. Corresponding entry not found.", txID, dnID, containerId); return; } dnsWithCommittedTxn.add(dnID); final ContainerInfo container = containerManager.getContainer(containerId); final Set<ContainerReplica> replicas = containerManager.getContainerReplicas(containerId); // The delete entry can be safely removed from the log if all the // corresponding nodes commit the txn. It is required to check that // the nodes returned in the pipeline match the replication factor. if (min(replicas.size(), dnsWithCommittedTxn.size()) >= container.getReplicationFactor().getNumber()) { List<UUID> containerDns = replicas.stream() .map(ContainerReplica::getDatanodeDetails) .map(DatanodeDetails::getUuid) .collect(Collectors.toList()); if (dnsWithCommittedTxn.containsAll(containerDns)) { transactionToDNsCommitMap.remove(txID); LOG.debug("Purging txId={} from block deletion log", txID); scmMetadataStore.getDeletedBlocksTXTable().delete(txID); } } LOG.debug("Datanode txId={} containerId={} committed by dnId={}", txID, containerId, dnID); } catch (IOException e) { LOG.warn("Could not commit delete block transaction: " + transactionResult.getTxID(), e); } } } finally { lock.unlock(); } }