@Override public Map<Symbol, Symbol> visitProject(ProjectNode node, Set<Symbol> lookupSymbols) { // Map from output Symbols to source Symbols Map<Symbol, Symbol> directSymbolTranslationOutputMap = Maps.transformValues( Maps.filterValues(node.getAssignments(), SymbolReference.class::isInstance), Symbol::from); Map<Symbol, Symbol> outputToSourceMap = lookupSymbols .stream() .filter(directSymbolTranslationOutputMap.keySet()::contains) .collect(toImmutableMap(identity(), directSymbolTranslationOutputMap::get)); checkState( !outputToSourceMap.isEmpty(), "No lookup symbols were able to pass through the projection"); // Map from source Symbols to underlying index source Symbols Map<Symbol, Symbol> sourceToIndexMap = node.getSource().accept(this, ImmutableSet.copyOf(outputToSourceMap.values())); // Generate the Map the connects lookup symbols to underlying index source symbols Map<Symbol, Symbol> outputToIndexMap = Maps.transformValues( Maps.filterValues(outputToSourceMap, in(sourceToIndexMap.keySet())), Functions.forMap(sourceToIndexMap)); return ImmutableMap.copyOf(outputToIndexMap); }
@Override public Map<Set<Entry<String, String>>, Integer> getAllDefaultValues() { return Maps.filterValues( Maps.transformValues( segments, dataEntry -> dataEntry == null ? null : dataEntry.getPermissionDefault()), v -> v != null); }
@Override public Map<Set<Entry<String, String>>, Map<String, Integer>> getAllPermissions() { return Maps.filterValues( Maps.transformValues( segments, dataEntry -> dataEntry == null ? null : dataEntry.getPermissions()), o -> o != null); }
@Override public Map<Set<Entry<String, String>>, Map<String, String>> getAllOptions() { return Maps.filterValues( Maps.transformValues( segments, dataEntry -> dataEntry == null ? null : dataEntry.getOptions()), el -> el != null); }
@Override public PlanNode visitIndexSource(IndexSourceNode node, RewriteContext<Set<Symbol>> context) { List<Symbol> newOutputSymbols = node.getOutputSymbols() .stream() .filter(context.get()::contains) .collect(toImmutableList()); Set<Symbol> newLookupSymbols = node.getLookupSymbols() .stream() .filter(context.get()::contains) .collect(toImmutableSet()); Set<Symbol> requiredAssignmentSymbols = context.get(); if (!node.getEffectiveTupleDomain().isNone()) { Set<Symbol> requiredSymbols = Maps.filterValues( node.getAssignments(), in(node.getEffectiveTupleDomain().getDomains().get().keySet())) .keySet(); requiredAssignmentSymbols = Sets.union(context.get(), requiredSymbols); } Map<Symbol, ColumnHandle> newAssignments = Maps.filterKeys(node.getAssignments(), in(requiredAssignmentSymbols)); return new IndexSourceNode( node.getId(), node.getIndexHandle(), node.getTableHandle(), newLookupSymbols, newOutputSymbols, newAssignments, node.getEffectiveTupleDomain()); }
@Override public Map<SkyKey, SkyValue> getSuccessfulValues(Iterable<SkyKey> keys) { return Maps.filterValues( Maps.transformValues( graph.getBatch(null, Reason.WALKABLE_GRAPH_VALUE, keys), GET_SKY_VALUE_FUNCTION), Predicates.notNull()); }
@Override public Set<Map.Entry<K, V>> entrySet() { checkState(!destroyed, destroyedMessage); return Maps.filterValues(items, MapValue::isAlive) .entrySet() .stream() .map(e -> Pair.of(e.getKey(), e.getValue().get())) .collect(Collectors.toSet()); }
public static Map<String, Key> getKeyInstances(final EvaluationConstraint constraint) { return Maps.transformValues( Maps.filterValues( KEY_MAP, CollectionUtils.propertyContainsPredicate( constraint, Functions.compose( PolicyKeyToEvaluationConstraints.INSTANCE, KeyClassToPolicyKey.INSTANCE))), KeyClassToKeyInstance.INSTANCE); }
@Override public Map<Set<Entry<String, String>>, List<Entry<String, String>>> getAllParents() { return Maps.filterValues( Maps.transformValues( segments, dataEntry -> dataEntry == null ? null : dataEntry.getParents() == null ? null : ImmutableList.copyOf(dataEntry.getParents())), v -> v != null); }
private Map<String, EquivalenceSummary> summaryMap( OptionalMap<String, EquivalenceSummary> childSummaries) { return Maps.filterValues( Maps.transformValues( childSummaries, new Function<Optional<EquivalenceSummary>, EquivalenceSummary>() { @Override public EquivalenceSummary apply(@Nullable Optional<EquivalenceSummary> input) { return input.orNull(); } }), Predicates.notNull()); }
@Override public void storeItemCooldowns(Player player) { deleteItemCooldowns(player); Map<Integer, ItemCooldown> itemCoolDowns = player.getItemCoolDowns(); if (itemCoolDowns == null) return; Map<Integer, ItemCooldown> map = Maps.filterValues(itemCoolDowns, itemCooldownPredicate); final Iterator<Map.Entry<Integer, ItemCooldown>> iterator = map.entrySet().iterator(); if (!iterator.hasNext()) { return; } Connection con = null; PreparedStatement st = null; try { con = DatabaseFactory.getConnection(); con.setAutoCommit(false); st = con.prepareStatement(INSERT_QUERY); while (iterator.hasNext()) { Map.Entry<Integer, ItemCooldown> entry = iterator.next(); st.setInt(1, player.getObjectId()); st.setInt(2, entry.getKey()); st.setInt(3, entry.getValue().getUseDelay()); st.setLong(4, entry.getValue().getReuseTime()); st.addBatch(); } st.executeBatch(); con.commit(); } catch (SQLException e) { log.error("Error while storing item cooldows for player " + player.getObjectId(), e); } finally { DatabaseFactory.close(st, con); } }
private Set<String> boundKeys() { return Maps.filterValues(bindKeysMap, input -> input.getType() == Value.Type.UNBOUND) .keySet(); }
@Override public Collection<V> values() { checkState(!destroyed, destroyedMessage); return Collections2.transform( Maps.filterValues(items, MapValue::isAlive).values(), MapValue::get); }
@Override public Set<K> keySet() { checkState(!destroyed, destroyedMessage); return Maps.filterValues(items, MapValue::isAlive).keySet(); }
@Override public void clear() { checkState(!destroyed, destroyedMessage); Maps.filterValues(items, MapValue::isAlive).forEach((k, v) -> remove(k)); }
@Override public int size() { checkState(!destroyed, destroyedMessage); // TODO: Maintain a separate counter for tracking live elements in map. return Maps.filterValues(items, MapValue::isAlive).size(); }