List of usage examples for com.google.common.collect Maps filterKeys
@CheckReturnValue public static <K, V> BiMap<K, V> filterKeys(BiMap<K, V> unfiltered, final Predicate<? super K> keyPredicate)
From source file:com.proofpoint.tracetoken.TraceToken.java
@JsonValue
Map<String, String> getJson() {
return Maps.filterKeys(this, key -> !key.startsWith("_"));
}
From source file:zotmc.collect.FluentMap.java
public FluentMap<K, V> filterKeys(Predicate<? super K> keyPredicate) { return from(Maps.filterKeys(delegatee(), keyPredicate)); }
From source file:io.prestosql.sql.planner.iterative.rule.PruneWindowColumns.java
@Override protected Optional<PlanNode> pushDownProjectOff(PlanNodeIdAllocator idAllocator, WindowNode windowNode, Set<Symbol> referencedOutputs) { Map<Symbol, WindowNode.Function> referencedFunctions = Maps.filterKeys(windowNode.getWindowFunctions(), referencedOutputs::contains); if (referencedFunctions.isEmpty()) { return Optional.of(windowNode.getSource()); }/*w ww . j a va 2 s .c om*/ ImmutableSet.Builder<Symbol> referencedInputs = ImmutableSet.<Symbol>builder().addAll( windowNode.getSource().getOutputSymbols().stream().filter(referencedOutputs::contains).iterator()) .addAll(windowNode.getPartitionBy()); windowNode.getOrderingScheme() .ifPresent(orderingScheme -> orderingScheme.getOrderBy().forEach(referencedInputs::add)); windowNode.getHashSymbol().ifPresent(referencedInputs::add); for (WindowNode.Function windowFunction : referencedFunctions.values()) { referencedInputs.addAll(SymbolsExtractor.extractUnique(windowFunction.getFunctionCall())); windowFunction.getFrame().getStartValue().ifPresent(referencedInputs::add); windowFunction.getFrame().getEndValue().ifPresent(referencedInputs::add); } PlanNode prunedWindowNode = new WindowNode(windowNode.getId(), restrictOutputs(idAllocator, windowNode.getSource(), referencedInputs.build()) .orElse(windowNode.getSource()), windowNode.getSpecification(), referencedFunctions, windowNode.getHashSymbol(), windowNode.getPrePartitionedInputs(), windowNode.getPreSortedOrderPrefix()); if (prunedWindowNode.getOutputSymbols().size() == windowNode.getOutputSymbols().size()) { // Neither function pruning nor input pruning was successful. return Optional.empty(); } return Optional.of(prunedWindowNode); }
From source file:com.facebook.presto.sql.planner.iterative.rule.PruneWindowColumns.java
@Override protected Optional<PlanNode> pushDownProjectOff(PlanNodeIdAllocator idAllocator, WindowNode windowNode, Set<Symbol> referencedOutputs) { Map<Symbol, WindowNode.Function> referencedFunctions = Maps.filterKeys(windowNode.getWindowFunctions(), referencedOutputs::contains); if (referencedFunctions.isEmpty()) { return Optional.of(windowNode.getSource()); }/* w w w. ja va 2s. co m*/ ImmutableSet.Builder<Symbol> referencedInputs = ImmutableSet .<Symbol>builder().addAll(windowNode.getSource().getOutputSymbols().stream() .filter(referencedOutputs::contains).iterator()) .addAll(windowNode.getPartitionBy()).addAll(windowNode.getOrderBy()); windowNode.getHashSymbol().ifPresent(referencedInputs::add); for (WindowNode.Function windowFunction : referencedFunctions.values()) { referencedInputs.addAll(SymbolsExtractor.extractUnique(windowFunction.getFunctionCall())); windowFunction.getFrame().getStartValue().ifPresent(referencedInputs::add); windowFunction.getFrame().getEndValue().ifPresent(referencedInputs::add); } PlanNode prunedWindowNode = new WindowNode(windowNode.getId(), restrictOutputs(idAllocator, windowNode.getSource(), referencedInputs.build()) .orElse(windowNode.getSource()), windowNode.getSpecification(), referencedFunctions, windowNode.getHashSymbol(), windowNode.getPrePartitionedInputs(), windowNode.getPreSortedOrderPrefix()); if (prunedWindowNode.getOutputSymbols().size() == windowNode.getOutputSymbols().size()) { // Neither function pruning nor input pruning was successful. return Optional.empty(); } return Optional.of(prunedWindowNode); }
From source file:io.mindmaps.graql.internal.query.match.MatchQuerySelect.java
@Override public Stream<Map<String, Concept>> transformStream(Stream<Map<String, Concept>> stream) { return stream.map(result -> Maps.filterKeys(result, names::contains)); }
From source file:eu.lp0.cursus.scoring.scores.impl.GenericOverallPointsData.java
@Override protected int calculateOverallPoints(Pilot pilot) { int points = 0; // Add race points but not discards for (Entry<Race, Integer> racePoints : Maps.filterKeys(scores.getRacePoints(pilot), Predicates.not(Predicates.in(scores.getDiscardedRaces(pilot)))).entrySet()) { points += racePoints.getValue(); }//from w ww . j a v a2 s . c o m // Add all penalties (this includes race penalties) points += scores.getOverallPenalties(pilot); if (points < 0) { points = 0; } return points; }
From source file:com.b2international.commons.dynamic.DynamicMapImpl.java
@SuppressWarnings("unchecked") public DynamicMapImpl(Map<?, ?> map) { valueMap = ImmutableMap.copyOf((Map<String, DynamicValue>) Maps .transformValues(Maps.filterKeys(map, stringKeyFilter), valueConverter)); }
From source file:eu.redzoo.reactive.kafka.rest.Environment.java
public ImmutableMap<String, String> getConfigValues(ImmutableSet<String> names) { return ImmutableMap.copyOf(Maps.filterKeys(configs, name -> names.contains(name))); }
From source file:org.jclouds.docker.compute.functions.CustomLoginPortFromImage.java
@Override public Optional<Integer> apply(final Container container) { Map<String, Set<LoginPortForContainer>> matchingFunctions = Maps.filterKeys(imageToPortLookup, new Predicate<String>() { @Override//from w w w .j a v a 2 s . co m public boolean apply(String input) { return container.config().image().matches(input); } }); // We allow to provide several forms in the image-to-function map: // - redis // - redis:12 // - owner/redis:12 // - registry:5000/owner/redis:12 // We consider the longest match first, as it is the more accurate one List<String> sortedImages = new ArrayList<String>(matchingFunctions.keySet()); Collections.sort(sortedImages, LongestStringFirst); for (String currentImage : sortedImages) { Set<LoginPortForContainer> functions = matchingFunctions.get(currentImage); for (LoginPortForContainer function : functions) { Optional<Integer> port = function.apply(container); if (port.isPresent()) { return port; } } } return Optional.absent(); }
From source file:io.fabric8.process.fabric.child.tasks.ApplyConfigurationTask.java
@Override public void install(ProcessConfig config, String id, File installDir) throws Exception { Map<String, String> templates = Maps.filterKeys(configuration, isTemplate); Map<String, String> plainFiles = Maps.difference(configuration, templates).entriesOnlyOnLeft(); Map<String, String> renderedTemplates = Maps.transformValues(templates, new MvelTemplateRendering(variables)); File baseDir = ProcessUtils.findInstallDir(installDir); applyTemplates(renderedTemplates, baseDir); applyPlainConfiguration(plainFiles, baseDir); }