Examples of StreamInput


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

        // test stream input over slice (upper half of original)
        int sliceOffset = randomIntBetween(1, length / 2);
        int sliceLength = length - sliceOffset;
        BytesReference slice = pbr.slice(sliceOffset, sliceLength);
        StreamInput sliceInput = slice.streamInput();

        // single reads
        assertEquals(slice.get(0), sliceInput.readByte());
        assertEquals(slice.get(1), sliceInput.readByte());
        assertEquals(slice.get(2), sliceInput.readByte());

        // reset the slice stream for bulk reading
        sliceInput.reset();

        // bulk read
        byte[] sliceBytes = new byte[sliceLength];
        sliceInput.readFully(sliceBytes);

        // compare slice content with upper half of original
        byte[] pbrSliceBytes = Arrays.copyOfRange(pbr.toBytes(), sliceOffset, length);
        assertArrayEquals(pbrSliceBytes, sliceBytes);

        // compare slice bytes with bytes read from slice via streamInput :D
        byte[] sliceToBytes = slice.toBytes();
        assertEquals(sliceBytes.length, sliceToBytes.length);
        assertArrayEquals(sliceBytes, sliceToBytes);

        sliceInput.reset();
        byte[] buffer = new byte[sliceLength + scaledRandomIntBetween(1, 100)];
        int offset = scaledRandomIntBetween(0, Math.max(1, buffer.length - sliceLength - 1));
        int read = sliceInput.read(buffer, offset, sliceLength / 2);
        sliceInput.read(buffer, offset + read, sliceLength);
        assertArrayEquals(sliceBytes, Arrays.copyOfRange(buffer, offset, offset + sliceLength));
    }
View Full Code Here

Examples of org.jbpm.pvm.internal.stream.StreamInput

  public TypesBinding() {
    super("types");
  }

  public Object parse(Element element, Parse parse, Parser parser) {
    StreamInput streamSource = null;
    if (element.hasAttribute("file")) {
      String fileName = element.getAttribute("file");
      File file = new File(fileName);
      if (file.exists() && file.isFile()) {
        streamSource = new FileStreamInput(file);
View Full Code Here

Examples of org.jbpm.pvm.internal.stream.StreamInput

      } else if ("properties".equals(XmlUtil.getTagLocalName(configElement))) {
        PropertiesDescriptor propertiesDescriptor = (PropertiesDescriptor) propertiesBinding.parse(configElement, parse, parser);
        descriptor.setPropertiesDescriptor(propertiesDescriptor);

      } else if ("cache-configuration".equals(XmlUtil.getTagLocalName(configElement))) {
        StreamInput streamSource = null;

        String cacheUsage = configElement.getAttribute("usage");
        if (! ( ("read-only".equals(cacheUsage))
                || ("nonstrict-read-write".equals(cacheUsage))
                || ("read-write".equals(cacheUsage))
View Full Code Here

Examples of org.jbpm.pvm.internal.stream.StreamInput

  public TypesBinding() {
    super("types");
  }

  public Object parse(Element element, Parse parse, Parser parser) {
    StreamInput streamSource = null;
    if (element.hasAttribute("file")) {
      String fileName = element.getAttribute("file");
      File file = new File(fileName);
      if (file.exists() && file.isFile()) {
        streamSource = new FileStreamInput(file);
View Full Code Here

Examples of org.jbpm.pvm.internal.stream.StreamInput

      } else if ("properties".equals(XmlUtil.getTagLocalName(configElement))) {
        PropertiesDescriptor propertiesDescriptor = (PropertiesDescriptor) propertiesBinding.parse(configElement, parse, parser);
        descriptor.setPropertiesDescriptor(propertiesDescriptor);

      } else if ("cache-configuration".equals(XmlUtil.getTagLocalName(configElement))) {
        StreamInput streamSource = null;

        String cacheUsage = configElement.getAttribute("usage");
        if (! ( ("read-only".equals(cacheUsage))
                || ("nonstrict-read-write".equals(cacheUsage))
                || ("read-write".equals(cacheUsage))
View Full Code Here

Examples of org.msgpack.io.StreamInput

    public MessagePackUnpacker(InputStream stream) {
        this(new MessagePack(), stream);
    }

    public MessagePackUnpacker(MessagePack msgpack, InputStream stream) {
        this(msgpack, new StreamInput(stream));
    }
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.