use of org.elasticsearch.common.io.stream.StreamInput in project crate by crate.
the class TopNProjectionTest method testStreaming.
@Test
public void testStreaming() throws Exception {
ImmutableList<Symbol> outputs = ImmutableList.of(new Value(DataTypes.BOOLEAN), new Value(DataTypes.INTEGER));
TopNProjection p = new TopNProjection(5, 10, outputs);
BytesStreamOutput out = new BytesStreamOutput();
Projection.toStream(p, out);
StreamInput in = StreamInput.wrap(out.bytes());
TopNProjection p2 = (TopNProjection) Projection.fromStream(in);
assertEquals(p, p2);
}
use of org.elasticsearch.common.io.stream.StreamInput in project crate by crate.
the class WriterProjectionTest method testStreaming.
@Test
public void testStreaming() throws Exception {
WriterProjection p = new WriterProjection(ImmutableList.<Symbol>of(new InputColumn(1)), Literal.of("/foo.json"), WriterProjection.CompressionType.GZIP, MapBuilder.<ColumnIdent, Symbol>newMapBuilder().put(new ColumnIdent("partitionColumn"), Literal.of(1)).map(), ImmutableList.of("foo"), WriterProjection.OutputFormat.JSON_OBJECT);
BytesStreamOutput out = new BytesStreamOutput();
Projection.toStream(p, out);
StreamInput in = StreamInput.wrap(out.bytes());
WriterProjection p2 = (WriterProjection) Projection.fromStream(in);
assertEquals(p, p2);
}
use of org.elasticsearch.common.io.stream.StreamInput in project crate by crate.
the class SerializationTests method testPutChunkReplicaRequestSerialization.
@Test
public void testPutChunkReplicaRequestSerialization() throws Exception {
BytesStreamOutput outputStream = new BytesStreamOutput();
UUID transferId = UUID.randomUUID();
PutChunkReplicaRequest requestOut = new PutChunkReplicaRequest();
requestOut.index("foo");
requestOut.transferId = transferId;
requestOut.currentPos = 10;
requestOut.isLast = false;
requestOut.content = new BytesArray(new byte[] { 0x65, 0x66 });
requestOut.sourceNodeId = "nodeId";
requestOut.writeTo(outputStream);
StreamInput inputStream = StreamInput.wrap(outputStream.bytes());
PutChunkReplicaRequest requestIn = new PutChunkReplicaRequest();
requestIn.readFrom(inputStream);
assertEquals(requestOut.currentPos, requestIn.currentPos);
assertEquals(requestOut.isLast, requestIn.isLast);
assertEquals(requestOut.content, requestIn.content);
assertEquals(requestOut.transferId, requestIn.transferId);
assertEquals(requestOut.index(), requestIn.index());
}
use of org.elasticsearch.common.io.stream.StreamInput in project crate by crate.
the class DeleteBlobRequestTest method testDeleteBlobRequestStreaming.
@Test
public void testDeleteBlobRequestStreaming() throws Exception {
byte[] digest = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 };
DeleteBlobRequest request = new DeleteBlobRequest("foo", digest);
BytesStreamOutput out = new BytesStreamOutput();
request.writeTo(out);
DeleteBlobRequest fromStream = new DeleteBlobRequest();
StreamInput in = StreamInput.wrap(out.bytes());
fromStream.readFrom(in);
assertThat(fromStream.index(), is("foo"));
assertThat(fromStream.id(), is(Hex.encodeHexString(digest)));
}
use of org.elasticsearch.common.io.stream.StreamInput in project crate by crate.
the class DeleteBlobResponseTest method testDeleteBlobResponseStreaming.
@Test
public void testDeleteBlobResponseStreaming() throws Exception {
DeleteBlobResponse response = new DeleteBlobResponse();
response.deleted = true;
response.setShardInfo(new ActionWriteResponse.ShardInfo());
BytesStreamOutput out = new BytesStreamOutput();
response.writeTo(out);
DeleteBlobResponse fromStream = new DeleteBlobResponse();
StreamInput in = StreamInput.wrap(out.bytes());
fromStream.readFrom(in);
assertThat(fromStream.deleted, is(true));
}
Aggregations