Java Code Examples for java.util.Set#addAll()

The following examples show how to use java.util.Set#addAll() . 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: InstanceConfig.java    From helix with Apache License 2.0 6 votes vote down vote up
/**
 * Get the partitions disabled by this instance
 * This method will be deprecated since we persist disabled partitions
 * based on instance and resource. The result will not be accurate as we
 * union all the partitions disabled.
 *
 * @return a list of partition names
 */
@Deprecated
public List<String> getDisabledPartitions() {
  List<String> oldDisabled =
      _record.getListField(InstanceConfigProperty.HELIX_DISABLED_PARTITION.name());
  Map<String, String> newDisabledMap =
      _record.getMapField(InstanceConfigProperty.HELIX_DISABLED_PARTITION.name());
  if (newDisabledMap == null && oldDisabled == null) {
    return null;
  }

  Set<String> disabledPartitions = new HashSet<String>();
  if (oldDisabled != null) {
    disabledPartitions.addAll(oldDisabled);
  }

  if (newDisabledMap != null) {
    for (String perResource : newDisabledMap.values()) {
      disabledPartitions.addAll(HelixUtil.deserializeByComma(perResource));
    }
  }
  return new ArrayList<String>(disabledPartitions);
}
 
Example 2
Source File: SelectRowCommandHandler.java    From translationstudio8 with GNU General Public License v2.0 6 votes vote down vote up
private Set<Range> internalSelectRow(int columnPosition, int rowPosition, boolean withShiftMask, boolean withControlMask) {
	Set<Range> changedRowRanges = new HashSet<Range>();
	
	if (noShiftOrControl(withShiftMask, withControlMask)) {
		changedRowRanges.addAll(selectionLayer.getSelectedRows());
		selectionLayer.clear();
		selectionLayer.selectCell(0, rowPosition, withShiftMask, withControlMask);
		selectionLayer.selectRegion(0, rowPosition, selectionLayer.getColumnCount(), 1);
		selectionLayer.moveSelectionAnchor(columnPosition, rowPosition);
		changedRowRanges.add(new Range(rowPosition, rowPosition + 1));
	} else if (bothShiftAndControl(withShiftMask, withControlMask)) {
		changedRowRanges.add(selectRowWithShiftKey(rowPosition));
	} else if (isShiftOnly(withShiftMask, withControlMask)) {
		changedRowRanges.add(selectRowWithShiftKey(rowPosition));
	} else if (isControlOnly(withShiftMask, withControlMask)) {
		changedRowRanges.add(selectRowWithCtrlKey(columnPosition, rowPosition));
	}

	selectionLayer.lastSelectedCell.columnPosition = selectionLayer.getColumnCount() - 1;
	selectionLayer.lastSelectedCell.rowPosition = rowPosition;
	
	return changedRowRanges;
}
 
Example 3
Source File: AccessorsFilter.java    From domino-jackson with Apache License 2.0 6 votes vote down vote up
protected Set<AccessorInfo> getAccessors(TypeMirror beanType) {
    TypeElement element = (TypeElement) typeUtils.asElement(beanType);
    TypeMirror superclass = element.getSuperclass();
    if (superclass.getKind().equals(TypeKind.NONE)) {
        return new HashSet<>();
    }

    Set<AccessorInfo> collect = ((TypeElement) ObjectMapperProcessor.typeUtils
            .asElement(beanType))
            .getEnclosedElements()
            .stream()
            .filter(e -> ElementKind.METHOD.equals(e.getKind()) &&
                    !e.getModifiers().contains(Modifier.STATIC) &&
                    e.getModifiers().contains(Modifier.PUBLIC))
            .map(e -> new AccessorInfo(Optional.of((ExecutableElement) e)))
            .collect(Collectors.toSet());
    collect.addAll(getAccessors(superclass));
    return collect;
}
 
Example 4
Source File: DefaultCuboidScheduler.java    From kylin-on-parquet-v2 with Apache License 2.0 6 votes vote down vote up
/**
 * Get all parent for children cuboids, considering dim cap.
 * @param children children cuboids
 * @return all parents cuboids
 */
