use of org.elasticsearch.common.io.stream.BytesStreamOutput in project crate by crate.
the class GeneratedReferenceTest method testStreaming.
@Test
public void testStreaming() throws Exception {
ReferenceIdent referenceIdent = new ReferenceIdent(T3.T1_INFO.ident(), "generated_column");
String formattedGeneratedExpression = "concat(a, 'bar')";
GeneratedReference generatedReferenceInfo = new GeneratedReference(referenceIdent, RowGranularity.DOC, StringType.INSTANCE, ColumnPolicy.STRICT, Reference.IndexType.ANALYZED, formattedGeneratedExpression, false);
generatedReferenceInfo.generatedExpression(SQL_EXPRESSIONS.normalize(SQL_EXPRESSIONS.asSymbol(formattedGeneratedExpression)));
generatedReferenceInfo.referencedReferences(ImmutableList.of(T3.T1_INFO.getReference(new ColumnIdent("a"))));
BytesStreamOutput out = new BytesStreamOutput();
Reference.toStream(generatedReferenceInfo, out);
StreamInput in = StreamInput.wrap(out.bytes());
GeneratedReference generatedReferenceInfo2 = Reference.fromStream(in);
assertThat(generatedReferenceInfo2, is(generatedReferenceInfo));
}
use of org.elasticsearch.common.io.stream.BytesStreamOutput in project crate by crate.
the class RoutingTest method testStreamingWithLocations.
@Test
public void testStreamingWithLocations() throws Exception {
Map<String, Map<String, List<Integer>>> locations = new TreeMap<>();
Map<String, List<Integer>> indexMap = new TreeMap<>();
indexMap.put("index-0", Arrays.asList(1, 2));
locations.put("node-0", indexMap);
BytesStreamOutput out = new BytesStreamOutput();
Routing routing1 = new Routing(locations);
routing1.writeTo(out);
StreamInput in = StreamInput.wrap(out.bytes());
Routing routing2 = new Routing(ImmutableMap.<String, Map<String, List<Integer>>>of());
routing2.readFrom(in);
assertThat(routing1.locations(), is(routing2.locations()));
}
use of org.elasticsearch.common.io.stream.BytesStreamOutput in project crate by crate.
the class GeoReferenceTest method testStreaming.
@Test
public void testStreaming() throws Exception {
TableIdent tableIdent = new TableIdent("doc", "test");
ReferenceIdent referenceIdent = new ReferenceIdent(tableIdent, "geo_column");
GeoReference geoReferenceInfo = new GeoReference(referenceIdent, "some_tree", "1m", 3, 0.5d);
BytesStreamOutput out = new BytesStreamOutput();
Reference.toStream(geoReferenceInfo, out);
StreamInput in = StreamInput.wrap(out.bytes());
GeoReference geoReferenceInfo2 = Reference.fromStream(in);
assertThat(geoReferenceInfo2, is(geoReferenceInfo));
GeoReference geoReferenceInfo3 = new GeoReference(referenceIdent, "some_tree", null, null, null);
out = new BytesStreamOutput();
Reference.toStream(geoReferenceInfo3, out);
in = StreamInput.wrap(out.bytes());
GeoReference geoReferenceInfo4 = Reference.fromStream(in);
assertThat(geoReferenceInfo4, is(geoReferenceInfo3));
}
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 BulkCreateIndicesRequestTest method testSerialization.
@Test
public void testSerialization() throws Exception {
UUID jobId = UUID.randomUUID();
BulkCreateIndicesRequest request = new BulkCreateIndicesRequest(Arrays.asList("a", "b", "c"), jobId);
BytesStreamOutput out = new BytesStreamOutput();
request.writeTo(out);
StreamInput in = StreamInput.wrap(out.bytes());
BulkCreateIndicesRequest requestDeserialized = new BulkCreateIndicesRequest();
requestDeserialized.readFrom(in);
assertThat(requestDeserialized.indices(), contains("a", "b", "c"));
assertThat(requestDeserialized.jobId(), is(jobId));
jobId = UUID.randomUUID();
request = new BulkCreateIndicesRequest(Arrays.asList("a", "b", "c"), jobId);
out = new BytesStreamOutput();
request.writeTo(out);
in = StreamInput.wrap(out.bytes());
requestDeserialized = new BulkCreateIndicesRequest();
requestDeserialized.readFrom(in);
assertThat(requestDeserialized.indices(), contains("a", "b", "c"));
assertThat(requestDeserialized.jobId(), is(jobId));
}
Aggregations