@Override public void addLock(final String taskid, final TaskLock taskLock) { giant.lock(); try { Preconditions.checkNotNull(taskid, "taskid"); Preconditions.checkNotNull(taskLock, "taskLock"); taskLocks.put(taskid, taskLock); } finally { giant.unlock(); } }
java.util.function.Function<? super T, ? extends V> valueFunction, java.util.function.Supplier<M> multimapSupplier) { checkNotNull(keyFunction); checkNotNull(valueFunction); checkNotNull(multimapSupplier); return Collector.of( multimapSupplier, (multimap, input) -> multimap.put(keyFunction.apply(input), valueFunction.apply(input)), (multimap1, multimap2) -> { multimap1.putAll(multimap2);
for (Map.Entry<String, Set<FileSplit>> entry : pathFileSplitsMap.entrySet()) { Utilities.getBucketFileNameFromPathSubString(entry.getKey()); int bucketId = Utilities.getBucketIdFromFile(bucketIdStr); if (bucketId == -1) { bucketIds.put(bucketId, bucketId); for (FileSplit fsplit : entry.getValue()) { bucketToInitialSplitMap.put(bucketId, fsplit); for (Map.Entry<String, Set<FileSplit>> entry : pathFileSplitsMap.entrySet()) { int bucketId = bucketNum % numBuckets; for (FileSplit fsplit : entry.getValue()) { bucketToInitialSplitMap.put(bucketId, fsplit); for (InputSplit fsplit : bucketToInitialSplitMap.get(loopedBucketId)) { bucketToInitialSplitMap.put(bucketNum, fsplit); int bucketIdBase = i * inputNumBuckets; for (Integer bucketId : bucketIds.keySet()) { for (InputSplit fsplit : bucketToInitialSplitMap.get(bucketId)) { bucketToInitialSplitMap.put(bucketIdBase + bucketId, fsplit);
ConfigStoreAccessor accessor = this.getConfigStoreAccessor(u); ConfigKeyPath configKeypath = ConfigClientUtils.buildConfigKeyPath(u, accessor.configStore); partitionedAccessor.put(accessor, configKeypath); reverseMap.put(accessor, new HashMap<ConfigKeyPath, URI>()); reverseMap.get(accessor).put(configKeypath, u); for (Map.Entry<ConfigStoreAccessor, Collection<ConfigKeyPath>> entry : partitionedAccessor.asMap().entrySet()) { Map<ConfigKeyPath, Config> batchResult = entry.getKey().valueInspector.getResolvedConfigs(entry.getValue()); for (Map.Entry<ConfigKeyPath, Config> resultEntry : batchResult.entrySet()) { URI orgURI = reverseMap.get(entry.getKey()).get(resultEntry.getKey()); result.put(orgURI, resultEntry.getValue());
public void register(BeanFactory beanFactory, String key, SpringValue springValue) { if (!registry.containsKey(beanFactory)) { synchronized (LOCK) { if (!registry.containsKey(beanFactory)) { registry.put(beanFactory, LinkedListMultimap.<String, SpringValue>create()); } } } registry.get(beanFactory).put(key, springValue); // lazy initialize if (initialized.compareAndSet(false, true)) { initialize(); } }
public static void registerClipboardFormat(ClipboardFormat format) { checkNotNull(format); for (String key : format.getAliases()) { String lowKey = key.toLowerCase(Locale.ENGLISH); ClipboardFormat old = aliasMap.put(lowKey, format); if (old != null) { aliasMap.put(lowKey, old); WorldEdit.logger.warning(format.getClass().getName() + " cannot override existing alias '" + lowKey + "' used by " + old.getClass().getName()); } } for (String ext : format.getFileExtensions()) { String lowExt = ext.toLowerCase(Locale.ENGLISH); fileExtensionMap.put(lowExt, format); } registeredFormats.add(format); }
private void emitTraps() { Chain<Trap> traps = body.getTraps(); SootClass throwable = Scene.v().getSootClass("java.lang.Throwable"); Map<LabelNode, Iterator<UnitBox>> handlers = new HashMap<LabelNode, Iterator<UnitBox>>(tryCatchBlocks.size()); for (TryCatchBlockNode tc : tryCatchBlocks) { UnitBox start = Jimple.v().newStmtBox(null); UnitBox end = Jimple.v().newStmtBox(null); Iterator<UnitBox> hitr = handlers.get(tc.handler); if (hitr == null) { hitr = trapHandlers.get(tc.handler).iterator(); handlers.put(tc.handler, hitr); } UnitBox handler = hitr.next(); SootClass cls = tc.type == null ? throwable : Scene.v().getSootClass(AsmUtil.toQualifiedName(tc.type)); Trap trap = Jimple.v().newTrap(cls, start, end, handler); traps.add(trap); labels.put(tc.start, start); labels.put(tc.end, end); } }
public ClassicTableTypeMapping () { hiveToClientMap.put(TableType.MANAGED_TABLE.name(), ClassicTableTypes.TABLE.name()); hiveToClientMap.put(TableType.EXTERNAL_TABLE.name(), ClassicTableTypes.TABLE.name()); hiveToClientMap.put(TableType.VIRTUAL_VIEW.name(), ClassicTableTypes.VIEW.name()); hiveToClientMap.put(TableType.MATERIALIZED_VIEW.toString(), ClassicTableTypes.MATERIALIZED_VIEW.toString()); clientToHiveMap.putAll(ClassicTableTypes.TABLE.name(), Arrays.asList( TableType.MANAGED_TABLE.name(), TableType.EXTERNAL_TABLE.name())); clientToHiveMap.put(ClassicTableTypes.VIEW.name(), TableType.VIRTUAL_VIEW.name()); clientToHiveMap.put(ClassicTableTypes.MATERIALIZED_VIEW.toString(), TableType.MATERIALIZED_VIEW.toString()); }
private static List<ExecutableElement> disambiguateMethods( Iterable<? extends ExecutableElement> methods) { Multimap<String, ExecutableElement> methodsAlternatives = HashMultimap.create(); for (ExecutableElement m : methods) { if (IsParameterlessNonstaticNonobject.PREDICATE.apply(m)) { methodsAlternatives.put(ToSimpleName.FUNCTION.apply(m), m); entries: for (Entry<String, Collection<ExecutableElement>> e : methodsAlternatives.asMap().entrySet()) { Collection<ExecutableElement> values = e.getValue(); if (values.size() == 1) { resolvedMethods.addAll(values);
multimap.asMap().entrySet(), Maps.immutableEntry(sampleKey, sampleValueAsCollection)); Collection<V> values = multimap.asMap().entrySet().iterator().next().getValue(); assertCollectionIsUnmodifiable(multimap.get(key), sampleValue); assertMultimapRemainsUnmodified(multimap, originalEntries); multimap.put(sampleKey, sampleValue); fail("put succeeded on unmodifiable multimap"); } catch (UnsupportedOperationException expected) { multimap2.put(sampleKey, sampleValue); try { multimap.putAll(multimap2);
@Override public void handleDataPoints(TaskInfo taskInfo, Collection<DataPoint> dataPoints) { synchronized (BUFFER) { for (DataPoint dp : dataPoints) { for (Map.Entry<String, Object> entry : expandComplexDataPoint(dp).entrySet()) { String metricName = entry.getKey(); Multimap<Integer, Object> taskIdToBucket = BUFFER.get(taskInfo.srcComponentId, metricName); if (null == taskIdToBucket) { taskIdToBucket = ArrayListMultimap.create(); taskIdToBucket.put(taskInfo.srcTaskId, entry.getValue()); } else { taskIdToBucket.get(taskInfo.srcTaskId).add(entry.getValue()); } BUFFER.put(taskInfo.srcComponentId, metricName, taskIdToBucket); } } } }
protected void match(Tracking<RAW, BASE> tracking, Function<Trackable, SearchKey> searchKeyFactory) { if (tracking.isComplete()) { return; } Multimap<SearchKey, BASE> baseSearch = ArrayListMultimap.create(); tracking.getUnmatchedBases() .forEach(base -> baseSearch.put(searchKeyFactory.apply(base), base)); tracking.getUnmatchedRaws().forEach(raw -> { SearchKey rawKey = searchKeyFactory.apply(raw); Collection<BASE> bases = baseSearch.get(rawKey); bases.stream() .sorted(comparing(this::statusRank).reversed() .thenComparing(comparing(Trackable::getCreationDate))) .findFirst() .ifPresent(match -> { tracking.match(raw, match); baseSearch.remove(rawKey, match); }); }); }
Multimap<Class<?>, Class<?>> testClasses = HashMultimap.create(); LinkedHashSet<Class<?>> candidateClasses = Sets.newLinkedHashSet(); for (Class<?> cls : classes) { Class<?> testedClass = classMap.get(testedClassName.get()); if (testedClass != null) { testClasses.put(testedClass, cls); NEXT_CANDIDATE: for (Class<?> candidate : Iterables.filter(candidateClasses, classFilter)) { for (Class<?> testClass : testClasses.get(candidate)) { if (hasTest(testClass, explicitTestNames)) {
public void testMultimapEquals() { Multimap<String, Integer> multimap = createMultimap(); Multimap<String, Integer> hashMultimap = HashMultimap.create(); hashMultimap.putAll("foo", Arrays.asList(1, 3)); hashMultimap.put("bar", 2); new EqualsTester() .addEqualityGroup( multimap, createMultimap(), hashMultimap, ImmutableSetMultimap.<String, Integer>builder() .put("bar", 2) .put("foo", 1) .put("foo", 3) .build(), ImmutableSetMultimap.<String, Integer>builder() .put("bar", 2) .put("foo", 3) .put("foo", 1) .build()) .addEqualityGroup( ImmutableSetMultimap.<String, Integer>builder() .put("foo", 2) .put("foo", 3) .put("foo", 1) .build()) .addEqualityGroup( ImmutableSetMultimap.<String, Integer>builder().put("bar", 2).put("foo", 3).build()) .testEquals(); }
/** * This method creates a mapping from each index source lookup symbol (directly applied to the index) * to the corresponding probe key Input */ private SetMultimap<Symbol, Integer> mapIndexSourceLookupSymbolToProbeKeyInput(IndexJoinNode node, Map<Symbol, Integer> probeKeyLayout) { Set<Symbol> indexJoinSymbols = node.getCriteria().stream() .map(IndexJoinNode.EquiJoinClause::getIndex) .collect(toImmutableSet()); // Trace the index join symbols to the index source lookup symbols // Map: Index join symbol => Index source lookup symbol Map<Symbol, Symbol> indexKeyTrace = IndexJoinOptimizer.IndexKeyTracer.trace(node.getIndexSource(), indexJoinSymbols); // Map the index join symbols to the probe key Input Multimap<Symbol, Integer> indexToProbeKeyInput = HashMultimap.create(); for (IndexJoinNode.EquiJoinClause clause : node.getCriteria()) { indexToProbeKeyInput.put(clause.getIndex(), probeKeyLayout.get(clause.getProbe())); } // Create the mapping from index source look up symbol to probe key Input ImmutableSetMultimap.Builder<Symbol, Integer> builder = ImmutableSetMultimap.builder(); for (Map.Entry<Symbol, Symbol> entry : indexKeyTrace.entrySet()) { Symbol indexJoinSymbol = entry.getKey(); Symbol indexLookupSymbol = entry.getValue(); builder.putAll(indexLookupSymbol, indexToProbeKeyInput.get(indexJoinSymbol)); } return builder.build(); }
Map<String, ApolloConfigNotification> filteredNotifications = filterNotifications(appId, notifications); for (Map.Entry<String, ApolloConfigNotification> notificationEntry : filteredNotifications.entrySet()) { String normalizedNamespace = notificationEntry.getKey(); ApolloConfigNotification notification = notificationEntry.getValue(); namespaces.add(normalizedNamespace); clientSideNotifications.put(normalizedNamespace, notification.getNotificationId()); if (!Objects.equals(notification.getNamespaceName(), normalizedNamespace)) { deferredResultWrapper.recordNamespaceNameNormalizedResult(notification.getNamespaceName(), normalizedNamespace); this.deferredResults.put(key, deferredResultWrapper);
public synchronized void catalog (String workerId, String graphAffinity) { WorkerObservation observation = new WorkerObservation(workerId, graphAffinity); WorkerObservation oldObservation = observationsByWorkerId.put(workerId, observation); if (oldObservation != null) { workersByGraph.remove(oldObservation.graphAffinity, workerId); } workersByGraph.put(graphAffinity, workerId); }