List of usage examples for com.google.common.collect Maps transformValues
@GwtIncompatible("NavigableMap") public static <K, V1, V2> NavigableMap<K, V2> transformValues(NavigableMap<K, V1> fromMap, Function<? super V1, V2> function)
From source file:com.facebook.swift.codec.ArrayField.java
public Map<Short, List<Double>> getMapDoubleList() { if (mapDoubleArray == null) { return null; }//from w w w .j ava2 s . c o m return Maps.transformValues(mapDoubleArray, doubleArrayAsList()); }
From source file:ninja.leaping.permissionsex.backend.sql.SqlSubjectData.java
@Override public Map<Set<Entry<String, String>>, Map<String, String>> getAllOptions() { return Maps.filterValues( Maps.transformValues(segments, dataEntry -> dataEntry == null ? null : dataEntry.getOptions()), el -> el != null);/* w ww .jav a 2 s . co m*/ }
From source file:eu.esdihumboldt.hale.ui.service.instance.sample.internal.sampler.first.FirstInstancesPerType.java
@Override public Map<TypeDefinition, InstanceCollection> fanout() { Map<TypeDefinition, InstanceCollection> fanout = super.fanout(); if (fanout != null) { // individually sample each instance collection return Maps.transformValues(fanout, new Function<InstanceCollection, InstanceCollection>() { @Override//w w w . j a v a 2 s. c o m public InstanceCollection apply(InstanceCollection org) { return new FirstOverallInstances(org, max); } }); } return null; }
From source file:org.gradle.api.internal.changedetection.state.CurrentTaskExecution.java
public HistoricalTaskExecution archive() { ImmutableSortedMap<String, HistoricalFileCollectionFingerprint> historicalInputFingerprints = ImmutableSortedMap .copyOfSorted(Maps.transformValues(inputFingerprints, ARCHIVE_FINGERPRINT)); ImmutableSortedMap<String, HistoricalFileCollectionFingerprint> historicalOutputFingerprints = ImmutableSortedMap .copyOfSorted(Maps.transformValues(outputFingerprints, ARCHIVE_FINGERPRINT)); return new HistoricalTaskExecution(getTaskImplementation(), getTaskActionImplementations(), getInputProperties(), getOutputPropertyNamesForCacheKey(), historicalInputFingerprints, historicalOutputFingerprints, successful, originExecutionMetadata); }
From source file:org.onosproject.store.primitives.impl.FederatedDistributedPrimitiveCreator.java
@Override public AsyncLeaderElector newAsyncLeaderElector(String name) { checkNotNull(name);/* w ww. j a v a 2 s . c om*/ Map<PartitionId, AsyncLeaderElector> leaderElectors = Maps.transformValues(members, partition -> partition.newAsyncLeaderElector(name)); Hasher<String> hasher = topic -> { int hashCode = Hashing.sha256().hashString(topic, Charsets.UTF_8).asInt(); return sortedMemberPartitionIds.get(Math.abs(hashCode) % members.size()); }; return new PartitionedAsyncLeaderElector(name, leaderElectors, hasher); }
From source file:com.facebook.buck.distributed.DistributedBuildTargetGraphCodec.java
public BuildJobStateTargetGraph dump(Collection<TargetNode<?>> targetNodes) throws InterruptedException { BuildJobStateTargetGraph result = new BuildJobStateTargetGraph(); BiMap<Integer, ProjectFilesystem> filesystemIndex = HashBiMap.create(); for (TargetNode<?> targetNode : targetNodes) { Map<String, Object> rawTargetNode = nodeToRawNode.apply(targetNode); ProjectFilesystem projectFilesystem = targetNode.getRuleFactoryParams().getProjectFilesystem(); BuildJobStateTargetNode remoteNode = new BuildJobStateTargetNode(); remoteNode.setFileSystemRootIndex(getIndex(projectFilesystem, filesystemIndex)); remoteNode.setBuildTarget(encodeBuildTarget(targetNode.getBuildTarget())); try {//w w w. j a va2s . c o m remoteNode.setRawNode(objectMapper.writeValueAsString(rawTargetNode)); } catch (JsonProcessingException e) { throw new RuntimeException(e); } result.addToNodes(remoteNode); } result.setFileSystemRoots(Maps.transformValues(filesystemIndex, new Function<ProjectFilesystem, String>() { @Override public String apply(ProjectFilesystem input) { return input.getRootPath().toString(); } })); return result; }
From source file:com.eviware.loadui.impl.statistics.store.TrackImpl.java
@Override public Iterable<Entry> getRange(String source, long startTime, long endTime, int interpolationLevel) { try {/* www. j a v a 2s . co m*/ return Iterables.transform( manager.read(execution.getId(), id, source, startTime, endTime, interpolationLevel), new Function<Map<String, Object>, Entry>() { @Override public Entry apply(Map<String, Object> entryData) { Long timestamp = (Long) entryData.remove(DataTable.STATIC_FIELD_TIMESTAMP); return new EntryImpl(timestamp, Maps.transformValues(entryData, new Function<Object, Number>() { @Override public Number apply(Object value) { return (Number) value; } })); } }); } catch (SQLException e) { throw new RuntimeException("Unable to retrieve next track entry!", e); } }
From source file:eu.crydee.alignment.aligner.ae.CosineSimilarityAE.java
private Map<Sentence, Double> squares(Map<Sentence, Collection<Token>> m) { return Maps.transformValues(m, v -> Math.sqrt(v.stream().mapToDouble(t -> Math.pow(t.getTfidf(), 2)).sum())); }
From source file:com.facebook.buck.features.lua.LuaStandaloneBinary.java
@Override public ImmutableList<Step> getBuildSteps(BuildContext context, BuildableContext buildableContext) { ImmutableList.Builder<Step> steps = ImmutableList.builder(); buildableContext.recordArtifact(output); // Make sure the parent directory exists. steps.add(MkdirStep.of(BuildCellRelativePath.fromCellRelativePath(context.getBuildCellRootPath(), getProjectFilesystem(), output.getParent()))); // Delete any other pex that was there (when switching between pex styles). steps.add(RmStep.of(BuildCellRelativePath.fromCellRelativePath(context.getBuildCellRootPath(), getProjectFilesystem(), output)).withRecursive(true)); SourcePathResolver resolver = context.getSourcePathResolver(); steps.add(new ShellStep(getProjectFilesystem().getRootPath()) { @Override//w ww . j a v a 2 s .co m protected Optional<String> getStdin(ExecutionContext context) { try { return Optional.of(ObjectMappers.WRITER.writeValueAsString(ImmutableMap.of("modules", Maps.transformValues(components.getModules(), Functions.compose(Object::toString, resolver::getAbsolutePath)), "pythonModules", Maps.transformValues(components.getPythonModules(), Functions.compose(Object::toString, resolver::getAbsolutePath)), "nativeLibraries", Maps.transformValues(components.getNativeLibraries(), Functions.compose(Object::toString, resolver::getAbsolutePath))))); } catch (IOException e) { throw new RuntimeException(e); } } @Override protected ImmutableList<String> getShellCommandInternal(ExecutionContext context) { ImmutableList.Builder<String> command = ImmutableList.builder(); command.addAll(builder.getCommandPrefix(resolver)); command.addAll(builderArgs); command.add("--entry-point", mainModule); command.add("--interpreter"); if (starter.isPresent()) { command.add(resolver.getAbsolutePath(starter.get()).toString()); } else { command.add(lua.getCommandPrefix(resolver).get(0)); } command.add(getProjectFilesystem().resolve(output).toString()); return command.build(); } @Override public String getShortName() { return "lua_package"; } }); return steps.build(); }
From source file:org.locationtech.geogig.model.internal.QuadTreeTestSupport.java
private void clone(QuadTreeClusteringStrategy source, QuadTreeClusteringStrategy target, DAG dag) { DAG clone = dag.clone();//from www .j a v a 2 s .com target.dagCache.add(clone); Set<NodeId> children = new HashSet<>(dag.childrenList()); Map<NodeId, Node> nodes = source.storageProvider.getNodes(children); Map<NodeId, DAGNode> dagnodes = Maps.transformValues(nodes, (n) -> DAGNode.of(n)); target.storageProvider.saveNodes(dagnodes); Set<TreeId> buckets = new HashSet<>(dag.bucketList()); List<DAG> dagTrees = source.getDagTrees(buckets); for (DAG d : dagTrees) { clone(source, target, d); } }