use of org.elasticsearch.common.io.stream.StreamInput in project crate by crate.
the class DistributionInfoTest method testStreamingDefaultImpl.
@Test
public void testStreamingDefaultImpl() throws Exception {
DistributionInfo distributionInfo = DistributionInfo.DEFAULT_BROADCAST;
BytesStreamOutput out = new BytesStreamOutput(10);
distributionInfo.writeTo(out);
StreamInput in = StreamInput.wrap(out.bytes());
DistributionInfo streamed = DistributionInfo.fromStream(in);
assertThat(streamed, equalTo(distributionInfo));
}
use of org.elasticsearch.common.io.stream.StreamInput in project crate by crate.
the class DistributedResultRequestTest method testStreaming.
@Test
public void testStreaming() throws Exception {
Streamer<?>[] streamers = new Streamer[] { DataTypes.STRING.streamer() };
Object[][] rows = new Object[][] { { new BytesRef("ab") }, { null }, { new BytesRef("cd") } };
UUID uuid = UUID.randomUUID();
DistributedResultRequest r1 = new DistributedResultRequest(uuid, 1, (byte) 3, 1, streamers, new ArrayBucket(rows), false);
BytesStreamOutput out = new BytesStreamOutput();
r1.writeTo(out);
StreamInput in = StreamInput.wrap(out.bytes());
DistributedResultRequest r2 = new DistributedResultRequest();
r2.readFrom(in);
r2.streamers(streamers);
assertTrue(r2.rowsCanBeRead());
assertEquals(r1.rows().size(), r2.rows().size());
assertThat(r1.isLast(), is(r2.isLast()));
assertThat(r1.executionPhaseInputId(), is(r2.executionPhaseInputId()));
assertThat(r2.rows(), contains(isRow("ab"), isNullRow(), isRow("cd")));
}
use of org.elasticsearch.common.io.stream.StreamInput in project crate by crate.
the class ShardDeleteRequestTest method testStreaming.
@Test
public void testStreaming() throws Exception {
ShardId shardId = new ShardId("test", 1);
UUID jobId = UUID.randomUUID();
ShardDeleteRequest request = new ShardDeleteRequest(shardId, "42", jobId);
request.add(123, new ShardDeleteRequest.Item("99"));
request.add(5, new ShardDeleteRequest.Item("42"));
BytesStreamOutput out = new BytesStreamOutput();
request.writeTo(out);
StreamInput in = StreamInput.wrap(out.bytes());
ShardDeleteRequest request2 = new ShardDeleteRequest();
request2.readFrom(in);
assertThat(request, equalTo(request2));
}
use of org.elasticsearch.common.io.stream.StreamInput in project crate by crate.
the class ShardUpsertRequestTest method testStreaming.
@Test
public void testStreaming() throws Exception {
ShardId shardId = new ShardId("test", 1);
String[] assignmentColumns = new String[] { "id", "name" };
UUID jobId = UUID.randomUUID();
Reference[] missingAssignmentColumns = new Reference[] { ID_REF, NAME_REF };
ShardUpsertRequest request = new ShardUpsertRequest.Builder(false, false, assignmentColumns, missingAssignmentColumns, jobId, false).newRequest(shardId, "42");
request.validateConstraints(false);
request.add(123, new ShardUpsertRequest.Item("99", null, new Object[] { 99, new BytesRef("Marvin") }, null));
request.add(5, new ShardUpsertRequest.Item("42", new Symbol[] { Literal.of(42), Literal.of("Deep Thought") }, null, 2L));
BytesStreamOutput out = new BytesStreamOutput();
request.writeTo(out);
StreamInput in = StreamInput.wrap(out.bytes());
ShardUpsertRequest request2 = new ShardUpsertRequest();
request2.readFrom(in);
assertThat(request, equalTo(request2));
}
use of org.elasticsearch.common.io.stream.StreamInput in project elasticsearch by elastic.
the class BaseAggregationTestCase method testSerialization.
/**
* Test serialization and deserialization of the test AggregatorFactory.
*/
public void testSerialization() throws IOException {
AB testAgg = createTestAggregatorBuilder();
try (BytesStreamOutput output = new BytesStreamOutput()) {
output.writeNamedWriteable(testAgg);
try (StreamInput in = new NamedWriteableAwareStreamInput(output.bytes().streamInput(), namedWriteableRegistry)) {
AggregationBuilder deserialized = in.readNamedWriteable(AggregationBuilder.class);
assertEquals(testAgg, deserialized);
assertEquals(testAgg.hashCode(), deserialized.hashCode());
assertNotSame(testAgg, deserialized);
}
}
}
Aggregations