Package java.nio

Examples of java.nio.Buffer


    public static void testFlip(Buffer buf) {
        // save state
        int oldPosition = buf.position();
        int oldLimit = buf.limit();

        Buffer ret = buf.flip();
        assertSame(ret, buf);
        assertEquals(buf.position(), 0);
        assertEquals(buf.limit(), oldPosition);
        try {
            buf.reset();
View Full Code Here


    public static void testLimitint(Buffer buf) {
        // save state
        int oldPosition = buf.position();
        int oldLimit = buf.limit();
       
        Buffer ret = buf.limit(buf.limit());
        assertSame(ret, buf);

        buf.mark();
        buf.limit(buf.capacity());
        assertEquals(buf.limit(), buf.capacity());
View Full Code Here

    public static void testMark(Buffer buf) {
        // save state
        int oldPosition = buf.position();
        int oldLimit = buf.limit();

        Buffer ret = buf.mark();
        assertSame(ret, buf);

        buf.mark();
        buf.position(buf.limit());
        buf.reset();
View Full Code Here

            } catch (InvalidMarkException e) {
                // expected
            }
        }
       
        Buffer ret = buf.position(0);
        assertSame(ret, buf);

        // restore state
        buf.limit(oldLimit);
        buf.position(oldPosition);
View Full Code Here

        buf.mark();
        buf.position(buf.limit());
        buf.reset();
        assertEquals(buf.position(), oldPosition);
       
        Buffer ret = buf.reset();
        assertSame(ret, buf);

        buf.clear();
        try {
            buf.reset();
View Full Code Here

    public static void testRewind(Buffer buf) {
        // save state
        int oldPosition = buf.position();
        int oldLimit = buf.limit();
       
        Buffer ret = buf.rewind();
        assertEquals(buf.position(), 0);
        assertSame(ret, buf);
        try {
            buf.reset();
            fail("Should throw Exception"); //$NON-NLS-1$
View Full Code Here

    if (dst.position() > 0) {
      presliced = dst;
      dst = dst.slice();
    }

    Buffer originalCompressed = compressedDirectBuf;
    Buffer originalUncompressed = uncompressedDirectBuf;
    int originalBufferSize = directBufferSize;
    compressedDirectBuf = src.slice();
    compressedDirectBufLen = src.remaining();
    uncompressedDirectBuf = dst;
    directBufferSize = dst.remaining();
View Full Code Here

    if (dst.position() > 0) {
      presliced = dst;
      dst = dst.slice();
    }

    Buffer originalCompressed = compressedDirectBuf;
    Buffer originalUncompressed = uncompressedDirectBuf;
    int originalBufferSize = directBufferSize;
    compressedDirectBuf = src;
    compressedDirectBufOff = src.position();
    compressedDirectBufLen = src.remaining();
    uncompressedDirectBuf = dst;
View Full Code Here

  @Test
  public void canSerializeNullableDecimals() throws SerDeException, IOException {
    String field = "{ \"name\":\"nullableBytes\", \"type\":[\"null\", " +
        "{\"type\":\"bytes\", \"logicalType\":\"decimal\", \"precision\":5, \"scale\":4}] }";
    Buffer bb = AvroSerdeUtils.getBufferFromDecimal(HiveDecimal.create("3.1416"), 4);
    GenericRecord r = serializeAndDeserialize(field, "nullableBytes", bb);

    Object result = r.get("nullableBytes");
    assertNotSame(bb, result);
    assertEquals(bb, result);
View Full Code Here

         * @param  length   The number of characters to read.
         * @throws IOException If an error (including EOF) occurred while reading the stream.
         */
        final void readFully(final int dataSize, int offset, int length) throws IOException {
            ensureBufferContains(Math.min(length * dataSize, buffer.capacity()));
            final Buffer view = createView(); // Must be after ensureBufferContains
            int n = Math.min(view.remaining(), length);
            transfer(offset, n);
            skipInBuffer(n * dataSize);
            while ((length -= n) != 0) {
                offset += n;
                ensureBufferContains(dataSize);
                view.position(0).limit(buffer.remaining() / dataSize);
                transfer(offset, n = Math.min(view.remaining(), length));
                skipInBuffer(n * dataSize);
            }
        }
View Full Code Here

TOP

Related Classes of java.nio.Buffer

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.