Package org.elasticsearch.common.io.stream

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


        p.values(ImmutableList.<Aggregation>of());
        p.setRequiredGranularity(RowGranularity.SHARD);
        BytesStreamOutput out = new BytesStreamOutput();
        Projection.toStream(p, out);

        BytesStreamInput in = new BytesStreamInput(out.bytes());
        GroupProjection p2 = (GroupProjection) Projection.fromStream(in);
        assertEquals(p, p2);
    }
}
View Full Code Here


        p.query(TestingHelpers.createFunction(AndOperator.NAME, DataTypes.BOOLEAN, Literal.newLiteral(true), Literal.newLiteral(false)));

        BytesStreamOutput out = new BytesStreamOutput();
        Projection.toStream(p, out);

        BytesStreamInput in = new BytesStreamInput(out.bytes());
        FilterProjection p2 = (FilterProjection) Projection.fromStream(in);

        assertEquals(p, p2);
    }
}
View Full Code Here

        BytesStreamOutput streamOutput = new BytesStreamOutput();
        state.writeTo(streamOutput);

        AggregationState newState = impl.newState();
        newState.readFrom(new BytesStreamInput(streamOutput.bytes()));
        assertEquals(state.value(), newState.value());
    }

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

        ArrayType arrayType = new ArrayType(new ArrayType(StringType.INSTANCE));
        BytesStreamOutput out = new BytesStreamOutput();

        DataTypes.toStream(arrayType, out);

        BytesStreamInput in = new BytesStreamInput(out.bytes());

        DataType readType = DataTypes.fromStream(in);
        assertThat(readType, instanceOf(ArrayType.class));

        ArrayType readArrayType = (ArrayType)readType;
View Full Code Here

        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

                    generator.close();

                } catch (Exception ex) {
                    response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.INTERNAL_SERVER_ERROR);
                }
                response.setContent(ChannelBuffers.copiedBuffer(out.bytes().toUtf8(), CharsetUtil.UTF_8));

                responses.add(out.bytes().toUtf8());
                if (logger.isDebugEnabled()) {
                    logger.debug("Sending response: " + out.bytes().toUtf8());
                }
View Full Code Here

                } catch (Exception ex) {
                    response = new DefaultHttpResponse(HttpVersion.HTTP_1_1, HttpResponseStatus.INTERNAL_SERVER_ERROR);
                }
                response.setContent(ChannelBuffers.copiedBuffer(out.bytes().toUtf8(), CharsetUtil.UTF_8));

                responses.add(out.bytes().toUtf8());
                if (logger.isDebugEnabled()) {
                    logger.debug("Sending response: " + out.bytes().toUtf8());
                }

                ChannelFuture future = e.getChannel().write(response);
View Full Code Here

                }
                response.setContent(ChannelBuffers.copiedBuffer(out.bytes().toUtf8(), CharsetUtil.UTF_8));

                responses.add(out.bytes().toUtf8());
                if (logger.isDebugEnabled()) {
                    logger.debug("Sending response: " + out.bytes().toUtf8());
                }

                ChannelFuture future = e.getChannel().write(response);
                future.addListener(ChannelFutureListener.CLOSE);
            }
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

        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

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.