List of usage examples for com.google.common.collect ImmutableMap.Builder putAll
public final void putAll(Map<? extends K, ? extends V> map)
From source file:io.crate.metadata.shard.ShardReferenceResolver.java
@Inject public ShardReferenceResolver(Index index, Schemas schemas, final Map<ReferenceIdent, ReferenceImplementation> globalImplementations, final Map<ReferenceIdent, ShardReferenceImplementation> shardImplementations) { ImmutableMap.Builder<ReferenceIdent, ReferenceImplementation> builder = ImmutableMap.builder(); builder.putAll(globalImplementations).putAll(shardImplementations); if (PartitionName.isPartition(index.name())) { PartitionName partitionName;//w ww.j a v a 2 s .c o m try { partitionName = PartitionName.fromIndexOrTemplate(index.name()); } catch (IllegalArgumentException e) { throw new UnhandledServerException(String.format(Locale.ENGLISH, "Unable to load PARTITIONED BY columns from partition %s", index.name()), e); } TableIdent tableIdent = partitionName.tableIdent(); try { DocTableInfo info = (DocTableInfo) schemas.getTableInfo(tableIdent); if (!schemas.isOrphanedAlias(info)) { assert info.isPartitioned(); int i = 0; int numPartitionedColumns = info.partitionedByColumns().size(); assert partitionName.values() .size() == numPartitionedColumns : "invalid number of partitioned columns"; for (Reference partitionedInfo : info.partitionedByColumns()) { builder.put(partitionedInfo.ident(), new PartitionedColumnExpression(partitionedInfo, partitionName.values().get(i))); i++; } } else { LOGGER.error("Orphaned partition '{}' with missing table '{}' found", index, tableIdent.fqn()); } } catch (ResourceUnknownException e) { LOGGER.error("Orphaned partition '{}' with missing table '{}' found", index, tableIdent.fqn()); } } this.implementations.putAll(builder.build()); }
From source file:org.apache.gobblin.runtime.JobExecutionEventSubmitter.java
/** * Submits an event for a given {@link TaskState}. It will include all metadata specified in the jobMetadata parameter. *//*from www. jav a 2s . c om*/ private void submitTaskStateEvent(TaskState taskState, Map<String, String> jobMetadata) { ImmutableMap.Builder<String, String> taskMetadataBuilder = new ImmutableMap.Builder<>(); taskMetadataBuilder.putAll(jobMetadata); taskMetadataBuilder.put(METADATA_TASK_ID, taskState.getTaskId()); taskMetadataBuilder.put(METADATA_TASK_START_TIME, Long.toString(taskState.getStartTime())); taskMetadataBuilder.put(METADATA_TASK_END_TIME, Long.toString(taskState.getEndTime())); taskMetadataBuilder.put(METADATA_TASK_WORKING_STATE, taskState.getWorkingState().toString()); taskMetadataBuilder.put(METADATA_TASK_FAILURE_CONTEXT, taskState.getTaskFailureException().or(UNKNOWN_VALUE)); taskMetadataBuilder.put(EventSubmitter.EVENT_TYPE, TASK_STATE); this.eventSubmitter.submit(TASK_STATE, taskMetadataBuilder.build()); }
From source file:com.wadpam.guja.exceptions.RestExceptionMapper.java
@Override public Response toResponse(RestException exception) { //LOGGER.debug("Map exception - {}", exception.getMessage()); //LOGGER.debug("Header context {}", httpHeaders.getAcceptableMediaTypes()); ImmutableMap.Builder<String, String> errorMessage = new ImmutableMap.Builder<>(); if (null != exception.getJson()) { errorMessage.putAll(exception.getJson()); }//from w w w . j av a 2s . c o m if (null != exception.getMessage()) { errorMessage.put("message", exception.getMessage()); } errorMessage.put("responseCode", String.valueOf(exception.getStatus().getStatusCode())); return Response.status(exception.getStatus()).entity(errorMessage.build()) // Throws exception if type is MediaType.WILDCARD_TYPE .type(getAcceptableMediaTypeNotWildcard()).build(); }
From source file:edu.berkeley.compbio.ml.cluster.AbstractSupervisedOnlineClusteringMethod.java
/** * for now we make a uniform prior//w w w.ja v a 2s .com */ protected synchronized void preparePriors() { try { final Multinomial<Cluster<T>> priorsMult = new Multinomial<Cluster<T>>(); for (final Cluster<T> cluster : getClusters()) { priorsMult.put(cluster, 1); } priorsMult.normalize(); final ImmutableMap.Builder<Cluster<T>, Double> builder = ImmutableMap.builder(); clusterPriors = builder.putAll(priorsMult.getValueMap()).build(); } catch (DistributionException e) { logger.error("Error", e); throw new ClusterRuntimeException(e); } }
From source file:com.rtoth.boilerplate.parameters.StringParameterRule.java
@NotNull @Override/* w w w. jav a 2 s . co m*/ public ImmutableMap<ParameterInitializer, Class<? extends Exception>> getInvalidInitializers() { ImmutableMap.Builder<ParameterInitializer, Class<? extends Exception>> initializers = ImmutableMap .builder(); initializers.putAll(super.getInvalidInitializers()); if (disallowBlank.isSelected()) { initializers.put(new ParameterInitializer("blank" + getCapitalizedName(), "\"\\n\\n \\t \""), IllegalArgumentException.class); } return initializers.build(); }
From source file:com.spotify.statistics.MergingMuninGraphProvider.java
@Override public Map<String, MuninGraph> getGraphs() { final ImmutableMap.Builder<String, MuninGraph> builder = ImmutableMap.builder(); for (final MuninGraphProvider provider : providers) { builder.putAll(provider.getGraphs()); }/* www .java 2s .c o m*/ return builder.build(); }
From source file:com.facebook.buck.skylark.io.impl.WatchmanGlobber.java
/** * Creates a JSON-like Watchman query to get a list of matching files. * * <p>The implementation should ideally match the one in glob_watchman.py. *//*from w w w .j a v a 2s. c o m*/ private ImmutableMap<String, ?> createWatchmanQuery(Collection<String> include, Collection<String> exclude, boolean excludeDirectories) { ImmutableMap.Builder<String, Object> builder = ImmutableMap.builder(); builder.putAll(ImmutableMap.of("relative_root", basePath, "expression", toMatchExpressions(exclude, excludeDirectories), "glob", include, "fields", FIELDS_TO_INCLUDE)); // Sync cookies cause a massive overhead when issuing thousands of // glob queries. Only enable them (by not setting sync_timeout to 0) // for the very first request issued by this process. if (syncCookieState.shouldSyncCookies()) { syncCookieState.disableSyncCookies(); } else { builder.put("sync_timeout", 0); } return builder.build(); }
From source file:org.parceler.internal.TransactionProcessorParcelJoin.java
@Override public Map<V, R> getResults() { ImmutableMap.Builder<V, R> builder = ImmutableMap.builder(); for (Map<V, R> externalResults : externalProcessor.getResults().values()) { builder.putAll(externalResults); }//from w w w.j a v a2 s.com builder.putAll(parcelProcessor.getResults()); return builder.build(); }
From source file:com.google.api.codegen.grpcmetadatagen.GrpcMetadataGenerator.java
@SuppressWarnings("unchecked") protected Map<String, Doc> generateDocs(Model model) throws IOException { String configContent = new String(Files.readAllBytes(Paths.get(options.get(METADATA_CONFIG_FILE))), StandardCharsets.UTF_8); PackageMetadataConfig config = PackageMetadataConfig.createFromString(configContent); TargetLanguage language = TargetLanguage.fromString(options.get(LANGUAGE)); // Copy gRPC package and create non-top-level files GrpcPackageCopierResult copierResults = getCopier(language).run(options, config); ImmutableMap.Builder<String, Doc> docs = new ImmutableMap.Builder<String, Doc>(); docs.putAll(copierResults.docs()); PackageMetadataTransformer transformer = new PackageMetadataTransformer(); for (String snippetFilename : getSnippets(language)) { PackageMetadataView view = transformer .generateMetadataView(config, model, snippetFilename, outputPath(snippetFilename), language) // Set language-specific GrpcCopierResults here. .namespacePackages(copierResults.namespacePackages()).build(); CommonSnippetSetRunner runner = new CommonSnippetSetRunner(view); Doc result = runner.generate(view); if (!result.isWhitespace()) { docs.put(view.outputPath(), result); }/*from ww w . ja v a2 s . c o m*/ } return docs.build(); }
From source file:com.facebook.buck.go.GoBinary.java
@Override public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) { buildableContext.recordArtifact(output); // There is no way to specify real-ld environment variables to the go linker - just hope // that the two sets don't collide. ImmutableList<String> cxxLinkerCommand = ImmutableList.of(); ImmutableMap.Builder<String, String> environment = ImmutableMap.builder(); if (cxxLinker.isPresent()) { environment.putAll(cxxLinker.get().getEnvironment()); cxxLinkerCommand = cxxLinker.get().getCommandPrefix(getResolver()); }/*from w ww. java 2s. c o m*/ environment.putAll(linker.getEnvironment()); return ImmutableList.of(new MkdirStep(getProjectFilesystem(), output.getParent()), new GoLinkStep(getProjectFilesystem().getRootPath(), environment.build(), cxxLinkerCommand, linker.getCommandPrefix(getResolver()), linkerFlags, ImmutableList.of(linkTree.getRoot()), platform, mainObject.getPathToOutput(), GoLinkStep.LinkMode.EXECUTABLE, output)); }