Package org.elasticsearch.common.io.stream

Examples of org.elasticsearch.common.io.stream.BytesStreamOutput.bytes()


    private <T extends InternalFacet> void serializeAndDeserialize(final T toSend, final T toReceive) throws Exception {
        final BytesStreamOutput bso = new BytesStreamOutput();
        toSend.writeTo(bso);
        bso.close();
        final BytesReference bytes = bso.bytes();
        final BytesStreamInput bsi = new BytesStreamInput(bytes);
        toReceive.readFrom(bsi);
        bsi.close();
        assertEquals(toSend.getName(), toReceive.getName());
        assertEquals(toSend.getType(), toReceive.getType());
View Full Code Here


    // TODO this is a direct copy from SerializationTest for date facets
    private <T extends InternalFacet> void serializeAndDeserialize(final T toSend, final T toReceive) throws Exception {
        final BytesStreamOutput bso = new BytesStreamOutput();
        toSend.writeTo(bso);
        bso.close();
        final BytesReference bytes = bso.bytes();
        final BytesStreamInput bsi = new BytesStreamInput(bytes);
        toReceive.readFrom(bsi);
        bsi.close();
        assertEquals(toSend.getName(), toReceive.getName());
        assertEquals(toSend.getType(), toReceive.getType());
View Full Code Here

        DistributedResultRequest r1 = new DistributedResultRequest(uuid, streamers);
        r1.rows(rows);

        BytesStreamOutput out = new BytesStreamOutput();
        r1.writeTo(out);
        BytesStreamInput in = new BytesStreamInput(out.bytes());
        DistributedResultRequest r2 = new DistributedResultRequest(cm);
        r2.readFrom(in);

        assertEquals(r1.rows().length, r2.rows().length);
View Full Code Here

        Value v = new Value(DataTypes.STRING);

        BytesStreamOutput out = new BytesStreamOutput();
        Symbol.toStream(v, out);

        BytesStreamInput in = new BytesStreamInput(out.bytes());
        Value v2 = (Value) Symbol.fromStream(in);
        assertEquals(v2.valueType(), DataTypes.STRING);
    }
}
View Full Code Here

        r1.rows(new Object[][]{new String[]{}});

        r1.writeTo(o);

        r2 = new SQLResponse();
        r2.readFrom(new BytesStreamInput(o.bytes()));


        assertArrayEquals(r1.cols(), r2.cols());
        assertArrayEquals(r1.columnTypes(), r2.columnTypes());
        assertArrayEquals(r1.rows(), r2.rows());
View Full Code Here

        r1.rows(new Object[][]{new String[]{"va", "vb"}});

        r1.writeTo(o);

        r2 = new SQLResponse();
        r2.readFrom(new BytesStreamInput(o.bytes()));

        assertArrayEquals(r1.cols(), r2.cols());
        assertArrayEquals(r1.columnTypes(), r2.columnTypes());
        assertArrayEquals(r1.rows(), r2.rows());
        assertEquals(r1.rowCount(), r2.rowCount());
View Full Code Here

        r1.rowCount(2L);

        r1.writeTo(o);

        r2 = new SQLResponse();
        r2.readFrom(new BytesStreamInput(o.bytes()));

        assertArrayEquals(r1.cols(), r2.cols());
        assertArrayEquals(r1.columnTypes(), r2.columnTypes());
        assertArrayEquals(r1.rows(), r2.rows());
        assertEquals(r1.rowCount(), r2.rowCount());
View Full Code Here

        BytesStreamOutput out = new BytesStreamOutput();
        resp.writeTo(out);

        byte[] expectedBytes = new byte[]
                { 0,0,2,2,4,99,111,108,49,4,99,111,108,50,0,0,0,2,0,9,114,111,119,49,95,99,111,108,49,0,9,114,111,119,49,95,99,111,108,50,0,9,114,111,119,50,95,99,111,108,49,0,9,114,111,119,50,95,99,111,108,50,0,1,0,0,0,2,4,4};
        byte[] bytes = out.bytes().toBytes();
        assertThat(bytes, is(expectedBytes));
    }

    @Test
    public void testSerializationReadFrom() throws Exception {
View Full Code Here

                        new Object[] { "more", "args" }
                });

        BytesStreamOutput out = new BytesStreamOutput();
        request.writeTo(out);
        BytesStreamInput in = new BytesStreamInput(out.bytes());
        SQLBulkRequest serialized = new SQLBulkRequest();
        serialized.readFrom(in);

        assertArrayEquals(request.bulkArgs(), serialized.bulkArgs());
    }
View Full Code Here

    @Test
    public void testEmptyBulkArgsSerialization() throws Exception {
        SQLBulkRequest request = new SQLBulkRequest("select * from sys.cluster");
        BytesStreamOutput out = new BytesStreamOutput();
        request.writeTo(out);
        BytesStreamInput in = new BytesStreamInput(out.bytes());
        SQLBulkRequest serialized = new SQLBulkRequest();
        serialized.readFrom(in);

        Object[][] empty = new Object[0][];
        assertArrayEquals(empty, serialized.bulkArgs());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.