Examples of BytesStreamOutput


Examples of org.elasticsearch.common.io.stream.BytesStreamOutput

        if (contentType == null) {
            // default to JSON
            contentType = XContentType.JSON;
        }
        XContentBuilder builder = new XContentBuilder(XContentFactory.xContent(contentType),
                new BytesStreamOutput());
        if (request.paramAsBoolean("pretty", false)) {
            builder.prettyPrint().lfAtEnd();
        }
        String casing = request.param("case");
        if (casing != null && "camelCase".equals(casing)) {
View Full Code Here

Examples of org.elasticsearch.common.io.stream.BytesStreamOutput

            }
        }
    }

    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

Examples of org.elasticsearch.common.io.stream.BytesStreamOutput

        assertEquals(randomWords, entries);
    }

    // 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

Examples of org.elasticsearch.common.io.stream.BytesStreamOutput

        }
        if (contentType == null) {
            // default to JSON
            contentType = XContentType.JSON;
        }
        XContentBuilder builder = new XContentBuilder(XContentFactory.xContent(contentType), new BytesStreamOutput());
        if (request.paramAsBoolean("pretty", false)) {
            builder.prettyPrint().lfAtEnd();
        }

        builder.humanReadable(request.paramAsBoolean("human", builder.humanReadable()));
View Full Code Here

Examples of org.elasticsearch.common.io.stream.BytesStreamOutput

        UUID uuid = UUID.randomUUID();

        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

Examples of org.elasticsearch.common.io.stream.BytesStreamOutput

    @Test
    public void testValueSymbol() throws Exception {
        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

Examples of org.elasticsearch.common.io.stream.BytesStreamOutput

    }

    @Test
    public void testResponseStreamable() throws Exception {

        BytesStreamOutput o = new BytesStreamOutput();
        SQLResponse r1, r2;

        r1 = new SQLResponse();
        r1.cols(new String[]{});
        r1.colTypes(new DataType[]{});
        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());
        assertEquals(r1.rowCount(), r2.rowCount());

        o.reset();
        r1 = new SQLResponse();
        r1.cols(new String[]{"a", "b"});
        r1.colTypes(new DataType[]{StringType.INSTANCE, StringType.INSTANCE});
        r1.includeTypes(true);
        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());

        o.reset();

        r1 = new SQLResponse();
        r1.cols(new String[]{"a", "b"});
        r1.colTypes(new DataType[0]);
        r1.rows(new Object[][]{new String[]{"ab","ba"}, new String[]{"ba", "ab"}});
        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

Examples of org.elasticsearch.common.io.stream.BytesStreamOutput

                2L,
                0,
                true
        );

        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));
    }
View Full Code Here

Examples of org.elasticsearch.common.io.stream.BytesStreamOutput

                new Object[][] {
                        new Object[] { "dummy", "args" },
                        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

Examples of org.elasticsearch.common.io.stream.BytesStreamOutput

    }

    @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.