Examples of bytes()


Examples of org.elasticsearch.common.io.BytesStream.bytes()

    BytesReference bytesReference = mock(BytesReference.class);
    BytesStream bytesStream = mock(BytesStream.class);

    when(nameBuilder.getIndexName(any(Event.class))).thenReturn("foo_index");
    when(bytesReference.toBytes()).thenReturn("{\"body\":\"test\"}".getBytes());
    when(bytesStream.bytes()).thenReturn(bytesReference);
    when(serializer.getContentBuilder(any(Event.class)))
        .thenReturn(bytesStream);
    when(elasticSearchClient.prepareIndex(anyString(), anyString()))
        .thenReturn(indexRequestBuilder);
    when(indexRequestBuilder.setSource(bytesReference)).thenReturn(
View Full Code Here

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

    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.ReleasableBytesStreamOutput.bytes()

            stream = new HandlesStreamOutput(stream);
            stream.setVersion(version);
            response.writeTo(stream);
            stream.close();

            ReleasableBytesReference bytes = bStream.bytes();
            ChannelBuffer buffer = bytes.toChannelBuffer();
            NettyHeader.writeHeader(buffer, requestId, status, version);
            ChannelFuture future = channel.write(buffer);
            ReleaseChannelFutureListener listener = new ReleaseChannelFutureListener(bytes);
            future.addListener(listener);
View Full Code Here

Examples of org.elasticsearch.common.text.Text.bytes()

        } else if (value instanceof BytesRef) {
            BytesRef bytes = (BytesRef) value;
            generator.writeBinary(bytes.bytes, bytes.offset, bytes.length);
        } else if (value instanceof Text) {
            Text text = (Text) value;
            if (text.hasBytes() && text.bytes().hasArray()) {
                generator.writeUTF8String(text.bytes().array(), text.bytes().arrayOffset(), text.bytes().length());
            } else if (text.hasString()) {
                generator.writeString(text.string());
            } else {
                BytesArray bytesArray = text.bytes().toBytesArray();
View Full Code Here

Examples of org.elasticsearch.common.unit.ByteSizeValue.bytes()

    public static void main(String[] args) throws InterruptedException {
        final ByteSizeValue payloadSize = new ByteSizeValue(10, ByteSizeUnit.MB);
        final int NUMBER_OF_ITERATIONS = 100000;
        final int NUMBER_OF_CLIENTS = 5;
        final byte[] payload = new byte[(int) payloadSize.bytes()];

        Settings settings = ImmutableSettings.settingsBuilder()
                .build();

        final ThreadPool threadPool = new ThreadPool();
View Full Code Here

Examples of org.elasticsearch.common.xcontent.XContentBuilder.bytes()

    }
    expected.endObject();

    XContentBuilder actual = fixture.getContentBuilder(event);

    assertEquals(new String(expected.bytes().array()), new String(actual
        .bytes().array()));

  }
}
View Full Code Here

Examples of org.elasticsearch.hadoop.util.BytesArray.bytes()

                generator.flush();
                generator.close();

                // jackson likely will add leading/trailing "" which are added down the pipeline so remove them
                // however that's not mandatory in case the source is a number (instead of a string)
                if ((lookForQuotes && !addQuotesIfNecessary) && ba.bytes()[ba.offset()] == '"') {
                    ba.size(Math.max(0, ba.length() - 2));
                    ba.offset(1);
                }
            }
        }
View Full Code Here

Examples of org.elasticsearch.hadoop.util.BytesArray.bytes()

    }

    public static void putMapping(String index, byte[] content) throws Exception {
        RestClient rc = new ExtendedRestClient();
        BytesArray bs = new BytesArray(content);
        rc.putMapping(index, index + "/_mapping", bs.bytes());
        rc.close();
    }

    public static Field getMapping(String index) throws Exception {
        ExtendedRestClient rc = new ExtendedRestClient();
View Full Code Here

Examples of org.elasticsearch.hadoop.util.FastByteArrayOutputStream.bytes()

    DataOutputStream da = new DataOutputStream(out);
    written.write(da);
    da.close();
   
    LinkedMapWritable read = new LinkedMapWritable();
    read.readFields(new DataInputStream(new FastByteArrayInputStream(out.bytes())));
    assertThat(read.size(), is(written.size()));
    assertThat(read.toString(), is(written.toString()));
  }
}
View Full Code Here

Examples of org.jruby.util.ByteList.bytes()

                ByteList buf = new ByteList();
                int c;
                while ((c = in.read()) != -1) {
                    buf.append(c);
                }
                return buf.bytes();
            }
        });
    }

    private byte[] safeGetBytes(String s) {
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.