private Set<Long> getOnTreeParentsByLayer(Collection<Long> children) {
    Set<Long> parents = new HashSet<>();
    for (long child : children) {
        parents.addAll(getOnTreeParents(child));
    }
    parents = Sets.newHashSet(Iterators.filter(parents.iterator(), new Predicate<Long>() {
        @Override
        public boolean apply(@Nullable Long cuboidId) {
            if (cuboidId == Cuboid.getBaseCuboidId(cubeDesc)) {
                return true;
            }

            for (AggregationGroup agg : cubeDesc.getAggregationGroups()) {
                if (agg.isOnTree(cuboidId) && checkDimCap(agg, cuboidId)) {
                    return true;
                }
            }

            return false;
        }
    }));
    return parents;
}
 
Example 5
Source File: OpenListResourceBundle.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Override
public Set<String> keySet() {
    if (keyset != null) {
        return keyset;
    }
    Set<String> ks = createSet();
    ks.addAll(handleKeySet());
    if (parent != null) {
        ks.addAll(parent.keySet());
    }
    synchronized (this) {
        if (keyset == null) {
            keyset = ks;
        }
    }
    return keyset;
}
 
Example 6
Source File: GetAvailableClassesInRevisionDatabaseAction.java    From BIMserver with GNU Affero General Public License v3.0 6 votes vote down vote up
@Override
public List<String> execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
	Revision revision = getRevisionByRoid(roid);

	EPackage ePackage = bimServer.getMetaDataManager().getPackageMetaData(revision.getProject().getSchema()).getEPackage();
	// TODO there are still some situations where there are no oid counters, in those cases this will fail
	
	Set<String> set = new HashSet<>();
	for (ConcreteRevision concreteRevision : revision.getConcreteRevisions()) {
		OidCounters oidCounters = new OidCounters(getDatabaseSession(), concreteRevision.getOidCounters());
		
		set.addAll(oidCounters.keySet().stream().filter(eClass -> eClass.getEPackage() == ePackage).map(EClass::getName).collect(Collectors.toSet()));
	}
	ArrayList<String> list = new ArrayList<>(set);
	Collections.sort(list);
	return list;
}
 
Example 7
Source File: DateTimePatternGenerator.java    From j2objc with Apache License 2.0 5 votes vote down vote up
/**
 * Return a list of all the base skeletons (in canonical form) from this class
 */
public Set<String> getBaseSkeletons(Set<String> result) {
    if (result == null) {
        result = new HashSet<String>();
    }
    result.addAll(basePattern_pattern.keySet());
    return result;
}
 
Example 8
Source File: SuggestionsAdapter.java    From Spyglass with Apache License 2.0 5 votes vote down vote up
/**
 * Method to notify the adapter that a new {@link QueryToken} has been received and that
 * suggestions will be added to the adapter once generated.
 *
 * @param queryToken the {@link QueryToken} that has been received
 * @param buckets    a list of string dictating which buckets the future query results will go into
 */

public void notifyQueryTokenReceived(@NonNull QueryToken queryToken,
                                     @NonNull List<String> buckets) {
    synchronized (mLock) {
        Set<String> currentBuckets = mWaitingForResults.get(queryToken);
        if (currentBuckets == null) {
            currentBuckets = new HashSet<>();
        }
        currentBuckets.addAll(buckets);
        mWaitingForResults.put(queryToken, currentBuckets);
    }
}
 
Example 9
Source File: TestInterceptor.java    From smallrye-graphql with Apache License 2.0 5 votes vote down vote up
private Set<Path> toListOfPaths(DirectoryStream<Path> directoryStream) {
    Set<Path> directories = new HashSet<>();
    for (Path p : directoryStream) {
        try (Stream<Path> paths = Files.walk(p)) {
            Set<Path> tree = paths.filter(Files::isDirectory)
                    .collect(Collectors.toSet());
            directories.addAll(tree);
        } catch (IOException ex) {
            LOG.errorf("Ignoring directory [{0}] - {1}", new Object[] { p.getFileName().toString(), ex.getMessage() });
        }
    }
    return directories;
}
 
