Search in sources :

Example 61 with StreamInput

use of org.elasticsearch.common.io.stream.StreamInput in project crate by crate.

the class ExtendedStatsTest method testExtendedFsStatsSerializationDefault.

@Test
public void testExtendedFsStatsSerializationDefault() throws IOException {
    ExtendedFsStats statOut = new ExtendedFsStats();
    statOut.writeTo(out);
    StreamInput in = StreamInput.wrap(out.bytes());
    ExtendedFsStats statIn = ExtendedFsStats.readExtendedFsStats(in);
    assertThat(statOut.total().dev(), is(statIn.total().dev()));
}
Also used : StreamInput(org.elasticsearch.common.io.stream.StreamInput) Test(org.junit.Test)

Example 62 with StreamInput

use of org.elasticsearch.common.io.stream.StreamInput 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));
}
Also used : StreamInput(org.elasticsearch.common.io.stream.StreamInput) UUID(java.util.UUID) BytesStreamOutput(org.elasticsearch.common.io.stream.BytesStreamOutput) Test(org.junit.Test)

Example 63 with StreamInput

use of org.elasticsearch.common.io.stream.StreamInput in project crate by crate.

the class FilterProjectionTest method testStreaming.

@Test
public void testStreaming() throws Exception {
    SqlExpressions sqlExpressions = new SqlExpressions(T3.SOURCES, T3.TR_1);
    FilterProjection p = new FilterProjection(sqlExpressions.normalize(sqlExpressions.asSymbol("a = 'foo'")), ImmutableList.of(new InputColumn(1)));
    p.requiredGranularity(RowGranularity.SHARD);
    BytesStreamOutput out = new BytesStreamOutput();
    Projection.toStream(p, out);
    StreamInput in = StreamInput.wrap(out.bytes());
    FilterProjection p2 = (FilterProjection) Projection.fromStream(in);
    assertEquals(p, p2);
}
Also used : InputColumn(io.crate.analyze.symbol.InputColumn) StreamInput(org.elasticsearch.common.io.stream.StreamInput) SqlExpressions(io.crate.testing.SqlExpressions) BytesStreamOutput(org.elasticsearch.common.io.stream.BytesStreamOutput) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 64 with StreamInput

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);
}
Also used : Symbol(io.crate.analyze.symbol.Symbol) Value(io.crate.analyze.symbol.Value) StreamInput(org.elasticsearch.common.io.stream.StreamInput) BytesStreamOutput(org.elasticsearch.common.io.stream.BytesStreamOutput) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Example 65 with StreamInput

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);
}
Also used : ColumnIdent(io.crate.metadata.ColumnIdent) InputColumn(io.crate.analyze.symbol.InputColumn) StreamInput(org.elasticsearch.common.io.stream.StreamInput) BytesStreamOutput(org.elasticsearch.common.io.stream.BytesStreamOutput) Test(org.junit.Test) CrateUnitTest(io.crate.test.integration.CrateUnitTest)

Aggregations

StreamInput (org.elasticsearch.common.io.stream.StreamInput)183 BytesStreamOutput (org.elasticsearch.common.io.stream.BytesStreamOutput)146 Test (org.junit.Test)52 CrateUnitTest (io.crate.test.integration.CrateUnitTest)37 NamedWriteableAwareStreamInput (org.elasticsearch.common.io.stream.NamedWriteableAwareStreamInput)30 BytesArray (org.elasticsearch.common.bytes.BytesArray)24 Version (org.elasticsearch.Version)21 IOException (java.io.IOException)13 BytesReference (org.elasticsearch.common.bytes.BytesReference)10 UUID (java.util.UUID)9 NamedWriteableRegistry (org.elasticsearch.common.io.stream.NamedWriteableRegistry)9 Symbol (io.crate.analyze.symbol.Symbol)8 BytesRef (org.apache.lucene.util.BytesRef)8 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)6 Map (java.util.Map)6 ShardId (org.elasticsearch.index.shard.ShardId)6 List (java.util.List)5 AliasFilter (org.elasticsearch.search.internal.AliasFilter)5 Aggregation (io.crate.analyze.symbol.Aggregation)4