@JsonCreator public AnnotationDescriptor( @JsonProperty("annotationType") String annotationType, @JsonProperty("attributes") List<AttributeDescriptor> attributes) { this.annotationType = annotationType; this.attributes = Collections.unmodifiableList(attributes); ImmutableMap.Builder<String, AttributeDescriptor> mapBuilder = ImmutableMap.builder(); for (AttributeDescriptor att : attributes) { mapBuilder.put(att.getName(), att); } this.attributeMap = mapBuilder.build(); }
/** * Returns a new instance of {@link ImmutableMap} with key case-insensitivity. This map is built from the given * map. See {@link ImmutableMap}. * * @param map map to copy from * @param <VALUE> type of values to be stored in the map * @return key case-insensitive immutable map */ public static <VALUE> CaseInsensitiveMap<VALUE> newImmutableMap(final Map<? extends String, ? extends VALUE> map) { final ImmutableMap.Builder<String, VALUE> builder = ImmutableMap.builder(); for (final Entry<? extends String, ? extends VALUE> entry : map.entrySet()) { builder.put(entry.getKey().toLowerCase(), entry.getValue()); } return new CaseInsensitiveMap<>(builder.build()); }
public List<KafkaPartitionScanSpec> parseTree() { ImmutableMap.Builder<TopicPartition, KafkaPartitionScanSpec> builder = ImmutableMap.builder(); for(KafkaPartitionScanSpec scanSpec : groupScan.getPartitionScanSpecList()) { builder.put(new TopicPartition(scanSpec.getTopicName(), scanSpec.getPartitionId()), scanSpec); } fullScanSpec = builder.build(); List<KafkaPartitionScanSpec> pushdownSpec = le.accept(this, null); /* Non-existing / invalid partitions may result in empty scan spec. This results in a "ScanBatch" with no reader. DRILL currently requires at least one reader to be present in a scan batch. */ if(pushdownSpec != null && pushdownSpec.isEmpty()) { TopicPartition firstPartition = new TopicPartition(groupScan.getKafkaScanSpec().getTopicName(), 0); KafkaPartitionScanSpec emptySpec = new KafkaPartitionScanSpec(firstPartition.topic(),firstPartition.partition(), fullScanSpec.get(firstPartition).getEndOffset(), fullScanSpec.get(firstPartition).getEndOffset()); pushdownSpec.add(emptySpec); } return pushdownSpec; }
private static Map<String, Object> createModel(final boolean authEnabled, final SecurityContext sc, final boolean showControls, final Object pageModel) { final boolean isAdmin = !authEnabled /* when auth is disabled every user is an admin user */ || (showControls && sc.isUserInRole(DrillUserPrincipal.ADMIN_ROLE)); final boolean isUserLoggedIn = AuthDynamicFeature.isUserLoggedIn(sc); final ImmutableMap.Builder<String, Object> mapBuilder = ImmutableMap.<String, Object>builder() .put("showStorage", isAdmin) .put("showOptions", isAdmin) .put("showThreads", isAdmin) .put("showLogs", isAdmin) .put("showLogin", authEnabled && showControls && !isUserLoggedIn) .put("showLogout", authEnabled && showControls && isUserLoggedIn) .put("loggedInUserName", authEnabled && showControls && isUserLoggedIn ? sc.getUserPrincipal().getName() : DrillUserPrincipal.ANONYMOUS_USER).put("showControls", showControls); if (pageModel != null) { mapBuilder.put("model", pageModel); } return mapBuilder.build(); } }
/** * Returns a new instance of {@link ImmutableMap} with key case-insensitivity. This map is built from the given * map. See {@link ImmutableMap}. * * @param map map to copy from * @param <VALUE> type of values to be stored in the map * @return key case-insensitive immutable map */ public static <VALUE> CaseInsensitiveMap<VALUE> newImmutableMap(final Map<? extends String, ? extends VALUE> map) { final ImmutableMap.Builder<String, VALUE> builder = ImmutableMap.builder(); for (final Entry<? extends String, ? extends VALUE> entry : map.entrySet()) { builder.put(entry.getKey().toLowerCase(), entry.getValue()); } return new CaseInsensitiveMap<>(builder.build()); }
/** * Parses a serialized trie representation of a map of reversed public suffixes into an immutable * map of public suffixes. */ static ImmutableMap<String, PublicSuffixType> parseTrie(CharSequence encoded) { ImmutableMap.Builder<String, PublicSuffixType> builder = ImmutableMap.builder(); int encodedLen = encoded.length(); int idx = 0; while (idx < encodedLen) { idx += doParseTrieToBuilder( Lists.<CharSequence>newLinkedList(), encoded.subSequence(idx, encodedLen), builder); } return builder.build(); }
/** * Returns a new immutable class-to-instance map containing the entries * provided to this builder. * * @throws IllegalArgumentException if duplicate keys were added */ public ImmutableClassToInstanceMap<B> build() { ImmutableMap<Class<? extends B>, B> map = mapBuilder.build(); if (map.isEmpty()) { return of(); } else { return new ImmutableClassToInstanceMap<B>(map); } } }
public LogicalPlan build() { return new LogicalPlan(this.planProperties, this.storageEngines.build(), this.operators.build()); } }
Object createMap(Builder<Object, Object> builder) { for (int i = 0; i < keys.length; i++) { builder.put(keys[i], values[i]); } return builder.build(); }
/** * Returns a new immutable type-to-instance map containing the entries provided to this builder. * * @throws IllegalArgumentException if duplicate keys were added */ public ImmutableTypeToInstanceMap<B> build() { return new ImmutableTypeToInstanceMap<B>(mapBuilder.build()); } }
private static <N> ImmutableMap<N, GraphConnections<N, Presence>> getNodeConnections( Graph<N> graph) { // ImmutableMap.Builder maintains the order of the elements as inserted, so the map will have // whatever ordering the graph's nodes do, so ImmutableSortedMap is unnecessary even if the // input nodes are sorted. ImmutableMap.Builder<N, GraphConnections<N, Presence>> nodeConnections = ImmutableMap.builder(); for (N node : graph.nodes()) { nodeConnections.put(node, connectionsOf(graph, node)); } return nodeConnections.build(); }
private static <N, V> ImmutableMap<N, GraphConnections<N, V>> getNodeConnections( ValueGraph<N, V> graph) { // ImmutableMap.Builder maintains the order of the elements as inserted, so the map will have // whatever ordering the graph's nodes do, so ImmutableSortedMap is unnecessary even if the // input nodes are sorted. ImmutableMap.Builder<N, GraphConnections<N, V>> nodeConnections = ImmutableMap.builder(); for (N node : graph.nodes()) { nodeConnections.put(node, connectionsOf(graph, node)); } return nodeConnections.build(); }
/** Returns a new {@code TypeResolver} with {@code variable} mapping to {@code type}. */ final TypeTable where(Map<TypeVariableKey, ? extends Type> mappings) { ImmutableMap.Builder<TypeVariableKey, Type> builder = ImmutableMap.builder(); builder.putAll(map); for (Map.Entry<TypeVariableKey, ? extends Type> mapping : mappings.entrySet()) { TypeVariableKey variable = mapping.getKey(); Type type = mapping.getValue(); checkArgument(!variable.equalsType(type), "Type variable %s bound to itself", variable); builder.put(variable, type); } return new TypeTable(builder.build()); }
private static <N, E> Map<E, N> getEdgeToReferenceNode(Network<N, E> network) { // ImmutableMap.Builder maintains the order of the elements as inserted, so the map will have // whatever ordering the network's edges do, so ImmutableSortedMap is unnecessary even if the // input edges are sorted. ImmutableMap.Builder<E, N> edgeToReferenceNode = ImmutableMap.builder(); for (E edge : network.edges()) { edgeToReferenceNode.put(edge, network.incidentNodes(edge).nodeU()); } return edgeToReferenceNode.build(); }
private static <N, E> Map<N, NetworkConnections<N, E>> getNodeConnections(Network<N, E> network) { // ImmutableMap.Builder maintains the order of the elements as inserted, so the map will have // whatever ordering the network's nodes do, so ImmutableSortedMap is unnecessary even if the // input nodes are sorted. ImmutableMap.Builder<N, NetworkConnections<N, E>> nodeConnections = ImmutableMap.builder(); for (N node : network.nodes()) { nodeConnections.put(node, connectionsOf(network, node)); } return nodeConnections.build(); }
@JsonCreator public AnnotationDescriptor( @JsonProperty("annotationType") String annotationType, @JsonProperty("attributes") List<AttributeDescriptor> attributes) { this.annotationType = annotationType; this.attributes = Collections.unmodifiableList(attributes); ImmutableMap.Builder<String, AttributeDescriptor> mapBuilder = ImmutableMap.builder(); for (AttributeDescriptor att : attributes) { mapBuilder.put(att.getName(), att); } this.attributeMap = mapBuilder.build(); }
/** * Returns a map from the ith element of list to i. */ static <E> ImmutableMap<E, Integer> indexMap(Collection<E> list) { ImmutableMap.Builder<E, Integer> builder = new ImmutableMap.Builder<E, Integer>(list.size()); int i = 0; for (E e : list) { builder.put(e, i++); } return builder.build(); }
static Map<String, AnnotationDescriptor> buildAnnotationsMap(List<AnnotationDescriptor> annotations) { ImmutableMap.Builder<String, AnnotationDescriptor> annMapBuilder = ImmutableMap.builder(); for (AnnotationDescriptor ann : annotations) { annMapBuilder.put(ann.getAnnotationType(), ann); } return annMapBuilder.build(); }
static Map<String, AnnotationDescriptor> buildAnnotationsMap(List<AnnotationDescriptor> annotations) { ImmutableMap.Builder<String, AnnotationDescriptor> annMapBuilder = ImmutableMap.builder(); for (AnnotationDescriptor ann : annotations) { annMapBuilder.put(ann.getAnnotationType(), ann); } return annMapBuilder.build(); }
public LogicalPlan build() { return new LogicalPlan(this.planProperties, this.storageEngines.build(), this.operators.build()); } }