use of org.elasticsearch.common.io.stream.StreamInput in project crate by crate.
the class FunctionTest method testSerialization.
@Test
public void testSerialization() throws Exception {
Function fn = new Function(new FunctionInfo(new FunctionIdent(randomAsciiOfLength(10), ImmutableList.of(DataTypes.BOOLEAN)), TestingHelpers.randomPrimitiveType(), FunctionInfo.Type.SCALAR, randomFeatures()), Collections.singletonList(TestingHelpers.createReference(randomAsciiOfLength(2), DataTypes.BOOLEAN)));
BytesStreamOutput output = new BytesStreamOutput();
Symbols.toStream(fn, output);
StreamInput input = StreamInput.wrap(output.bytes());
Function fn2 = (Function) Symbols.fromStream(input);
assertThat(fn, is(equalTo(fn2)));
assertThat(fn.hashCode(), is(fn2.hashCode()));
}
use of org.elasticsearch.common.io.stream.StreamInput in project crate by crate.
the class ReferenceTest method testStreaming.
@Test
public void testStreaming() throws Exception {
TableIdent tableIdent = new TableIdent("doc", "test");
ReferenceIdent referenceIdent = new ReferenceIdent(tableIdent, "object_column");
Reference reference = new Reference(referenceIdent, RowGranularity.DOC, new ArrayType(DataTypes.OBJECT), ColumnPolicy.STRICT, Reference.IndexType.ANALYZED, false);
BytesStreamOutput out = new BytesStreamOutput();
Reference.toStream(reference, out);
StreamInput in = StreamInput.wrap(out.bytes());
Reference reference2 = Reference.fromStream(in);
assertThat(reference2, is(reference));
}
use of org.elasticsearch.common.io.stream.StreamInput in project crate by crate.
the class RoutingTest method testStreamingWithoutLocations.
@Test
public void testStreamingWithoutLocations() throws Exception {
BytesStreamOutput out = new BytesStreamOutput();
Routing routing1 = new Routing(ImmutableMap.<String, Map<String, List<Integer>>>of());
routing1.writeTo(out);
StreamInput in = StreamInput.wrap(out.bytes());
Routing routing2 = Routing.fromStream(in);
assertThat(routing1.locations(), is(routing2.locations()));
}
use of org.elasticsearch.common.io.stream.StreamInput in project crate by crate.
the class ArrayTypeTest method testArrayTypeSerialization.
@Test
public void testArrayTypeSerialization() throws Exception {
// nested string array: [ ["x"], ["y"] ]
ArrayType arrayType = new ArrayType(new ArrayType(StringType.INSTANCE));
BytesStreamOutput out = new BytesStreamOutput();
DataTypes.toStream(arrayType, out);
StreamInput in = StreamInput.wrap(out.bytes());
DataType readType = DataTypes.fromStream(in);
assertThat(readType, instanceOf(ArrayType.class));
ArrayType readArrayType = (ArrayType) readType;
assertThat(readArrayType.innerType(), instanceOf(ArrayType.class));
ArrayType readInnerArrayType = (ArrayType) readArrayType.innerType();
assertThat(readInnerArrayType.innerType(), instanceOf(StringType.class));
assertSame(readInnerArrayType.innerType(), StringType.INSTANCE);
}
use of org.elasticsearch.common.io.stream.StreamInput in project crate by crate.
the class GeoPointTypeTest method testStreaming.
@Test
public void testStreaming() throws Throwable {
Double[] p1 = new Double[] { 41.2, -37.4 };
BytesStreamOutput out = new BytesStreamOutput();
DataTypes.GEO_POINT.writeValueTo(out, p1);
StreamInput in = StreamInput.wrap(out.bytes());
Double[] p2 = DataTypes.GEO_POINT.readValueFrom(in);
assertThat(p1, equalTo(p2));
}
Aggregations