List of usage examples for com.google.common.collect ImmutableSet.Builder addAll
boolean addAll(Collection<? extends E> c);
From source file:com.cloudera.csd.validation.components.ServiceDescriptorValidatorImpl.java
@Override public Set<String> validate(ServiceDescriptor descriptor) { Set<ConstraintViolation<ServiceDescriptor>> constraintViolations; constraintViolations = getViolations(descriptor); ImmutableSet.Builder<String> violations = ImmutableSet.builder(); for (ConstraintViolation<ServiceDescriptor> violation : constraintViolations) { String message = violation.getMessage(); String relativePath = violation.getPropertyPath().toString(); violations.add(String.format("%s.%s %s", "service", relativePath, message)); }/*from w ww . j av a2 s. c o m*/ violations.addAll(dependencyViolationStringSet); dependencyViolationStringSet.clear(); return violations.build(); }
From source file:com.google.idea.blaze.cpp.BlazeResolveConfigurationTemporaryBase.java
@Override public HeaderRoots getLibraryHeadersRoots(OCResolveRootAndConfiguration headerContext) { OCLanguageKind languageKind = headerContext.getKind(); VirtualFile sourceFile = headerContext.getRootFile(); if (languageKind == null) { languageKind = getLanguageKind(sourceFile); }//from w w w .j ava 2 s .c o m ImmutableSet.Builder<HeadersSearchRoot> roots = ImmutableSet.builder(); if (languageKind == OCLanguageKind.C) { roots.addAll(cLibraryIncludeRoots); } else { roots.addAll(cppLibraryIncludeRoots); } CidrCompilerResult<CompilerInfoCache.Entry> compilerInfoCacheHolder = compilerInfoCache .getCompilerInfoCache(project, compilerSettings, languageKind, sourceFile); CompilerInfoCache.Entry compilerInfo = compilerInfoCacheHolder.getResult(); if (compilerInfo != null) { roots.addAll(compilerInfo.headerSearchPaths); } return new HeaderRoots(roots.build().asList()); }
From source file:org.kiji.rest.ManagedKijiClient.java
/** * Update the instances served by this ManagedKijiClient. * * @throws IOException if an instance can not be added to the cache. *//* w w w.j av a 2 s.co m*/ public void refreshInstances() throws IOException { final State state = mState.get(); Preconditions.checkState(state == State.STARTED, "Can not invalidate instance while in state %s.", state); LOG.info("Refreshing instances."); Set<String> instances = Sets.newHashSet(); // If the visible instances configured is not specified OR it's not empty then // iterate on the ZK instances to find the valid instances and make them accessible // by KijiREST keeping only the ones that were specified in the config. if (mVisibleKijiInstances == null || !mVisibleKijiInstances.isEmpty()) { for (ChildData node : mZKInstances.getCurrentData()) { instances.add(Iterables.getLast(Splitter.on('/').split(node.getPath()))); } if (mVisibleKijiInstances != null) { // Keep the intersection of the visible and actual sets. instances.retainAll(mVisibleKijiInstances); } } final ImmutableSet.Builder<String> instancesBuilder = ImmutableSet.builder(); instancesBuilder.addAll(instances); mKijiInstances = instancesBuilder.build(); }
From source file:google.registry.batch.MapreduceEntityCleanupUtil.java
/** * Called by getPossibleIdsForPipelineJob(), and by itself recursively. * * @param datastore The datastore service, which can be either synchronous or asynchronous, since * the only interaction with the database is via prepared queries * @param jobId The pipeline job ID/*from w w w . j a v a 2 s.c o m*/ * @param handledJobIds The set of job IDs which have been handled so far; this is a sanity check * to prevent an infinite loop if, for some crazy reason, the job dependency graph is cyclic * @return the IDs of MR-ShardedJob entities that the Mapreduce library might have created, * depending on which steps of the mapreduce were used */ private ImmutableSet<String> getPossibleIdsForPipelineJobRecur(BaseDatastoreService datastore, String jobId, Set<String> handledJobIds) { if (handledJobIds.contains(jobId)) { return ImmutableSet.<String>of(); } handledJobIds.add(jobId); JobRecord jobRecord; try { jobRecord = PipelineManager.getJob(jobId); } catch (NoSuchObjectException e) { return ImmutableSet.<String>of(); } ImmutableSet.Builder<String> idSetBuilder = new ImmutableSet.Builder<>(); for (String jobPrefix : JOB_PREFIXES) { idSetBuilder.add("MR-ShardedJob", jobPrefix + jobId); } for (Key childKey : jobRecord.getChildKeys()) { idSetBuilder.addAll(getPossibleIdsForPipelineJobRecur(datastore, childKey.getName(), handledJobIds)); } return idSetBuilder.build(); }
From source file:com.facebook.presto.sql.planner.TableWriter.java
private void addPartitionShard(String partition, boolean lastSplit, List<? extends PartitionKey> partitionKeys, Long shardId) {//from w w w . ja v a 2 s. c o m PartitionInfo partitionInfo = openPartitions.get(partition); ImmutableSet.Builder<Long> builder = ImmutableSet.builder(); if (partitionInfo != null) { Set<Long> partitionSplits = partitionInfo.getShardIds(); builder.addAll(partitionSplits); } if (shardId != null) { builder.add(shardId); } else { checkState(lastSplit, "shardId == null and lastSplit unset!"); } Set<Long> shardIds = builder.build(); // This can only happen if the method gets called with a partition name, and no shard id and the last split // is set. As this only happens to close out the partitions that we saw before (a loop over openPartitions), // so any partition showing up here must have at least one split. checkState(shardIds.size() > 0, "Never saw a split for partition %s", partition); PartitionInfo newPartitionInfo = new PartitionInfo(shardIds, partitionKeys); if (lastSplit) { checkState(null == finishedPartitions.put(partition, newPartitionInfo), "Partition %s finished multiple times", partition); openPartitions.remove(partition); } else { openPartitions.put(partition, newPartitionInfo); } }
From source file:com.facebook.buck.features.go.GoTestDescription.java
@Override public BuildRule createBuildRule(BuildRuleCreationContextWithTargetGraph context, BuildTarget buildTarget, BuildRuleParams params, GoTestDescriptionArg args) { GoPlatform platform = GoDescriptors.getPlatformForRule(getGoToolchain(), this.goBuckConfig, buildTarget, args);/*from w w w . j a v a 2 s . co m*/ ActionGraphBuilder graphBuilder = context.getActionGraphBuilder(); SourcePathRuleFinder ruleFinder = new SourcePathRuleFinder(graphBuilder); SourcePathResolver pathResolver = DefaultSourcePathResolver.from(ruleFinder); ProjectFilesystem projectFilesystem = context.getProjectFilesystem(); GoTestCoverStep.Mode coverageMode; ImmutableSortedSet.Builder<BuildRule> extraDeps = ImmutableSortedSet.naturalOrder(); ImmutableSet.Builder<SourcePath> srcs; ImmutableMap<String, Path> coverVariables; ImmutableSet.Builder<SourcePath> rawSrcs = ImmutableSet.builder(); rawSrcs.addAll(args.getSrcs()); if (args.getLibrary().isPresent()) { GoLibraryDescriptionArg libraryArg = graphBuilder .requireMetadata(args.getLibrary().get(), GoLibraryDescriptionArg.class).get(); rawSrcs.addAll(libraryArg.getSrcs()); } if (args.getCoverageMode().isPresent()) { coverageMode = args.getCoverageMode().get(); GoTestCoverStep.Mode coverage = coverageMode; GoTestCoverSource coverSource = (GoTestCoverSource) graphBuilder.computeIfAbsent( buildTarget.withAppendedFlavors(InternalFlavor.of("gen-cover")), target -> new GoTestCoverSource(target, projectFilesystem, ruleFinder, pathResolver, platform, rawSrcs.build(), platform.getCover(), coverage)); coverVariables = coverSource.getVariables(); srcs = ImmutableSet.builder(); srcs.addAll(coverSource.getCoveredSources()).addAll(coverSource.getTestSources()); extraDeps.add(coverSource); } else { srcs = rawSrcs; coverVariables = ImmutableMap.of(); coverageMode = GoTestCoverStep.Mode.NONE; } if (buildTarget.getFlavors().contains(TEST_LIBRARY_FLAVOR)) { return createTestLibrary(buildTarget, projectFilesystem, params.copyAppendingExtraDeps(extraDeps.build()), graphBuilder, srcs.build(), args, platform); } GoBinary testMain = createTestMainRule(buildTarget, projectFilesystem, params.copyAppendingExtraDeps(extraDeps.build()), graphBuilder, srcs.build(), coverVariables, coverageMode, args, platform); graphBuilder.addToIndex(testMain); StringWithMacrosConverter macrosConverter = StringWithMacrosConverter.builder().setBuildTarget(buildTarget) .setCellPathResolver(context.getCellPathResolver()).setExpanders(MACRO_EXPANDERS).build(); return new GoTest(buildTarget, projectFilesystem, params.withDeclaredDeps(ImmutableSortedSet.of(testMain)).withoutExtraDeps(), testMain, args.getLabels(), args.getContacts(), args.getTestRuleTimeoutMs().map(Optional::of).orElse( goBuckConfig.getDelegate().getView(TestBuckConfig.class).getDefaultTestRuleTimeoutMs()), ImmutableMap .copyOf(Maps.transformValues(args.getEnv(), x -> macrosConverter.convert(x, graphBuilder))), args.getRunTestSeparately(), args.getResources(), coverageMode); }
From source file:com.facebook.presto.sql.planner.MaterializedViewWriter.java
private void addPartitionShard(String partition, boolean lastSplit, List<? extends PartitionKey> partitionKeys, UUID shardUuid) {//from w ww . j a va 2 s. com PartitionInfo partitionInfo = openPartitions.get(partition); ImmutableSet.Builder<UUID> builder = ImmutableSet.builder(); if (partitionInfo != null) { Set<UUID> partitionSplits = partitionInfo.getShardUuids(); builder.addAll(partitionSplits); } if (shardUuid != null) { builder.add(shardUuid); } else { checkState(lastSplit, "shardUuid == null and lastSplit unset!"); } Set<UUID> shardUuids = builder.build(); // This can only happen if the method gets called with a partition name, and no shard id and the last split // is set. As this only happens to close out the partitions that we saw before (a loop over openPartitions), // so any partition showing up here must have at least one split. checkState(!shardUuids.isEmpty(), "Never saw a split for partition %s", partition); PartitionInfo newPartitionInfo = new PartitionInfo(shardUuids, partitionKeys); if (lastSplit) { checkState(null == finishedPartitions.put(partition, newPartitionInfo), "Partition %s finished multiple times", partition); openPartitions.remove(partition); } else { openPartitions.put(partition, newPartitionInfo); } }
From source file:com.facebook.buck.python.CxxPythonExtensionDescription.java
@Override public Iterable<BuildTarget> findDepsForTargetFromConstructorArgs(BuildTarget buildTarget, CellPathResolver cellRoots, Arg constructorArg) { ImmutableSet.Builder<BuildTarget> deps = ImmutableSet.builder(); // Get any parse time deps from the C/C++ platforms. deps.addAll(CxxPlatforms.getParseTimeDeps(cxxPlatforms.getValues())); for (PythonPlatform pythonPlatform : pythonPlatforms.getValues()) { deps.addAll(OptionalCompat.asSet(pythonPlatform.getCxxLibrary())); }/*w w w .j av a 2 s.co m*/ return deps.build(); }
From source file:ninja.leaping.permissionsex.bukkit.PEXPermissible.java
@Override public Set<PermissionAttachmentInfo> getEffectivePermissions() { ImmutableSet.Builder<PermissionAttachmentInfo> ret = ImmutableSet.builder(); final Set<Map.Entry<String, String>> activeContexts = getActiveContexts(); ret.addAll(Iterables.transform(subj.getPermissions(activeContexts).asMap().entrySet(), input -> new PermissionAttachmentInfo(player, input.getKey(), null, input.getValue() > 0))); for (Metapermission mPerm : METAPERMISSIONS) { ret.addAll(Iterators.transform(mPerm.getValues(this.subj, activeContexts), input -> new PermissionAttachmentInfo(player, input, null, true))); }/*from w ww . j a va 2 s . c o m*/ return ret.build(); }
From source file:org.graylog2.shared.security.Permissions.java
public Set<String> readerPermissions(String username) { final ImmutableSet.Builder<String> perms = ImmutableSet.<String>builder().addAll(readerBasePermissions); if (isNullOrEmpty(username)) { LOG.error("Username cannot be empty or null for creating reader permissions"); throw new IllegalArgumentException("Username was null or empty when getting reader permissions."); }/*w w w.ja v a2 s.co m*/ perms.addAll(userSelfEditPermissions(username)); return perms.build(); }