private Set<RemoteTask> assignSplits(Multimap<Node, Split> splitAssignment, Multimap<Node, Lifespan> noMoreSplitsNotification) { ImmutableSet.Builder<RemoteTask> newTasks = ImmutableSet.builder(); ImmutableSet<Node> nodes = ImmutableSet.<Node>builder() .addAll(splitAssignment.keySet()) .addAll(noMoreSplitsNotification.keySet()) .build(); for (Node node : nodes) { // source partitioned tasks can only receive broadcast data; otherwise it would have a different distribution ImmutableMultimap<PlanNodeId, Split> splits = ImmutableMultimap.<PlanNodeId, Split>builder() .putAll(partitionedNode, splitAssignment.get(node)) .build(); ImmutableMultimap.Builder<PlanNodeId, Lifespan> noMoreSplits = ImmutableMultimap.builder(); if (noMoreSplitsNotification.containsKey(node)) { noMoreSplits.putAll(partitionedNode, noMoreSplitsNotification.get(node)); } newTasks.addAll(stage.scheduleSplits( node, splits, noMoreSplits.build())); } return newTasks.build(); }
@Override public Map<String, Collection<String>> getHeaders() { ImmutableMultimap.Builder<String, String> builder = ImmutableMultimap.builder(); for ( String name : fromEnumeration( req.getHeaderNames() ) ) { builder.putAll( name, fromEnumeration( req.getHeaders( name ) ) ); } return builder.build().asMap(); }
@Override public Map<String, Collection<String>> getParameters() { ImmutableMultimap.Builder<String, String> builder = ImmutableMultimap.builder(); for ( String name : fromEnumeration( req.getParameterNames() ) ) { builder.putAll( name, req.getParameterValues( name ) ); } return builder.build().asMap(); }
private JoinGraph joinWith(JoinGraph other, List<JoinNode.EquiJoinClause> joinClauses, Context context, PlanNodeId newRoot) { for (PlanNode node : other.nodes) { checkState(!edges.containsKey(node.getId()), format("Node [%s] appeared in two JoinGraphs", node)); } List<PlanNode> nodes = ImmutableList.<PlanNode>builder() .addAll(this.nodes) .addAll(other.nodes) .build(); ImmutableMultimap.Builder<PlanNodeId, Edge> edges = ImmutableMultimap.<PlanNodeId, Edge>builder() .putAll(this.edges) .putAll(other.edges); List<Expression> joinedFilters = ImmutableList.<Expression>builder() .addAll(this.filters) .addAll(other.filters) .build(); for (JoinNode.EquiJoinClause edge : joinClauses) { Symbol leftSymbol = edge.getLeft(); Symbol rightSymbol = edge.getRight(); checkState(context.containsSymbol(leftSymbol)); checkState(context.containsSymbol(rightSymbol)); PlanNode left = context.getSymbolSource(leftSymbol); PlanNode right = context.getSymbolSource(rightSymbol); edges.put(left.getId(), new Edge(right, leftSymbol, rightSymbol)); edges.put(right.getId(), new Edge(left, rightSymbol, leftSymbol)); } return new JoinGraph(nodes, edges.build(), newRoot, joinedFilters, Optional.empty()); }
TreePath enclosingClassPath, VisitorState state) { ClassTree enclosingClass = (ClassTree) enclosingClassPath.getLeaf(); ImmutableMultimap.Builder<Tree, Element> builder = ImmutableMultimap.builder(); if (memberTree instanceof VariableTree || memberTree instanceof BlockTree) { builder.putAll(memberTree, initThusFar); constructors.stream().forEach((c) -> builder.putAll(c, initThusFar)); Symbol.ClassSymbol classSymbol = ASTHelpers.getSymbol(enclosingClass); FieldInitEntities entities = class2Entities.get(classSymbol); initThusFar, Sets.difference(entities.nonnullInstanceFields(), constructorUninitSymbols)); builder.putAll(initMethod, initAfterConstructors); builder.putAll(staticInitMethod, initThusFar); return builder.build();
@Benchmark @OperationsPerInvocation(SPLITS) public Object benchmark(BenchmarkData data) { List<RemoteTask> remoteTasks = ImmutableList.copyOf(data.getTaskMap().values()); Iterator<MockRemoteTaskFactory.MockRemoteTask> finishingTask = Iterators.cycle(data.getTaskMap().values()); Iterator<Split> splits = data.getSplits().iterator(); Set<Split> batch = new HashSet<>(); while (splits.hasNext() || !batch.isEmpty()) { Multimap<Node, Split> assignments = data.getNodeSelector().computeAssignments(batch, remoteTasks).getAssignments(); for (Node node : assignments.keySet()) { MockRemoteTaskFactory.MockRemoteTask remoteTask = data.getTaskMap().get(node); remoteTask.addSplits(ImmutableMultimap.<PlanNodeId, Split>builder() .putAll(new PlanNodeId("sourceId"), assignments.get(node)) .build()); remoteTask.startSplits(MAX_SPLITS_PER_NODE); } if (assignments.size() == batch.size()) { batch.clear(); } else { batch.removeAll(assignments.values()); } while (batch.size() < SPLIT_BATCH_SIZE && splits.hasNext()) { batch.add(splits.next()); } finishingTask.next().finishSplits((int) Math.ceil(MAX_SPLITS_PER_NODE / 50.0)); } return remoteTasks; }
for (Node node : assignments.keySet()) { RemoteTask remoteTask = taskMap.get(node); remoteTask.addSplits(ImmutableMultimap.<PlanNodeId, Split>builder() .putAll(new PlanNodeId("sourceId"), assignments.get(node)) .build()); for (Node node : assignments.keySet()) { RemoteTask remoteTask = taskMap.get(node); remoteTask.addSplits(ImmutableMultimap.<PlanNodeId, Split>builder() .putAll(new PlanNodeId("sourceId"), assignments.get(node)) .build()); for (Node node : assignments.keySet()) { RemoteTask remoteTask = taskMap.get(node); remoteTask.addSplits(ImmutableMultimap.<PlanNodeId, Split>builder() .putAll(new PlanNodeId("sourceId"), assignments.get(node)) .build());
/** Builds a map of module dependencies. */ private static ImmutableMultimap<String, String> buildAdjacencyMap(Variant variant) { ImmutableMultimap.Builder<String, String> moduleDependenciesMap = ImmutableMultimap.builder(); variant .getApkSetList() .stream() .map(ApkSet::getModuleMetadata) .forEach( moduleMetadata -> { moduleDependenciesMap.putAll( moduleMetadata.getName(), moduleMetadata.getDependenciesList()); moduleDependenciesMap.put(moduleMetadata.getName(), "base"); }); return moduleDependenciesMap.build(); }