/** 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 (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()); }
public void testBuilderPutAll() { Map<String, Integer> toPut = new LinkedHashMap<>(); toPut.put("one", 1); toPut.put("two", 2); toPut.put("three", 3); Map<String, Integer> moreToPut = new LinkedHashMap<>(); moreToPut.put("four", 4); moreToPut.put("five", 5); ImmutableMap<String, Integer> map = new Builder<String, Integer>().putAll(toPut).putAll(moreToPut).build(); assertMapEquals(map, "one", 1, "two", 2, "three", 3, "four", 4, "five", 5); }
/** * Submits an event for a given {@link TaskState}. It will include all metadata specified in the jobMetadata parameter. */ private void submitTaskStateEvent(TaskState taskState, Map<String, String> jobMetadata) { ImmutableMap.Builder<String, String> taskMetadataBuilder = new ImmutableMap.Builder<>(); taskMetadataBuilder.putAll(jobMetadata); taskMetadataBuilder.put(METADATA_TASK_ID, taskState.getTaskId()); taskMetadataBuilder.put(METADATA_TASK_START_TIME, Long.toString(taskState.getStartTime())); taskMetadataBuilder.put(METADATA_TASK_END_TIME, Long.toString(taskState.getEndTime())); taskMetadataBuilder.put(METADATA_TASK_WORKING_STATE, taskState.getWorkingState().toString()); taskMetadataBuilder.put(METADATA_TASK_FAILURE_CONTEXT, taskState.getTaskFailureException().or(UNKNOWN_VALUE)); taskMetadataBuilder.put(EventSubmitter.EVENT_TYPE, TASK_STATE); this.eventSubmitter.submit(TASK_STATE, taskMetadataBuilder.build()); } }
private Map<Symbol, Integer> createJoinSourcesLayout(Map<Symbol, Integer> lookupSourceLayout, Map<Symbol, Integer> probeSourceLayout) { Builder<Symbol, Integer> joinSourcesLayout = ImmutableMap.builder(); joinSourcesLayout.putAll(lookupSourceLayout); for (Map.Entry<Symbol, Integer> probeLayoutEntry : probeSourceLayout.entrySet()) { joinSourcesLayout.put(probeLayoutEntry.getKey(), probeLayoutEntry.getValue() + lookupSourceLayout.size()); } return joinSourcesLayout.build(); }
public ServiceEmitter( String service, String host, Emitter emitter, ImmutableMap<String, String> otherServiceDimensions ) { this.serviceDimensions = ImmutableMap .<String, String>builder() .put("service", Preconditions.checkNotNull(service)) .put("host", Preconditions.checkNotNull(host)) .putAll(otherServiceDimensions) .build(); this.emitter = emitter; }
@Override @JsonValue public Map<String, Object> toMap() { return ImmutableMap.<String, Object>builder() .put("feed", getFeed()) .put("timestamp", createdTime.toString()) .putAll(serviceDimensions) .put("severity", severity.toString()) .put("description", description) .put("data", dataMap) .build(); }
@Override public Map<Integer, ColumnStatistics> finishRowGroup() { checkState(!closed); ColumnStatistics statistics = new ColumnStatistics((long) nonNullValueCount, 0, null, null, null, null, null, null, null, null); rowGroupColumnStatistics.add(statistics); nonNullValueCount = 0; ImmutableMap.Builder<Integer, ColumnStatistics> columnStatistics = ImmutableMap.builder(); columnStatistics.put(column, statistics); columnStatistics.putAll(elementWriter.finishRowGroup()); return columnStatistics.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 (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()); }
public ShrunkenDictionary(ValueSerializer<T> valueSerializer, int minId, int maxId, int sizeOfId, int sizeOfValue, Map<T, Integer> valueToIdMap) { this.valueSerializer = valueSerializer; this.minId = minId; this.maxId = maxId; this.sizeOfId = sizeOfId; this.sizeOfValue = sizeOfValue; Preconditions.checkNotNull(valueToIdMap); this.valueToIdMap = ImmutableMap.<T, Integer> builder().putAll(valueToIdMap).build(); }
@Override public Map<Integer, ColumnEncoding> getColumnEncodings() { ImmutableMap.Builder<Integer, ColumnEncoding> encodings = ImmutableMap.builder(); encodings.put(column, columnEncoding); encodings.putAll(keyWriter.getColumnEncodings()); encodings.putAll(valueWriter.getColumnEncodings()); return encodings.build(); }
@Override public Map<Integer, ColumnStatistics> getColumnStripeStatistics() { checkState(closed); ImmutableMap.Builder<Integer, ColumnStatistics> columnStatistics = ImmutableMap.builder(); columnStatistics.put(column, ColumnStatistics.mergeColumnStatistics(rowGroupColumnStatistics)); columnStatistics.putAll(elementWriter.getColumnStripeStatistics()); return columnStatistics.build(); }