Skip to content

Commit

Permalink
Deduplicate non-empty InternalAggregation metadata when deserializing (
Browse files Browse the repository at this point in the history
  • Loading branch information
iverase authored Nov 12, 2024
1 parent eb6d47f commit fa4e950
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
*/
public abstract class InternalAggregation implements Aggregation, NamedWriteable {
protected final String name;

protected final Map<String, Object> metadata;

/**
Expand All @@ -53,12 +52,14 @@ protected InternalAggregation(String name, Map<String, Object> metadata) {
*/
protected InternalAggregation(StreamInput in) throws IOException {
final String name = in.readString();
final Map<String, Object> metadata = in.readGenericMap();
if (in instanceof DelayableWriteable.Deduplicator d) {
this.name = d.deduplicate(name);
this.metadata = metadata == null || metadata.isEmpty() ? metadata : d.deduplicate(metadata);
} else {
this.name = name;
this.metadata = metadata;
}
metadata = in.readGenericMap();
}

@Override
Expand Down

0 comments on commit fa4e950

Please sign in to comment.