Example 10
Source File: ScriptObject.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected void init() {
    final Set<String> keys = new LinkedHashSet<>();
    for (ScriptObject self = object; self != null; self = self.getProto()) {
        keys.addAll(Arrays.asList(self.getOwnKeys(false)));
    }
    this.values = keys.toArray(new String[keys.size()]);
}
 
Example 11
Source File: PipFreezeAction.java    From pygradle with Apache License 2.0 5 votes vote down vote up
public Map<String, String> getDependencies() {
    final PythonExtension settings = ExtensionUtils.getPythonExtension(project);

    // Setup requirements, build, and test dependencies
    Set<String> developmentDependencies = configurationToSet(project, StandardTextValues.CONFIGURATION_SETUP_REQS.getValue());
    developmentDependencies.addAll(configurationToSet(project, StandardTextValues.CONFIGURATION_BUILD_REQS.getValue()));
    developmentDependencies.addAll(configurationToSet(project, StandardTextValues.CONFIGURATION_TEST.getValue()));

    developmentDependencies.removeAll(configurationToSet(project, StandardTextValues.CONFIGURATION_PYTHON.getValue()));

    final ByteArrayOutputStream requirements = new ByteArrayOutputStream();

    /*
     * NOTE: It is very important to provide "--all" in the list of arguments
     * to "pip freeze". Otherwise, setuptools, wheel, or pip would not be included
     * even if required by runtime configuration "python".
     */
    project.exec(execSpec -> {
        execSpec.environment(settings.getEnvironment());
        execSpec.commandLine(
            settings.getDetails().getVirtualEnvInterpreter(),
            settings.getDetails().getVirtualEnvironment().getPip(),
            "freeze",
            "--all",
            "--disable-pip-version-check"
        );
        execSpec.setStandardOutput(requirements);
    });

    Map<String, String> dependencies = PipFreezeOutputParser.getDependencies(developmentDependencies, requirements);
    // Always add project unconditionally.
    dependencies.put(project.getName(), project.getVersion().toString());
    return dependencies;
}
 
Example 12
Source File: Configuration.java    From big-c with Apache License 2.0 5 votes vote down vote up
/**
 * Get the set of parameters marked final.
 *
 * @return final parameter set.
 */
public Set<String> getFinalParameters() {
  Set<String> setFinalParams = Collections.newSetFromMap(
      new ConcurrentHashMap<String, Boolean>());
  setFinalParams.addAll(finalParameters);
  return setFinalParams;
}
 
Example 13
Source File: JsonDataTypeHelper.java    From datawave with Apache License 2.0 5 votes vote down vote up
public JsonObjectFlattener newFlattener() {
    
    // Set flattener's whitelist and blacklist according to current state of the helper
    
    Set<String> whitelistFields;
    Set<String> blacklistFields;
    
    if (this.getHeader() != null && this.getHeader().length > 0 && !this.processExtraFields()) {
        // In this case, 'header' fields are enabled and the client doesn't want to process any non-header
        // fields. This forces our whitelist to include the header fields themselves...
        whitelistFields = new HashSet<>(Arrays.asList(this.getHeader()));
        // Add to that any fields explicitly configured to be whitelisted
        if (null != this.getFieldWhitelist()) {
            whitelistFields.addAll(this.getFieldWhitelist());
        }
    } else if (null != this.getFieldWhitelist()) {
        whitelistFields = this.getFieldWhitelist();
    } else {
        whitelistFields = Collections.EMPTY_SET;
    }
    
    if (null != this.getFieldBlacklist()) {
        blacklistFields = this.getFieldBlacklist();
    } else {
        blacklistFields = Collections.EMPTY_SET;
    }
    
    return new JsonIngestFlattener.Builder().jsonDataTypeHelper(this).mapKeyWhitelist(whitelistFields).mapKeyBlacklist(blacklistFields)
                    .flattenMode(getJsonObjectFlattenMode()).addArrayIndexToFieldName(false).build();
}
 
Example 14
Source File: MenuCompositeTest.java    From head-first-design-patterns with Apache License 2.0 5 votes vote down vote up
private Set<String> getRightMenu() {
    Set<String> menuItems = new LinkedHashSet<String>();
    menuItems.add("ALL MENUS, All menus combined");
    menuItems.addAll(getRightBreakfastMenu());
    menuItems.addAll(getRightLunchMenu());
    menuItems.addAll(getRightDessertsMenu());
    return menuItems;
}
 
