use of io.crate.executor.transport.distributed.DistributedResultRequest 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 io.crate.executor.transport.distributed.DistributedResultRequest in project crate by crate.
the class DistributedResultRequestTest method testStreamingOfFailure.
@Test
public void testStreamingOfFailure() throws Exception {
UUID uuid = UUID.randomUUID();
Throwable throwable = new IllegalStateException("dummy");
DistributedResultRequest r1 = new DistributedResultRequest(uuid, 1, (byte) 3, 1, throwable, true);
BytesStreamOutput out = new BytesStreamOutput();
r1.writeTo(out);
StreamInput in = StreamInput.wrap(out.bytes());
DistributedResultRequest r2 = new DistributedResultRequest();
r2.readFrom(in);
assertThat(r2.throwable(), instanceOf(throwable.getClass()));
assertThat(r2.isKilled(), is(r1.isKilled()));
}
Aggregations