List of usage examples for com.google.common.collect ImmutableMultimap.Builder put
@Deprecated @Override public boolean put(K key, V value)
From source file:com.facebook.swift.service.ThriftServiceProcessor.java
public ThriftServiceProcessor(ThriftCodecManager codecManager, List<Object> services) { Preconditions.checkNotNull(codecManager, "codecManager is null"); Preconditions.checkNotNull(services, "service is null"); Preconditions.checkArgument(!services.isEmpty(), "services is empty"); // NOTE: ImmutableMap enforces that we don't have duplicate method names ImmutableMap.Builder<String, ThriftMethodProcessor> processorBuilder = ImmutableMap.builder(); ImmutableMultimap.Builder<String, ThriftMethodStats> statsBuilder = ImmutableMultimap.builder(); for (Object service : services) { ThriftServiceMetadata serviceMetadata = new ThriftServiceMetadata(service.getClass(), codecManager.getCatalog()); for (ThriftMethodMetadata methodMetadata : serviceMetadata.getMethods().values()) { ThriftMethodProcessor methodProcessor = new ThriftMethodProcessor(service, methodMetadata, codecManager);//ww w . j a va 2 s. co m processorBuilder.put(methodMetadata.getName(), methodProcessor); statsBuilder.put(serviceMetadata.getName(), methodProcessor.getStats()); } } methods = processorBuilder.build(); serviceStats = statsBuilder.build(); }
From source file:org.auraframework.impl.css.token.TokenCacheImpl.java
public TokenCacheImpl(DefinitionService definitionService, Iterable<DefDescriptor<TokensDef>> descriptors) throws QuickFixException { checkNotNull(descriptors, "descriptors cannot be null, see EmptyTokenCache instead"); this.definitionService = definitionService; // we want a unique list of the concrete descs. Since last one wins, there's no need to include duplicate // entries; just the last one. duplicate entries could come from descriptor providers that resolve to the // same descriptor, or just user error/inefficiency Set<DefDescriptor<TokensDef>> unique = new LinkedHashSet<>(); // in the case of descriptor providers, maintain a mapping to the original descriptor(s) ImmutableMultimap.Builder<DefDescriptor<TokensDef>, DefDescriptor<TokensDef>> origs = ImmutableMultimap .builder();//w ww.j a v a 2 s.c o m for (DefDescriptor<TokensDef> descriptor : descriptors) { DefDescriptor<TokensDef> concrete = definitionService.getDefinition(descriptor).getConcreteDescriptor(); unique.remove(concrete); // unlike the normal behavior, we want to move the position of duplicate entries unique.add(concrete); if (descriptor != concrete) { origs.put(concrete, descriptor); } } this.originals = origs.build(); this.descriptors = ImmutableList.copyOf(unique); this.reversed = this.descriptors.reverse(); ImmutableTable.Builder<String, DefDescriptor<TokensDef>, String> table = ImmutableTable.builder(); for (DefDescriptor<TokensDef> descriptor : this.descriptors) { // iterate through the unique list TokensDef def = definitionService.getDefinition(descriptor); if (def.getMapProvider() != null) { TokenMapProviderDef tokenMapProviderDef = definitionService.getDefinition(def.getMapProvider()); TokenMapProviderInstance instance = Aura.getInstanceService().getInstance(tokenMapProviderDef); Map<String, String> map = instance.provide(); for (Entry<String, String> entry : map.entrySet()) { table.put(entry.getKey(), descriptor, entry.getValue()); } } } this.dynamicTokens = table.build(); }
From source file:com.vecna.dbDiff.model.relationalDb.RelationalTable.java
/** * Set the indices./* w w w . java 2s. c o m*/ * @param indices The indices to set * @throws InconsistentSchemaException If adding an index not recognized by the current table */ public void setIndices(List<RelationalIndex> indices) throws InconsistentSchemaException { ImmutableMultimap.Builder<List<String>, RelationalIndex> indexMapBuilder = ImmutableListMultimap.builder(); if (getName() == null) { throw new InconsistentSchemaException("Trying to add indices without setting a table!"); } else { for (RelationalIndex ri : indices) { if (!getCatalogSchema().equals(ri.getCatalogSchema())) { throw new InconsistentSchemaException("Index " + ri.getName() + " and table " + getName() + " belong to different catalogs or schemas."); } indexMapBuilder.put(ri.getColumnNames(), ri); } } m_indicesByColumns = indexMapBuilder.build(); }
From source file:com.sun.tools.hat.internal.server.QueryHandler.java
/** * Prints out breadcrumbs for accessing previous elements in the * referrer chain./*from ww w .j a v a2 s. co m*/ * * <p>For queries that support referrer chains, there is a primary * class that the query works on, followed by a referrer chain that * further filters instances. The primary class is specified as * {@code clazz}. * * <p>The referrer chain is always written with parameter name * {@code referrer}, so the query handler should use that name to get * the referrer chain. Additionally, if the primary class is omitted, * then the referrer chain is irrelevant and will not be printed. * * @param path the static portion of the link target (see {@link #formatLink}) * @param pathInfo the non-static portion of the link target * (see {@link #formatLink}); ignored if {@code name} * is omitted * @param name the parameter name for referring to the primary class; * if omitted, place the class reference in {@code pathInfo} * @param clazz the primary class in use * @param referrers the referrer chain in use * @param params any further parameters to be prepended */ protected void printBreadcrumbs(String path, String pathInfo, String name, JavaClass clazz, Iterable<JavaClass> referrers, Multimap<String, String> params) { ImmutableMultimap.Builder<String, String> builder = ImmutableMultimap.builder(); if (params != null) { builder.putAll(params); } if (clazz != null) { out.print("<p align='center'>"); if (name != null) { builder.put(name, clazz.getIdString()); } else { pathInfo = clazz.getIdString(); } out.print(formatLink(path, pathInfo, clazz.getName(), builder.build())); for (JavaClass referrer : referrers) { out.print(" → "); builder.put("referrer", referrer.getIdString()); out.print(formatLink(path, pathInfo, referrer.getName(), builder.build())); } out.println("</p>"); } }
From source file:io.prestosql.execution.SqlStageExecution.java
public synchronized void addExchangeLocations(PlanFragmentId fragmentId, Set<RemoteTask> sourceTasks, boolean noMoreExchangeLocations) { requireNonNull(fragmentId, "fragmentId is null"); requireNonNull(sourceTasks, "sourceTasks is null"); RemoteSourceNode remoteSource = exchangeSources.get(fragmentId); checkArgument(remoteSource != null, "Unknown remote source %s. Known sources are %s", fragmentId, exchangeSources.keySet());/*w ww . jav a2 s . c om*/ this.sourceTasks.putAll(remoteSource.getId(), sourceTasks); for (RemoteTask task : getAllTasks()) { ImmutableMultimap.Builder<PlanNodeId, Split> newSplits = ImmutableMultimap.builder(); for (RemoteTask sourceTask : sourceTasks) { URI exchangeLocation = sourceTask.getTaskStatus().getSelf(); newSplits.put(remoteSource.getId(), createRemoteSplitFor(task.getTaskId(), exchangeLocation)); } task.addSplits(newSplits.build()); } if (noMoreExchangeLocations) { completeSourceFragments.add(fragmentId); // is the source now complete? if (completeSourceFragments.containsAll(remoteSource.getSourceFragmentIds())) { completeSources.add(remoteSource.getId()); for (RemoteTask task : getAllTasks()) { task.noMoreSplits(remoteSource.getId()); } } } }
From source file:no.ssb.jsonstat.v2.Dataset.java
/** * Return an {@link ImmutableMultimap} representing the roles of the dimensions. * * @see <a href="https://json-stat.org/format/#role">json-stat.org/format/#role</a> *//*from w w w . ja v a 2 s . co m*/ public ImmutableMultimap<Dimension.Roles, String> getRole() { ImmutableMultimap.Builder<Dimension.Roles, String> builder; builder = ImmutableMultimap.builder(); for (Map.Entry<String, Dimension> dimensionEntry : getDimension().entrySet()) { Dimension.Roles role = dimensionEntry.getValue().getRole(); if (role != null) { builder.put(role, dimensionEntry.getKey()); } } return builder.build(); }
From source file:org.kiji.schema.zookeeper.UsersTracker.java
/** * Retrieve a multimap of the current users to their respective value (either table layout version * if tracking table users, or system version if tracking instance users). * * @return a multimap of the current table users to their respective value. * @throws IOException on failure.//from w w w .ja va 2 s .co m */ public Multimap<String, String> getUsers() throws IOException { ImmutableMultimap.Builder<String, String> users = ImmutableSetMultimap.builder(); for (ChildData child : mCache.getCurrentData()) { String nodeName = Iterables.getLast(Splitter.on('/').split(child.getPath())); String[] split = nodeName.split(ZooKeeperUtils.ZK_NODE_NAME_SEPARATOR); if (split.length != 2) { LOG.error("Ignoring invalid ZooKeeper table user node: {}.", nodeName); continue; } final String userID = URLDecoder.decode(split[0], Charsets.UTF_8.displayName()); final String layoutID = URLDecoder.decode(split[1], Charsets.UTF_8.displayName()); users.put(userID, layoutID); } return users.build(); }
From source file:org.sosy_lab.cpachecker.cpa.loopstack.LoopstackTransferRelation.java
public LoopstackTransferRelation(int maxLoopIterations, CFA pCfa) throws InvalidCFAException { this.maxLoopIterations = maxLoopIterations; if (!pCfa.getLoopStructure().isPresent()) { throw new InvalidCFAException("LoopstackCPA does not work without loop information!"); }/*from ww w.j a va 2 s. c o m*/ LoopStructure loops = pCfa.getLoopStructure().get(); ImmutableMap.Builder<CFAEdge, Loop> entryEdges = ImmutableMap.builder(); ImmutableMap.Builder<CFAEdge, Loop> exitEdges = ImmutableMap.builder(); ImmutableMultimap.Builder<CFANode, Loop> heads = ImmutableMultimap.builder(); for (Loop l : loops.getAllLoops()) { // function edges do not count as incoming/outgoing edges Iterable<CFAEdge> incomingEdges = filter(l.getIncomingEdges(), not(instanceOf(CFunctionReturnEdge.class))); Iterable<CFAEdge> outgoingEdges = filter(l.getOutgoingEdges(), not(instanceOf(CFunctionCallEdge.class))); for (CFAEdge e : incomingEdges) { entryEdges.put(e, l); } for (CFAEdge e : outgoingEdges) { exitEdges.put(e, l); } for (CFANode h : l.getLoopHeads()) { heads.put(h, l); } } loopEntryEdges = entryEdges.build(); loopExitEdges = exitEdges.build(); loopHeads = heads.build(); }
From source file:org.apache.calcite.adapter.java.ReflectiveSchema.java
@Override protected Multimap<String, Function> getFunctionMultimap() { final ImmutableMultimap.Builder<String, Function> builder = ImmutableMultimap.builder(); for (Method method : clazz.getMethods()) { final String methodName = method.getName(); if (method.getDeclaringClass() == Object.class || methodName.equals("toString")) { continue; }/*from w w w . j av a 2 s . co m*/ if (TranslatableTable.class.isAssignableFrom(method.getReturnType())) { final TableMacro tableMacro = new MethodTableMacro(this, method); builder.put(methodName, tableMacro); } } return builder.build(); }
From source file:io.prestosql.execution.SqlStageExecution.java
private synchronized RemoteTask scheduleTask(Node node, TaskId taskId, Multimap<PlanNodeId, Split> sourceSplits, OptionalInt totalPartitions) { checkArgument(!allTasks.contains(taskId), "A task with id %s already exists", taskId); ImmutableMultimap.Builder<PlanNodeId, Split> initialSplits = ImmutableMultimap.builder(); initialSplits.putAll(sourceSplits);/*from ww w.java 2 s.co m*/ sourceTasks.forEach((planNodeId, task) -> { TaskStatus status = task.getTaskStatus(); if (status.getState() != TaskState.FINISHED) { initialSplits.put(planNodeId, createRemoteSplitFor(taskId, status.getSelf())); } }); OutputBuffers outputBuffers = this.outputBuffers.get(); checkState(outputBuffers != null, "Initial output buffers must be set before a task can be scheduled"); RemoteTask task = remoteTaskFactory.createRemoteTask(stateMachine.getSession(), taskId, node, stateMachine.getFragment(), initialSplits.build(), totalPartitions, outputBuffers, nodeTaskMap.createPartitionedSplitCountTracker(node, taskId), summarizeTaskInfo); completeSources.forEach(task::noMoreSplits); allTasks.add(taskId); tasks.computeIfAbsent(node, key -> newConcurrentHashSet()).add(task); nodeTaskMap.addTask(node, task); task.addStateChangeListener(new StageTaskListener()); task.addFinalTaskInfoListener(this::updateFinalTaskInfo); if (!stateMachine.getState().isDone()) { task.start(); } else { // stage finished while we were scheduling this task task.abort(); } return task; }