Example 15
Source File: FastPropagateSubgraphInspector.java    From CloverETL-Engine with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Finds all components on the way from SubgraphInput to SubgraphOutput
 * @param loopComponent
 */
private static void inspectEdges(InspectedComponent subgraphInputComponent, InspectedComponent subgraphOutputComponent) {
	Set<InspectedComponent> componentsOnTheWay = new HashSet<>();
	componentsOnTheWay.add(subgraphInputComponent);
	componentsOnTheWay.add(subgraphOutputComponent);
	
	Stack<InspectedComponent> path = new Stack<>();
	
	InspectedComponent pointer = subgraphInputComponent;
	path.push(pointer);
	while (pointer != null) {
		InspectedComponent follower = pointer.getNextComponent();
		if (follower != null) {
			if (componentsOnTheWay.contains(follower)) {
				componentsOnTheWay.addAll(path);
			} else if (!path.contains(follower)) {
				path.push(follower);
				pointer = follower;
			}
		} else {
			path.pop();
			pointer = !path.isEmpty() ? path.peek() : null;
		}
	}
	
	//converts list of inspected components to list of engine components
	Set<Node> engineComponents = new HashSet<>();
	for (InspectedComponent component : componentsOnTheWay) {
		Node engineComponent = component.getComponent();
		//if one of inspected components is a Subgraph, the subgraph has to be executed in fast-propagate mode
		if (SubgraphUtils.isSubJobComponent(engineComponent.getType())) {
			//the component can be also instance of MockupComponent, which is used for cluster graph analyse 
			if (engineComponent instanceof SubgraphComponent) {
				((SubgraphComponent) engineComponent).setFastPropagateExecution(true);
			}
		}
		engineComponents.add(engineComponent);
	}

	//convert all edges to fast-propagate type
	try {
		GraphUtils.makeEdgesFastPropagate(engineComponents);
	} catch (Exception e) {
		throw new JetelRuntimeException("The subgraph can not be used in loops. Phase edge detected inside the subgraph.", e);
	}
}
 
Example 16
Source File: ZkStateReader.java    From lucene-solr with Apache License 2.0 4 votes vote down vote up
private Set<String> getCurrentCollections() {
  Set<String> collections = new HashSet<>();
  collections.addAll(watchedCollectionStates.keySet());
  collections.addAll(lazyCollectionStates.keySet());
  return collections;
}
 
Example 17
Source File: UIFlagData.java    From GriefDefender with MIT License 4 votes vote down vote up
public Set<Context> getAllContexts() {
    Set<Context> allContexts = new HashSet<>();
    allContexts.addAll(this.removedContexts);
    allContexts.addAll(this.contexts);
    return allContexts;
}
 
