mirror of
https://github.com/honeymoose/OpenSearch.git
synced 2025-02-20 03:45:02 +00:00
Replace (read|write)AggregatorBuilder with (read|write)NamedWriteable
This commit is contained in:
parent
70d55b36e1
commit
4ba8bce3fd
@ -739,13 +739,6 @@ public abstract class StreamInput extends InputStream {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Reads a {@link AggregatorBuilder} from the current stream
|
|
||||||
*/
|
|
||||||
public AggregatorBuilder<?> readAggregatorBuilder() throws IOException {
|
|
||||||
return readNamedWriteable(AggregatorBuilder.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a {@link PipelineAggregatorBuilder} from the current stream
|
* Reads a {@link PipelineAggregatorBuilder} from the current stream
|
||||||
*/
|
*/
|
||||||
|
@ -704,13 +704,6 @@ public abstract class StreamOutput extends OutputStream {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Writes a {@link AggregatorBuilder} to the current stream
|
|
||||||
*/
|
|
||||||
public void writeAggregatorBuilder(AggregatorBuilder<?> builder) throws IOException {
|
|
||||||
writeNamedWriteable(builder);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a {@link PipelineAggregatorBuilder} to the current stream
|
* Writes a {@link PipelineAggregatorBuilder} to the current stream
|
||||||
*/
|
*/
|
||||||
|
@ -277,13 +277,11 @@ public class AggregatorFactories {
|
|||||||
Builder builder = new Builder();
|
Builder builder = new Builder();
|
||||||
int factoriesSize = in.readVInt();
|
int factoriesSize = in.readVInt();
|
||||||
for (int i = 0; i < factoriesSize; i++) {
|
for (int i = 0; i < factoriesSize; i++) {
|
||||||
AggregatorBuilder<?> factory = in.readAggregatorBuilder();
|
builder.addAggregator(in.readNamedWriteable(AggregatorBuilder.class));
|
||||||
builder.addAggregator(factory);
|
|
||||||
}
|
}
|
||||||
int pipelineFactoriesSize = in.readVInt();
|
int pipelineFactoriesSize = in.readVInt();
|
||||||
for (int i = 0; i < pipelineFactoriesSize; i++) {
|
for (int i = 0; i < pipelineFactoriesSize; i++) {
|
||||||
PipelineAggregatorBuilder<?> factory = in.readPipelineAggregatorBuilder();
|
builder.addPipelineAggregator(in.readNamedWriteable(PipelineAggregatorBuilder.class));
|
||||||
builder.addPipelineAggregator(factory);
|
|
||||||
}
|
}
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
@ -291,12 +289,12 @@ public class AggregatorFactories {
|
|||||||
@Override
|
@Override
|
||||||
public void writeTo(StreamOutput out) throws IOException {
|
public void writeTo(StreamOutput out) throws IOException {
|
||||||
out.writeVInt(this.aggregatorBuilders.size());
|
out.writeVInt(this.aggregatorBuilders.size());
|
||||||
for (AggregatorBuilder<?> factory : aggregatorBuilders) {
|
for (AggregatorBuilder<?> builder : aggregatorBuilders) {
|
||||||
out.writeAggregatorBuilder(factory);
|
out.writeNamedWriteable(builder);
|
||||||
}
|
}
|
||||||
out.writeVInt(this.pipelineAggregatorBuilders.size());
|
out.writeVInt(this.pipelineAggregatorBuilders.size());
|
||||||
for (PipelineAggregatorBuilder<?> factory : pipelineAggregatorBuilders) {
|
for (PipelineAggregatorBuilder<?> builder : pipelineAggregatorBuilders) {
|
||||||
out.writePipelineAggregatorBuilder(factory);
|
out.writeNamedWriteable(builder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -251,9 +251,9 @@ public abstract class BaseAggregationTestCase<AB extends AggregatorBuilder<AB>>
|
|||||||
public void testSerialization() throws IOException {
|
public void testSerialization() throws IOException {
|
||||||
AB testAgg = createTestAggregatorBuilder();
|
AB testAgg = createTestAggregatorBuilder();
|
||||||
try (BytesStreamOutput output = new BytesStreamOutput()) {
|
try (BytesStreamOutput output = new BytesStreamOutput()) {
|
||||||
output.writeAggregatorBuilder(testAgg);
|
output.writeNamedWriteable(testAgg);
|
||||||
try (StreamInput in = new NamedWriteableAwareStreamInput(StreamInput.wrap(output.bytes()), namedWriteableRegistry)) {
|
try (StreamInput in = new NamedWriteableAwareStreamInput(StreamInput.wrap(output.bytes()), namedWriteableRegistry)) {
|
||||||
AggregatorBuilder deserialized = in.readAggregatorBuilder();
|
AggregatorBuilder<?> deserialized = in.readNamedWriteable(AggregatorBuilder.class);
|
||||||
assertEquals(testAgg, deserialized);
|
assertEquals(testAgg, deserialized);
|
||||||
assertEquals(testAgg.hashCode(), deserialized.hashCode());
|
assertEquals(testAgg.hashCode(), deserialized.hashCode());
|
||||||
assertNotSame(testAgg, deserialized);
|
assertNotSame(testAgg, deserialized);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user