@Override public synchronized Set<Node> getActiveConnectorNodes(ConnectorId connectorId) { return activeNodesByConnectorId.get(connectorId); }
public Set<String> getQueryDatasources(final String queryId) { return queryDatasources.get(queryId); } }
public Iterable<Set<String>> getColumnIndexes(TpchScaledTable table) { return spec.get(table); }
@Override public Set<Node> getActiveConnectorNodes(ConnectorId connectorId) { return ImmutableSet.copyOf(remoteNodes.get(connectorId)); }
@Override protected void scanJarFile(ClassLoader classloader, JarFile file) { Enumeration<JarEntry> entries = file.entries(); while (entries.hasMoreElements()) { JarEntry entry = entries.nextElement(); if (entry.isDirectory() || entry.getName().equals(JarFile.MANIFEST_NAME)) { continue; } resources.get(classloader).add(entry.getName()); } }
@Override public Set<V> get(K key) { /* * Note that this doesn't return a SortedSet when delegate is a * SortedSetMultiset, unlike (SortedSet<V>) super.get(). */ return Collections.unmodifiableSet(delegate().get(key)); }
private <T> Function<T, Optional<T>> createTranslator(SetMultimap<T, T> inputToOutput) { return input -> inputToOutput.get(input).stream().findAny(); }
private <T> Function<T, T> createDirectTranslator(SetMultimap<T, T> inputToOutput) { return input -> inputToOutput.get(input).iterator().next(); }
private synchronized TaskSource getSource(PlanNodeId planNodeId) { Set<ScheduledSplit> splits = pendingSplits.get(planNodeId); boolean pendingNoMoreSplits = Boolean.TRUE.equals(this.noMoreSplits.get(planNodeId)); boolean noMoreSplits = this.noMoreSplits.containsKey(planNodeId); Set<Lifespan> noMoreSplitsForLifespan = pendingNoMoreSplitsForLifespan.get(planNodeId); TaskSource element = null; if (!splits.isEmpty() || !noMoreSplitsForLifespan.isEmpty() || pendingNoMoreSplits) { element = new TaskSource(planNodeId, splits, noMoreSplitsForLifespan, noMoreSplits); } return element; }
@Override protected void scanJarFile(ClassLoader classloader, JarFile file) { Enumeration<JarEntry> entries = file.entries(); while (entries.hasMoreElements()) { JarEntry entry = entries.nextElement(); if (entry.isDirectory() || entry.getName().equals(JarFile.MANIFEST_NAME)) { continue; } resources.get(classloader).add(entry.getName()); } }
@Override public Set<V> get(K key) { synchronized (mutex) { return set(delegate().get(key), mutex); } }
@Override public Set<V> get(@Nullable K key) { return delegate().get(key); }
/** * Returns a canonical expression that is fully contained by the symbolScope and that is equivalent * to the specified expression. Returns null if unable to to find a canonical. */ @VisibleForTesting Expression getScopedCanonical(Expression expression, Predicate<Symbol> symbolScope) { Expression canonicalIndex = canonicalMap.get(expression); if (canonicalIndex == null) { return null; } return getCanonical(filter(equalitySets.get(canonicalIndex), symbolToExpressionPredicate(symbolScope))); }
public void revokeAllRolesFor(String username) { final RoleUser roleUser = new RoleUser(username); synchronized (roleToUsersMappings) { Set<PluginRoleConfig> pluginRoles = new HashSet<>(roleToUsersMappings.keySet()); for (PluginRoleConfig pluginRole : pluginRoles) { roleToUsersMappings.get(pluginRole).remove(roleUser); } } }
@GuardedBy("monitor") void checkHealthy() { if (states.count(RUNNING) != numberOfServices) { IllegalStateException exception = new IllegalStateException( "Expected to be healthy after starting. The following services are not running: " + Multimaps.filterKeys(servicesByState, not(equalTo(RUNNING)))); for (Service service : servicesByState.get(State.FAILED)) { exception.addSuppressed(new FailedService(service)); } throw exception; } } }
public void testFilteredKeysSetMultimapGetBadValue() { SetMultimap<String, Integer> multimap = LinkedHashMultimap.create(); multimap.put("foo", 1); multimap.put("bar", 2); multimap.put("baz", 3); multimap.put("bar", 4); SetMultimap<String, Integer> filtered = Multimaps.filterKeys(multimap, Predicates.in(ImmutableSet.of("foo", "bar"))); Set<Integer> bazSet = filtered.get("baz"); assertThat(bazSet).isEmpty(); try { bazSet.add(5); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { } try { bazSet.addAll(ImmutableSet.of(6, 7)); fail("Expected IllegalArgumentException"); } catch (IllegalArgumentException expected) { } }
@MapFeature.Require(SUPPORTS_PUT) public void testPutDuplicateValue() { List<Entry<K, V>> entries = copyToList(multimap().entries()); for (Entry<K, V> entry : entries) { resetContainer(); K k = entry.getKey(); V v = entry.getValue(); Set<V> values = multimap().get(k); Set<V> expectedValues = copyToSet(values); assertFalse(multimap().put(k, v)); assertEquals(expectedValues, values); assertGet(k, expectedValues); } }
@MapFeature.Require(SUPPORTS_PUT) public void testPutAllHandlesDuplicates() { @SuppressWarnings("unchecked") List<V> valuesToPut = Arrays.asList(v0(), v1(), v0()); for (K k : sampleKeys()) { resetContainer(); Set<V> expectedValues = copyToSet(multimap().get(k)); multimap().putAll(k, valuesToPut); expectedValues.addAll(valuesToPut); assertGet(k, expectedValues); } } }
@Override protected Set<String> create(String[] elements) { PopulatableMapAsMultimap<Integer, String> multimap = PopulatableMapAsMultimap.create(); populateMultimapForGet(multimap, elements); return multimap.build().get(3); } })
public void testNewSetMultimap() { CountingSupplier<Set<Integer>> factory = new SetSupplier(); Map<Color, Collection<Integer>> map = Maps.newHashMap(); SetMultimap<Color, Integer> multimap = Multimaps.newSetMultimap(map, factory); assertEquals(0, factory.count); multimap.putAll(Color.BLUE, asList(3, 1, 4)); assertEquals(1, factory.count); multimap.putAll(Color.RED, asList(2, 7, 1, 8)); assertEquals(2, factory.count); assertEquals(Sets.newHashSet(4, 3, 1), multimap.get(Color.BLUE)); }