public BoundVariables(Map<String, Type> typeVariables, Map<String, Long> longVariables) { requireNonNull(typeVariables, "typeVariableBindings is null"); requireNonNull(longVariables, "longVariableBindings is null"); this.typeVariables = ImmutableMap.copyOf(typeVariables); this.longVariables = ImmutableMap.copyOf(longVariables); }
/** * Returns an immutable map whose keys are the distinct elements of {@code keys} and whose value * for each key was computed by {@code valueFunction}. The map's iteration order is the order of * the first appearance of each key in {@code keys}. * * <p>When there are multiple instances of a key in {@code keys}, it is unspecified whether {@code * valueFunction} will be applied to more than one instance of that key and, if it is, which * result will be mapped to that key in the returned map. * * @throws NullPointerException if any element of {@code keys} is {@code null}, or if {@code * valueFunction} produces {@code null} for any key * @since 14.0 */ public static <K, V> ImmutableMap<K, V> toMap( Iterator<K> keys, Function<? super K, V> valueFunction) { checkNotNull(valueFunction); // Using LHM instead of a builder so as not to fail on duplicate keys Map<K, V> builder = newLinkedHashMap(); while (keys.hasNext()) { K key = keys.next(); builder.put(key, valueFunction.apply(key)); } return ImmutableMap.copyOf(builder); }
static <N, V> DirectedGraphConnections<N, V> ofImmutable( Set<N> predecessors, Map<N, V> successorValues) { Map<N, Object> adjacentNodeValues = new HashMap<>(); adjacentNodeValues.putAll(successorValues); for (N predecessor : predecessors) { Object value = adjacentNodeValues.put(predecessor, PRED); if (value != null) { adjacentNodeValues.put(predecessor, new PredAndSucc(value)); } } return new DirectedGraphConnections<>( ImmutableMap.copyOf(adjacentNodeValues), predecessors.size(), successorValues.size()); }
final Map<PartitionIdType, SequenceOffsetType> snapshot = ImmutableMap.copyOf(currOffsets); lastPersistedOffsets.clear(); lastPersistedOffsets.putAll(snapshot); currOffsets.put(record.getPartitionId(), record.getSequenceNumber()); } else if (createSequenceNumber(record.getSequenceNumber()).compareTo( createSequenceNumber(endOffsets.get(record.getPartitionId()))) <= 0) { "Handoff completed for segments %s with metadata[%s].", Lists.transform(handedOff.getSegments(), DataSegment::getId), Preconditions.checkNotNull(handedOff.getCommitMetadata(), "commitMetadata") );
public void set(Collection<ActiveRule> activeRules) { requireNonNull(activeRules, "Active rules cannot be null"); checkState(activeRulesByKey == null, "Active rules have already been initialized"); Map<RuleKey, ActiveRule> temp = new HashMap<>(); for (ActiveRule activeRule : activeRules) { ActiveRule previousValue = temp.put(activeRule.getRuleKey(), activeRule); if (previousValue != null) { throw new IllegalArgumentException("Active rule must not be declared multiple times: " + activeRule.getRuleKey()); } } activeRulesByKey = ImmutableMap.copyOf(temp); } }
@JsonCreator public StatisticAggregationsDescriptor( @JsonProperty("grouping") Map<String, T> grouping, @JsonProperty("tableStatistics") Map<TableStatisticType, T> tableStatistics, @JsonProperty("columnStatistics") Map<ColumnStatisticMetadata, T> columnStatistics) { this.grouping = ImmutableMap.copyOf(requireNonNull(grouping, "grouping is null")); this.tableStatistics = ImmutableMap.copyOf(requireNonNull(tableStatistics, "tableStatistics is null")); this.columnStatistics = ImmutableMap.copyOf(requireNonNull(columnStatistics, "columnStatistics is null")); }
private synchronized Map<String, ConnectorId> getCatalogNames() { // todo if repeatable read, this must be recorded Map<String, ConnectorId> catalogNames = new HashMap<>(); catalogByName.values().stream() .filter(Optional::isPresent) .map(Optional::get) .forEach(catalog -> catalogNames.put(catalog.getCatalogName(), catalog.getConnectorId())); catalogManager.getCatalogs().stream() .forEach(catalog -> catalogNames.putIfAbsent(catalog.getCatalogName(), catalog.getConnectorId())); return ImmutableMap.copyOf(catalogNames); }
public Builder(Global global, List<LocalProperty<Symbol>> localProperties, Map<Symbol, NullableValue> constants) { this.global = requireNonNull(global, "global is null"); this.localProperties = ImmutableList.copyOf(localProperties); this.constants = ImmutableMap.copyOf(constants); }
public JvmThreadsMonitor(Map<String, String[]> dimensions, String feed) { super(feed); Preconditions.checkNotNull(dimensions, "dimensions"); this.dimensions = ImmutableMap.copyOf(dimensions); }
private Job(final JobId id, final Builder.Parameters pm) { this.id = id; this.image = pm.image; this.hostname = pm.hostname; this.created = pm.created; this.command = ImmutableList.copyOf(checkNotNull(pm.command, "command")); this.env = ImmutableMap.copyOf(checkNotNull(pm.env, "env")); this.resources = pm.resources; this.ports = ImmutableMap.copyOf(checkNotNull(pm.ports, "ports")); this.registration = ImmutableMap.copyOf(checkNotNull(pm.registration, "registration")); this.gracePeriod = pm.gracePeriod; this.volumes = ImmutableMap.copyOf(checkNotNull(pm.volumes, "volumes")); this.expires = pm.expires; this.registrationDomain = Optional.fromNullable(pm.registrationDomain) .or(EMPTY_REGISTRATION_DOMAIN); this.creatingUser = pm.creatingUser; this.token = pm.token; this.healthCheck = pm.healthCheck; this.securityOpt = pm.securityOpt; this.networkMode = pm.networkMode; this.metadata = ImmutableMap.copyOf(pm.metadata); this.addCapabilities = ImmutableSet.copyOf(pm.addCapabilities); this.dropCapabilities = ImmutableSet.copyOf(pm.dropCapabilities); this.secondsToWaitBeforeKill = pm.secondsToWaitBeforeKill; this.labels = ImmutableMap.copyOf(pm.labels); this.ramdisks = ImmutableMap.copyOf(pm.ramdisks); this.rolloutOptions = pm.rolloutOptions; this.runtime = pm.runtime; }
@JsonCreator public HadoopDruidConverterConfig( @JsonProperty("dataSource") final String dataSource, @JsonProperty("interval") final Interval interval, @JsonProperty("indexSpec") final IndexSpec indexSpec, @JsonProperty("segments") final List<DataSegment> segments, @JsonProperty("validate") final Boolean validate, @JsonProperty("distributedSuccessCache") URI distributedSuccessCache, @JsonProperty("hadoopProperties") Map<String, String> hadoopProperties, @JsonProperty("jobPriority") String jobPriority, @JsonProperty("segmentOutputPath") String segmentOutputPath ) { this.dataSource = Preconditions.checkNotNull(dataSource, "dataSource"); this.interval = Preconditions.checkNotNull(interval, "interval"); this.indexSpec = Preconditions.checkNotNull(indexSpec, "indexSpec"); this.distributedSuccessCache = Preconditions.checkNotNull(distributedSuccessCache, "distributedSuccessCache"); this.segments = segments; this.validate = validate == null ? false : validate; this.hadoopProperties = hadoopProperties == null ? ImmutableMap.of() : ImmutableMap.copyOf(hadoopProperties); this.jobPriority = jobPriority; this.segmentOutputPath = Preconditions.checkNotNull(segmentOutputPath, "segmentOutputPath"); }
@JsonCreator public TableStatisticsData( @JsonProperty("rowCount") long rowCount, @JsonProperty("columns") Map<String, ColumnStatisticsData> columns) { this.rowCount = rowCount; this.columns = ImmutableMap.copyOf(columns); }
@JsonCreator public MesosResourcesObject(Map<String, Object> properties) { this.properties = ImmutableMap.copyOf(checkNotNull(properties, "properties is null")); }
@JsonProperty public Map<String, String> getMap() { return ImmutableMap.copyOf(map); }
/** * Returns an immutable map whose keys are the distinct elements of {@code keys} and whose value * for each key was computed by {@code valueFunction}. The map's iteration order is the order of * the first appearance of each key in {@code keys}. * * <p>When there are multiple instances of a key in {@code keys}, it is unspecified whether {@code * valueFunction} will be applied to more than one instance of that key and, if it is, which * result will be mapped to that key in the returned map. * * @throws NullPointerException if any element of {@code keys} is {@code null}, or if {@code * valueFunction} produces {@code null} for any key * @since 14.0 */ public static <K, V> ImmutableMap<K, V> toMap( Iterator<K> keys, Function<? super K, V> valueFunction) { checkNotNull(valueFunction); // Using LHM instead of a builder so as not to fail on duplicate keys Map<K, V> builder = newLinkedHashMap(); while (keys.hasNext()) { K key = keys.next(); builder.put(key, valueFunction.apply(key)); } return ImmutableMap.copyOf(builder); }
static <N, V> DirectedGraphConnections<N, V> ofImmutable( Set<N> predecessors, Map<N, V> successorValues) { Map<N, Object> adjacentNodeValues = new HashMap<>(); adjacentNodeValues.putAll(successorValues); for (N predecessor : predecessors) { Object value = adjacentNodeValues.put(predecessor, PRED); if (value != null) { adjacentNodeValues.put(predecessor, new PredAndSucc(value)); } } return new DirectedGraphConnections<>( ImmutableMap.copyOf(adjacentNodeValues), predecessors.size(), successorValues.size()); }
@JsonCreator public StatsAndCosts( @JsonProperty("stats") Map<PlanNodeId, PlanNodeStatsEstimate> stats, @JsonProperty("costs") Map<PlanNodeId, PlanNodeCostEstimate> costs) { this.stats = ImmutableMap.copyOf(requireNonNull(stats, "stats is null")); this.costs = ImmutableMap.copyOf(requireNonNull(costs, "costs is null")); }