List of usage examples for com.google.common.collect Multimaps asMap
@Beta public static <K, V> Map<K, Collection<V>> asMap(Multimap<K, V> multimap)
From source file:com.palantir.atlasdb.keyvalue.cassandra.TimestampExtractor.java
@Override public Map<Cell, Set<Long>> asMap() { return Multimaps.asMap(collector); }
From source file:org.tensorics.core.tensor.lang.OngoingDimensionFlattening.java
public Tensor<Set<S>> intoTensorOfSets() { return Tensorics.fromMap(remainingDimensions(), Multimaps.asMap(intoSetMultimap())); }
From source file:com.palantir.atlasdb.keyvalue.cassandra.HistoryExtractor.java
@Override public Map<Cell, Set<Value>> asMap() { return Multimaps.asMap(collector); }
From source file:org.tensorics.core.tensor.lang.OngoingOrderedFlattening.java
public Tensor<List<S>> intoTensorOfLists() { return Tensorics.fromMap(remainingDimensions(), Multimaps.asMap(intoListMultimap())); }
From source file:com.google.template.soy.internal.proto.Field.java
/** Returns the set of fields indexed by soy accessor name for the given type. */ public static <T extends Field> ImmutableMap<String, T> getFieldsForType(Descriptor descriptor, Set<FieldDescriptor> extensions, Factory<T> factory) { ImmutableMap.Builder<String, T> fields = ImmutableMap.builder(); for (FieldDescriptor fieldDescriptor : descriptor.getFields()) { if (ProtoUtils.shouldJsIgnoreField(fieldDescriptor)) { continue; }//from w w w .java 2s . c o m T field = factory.create(fieldDescriptor); fields.put(field.getName(), field); } SetMultimap<String, T> extensionsBySoyName = MultimapBuilder.hashKeys().hashSetValues().build(); for (FieldDescriptor extension : extensions) { T field = factory.create(extension); extensionsBySoyName.put(field.getName(), field); } for (Map.Entry<String, Set<T>> group : Multimaps.asMap(extensionsBySoyName).entrySet()) { Set<T> ambiguousFields = group.getValue(); String fieldName = group.getKey(); if (ambiguousFields.size() == 1) { fields.put(fieldName, Iterables.getOnlyElement(ambiguousFields)); } else { T value = factory.createAmbiguousFieldSet(ambiguousFields); logger.severe("Proto " + descriptor.getFullName() + " has multiple extensions with the name \"" + fieldName + "\": " + fullFieldNames(ambiguousFields) + "\nThis field will not be accessible from soy"); fields.put(fieldName, value); } } return fields.build(); }
From source file:com.foundationdb.server.test.mt.util.TimeMarkerComparison.java
/** See {@link #combineTimeMarkers(TimeMarker...)}. */ static List<List<String>> combineTimeMarkers(Collection<TimeMarker> timeMarkers) { // Sort by time, list of lists of messages from all markers ListMultimap<Long, List<String>> timeToMarks = Multimaps .newListMultimap(new TreeMap<Long, Collection<List<String>>>(), new Supplier<List<List<String>>>() { @Override/*from w w w .j a v a2s. c o m*/ public List<List<String>> get() { return new ArrayList<>(); } }); for (TimeMarker tm : timeMarkers) { for (Entry<Long, List<String>> entry : Multimaps.asMap(tm.getMarks()).entrySet()) { timeToMarks.put(entry.getKey(), entry.getValue()); } } // Concatenate into final ordering List<List<String>> output = new ArrayList<>(); for (List<List<String>> singleTimeMarks : Multimaps.asMap(timeToMarks).values()) { // Split a given Marker's messages apart, coalesce overlapping timestamps from multiple Marker's ListMultimap<Integer, String> split = ArrayListMultimap.create(); for (List<String> marks : singleTimeMarks) { for (int i = 0; i < marks.size(); ++i) { split.put(i, marks.get(i)); } } // Sort any coalesced and output for (List<String> marks : Multimaps.asMap(split).values()) { Collections.sort(marks); output.add(marks); } } return output; }
From source file:com.google.devtools.build.lib.profiler.chart.SkylarkStatistics.java
/** * For each Skylark function compute a {@link TasksStatistics} object from the execution times of * all corresponding {@link Task}s and add it to the list. * @param tasks Map from function name to all corresponding tasks. * @param stats The list to which {@link TasksStatistics} are to be added. * @return The sum of the execution times of all {@link Task} values in the map. *//* www. j a v a 2 s. c o m*/ private static long computeStatistics(ListMultimap<String, Task> tasks, List<TasksStatistics> stats) { long total = 0L; for (Entry<String, List<Task>> entry : Multimaps.asMap(tasks).entrySet()) { TasksStatistics functionStats = TasksStatistics.create(entry.getKey(), entry.getValue()); stats.add(functionStats); total += functionStats.totalNanos; } return total; }
From source file:dagger.internal.codegen.IncompatiblyScopedBindingsValidation.java
@Override public void visitGraph(BindingGraph bindingGraph, DiagnosticReporter diagnosticReporter) { ImmutableSetMultimap.Builder<ComponentNode, BindingNode> incompatibleBindingNodes = ImmutableSetMultimap .builder();//from w ww . j a v a2s . c om for (BindingNode bindingNode : bindingGraph.bindingNodes()) { bindingNode.binding().scope().ifPresent(scope -> { if (scope.isReusable()) { return; } ComponentNode componentNode = bindingGraph.componentNode(bindingNode.componentPath()).get(); if (!componentNode.scopes().contains(scope)) { incompatibleBindingNodes.put(componentNode, bindingNode); } }); } Multimaps.asMap(incompatibleBindingNodes.build()) .forEach((componentNode, bindingNodes) -> diagnosticReporter.reportComponent(ERROR, componentNode, incompatibleBindingScopesError(componentNode, bindingNodes))); }
From source file:com.google.template.soy.types.proto.SoyProtoType.java
SoyProtoType(SoyTypeRegistry typeRegistry, Descriptor descriptor, Set<FieldDescriptor> extensions) { this.typeDescriptor = descriptor; ImmutableMap.Builder<String, Field> fields = ImmutableMap.builder(); for (FieldDescriptor fieldDescriptor : descriptor.getFields()) { if (Protos.shouldJsIgnoreField(fieldDescriptor)) { continue; }//from ww w . j a v a2 s. c o m NormalField field = new NormalField(typeRegistry, fieldDescriptor); fields.put(field.getName(), field); } SetMultimap<String, ExtensionField> extensionsBySoyName = MultimapBuilder.hashKeys().hashSetValues() .build(); for (FieldDescriptor extension : extensions) { ExtensionField field = new ExtensionField(typeRegistry, extension); extensionsBySoyName.put(field.getName(), field); } for (Map.Entry<String, Set<ExtensionField>> group : Multimaps.asMap(extensionsBySoyName).entrySet()) { String fieldName = group.getKey(); Set<ExtensionField> ambiguousFields = group.getValue(); if (ambiguousFields.size() == 1) { fields.put(fieldName, Iterables.getOnlyElement(ambiguousFields)); } else { AmbiguousFieldSet value = new AmbiguousFieldSet(fieldName, ambiguousFields); logger.severe("Proto " + descriptor.getFullName() + " has multiple extensions with the name \"" + fieldName + "\": " + value.getFullFieldNames() + "\nThis field will not be accessible from soy"); fields.put(fieldName, value); } } this.fields = fields.build(); }
From source file:org.tensorics.core.tensor.lang.OngoingOrderedFlattening.java
public Tensor<List<C>> intoTensorOfKeyLists() { return Tensorics.fromMap(remainingDimensions(), Multimaps.asMap(intoKeyListMultimap())); }