Examples of rewind()


Examples of java.nio.ByteBuffer.rewind()

      ByteBuffer buf = getByteBuffer(nio_segment_size);

      int index = 0;
      while (index < src.length)
      {
        buf.rewind();
        int remaining = src.length - index;
        int size = Math.min(nio_segment_size, remaining);
        if (size != buf.capacity())
        {
          // System.out.println("reallocating segment_size: " +
View Full Code Here

Examples of java.nio.ByteBuffer.rewind()

              actualBuffer.position(2);
              actualBuffer = actualBuffer.slice();
            }

            ByteBuffer expectedBuffer = encodedBlocks.get(blockId);
            expectedBuffer.rewind();

            // test if content matches, produce nice message
            assertBuffersEqual(expectedBuffer, actualBuffer, algo, encoding,
                pread);
          }
View Full Code Here

Examples of java.nio.ByteBuffer.rewind()

    final int rawBlockSize = writeTestKeyValues(doubleOutputStream,
        blockId, includesMemstoreTS);

    ByteBuffer rawBuf = ByteBuffer.wrap(baos.toByteArray());
    rawBuf.rewind();

    final int encodedSize;
    final ByteBuffer encodedBuf;
    if (encoding == DataBlockEncoding.NONE) {
      encodedSize = rawBlockSize;
View Full Code Here

Examples of java.nio.ByteBuffer.rewind()

              actualBuffer.position(2);
              actualBuffer = actualBuffer.slice();
            }

            ByteBuffer expectedBuffer = encodedBlocks.get(blockId);
            expectedBuffer.rewind();

            // test if content matches, produce nice message
            TestHFileBlock.assertBuffersEqual(expectedBuffer, actualBuffer, algo, encoding,
                pread);
          }
View Full Code Here

Examples of java.nio.ByteBuffer.rewind()

        this.delimiter = delimiter;

        // Convert delimiter to ByteBuffer if not done yet.
        if (delimBuf == null) {
            ByteBuffer tmp = charset.encode(CharBuffer.wrap(delimiter.getValue()));
            tmp.rewind();
            delimBuf = tmp;
        }
    }

    /**
 
View Full Code Here

Examples of java.nio.ByteBuffer.rewind()

        for (T object : getObjects()) {
            int size = encoder.getEncodedSize(object);
            ByteBuffer out = ByteBuffer.allocate(size);
            encoder.writeTo(object, out);           
            assertEquals(size, out.position());
            out.rewind();
            assertEquals(object, decoder.decode(IoBuffer.wrap(out)));
        }
    }
}
View Full Code Here

Examples of java.nio.ByteBuffer.rewind()

    public void verifyThatHeaderWithoutLeadingSpaceIsSupported() throws UnsupportedEncodingException,
            ProtocolDecoderException {
        String reqStr = "GET / HTTP/1.0\r\nHost:localhost\r\n\r\n";
        ByteBuffer buffer = ByteBuffer.allocate(reqStr.length());
        buffer.put(reqStr.getBytes("US-ASCII"));
        buffer.rewind();
        HttpServerDecoder decoder = new HttpServerDecoder();
        HttpDecoderState state = decoder.createDecoderState();
        HttpPdu pdus = decoder.decode(buffer, state);
        assertNotNull(pdus);
View Full Code Here

Examples of java.nio.ByteBuffer.rewind()

    public void verifyThatLeadingSpacesAreRemovedFromHeader() throws UnsupportedEncodingException,
            ProtocolDecoderException {
        String reqStr = "GET / HTTP/1.0\r\nHost:  localhost\r\n\r\n";
        ByteBuffer buffer = ByteBuffer.allocate(reqStr.length());
        buffer.put(reqStr.getBytes("US-ASCII"));
        buffer.rewind();
        HttpServerDecoder decoder = new HttpServerDecoder();
        HttpDecoderState state = decoder.createDecoderState();
        HttpPdu pdus = decoder.decode(buffer, state);
        assertNotNull(pdus);
        assertEquals("localhost", ((HttpRequestImpl) pdus).getHeader("host"));
View Full Code Here

Examples of java.nio.ByteBuffer.rewind()

    public void verifyThatTrailingSpacesAreRemovedFromHeader() throws UnsupportedEncodingException,
            ProtocolDecoderException {
        String reqStr = "GET / HTTP/1.0\r\nHost:localhost  \r\n\r\n";
        ByteBuffer buffer = ByteBuffer.allocate(reqStr.length());
        buffer.put(reqStr.getBytes("US-ASCII"));
        buffer.rewind();
        HttpServerDecoder decoder = new HttpServerDecoder();
        HttpDecoderState state = decoder.createDecoderState();
        HttpPdu pdus = decoder.decode(buffer, state);
        assertNotNull(pdus);
        assertEquals("localhost", ((HttpRequestImpl) pdus).getHeader("host"));
View Full Code Here

Examples of java.nio.ByteBuffer.rewind()

          inMemory);
      bucketEntry.setDeserialiserReference(data.getDeserializer(), deserialiserMap);
      try {
        if (data instanceof HFileBlock) {
          ByteBuffer sliceBuf = ((HFileBlock) data).getBufferReadOnlyWithHeader();
          sliceBuf.rewind();
          assert len == sliceBuf.limit() + HFileBlock.EXTRA_SERIALIZATION_SPACE;
          ByteBuffer extraInfoBuffer = ByteBuffer.allocate(HFileBlock.EXTRA_SERIALIZATION_SPACE);
          ((HFileBlock) data).serializeExtraInfo(extraInfoBuffer);
          ioEngine.write(sliceBuf, offset);
          ioEngine.write(extraInfoBuffer, offset + len - HFileBlock.EXTRA_SERIALIZATION_SPACE);
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.