@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; }
/** * Adds the given {@code entry} to the bimap. Duplicate keys or values * are not allowed, and will cause {@link #build} to fail. * * @since 19.0 */ @CanIgnoreReturnValue @Override public Builder<K, V> put(Entry<? extends K, ? extends V> entry) { super.put(entry); return this; }
Object createMap(Builder<Object, Object> builder) { for (int i = 0; i < keys.length; i++) { builder.put(keys[i], values[i]); } return builder.build(); }
public LogicalPlanBuilder addStorageEngine(String name, StoragePluginConfig config) { this.storageEngines.put(name, config); return this; } public LogicalPlanBuilder addLogicalOperator(LogicalOperator operator) {
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(); }
/** * Associates {@code key} with {@code value} in the built bimap. Duplicate * keys or values are not allowed, and will cause {@link #build} to fail. */ @CanIgnoreReturnValue @Override public Builder<K, V> put(K key, V value) { super.put(key, value); return this; }
static <T, K, V> Collector<T, ?, ImmutableMap<K, V>> toImmutableMap( Function<? super T, ? extends K> keyFunction, Function<? super T, ? extends V> valueFunction) { checkNotNull(keyFunction); checkNotNull(valueFunction); return Collector.of( ImmutableMap.Builder<K, V>::new, (builder, input) -> builder.put(keyFunction.apply(input), valueFunction.apply(input)), ImmutableMap.Builder::combine, ImmutableMap.Builder::build); }
/** * Associates {@code key} with {@code value} in the built map. Duplicate * keys are not allowed, and will cause {@link #build} to fail. */ @CanIgnoreReturnValue public <T extends B> Builder<B> put(Class<T> key, T value) { mapBuilder.put(key, value); return this; }
/** * Adds the given {@code entry} to the map, making it immutable if * necessary. Duplicate keys are not allowed, and will cause {@link #build} * to fail. * * @since 11.0 */ @CanIgnoreReturnValue public Builder<K, V> put(Entry<? extends K, ? extends V> entry) { return put(entry.getKey(), entry.getValue()); }
/** * 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(); }
/** * Associates {@code key} with {@code value} in the built map. Duplicate keys are not allowed, * and will cause {@link #build} to fail. */ @CanIgnoreReturnValue public <T extends B> Builder<B> put(TypeToken<T> key, T value) { mapBuilder.put(key.rejectTypeVariables(), value); return this; }
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 LogicalPlanBuilder addStorageEngine(String name, StoragePluginConfig config) { this.storageEngines.put(name, config); return this; } public LogicalPlanBuilder addLogicalOperator(LogicalOperator operator) {