Example 18
Source File: TestResourceGroups.java    From presto with Apache License 2.0 4 votes vote down vote up
@Test
public void testGetBlockedQueuedQueries()
{
    InternalResourceGroup root = new InternalResourceGroup("root", (group, export) -> {}, directExecutor());
    root.setSoftMemoryLimitBytes(DataSize.of(1, MEGABYTE).toBytes());
    root.setMaxQueuedQueries(40);
    // Start with zero capacity, so that nothing starts running until we've added all the queries
    root.setHardConcurrencyLimit(0);

    InternalResourceGroup rootA = root.getOrCreateSubGroup("a");
    rootA.setSoftMemoryLimitBytes(DataSize.of(1, MEGABYTE).toBytes());
    rootA.setMaxQueuedQueries(20);
    rootA.setHardConcurrencyLimit(8);

    InternalResourceGroup rootAX = rootA.getOrCreateSubGroup("x");
    rootAX.setSoftMemoryLimitBytes(DataSize.of(1, MEGABYTE).toBytes());
    rootAX.setMaxQueuedQueries(10);
    rootAX.setHardConcurrencyLimit(8);

    InternalResourceGroup rootAY = rootA.getOrCreateSubGroup("y");
    rootAY.setSoftMemoryLimitBytes(DataSize.of(1, MEGABYTE).toBytes());
    rootAY.setMaxQueuedQueries(10);
    rootAY.setHardConcurrencyLimit(5);

    InternalResourceGroup rootB = root.getOrCreateSubGroup("b");
    rootB.setSoftMemoryLimitBytes(DataSize.of(1, MEGABYTE).toBytes());
    rootB.setMaxQueuedQueries(20);
    rootB.setHardConcurrencyLimit(8);

    InternalResourceGroup rootBX = rootB.getOrCreateSubGroup("x");
    rootBX.setSoftMemoryLimitBytes(DataSize.of(1, MEGABYTE).toBytes());
    rootBX.setMaxQueuedQueries(10);
    rootBX.setHardConcurrencyLimit(8);

    InternalResourceGroup rootBY = rootB.getOrCreateSubGroup("y");
    rootBY.setSoftMemoryLimitBytes(DataSize.of(1, MEGABYTE).toBytes());
    rootBY.setMaxQueuedQueries(10);
    rootBY.setHardConcurrencyLimit(5);

    // Queue 40 queries (= maxQueuedQueries (40) + maxRunningQueries (0))
    Set<MockManagedQueryExecution> queries = fillGroupTo(rootAX, ImmutableSet.of(), 10, false);
    queries.addAll(fillGroupTo(rootAY, ImmutableSet.of(), 10, false));
    queries.addAll(fillGroupTo(rootBX, ImmutableSet.of(), 10, true));
    queries.addAll(fillGroupTo(rootBY, ImmutableSet.of(), 10, true));

    assertEquals(root.getWaitingQueuedQueries(), 16);
    assertEquals(rootA.getWaitingQueuedQueries(), 13);
    assertEquals(rootAX.getWaitingQueuedQueries(), 10);
    assertEquals(rootAY.getWaitingQueuedQueries(), 10);
    assertEquals(rootB.getWaitingQueuedQueries(), 13);
    assertEquals(rootBX.getWaitingQueuedQueries(), 10);
    assertEquals(rootBY.getWaitingQueuedQueries(), 10);

    root.setHardConcurrencyLimit(20);
    root.updateGroupsAndProcessQueuedQueries();
    assertEquals(root.getWaitingQueuedQueries(), 0);
    assertEquals(rootA.getWaitingQueuedQueries(), 5);
    assertEquals(rootAX.getWaitingQueuedQueries(), 6);
    assertEquals(rootAY.getWaitingQueuedQueries(), 6);
    assertEquals(rootB.getWaitingQueuedQueries(), 5);
    assertEquals(rootBX.getWaitingQueuedQueries(), 6);
    assertEquals(rootBY.getWaitingQueuedQueries(), 6);
}
 
Example 19
Source File: PageLocksCommand.java    From ignite with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override public void parseArguments(CommandArgIterator argIter) {
    Operation op = Operation.DUMP_LOG;

    String path = null;
    boolean allNodes = false;
    Set<String> nodeIds = new HashSet<>();

    while (argIter.hasNextArg()) {
        String nextArg = argIter.nextArg("");

        PageLocksCommandArg arg = CommandArgUtils.of(nextArg, PageLocksCommandArg.class);

        if (arg == null)
            break;

        switch (arg) {
            case DUMP:
                op = Operation.DUMP_FILE;

                break;
            case DUMP_LOG:
                op = Operation.DUMP_LOG;

                break;
            case ALL:
                allNodes = true;

                break;
            case NODES:
                nodeIds.addAll(argIter.nextStringSet(""));

                break;
            case PATH:
                path = argIter.nextArg("");

                break;
            default:
                throw new IllegalArgumentException(
                    "Unexpected argumetn:" + arg + ", supported:" + Arrays.toString(PageLocksCommandArg.values())
                );
        }
    }

    arguments = new Arguments(op, path, allNodes, nodeIds);
}
 
Example 20
Source File: ContainsSameElements.java    From vespa with Apache License 2.0 4 votes vote down vote up
public static <T> Set<T> toIdentitySet(Collection<? extends T> collection) {
    Set<T> identitySet = Collections.newSetFromMap(new IdentityHashMap<T, Boolean>());
    identitySet.addAll(collection);
    return identitySet;
}