Package org.elasticsearch.common.io.stream

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


        for (int i = 0; i < fields.size(); i++) {
            header.writeString(fields.get(i));
            header.writeVLong(fieldOffset.get(i).longValue());
        }
        header.close();
        return header.bytes();
    }

    private DocsEnum writeTermWithDocsOnly(TermsEnum iterator, DocsEnum docsEnum) throws IOException {
        docsEnum = iterator.docs(null, docsEnum);
        int nextDoc = docsEnum.nextDoc();
View Full Code Here


        byte status = 0;
        status = TransportStatus.setResponse(status);
        stream.writeByte(status); // 0 for request, 1 for response.
        response.writeTo(stream);
        stream.close();
        final byte[] data = bStream.bytes().toBytes();
        targetTransport.workers().execute(new Runnable() {
            @Override
            public void run() {
                targetTransport.messageReceived(data, action, sourceTransport, version, null);
            }
View Full Code Here

            RemoteTransportException tx = new RemoteTransportException(targetTransport.nodeName(), targetTransport.boundAddress().boundAddress(), action, new NotSerializableTransportException(error));
            ThrowableObjectOutputStream too = new ThrowableObjectOutputStream(stream);
            too.writeObject(tx);
            too.close();
        }
        final byte[] data = stream.bytes().toBytes();
        targetTransport.workers().execute(new Runnable() {
            @Override
            public void run() {
                targetTransport.messageReceived(data, action, sourceTransport, version, null);
            }
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()));
View Full Code Here

                        if ("doc".equals(currentFieldName)) {
                            BytesStreamOutput bStream = new BytesStreamOutput();
                            XContentBuilder builder = XContentFactory.contentBuilder(XContentType.SMILE, bStream);
                            builder.copyCurrentStructure(parser);
                            builder.close();
                            doc.setSource(bStream.bytes());
                            break;
                        } else {
                            parser.skipChildren();
                        }
                    } else if (token == null) {
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()));
View Full Code Here

                writer.close();
            } catch (IOException e) {
                logger.error("Could not execute query template (failed to close writer): ", e);
            }
        }
        return result.bytes();
    }

    @Override
    public String[] types() {
        return new String[] {"mustache"};
View Full Code Here

                    writer.close();
                } catch (IOException e) {
                    logger.error("Could not execute query template (failed to close writer): ", e);
                }
            }
            return result.bytes();
        }

        @Override
        public Object unwrap(Object value) {
            return value;
View Full Code Here

        int length = randomIntBetween(10, PAGE_SIZE * 4);
        BytesReference pbr = getRandomizedPagedBytesReference(length);
        BytesStreamOutput out = new BytesStreamOutput();
        pbr.writeTo(out);
        assertEquals(pbr.length(), out.size());
        assertArrayEquals(pbr.toBytes(), out.bytes().toBytes());
        out.close();
    }

    public void testWriteToChannel() throws IOException {
        int length = randomIntBetween(10, PAGE_SIZE * 4);
 
View Full Code Here

        int sliceLength = length - sliceOffset;
        BytesReference slice = pbr.slice(sliceOffset, sliceLength);
        BytesStreamOutput sliceOut = new BytesStreamOutput(sliceLength);
        slice.writeTo(sliceOut);
        assertEquals(slice.length(), sliceOut.size());
        assertArrayEquals(slice.toBytes(), sliceOut.bytes().toBytes());
        sliceOut.close();
    }

    public void testSliceWriteToChannel() throws IOException {
        int length = randomIntBetween(10, PAGE_SIZE * randomIntBetween(2, 5));
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.