use of org.elasticsearch.common.io.stream.BytesStreamOutput in project crate by crate.
the class IndexReferenceTest method testStreaming.
@Test
public void testStreaming() throws Exception {
TableIdent tableIdent = new TableIdent("doc", "test");
ReferenceIdent referenceIdent = new ReferenceIdent(tableIdent, "string_col");
Reference reference = new Reference(referenceIdent, RowGranularity.DOC, StringType.INSTANCE);
ReferenceIdent indexReferenceIdent = new ReferenceIdent(tableIdent, "index_column");
IndexReference indexReferenceInfo = new IndexReference(indexReferenceIdent, Reference.IndexType.ANALYZED, ImmutableList.of(reference), "my_analyzer");
BytesStreamOutput out = new BytesStreamOutput();
Reference.toStream(indexReferenceInfo, out);
StreamInput in = StreamInput.wrap(out.bytes());
IndexReference indexReferenceInfo2 = Reference.fromStream(in);
assertThat(indexReferenceInfo2, is(indexReferenceInfo));
}
use of org.elasticsearch.common.io.stream.BytesStreamOutput 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.BytesStreamOutput 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.BytesStreamOutput 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.BytesStreamOutput in project crate by crate.
the class NodeFetchRequestTest method testStreaming.
@Test
public void testStreaming() throws Exception {
IntObjectHashMap<IntContainer> toFetch = new IntObjectHashMap<>();
IntHashSet docIds = new IntHashSet(3);
toFetch.put(1, docIds);
NodeFetchRequest orig = new NodeFetchRequest(UUID.randomUUID(), 1, true, toFetch);
BytesStreamOutput out = new BytesStreamOutput();
orig.writeTo(out);
StreamInput in = StreamInput.wrap(out.bytes());
NodeFetchRequest streamed = new NodeFetchRequest();
streamed.readFrom(in);
assertThat(orig.jobId(), is(streamed.jobId()));
assertThat(orig.fetchPhaseId(), is(streamed.fetchPhaseId()));
assertThat(orig.isCloseContext(), is(streamed.isCloseContext()));
assertThat(orig.toFetch().toString(), is(streamed.toFetch().toString()));
}
Aggregations