Package org.elasticsearch.common.io.stream

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


        BytesStreamOutput out = new BytesStreamOutput();
        out.setVersion(randomVersion());
        mltRequest.writeTo(out);

        BytesStreamInput in = new BytesStreamInput(out.bytes());
        in.setVersion(out.getVersion());
        MoreLikeThisRequest mltRequest2 = new MoreLikeThisRequest();
        mltRequest2.readFrom(in);

        assertThat(mltRequest2.index(), equalTo(mltRequest.index()));
        assertThat(mltRequest2.type(), equalTo(mltRequest.type()));
View Full Code Here


        BytesStreamOutput out = new BytesStreamOutput();
        out.setVersion(randomVersion());
        request.writeTo(out);

        BytesStreamInput in = new BytesStreamInput(out.bytes());
        in.setVersion(out.getVersion());
        GetIndexedScriptRequest request2 = new GetIndexedScriptRequest();
        request2.readFrom(in);

        assertThat(request2.id(), equalTo(request.id()));
        assertThat(request2.scriptLang(), equalTo(request.scriptLang()));
View Full Code Here

        private long sumTotalTermFreq;
        private long sumDocFreq;
        private int docCount;

        public TermVector(BytesReference termVectors, long readOffset) throws IOException {
            this.perFieldTermVectorInput = new BytesStreamInput(termVectors);
            this.readOffset = readOffset;
            reset();
        }
View Full Code Here

     * @param headerRef   Stores offsets per field in the {@code termVectors} and some
     *                    header information as {@link BytesRef}.
     * @param termVectors Stores the actual term vectors as a {@link BytesRef}.
     */
    public TermVectorFields(BytesReference headerRef, BytesReference termVectors) throws IOException {
        BytesStreamInput header = new BytesStreamInput(headerRef);
        fieldMap = new ObjectLongOpenHashMap<>();

        // here we read the header to fill the field offset map
        String headerString = header.readString();
        assert headerString.equals("TV");
        int version = header.readInt();
        assert version == -1;
        hasTermStatistic = header.readBoolean();
        hasFieldStatistic = header.readBoolean();
        final int numFields = header.readVInt();
        for (int i = 0; i < numFields; i++) {
            fieldMap.put((header.readString()), header.readVLong());
        }
        header.close();
        // reference to the term vector data
        this.termVectors = termVectors;
    }
View Full Code Here

            BytesStreamOutput output = new BytesStreamOutput();
            Version outputVersion = randomVersion();
            output.setVersion(outputVersion);
            indicesOptions.writeIndicesOptions(output);

            BytesStreamInput bytesStreamInput = new BytesStreamInput(output.bytes());
            bytesStreamInput.setVersion(randomVersion());
            IndicesOptions indicesOptions2 = IndicesOptions.readIndicesOptions(bytesStreamInput);

            assertThat(indicesOptions2.ignoreUnavailable(), equalTo(indicesOptions.ignoreUnavailable()));
            assertThat(indicesOptions2.allowNoIndices(), equalTo(indicesOptions.allowNoIndices()));
            assertThat(indicesOptions2.expandWildcardsOpen(), equalTo(indicesOptions.expandWildcardsOpen()));
View Full Code Here

    }

    @Override
    public Map<String, String> load(byte[] source) throws IOException {
        Properties props = new Properties();
        BytesStreamInput stream = new BytesStreamInput(source, false);
        try {
            props.load(stream);
            Map<String, String> result = newHashMap();
            for (Map.Entry entry : props.entrySet()) {
                result.put((String) entry.getKey(), (String) entry.getValue());
View Full Code Here


    public static XContentParser createParser(byte[] data, int offset, int length) throws IOException {
        Compressor compressor = CompressorFactory.compressor(data, offset, length);
        if (compressor != null) {
            CompressedStreamInput compressedInput = compressor.streamInput(new BytesStreamInput(data, offset, length, false));
            XContentType contentType = XContentFactory.xContentType(compressedInput);
            compressedInput.resetToBufferStart();
            return XContentFactory.xContent(contentType).createParser(compressedInput);
        } else {
            return XContentFactory.xContent(data, offset, length).createParser(data, offset, length);
View Full Code Here

        try {
            XContentParser parser;
            XContentType contentType;
            Compressor compressor = CompressorFactory.compressor(data, offset, length);
            if (compressor != null) {
                CompressedStreamInput compressedStreamInput = compressor.streamInput(new BytesStreamInput(data, offset, length, false));
                contentType = XContentFactory.xContentType(compressedStreamInput);
                compressedStreamInput.resetToBufferStart();
                parser = XContentFactory.xContent(contentType).createParser(compressedStreamInput);
            } else {
                contentType = XContentFactory.xContentType(data, offset, length);
View Full Code Here

        rwl.readLock().lock();
        try {
            FsTranslogFile translog = translogForLocation(location);
            if (translog != null) {
                byte[] data = translog.read(location);
                try (BytesStreamInput in = new BytesStreamInput(data, false)) {
                    // Return the Operation using the current version of the
                    // stream based on which translog is being read
                    return translog.getStream().read(in);
                }
            }
View Full Code Here

                // read beyond the EOF, must be an abrupt EOF
                throw new EOFException("tried to read past EOF. opSize [" + opSize + "] position [" + position + "] length [" + length + "]");
            }
            cacheBuffer.flip();
            position += opSize;
            return TranslogStreams.readTranslogOperation(new BytesStreamInput(cacheBuffer.array(), 0, opSize, true));
        } catch (IOException e) {
            throw new ElasticsearchException("unexpected exception reading from translog snapshot of " + this.raf.file(), e);
        }
    }
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.