@Override Map<K, Collection<V>> createAsMap() { return Maps.filterKeys(unfiltered.asMap(), keyPredicate); }
@Override Map<K, Collection<V>> createAsMap() { return Maps.filterKeys(unfiltered.asMap(), keyPredicate); }
@Override public List<K> apply(final V input) { return Lists.newArrayList(Maps.filterKeys(mapCache, new Predicate<K>() { @Override public boolean apply(K key) { V retVal = mapCache.get(key); if (retVal == null) { return false; } return retVal.equals(input); } }).keySet()); } }
public Message(final Map<String, Object> fields) { this((String) fields.get(FIELD_ID), Maps.filterKeys(fields, not(equalTo(FIELD_ID)))); }
@GET @Path("failed") public Collection<HeartbeatFailureDetector.Stats> getFailed() { return Maps.filterKeys(failureDetector.getStats(), in(failureDetector.getFailed())).values(); } }
private void logIt(String format) { if (t == null) { error(format, description, dataMap); } else { // Filter out the stack trace from the message, because it should be in the logline already if it's wanted. error( t, format, description, Maps.filterKeys(dataMap, Predicates.not(Predicates.equalTo("exceptionStackTrace"))) ); } } }
@Override protected Map<String, String> create(Entry<String, String>[] entries) { Map<String, String> map = Maps.newHashMap(); putEntries(map, entries); map.putAll(ENTRIES_TO_FILTER); return Maps.filterKeys(map, FILTER_KEYS); } })
@Override protected NavigableMap<String, String> create(Entry<String, String>[] entries) { NavigableMap<String, String> map = new SafeTreeMap<>(); putEntries(map, entries); map.put("banana", "toast"); map.put("eggplant", "spam"); return Maps.filterKeys(map, FILTER_KEYS); } })
public Map<String, Object> contents(AlertEvent a) { return Maps.filterKeys(a.toMap(), new Predicate<String>() { @Override public boolean apply(String k) { return !"timestamp".equals(k); } }); } }
@Override protected BiMap<String, String> create(Entry<String, String>[] entries) { BiMap<String, String> map = HashBiMap.create(); putEntries(map, entries); map.putAll(ENTRIES_TO_FILTER); return Maps.filterKeys(map, FILTER_KEYS); } })
public void testFilteredKeysIllegalPut() { Map<String, Integer> unfiltered = createUnfiltered(); Map<String, Integer> filtered = Maps.filterKeys(unfiltered, NOT_LENGTH_3); filtered.put("a", 1); filtered.put("b", 2); assertEquals(ImmutableMap.of("a", 1, "b", 2), filtered); try { filtered.put("yyy", 3); fail(); } catch (IllegalArgumentException expected) { } }
@Override protected SortedMap<String, String> create(Entry<String, String>[] entries) { SortedMap<String, String> map = new NonNavigableSortedMap(); putEntries(map, entries); map.putAll(ENTRIES_TO_FILTER); return Maps.filterKeys(map, FILTER_KEYS); } })
public void testFilteredKeysIllegalPutAll() { Map<String, Integer> unfiltered = createUnfiltered(); Map<String, Integer> filtered = Maps.filterKeys(unfiltered, NOT_LENGTH_3); filtered.put("a", 1); filtered.put("b", 2); assertEquals(ImmutableMap.of("a", 1, "b", 2), filtered); try { filtered.putAll(ImmutableMap.of("c", 3, "zzz", 4, "b", 5)); fail(); } catch (IllegalArgumentException expected) { } assertEquals(ImmutableMap.of("a", 1, "b", 2), filtered); }
public void testFilteredKeysFilteredReflectsBackingChanges() { Map<String, Integer> unfiltered = createUnfiltered(); Map<String, Integer> filtered = Maps.filterKeys(unfiltered, NOT_LENGTH_3); unfiltered.put("two", 2); unfiltered.put("three", 3); unfiltered.put("four", 4); assertEquals(ImmutableMap.of("two", 2, "three", 3, "four", 4), unfiltered); assertEquals(ImmutableMap.of("three", 3, "four", 4), filtered); unfiltered.remove("three"); assertEquals(ImmutableMap.of("two", 2, "four", 4), unfiltered); assertEquals(ImmutableMap.of("four", 4), filtered); unfiltered.clear(); assertEquals(ImmutableMap.of(), unfiltered); assertEquals(ImmutableMap.of(), filtered); }
private SubPlan buildFragment(PlanNode root, FragmentProperties properties, PlanFragmentId fragmentId) { Set<Symbol> dependencies = SymbolsExtractor.extractOutputSymbols(root); List<PlanNodeId> schedulingOrder = scheduleOrder(root); boolean equals = properties.getPartitionedSources().equals(ImmutableSet.copyOf(schedulingOrder)); checkArgument(equals, "Expected scheduling order (%s) to contain an entry for all partitioned sources (%s)", schedulingOrder, properties.getPartitionedSources()); PlanFragment fragment = new PlanFragment( fragmentId, root, Maps.filterKeys(types.allTypes(), in(dependencies)), properties.getPartitioningHandle(), schedulingOrder, properties.getPartitioningScheme(), StageExecutionDescriptor.ungroupedExecution(), statsAndCosts.getForSubplan(root)); return new SubPlan(fragment, properties.getChildren()); }
@Test(dataProvider = "caches") @CacheSpec(population = { Population.PARTIAL, Population.FULL }) public void invalidateAll_partial(Cache<Integer, Integer> cache, CacheContext context) { List<Integer> keys = cache.asMap().keySet().stream() .filter(i -> ((i % 2) == 0)) .collect(Collectors.toList()); cache.invalidateAll(keys); assertThat(cache.estimatedSize(), is(context.initialSize() - keys.size())); assertThat(cache, hasRemovalNotifications(context, keys.size(), RemovalCause.EXPLICIT)); verifyWriter(context, (verifier, writer) -> { verifier.deletedAll(Maps.filterKeys(context.original(), Predicates.in(keys)), RemovalCause.EXPLICIT); }); }
@BeforeMethod public void setUp() { scanAssignments = ImmutableMap.<Symbol, ColumnHandle>builder() .put(A, new TestingColumnHandle("a")) .put(B, new TestingColumnHandle("b")) .put(C, new TestingColumnHandle("c")) .put(D, new TestingColumnHandle("d")) .put(E, new TestingColumnHandle("e")) .put(F, new TestingColumnHandle("f")) .build(); Map<Symbol, ColumnHandle> assignments = Maps.filterKeys(scanAssignments, Predicates.in(ImmutableList.of(A, B, C, D, E, F))); baseTableScan = new TableScanNode( newId(), DUAL_TABLE_HANDLE, ImmutableList.copyOf(assignments.keySet()), assignments); expressionNormalizer = new ExpressionIdentityNormalizer(); }
@Override protected Optional<PlanNode> pushDownProjectOff(PlanNodeIdAllocator idAllocator, TableScanNode tableScanNode, Set<Symbol> referencedOutputs) { return Optional.of( new TableScanNode( tableScanNode.getId(), tableScanNode.getTable(), filteredCopy(tableScanNode.getOutputSymbols(), referencedOutputs::contains), filterKeys(tableScanNode.getAssignments(), referencedOutputs::contains), tableScanNode.getLayout(), tableScanNode.getCurrentConstraint(), tableScanNode.getEnforcedConstraint())); } }
/** * Return measures that were added by the step (using {@link #add(Component, Metric, Measure)}). * It does not contain the one added in the test by {@link #addRawMeasure(int, String, Measure)} */ public SetMultimap<String, Measure> getAddedRawMeasures(Component component) { checkAndInitProvidersState(); ImmutableSetMultimap.Builder<String, Measure> builder = ImmutableSetMultimap.builder(); for (Map.Entry<InternalKey, Measure> entry : from(filterKeys(rawMeasures, hasComponentRef(component)).entrySet()).filter(isAddedMeasure)) { builder.put(entry.getKey().getMetricKey(), entry.getValue()); } return builder.build(); }
@Override public SetMultimap<String, Measure> getRawMeasures(Component component) { ImmutableSetMultimap.Builder<String, Measure> builder = ImmutableSetMultimap.builder(); for (Map.Entry<InternalKey, Measure> entry : filterKeys(rawMeasures, hasComponentRef(component)).entrySet()) { builder.put(entry.getKey().getMetricKey(), entry.getValue()); } return builder.build(); }