Package org.elasticsearch.common.io.stream

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


        Double[] p1 = new Double[] { 41.2, -37.4 };

        BytesStreamOutput out = new BytesStreamOutput();
        DataTypes.GEO_POINT.writeValueTo(out, p1);

        BytesStreamInput in = new BytesStreamInput(out.bytes());
        Double[] p2 = DataTypes.GEO_POINT.readValueFrom(in);

        assertThat(p1, equalTo(p2));
    }
View Full Code Here


    public void testStreamer() throws Exception {
        Shape value = GeoShapeType.INSTANCE.value("POINT (10 10)");

        BytesStreamOutput out = new BytesStreamOutput();
        GeoShapeType.INSTANCE.writeValueTo(out, value);
        BytesStreamInput in = new BytesStreamInput(out.bytes());
        Shape streamedShape = GeoShapeType.INSTANCE.readValueFrom(in);

        assertThat(streamedShape, equalTo(value));
    }
View Full Code Here

    private void addFromBytesReference(BytesReference bytesReference, DownstreamOperationContext ctx) {
        // bytesReference must be wrapped into HandlesStreamInput because it has a different readString()
        // implementation than BytesStreamInput alone.
        // and the memoryOutputStream originates from a HandlesStreamOutput.
        HandlesStreamInput wrappedStream = new HandlesStreamInput(new BytesStreamInput(bytesReference));
        Object[][] rows = null;
        try {
            rows = DistributedResultRequest.readRemaining(ctx.streamers(), wrappedStream);
        } catch (IOException e) {
            ctx.addFailure(e);
View Full Code Here

        requestOut.isLast = false;
        requestOut.content = new BytesArray(new byte[] { 0x65, 0x66 });
        requestOut.sourceNodeId = "nodeId";

        requestOut.writeTo(outputStream);
        BytesStreamInput inputStream = new BytesStreamInput(outputStream.bytes().copyBytesArray());

        PutChunkReplicaRequest requestIn = new PutChunkReplicaRequest();
        requestIn.readFrom(inputStream);

        assertEquals(requestOut.currentPos, requestIn.currentPos);
View Full Code Here

    public void testStreaming() throws Exception {
        BytesRef b1 = new BytesRef("hello");
        BytesStreamOutput out = new BytesStreamOutput();
        Streamer streamer = DataTypes.STRING.streamer();
        streamer.writeValueTo(out, b1);
        BytesStreamInput in = new BytesStreamInput(out.bytes());
        BytesRef b2 = (BytesRef) streamer.readValueFrom(in);
        assertEquals(b1, b2);
    }
View Full Code Here

    public void testStreamingNull() throws Exception {
        BytesRef b1 = null;
        BytesStreamOutput out = new BytesStreamOutput();
        Streamer streamer = DataTypes.STRING.streamer();
        streamer.writeValueTo(out, b1);
        BytesStreamInput in = new BytesStreamInput(out.bytes());
        BytesRef b2 = (BytesRef) streamer.readValueFrom(in);
        assertNull(b2);
    }
View Full Code Here

     * @throws IOException
     */
    public static Id fromString(String base64encodedString) throws IOException {
        assert base64encodedString != null;
        byte[] inputBytes = Base64.decode(base64encodedString);
        BytesStreamInput in = new BytesStreamInput(inputBytes, true);
        Id id = new Id();
        id.decodeValues(in);
        return id;
    }
View Full Code Here

        return new BytesArray(bytes, offset + from, length);
    }

    @Override
    public StreamInput streamInput() {
        return new BytesStreamInput(bytes, offset, length, false);
    }
View Full Code Here

        return new BytesArray(bytes, from, length);
    }

    @Override
    public StreamInput streamInput() {
        return new BytesStreamInput(bytes, false);
    }
View Full Code Here

                new MoveAllocationCommand(new ShardId("test", 3), "node2", "node3"),
                new CancelAllocationCommand(new ShardId("test", 4), "node5", true)
        );
        BytesStreamOutput bytes = new BytesStreamOutput();
        AllocationCommands.writeTo(commands, bytes);
        AllocationCommands sCommands = AllocationCommands.readFrom(new BytesStreamInput(bytes.bytes()));

        assertThat(sCommands.commands().size(), equalTo(3));
        assertThat(((AllocateAllocationCommand) (sCommands.commands().get(0))).shardId(), equalTo(new ShardId("test", 1)));
        assertThat(((AllocateAllocationCommand) (sCommands.commands().get(0))).node(), equalTo("node1"));
        assertThat(((AllocateAllocationCommand) (sCommands.commands().get(0))).allowPrimary(), equalTo(true));
View Full Code Here

TOP

Related Classes of org.elasticsearch.common.io.stream.BytesStreamInput

Copyright © 2018 www.massapicom. 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.