Skip to content

Commit

Permalink
Rename StreamInput#readGenericMap (#104045)
Browse files Browse the repository at this point in the history
`StreamInput#readMap()` is quite different from the other `readMap`
overloads, and pairs up with `StreamOutput#writeGenericMap`. This commit
renames it to avoid accidental misuse and so that the names line up
better between writer and reader.
  • Loading branch information
DaveCTurner authored Jan 8, 2024
1 parent 012655d commit af916a0
Show file tree
Hide file tree
Showing 103 changed files with 143 additions and 135 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ private void read(StreamInput in) throws IOException {
fields = (ArrayList<String>) in.readGenericValue();
userValueTypeHint = in.readOptionalWriteable(ValueType::readFromStream);
format = in.readOptionalString();
missingMap = in.readMap();
missingMap = in.readGenericMap();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public SearchTemplateRequest(StreamInput in) throws IOException {
scriptType = ScriptType.readFrom(in);
script = in.readOptionalString();
if (in.readBoolean()) {
scriptParams = in.readMap();
scriptParams = in.readGenericMap();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ static void validateEvaluatedQuery(SearchSourceBuilder evaluationRequest) {
for (int i = 0; i < intentSize; i++) {
ratedDocs.add(new RatedDocument(in));
}
this.params = in.readMap();
this.params = in.readGenericMap();
int summaryFieldsSize = in.readInt();
summaryFields = new ArrayList<>(summaryFieldsSize);
for (int i = 0; i < summaryFieldsSize; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public CreateSnapshotRequest(StreamInput in) throws IOException {
includeGlobalState = in.readBoolean();
waitForCompletion = in.readBoolean();
partial = in.readBoolean();
userMetadata = in.readMap();
userMetadata = in.readGenericMap();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ public AnalyzeToken(
positionLength = 1;
}
type = in.readOptionalString();
attributes = in.readMap();
attributes = in.readGenericMap();
}

public String getTerm() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class FieldCapabilitiesNodeRequest extends ActionRequest implements IndicesReque
originalIndices = OriginalIndices.readOriginalIndices(in);
indexFilter = in.readOptionalNamedWriteable(QueryBuilder.class);
nowInMillis = in.readLong();
runtimeFields = in.readMap();
runtimeFields = in.readGenericMap();
}

FieldCapabilitiesNodeRequest(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public FieldCapabilitiesRequest(StreamInput in) throws IOException {
includeUnmapped = in.readBoolean();
indexFilter = in.readOptionalNamedWriteable(QueryBuilder.class);
nowInMillis = in.readOptionalLong();
runtimeFields = in.readMap();
runtimeFields = in.readGenericMap();
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_2_0)) {
filters = in.readStringArray();
types = in.readStringArray();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ private WriteableIngestDocument(Map<String, Object> sourceAndMetadata, Map<Strin
}

WriteableIngestDocument(StreamInput in) throws IOException {
this(in.readMap(), in.readMap());
this(in.readGenericMap(), in.readGenericMap());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public TermVectorsRequest() {}
}
}
if (in.readBoolean()) {
perFieldAnalyzer = readPerFieldAnalyzer(in.readMap());
perFieldAnalyzer = readPerFieldAnalyzer(in.readGenericMap());
}
if (in.readBoolean()) {
filterSettings = new FilterSettings();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ private static Entry readFrom(StreamInput in) throws IOException {
final Map<ShardId, ShardSnapshotStatus> shards = in.readImmutableMap(ShardId::new, ShardSnapshotStatus::readFrom);
final long repositoryStateId = in.readLong();
final String failure = in.readOptionalString();
final Map<String, Object> userMetadata = in.readMap();
final Map<String, Object> userMetadata = in.readGenericMap();
final IndexVersion version = IndexVersion.readVersion(in);
final List<String> dataStreams = in.readStringCollectionAsImmutableList();
final SnapshotId source = in.readOptionalWriteable(SnapshotId::new);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public ComponentTemplate(StreamInput in) throws IOException {
this.template = new Template(in);
this.version = in.readOptionalVLong();
if (in.readBoolean()) {
this.metadata = in.readMap();
this.metadata = in.readGenericMap();
} else {
this.metadata = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public ComposableIndexTemplate(StreamInput in) throws IOException {
this.componentTemplates = in.readOptionalStringCollectionAsList();
this.priority = in.readOptionalVLong();
this.version = in.readOptionalVLong();
this.metadata = in.readMap();
this.metadata = in.readGenericMap();
this.dataStreamTemplate = in.readOptionalWriteable(DataStreamTemplate::new);
this.allowAutoCreate = in.readOptionalBoolean();
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_7_0)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -859,7 +859,7 @@ public DataStream(StreamInput in) throws IOException {
readName(in),
readIndices(in),
in.readVLong(),
in.readMap(),
in.readGenericMap(),
in.readBoolean(),
in.readBoolean(),
in.readBoolean(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public class DiffableStringMap extends AbstractMap<String, String> implements Di

@SuppressWarnings("unchecked")
public static DiffableStringMap readFrom(StreamInput in) throws IOException {
final Map<String, String> map = (Map) in.readMap();
final Map<String, String> map = (Map) in.readGenericMap();
return map.isEmpty() ? EMPTY : new DiffableStringMap(map);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ public <K, V> Map<K, V> readMapValues(final Writeable.Reader<V> valueReader, fin
*/
@Nullable
@SuppressWarnings("unchecked")
public Map<String, Object> readMap() throws IOException {
public Map<String, Object> readGenericMap() throws IOException {
return (Map<String, Object>) readGenericValue();
}

Expand Down
4 changes: 2 additions & 2 deletions server/src/main/java/org/elasticsearch/script/Script.java
Original file line number Diff line number Diff line change
Expand Up @@ -556,9 +556,9 @@ public Script(StreamInput in) throws IOException {
this.lang = in.readOptionalString();
this.idOrCode = in.readString();
@SuppressWarnings("unchecked")
Map<String, String> options = (Map<String, String>) (Map) in.readMap();
Map<String, String> options = (Map<String, String>) (Map) in.readGenericMap();
this.options = options;
this.params = in.readMap();
this.params = in.readGenericMap();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ public StoredScriptSource(StreamInput in) throws IOException {
this.lang = in.readString();
this.source = in.readString();
@SuppressWarnings("unchecked")
Map<String, String> options = (Map<String, String>) (Map) in.readMap();
Map<String, String> options = (Map<String, String>) (Map) in.readGenericMap();
this.options = options;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ protected AbstractAggregationBuilder(
protected AbstractAggregationBuilder(StreamInput in) throws IOException {
super(in.readString());
factoriesBuilder = new AggregatorFactories.Builder(in);
metadata = in.readMap();
metadata = in.readGenericMap();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected InternalAggregation(String name, Map<String, Object> metadata) {
*/
protected InternalAggregation(StreamInput in) throws IOException {
name = in.readString();
metadata = in.readMap();
metadata = in.readGenericMap();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public CompositeAggregationBuilder(StreamInput in) throws IOException {
}
this.size = in.readVInt();
if (in.readBoolean()) {
this.after = in.readMap();
this.after = in.readGenericMap();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public ScriptedMetricAggregationBuilder(StreamInput in) throws IOException {
combineScript = in.readOptionalWriteable(Script::new);
reduceScript = in.readOptionalWriteable(Script::new);
if (in.readBoolean()) {
params = in.readMap();
params = in.readGenericMap();
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected AbstractPipelineAggregationBuilder(String name, String type, String[]
*/
protected AbstractPipelineAggregationBuilder(StreamInput in, String type) throws IOException {
this(in.readString(), type, in.readStringArray());
metadata = in.readMap();
metadata = in.readGenericMap();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ public SearchSourceBuilder(StreamInput in) throws IOException {
fetchFields = in.readCollectionAsList(FieldAndFormat::new);
}
pointInTimeBuilder = in.readOptionalWriteable(PointInTimeBuilder::new);
runtimeMappings = in.readMap();
runtimeMappings = in.readGenericMap();
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_4_0)) {
if (in.getTransportVersion().before(TransportVersions.V_8_7_0)) {
KnnSearchBuilder searchBuilder = in.readOptionalWriteable(KnnSearchBuilder::new);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ protected AbstractHighlighterBuilder(StreamInput in) throws IOException {
noMatchSize(in.readOptionalVInt());
phraseLimit(in.readOptionalVInt());
if (in.readBoolean()) {
options(in.readMap());
options(in.readGenericMap());
}
requireFieldMatch(in.readOptionalBoolean());
maxAnalyzedOffset(in.readOptionalInt());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ public PhraseSuggestionBuilder(StreamInput in) throws IOException {
if (in.readBoolean()) {
collateQuery = new Script(in);
}
collateParams = in.readMap();
collateParams = in.readGenericMap();
collatePrune = in.readOptionalBoolean();
int generatorsEntries = in.readVInt();
for (int i = 0; i < generatorsEntries; i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ public static SnapshotInfo readFrom(final StreamInput in) throws IOException {
final List<SnapshotShardFailure> shardFailures = in.readCollectionAsImmutableList(SnapshotShardFailure::new);
final IndexVersion version = in.readBoolean() ? IndexVersion.readVersion(in) : null;
final Boolean includeGlobalState = in.readOptionalBoolean();
final Map<String, Object> userMetadata = in.readMap();
final Map<String, Object> userMetadata = in.readGenericMap();
final List<String> dataStreams = in.readStringCollectionAsImmutableList();
final List<SnapshotFeatureInfo> featureStates = in.readCollectionAsImmutableList(SnapshotFeatureInfo::new);
final Map<String, IndexSnapshotDetails> indexSnapshotDetails = in.readImmutableMap(IndexSnapshotDetails::new);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public SystemIndexMigrationTaskState(String currentIndex, String currentFeature,
public SystemIndexMigrationTaskState(StreamInput in) throws IOException {
this.currentIndex = in.readString();
this.currentFeature = in.readString();
this.featureCallbackMetadata = in.readMap();
this.featureCallbackMetadata = in.readGenericMap();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ public void testReadMapByUsingWriteMapWithConsistentOrder() throws IOException {
try (TestStreamOutput streamOut = new TestStreamOutput()) {
streamOut.writeMapWithConsistentOrder(streamOutMap);
StreamInput in = StreamInput.wrap(BytesReference.toBytes(streamOut.bytes()));
Map<String, Object> streamInMap = in.readMap();
Map<String, Object> streamInMap = in.readGenericMap();
assertEquals(streamOutMap, streamInMap);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ public void testReadMapByUsingWriteMapWithConsistentOrder() throws IOException {
try (RecyclerBytesStreamOutput streamOut = new RecyclerBytesStreamOutput(recycler)) {
streamOut.writeMapWithConsistentOrder(streamOutMap);
StreamInput in = StreamInput.wrap(BytesReference.toBytes(streamOut.bytes()));
Map<String, Object> streamInMap = in.readMap();
Map<String, Object> streamInMap = in.readGenericMap();
assertEquals(streamOutMap, streamInMap);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ public FeatureSet(String name, boolean available, boolean enabled) {
public FeatureSet(StreamInput in) throws IOException {
this(in.readString(), readAvailable(in), in.readBoolean());
if (in.getTransportVersion().before(TransportVersions.V_8_0_0)) {
in.readMap(); // backcompat reading native code info, but no longer used here
in.readGenericMap(); // backcompat reading native code info, but no longer used here
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public class HealthApiFeatureSetUsage extends XPackFeatureSet.Usage {

public HealthApiFeatureSetUsage(StreamInput in) throws IOException {
super(in);
usageStats = in.readMap();
usageStats = in.readGenericMap();
}

public HealthApiFeatureSetUsage(boolean available, boolean enabled, @Nullable Counters stats) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ public EnterpriseSearchFeatureSetUsage(

public EnterpriseSearchFeatureSetUsage(StreamInput in) throws IOException {
super(in);
this.searchApplicationsUsage = in.readMap();
this.searchApplicationsUsage = in.readGenericMap();
Map<String, Object> analyticsCollectionsUsage = new HashMap<>();
Map<String, Object> queryRulesUsage = new HashMap<>();
if (in.getTransportVersion().onOrAfter(QUERY_RULES_TRANSPORT_VERSION)) {
analyticsCollectionsUsage = in.readMap();
queryRulesUsage = in.readMap();
analyticsCollectionsUsage = in.readGenericMap();
queryRulesUsage = in.readGenericMap();
} else if (in.getTransportVersion().onOrAfter(BEHAVIORAL_ANALYTICS_TRANSPORT_VERSION)) {
analyticsCollectionsUsage = in.readMap();
analyticsCollectionsUsage = in.readGenericMap();
}
this.analyticsCollectionsUsage = analyticsCollectionsUsage;
this.queryRulesUsage = queryRulesUsage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public DeprecationIssue(StreamInput in) throws IOException {
url = in.readString();
details = in.readOptionalString();
resolveDuringRollingUpgrade = in.readBoolean();
meta = in.readMap();
meta = in.readGenericMap();
}

public Level getLevel() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class EqlFeatureSetUsage extends XPackFeatureSet.Usage {

public EqlFeatureSetUsage(StreamInput in) throws IOException {
super(in);
stats = in.readMap();
stats = in.readGenericMap();
}

public EqlFeatureSetUsage(Map<String, Object> stats) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class EsqlFeatureSetUsage extends XPackFeatureSet.Usage {

public EsqlFeatureSetUsage(StreamInput in) throws IOException {
super(in);
stats = in.readMap();
stats = in.readGenericMap();
}

public EsqlFeatureSetUsage(Map<String, Object> stats) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public LifecyclePolicy(StreamInput in) throws IOException {
type = in.readNamedWriteable(LifecycleType.class);
name = in.readString();
phases = in.readImmutableMap(Phase::new);
this.metadata = in.readMap();
this.metadata = in.readGenericMap();
if (in.getTransportVersion().onOrAfter(TransportVersions.DEPRECATED_COMPONENT_TEMPLATES_ADDED)) {
this.deprecated = in.readOptionalBoolean();
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public Request(StreamInput in) throws IOException {
} else {
this.input = List.of(in.readString());
}
this.taskSettings = in.readMap();
this.taskSettings = in.readGenericMap();
}

public TaskType getTaskType() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ public MachineLearningFeatureSetUsage(

public MachineLearningFeatureSetUsage(StreamInput in) throws IOException {
super(in);
this.jobsUsage = in.readMap();
this.datafeedsUsage = in.readMap();
this.analyticsUsage = in.readMap();
this.inferenceUsage = in.readMap();
this.jobsUsage = in.readGenericMap();
this.datafeedsUsage = in.readGenericMap();
this.analyticsUsage = in.readGenericMap();
this.inferenceUsage = in.readGenericMap();
this.nodeCount = in.readInt();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ public Request(StreamInput in) throws IOException {
this.modelId = in.readString();
this.requestModelType = in.readEnum(RequestModelType.class);
this.inputs = in.readOptionalStringCollectionAsList();
this.taskSettings = in.readMap();
this.objectsToInfer = in.readOptionalCollectionAsList(StreamInput::readMap);
this.taskSettings = in.readGenericMap();
this.objectsToInfer = in.readOptionalCollectionAsList(StreamInput::readGenericMap);
this.inferenceConfigUpdate = in.readOptionalNamedWriteable(InferenceConfigUpdate.class);
this.previouslyLicensed = in.readOptionalBoolean();
this.inferenceTimeout = in.readOptionalTimeValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ public static Request forTextInput(
public Request(StreamInput in) throws IOException {
super(in);
this.id = in.readString();
this.objectsToInfer = in.readCollectionAsImmutableList(StreamInput::readMap);
this.objectsToInfer = in.readCollectionAsImmutableList(StreamInput::readGenericMap);
this.update = in.readNamedWriteable(InferenceConfigUpdate.class);
this.previouslyLicensed = in.readBoolean();
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_3_0)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public static Request forTextInput(String id, InferenceConfigUpdate update, List
public Request(StreamInput in) throws IOException {
super(in);
id = in.readString();
docs = in.readCollectionAsImmutableList(StreamInput::readMap);
docs = in.readCollectionAsImmutableList(StreamInput::readGenericMap);
update = in.readOptionalNamedWriteable(InferenceConfigUpdate.class);
inferenceTimeout = in.readOptionalTimeValue();
if (in.getTransportVersion().onOrAfter(TransportVersions.V_8_3_0)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public Response() {

public Response(StreamInput in) throws IOException {
super(in);
info = in.readMap();
info = in.readGenericMap();
}

public Map<String, Object> getInfo() {
Expand Down
Loading

0 comments on commit af916a0

Please sign in to comment.