Package java.nio

Examples of java.nio.ByteBuffer.slice()


            : JavaUtil.convertRubyToJava(parameter, paramClass));
    }
    public static final ByteBuffer slice(ByteBuffer buf, int offset) {
        ByteBuffer tmp = buf.duplicate();
        tmp.position((int) offset);
        return tmp.slice();
    }
}
View Full Code Here


            return false;
        }
        static ByteBuffer slice(ByteBuffer buffer, int position, int size) {
            ByteBuffer tmp = buffer.duplicate();
            tmp.position(position).limit(position + size);
            return tmp.slice();
        }
        @Override
        public Pointer getPointer(long offset) {
            if (Platform.getPlatform().longSize() == 32) {
                IntByReference ref = new IntByReference(getInt(offset));
View Full Code Here

            if (encoding != DataBlockEncoding.NONE) {
              // We expect a two-byte big-endian encoding id.
              assertEquals(0, actualBuffer.get(0));
              assertEquals(encoding.getId(), actualBuffer.get(1));
              actualBuffer.position(2);
              actualBuffer = actualBuffer.slice();
            }

            ByteBuffer expectedBuffer = encodedBlocks.get(blockId);
            expectedBuffer.rewind();
View Full Code Here

            if (encoding != DataBlockEncoding.NONE) {
              // We expect a two-byte big-endian encoding id.
              assertEquals(0, actualBuffer.get(0));
              assertEquals(encoding.getId(), actualBuffer.get(1));
              actualBuffer.position(2);
              actualBuffer = actualBuffer.slice();
            }

            ByteBuffer expectedBuffer = encodedBlocks.get(blockId);
            expectedBuffer.rewind();
View Full Code Here

            for (int i = 1; i < 5; i++) {
                int size = buffer.remaining() + i;
                IoBuffer extendedBuffer = IoBuffer.wrap(ByteBuffer.allocate(size));
                int start = extendedBuffer.position();
                extendedBuffer.put(buffer.slice());
                extendedBuffer.position(start);
                extendedBuffer.limit(start + size);

                try {
                    decoder.decode(extendedBuffer);
View Full Code Here

        byte[] dataAsBytes = new byte[bodySize];
        tupleInput.readFast(dataAsBytes);

        ByteBuffer buf = ByteBuffer.wrap(dataAsBytes);
        buf.position(1);
        buf = buf.slice();
        MessageMetaDataType type = MessageMetaDataTypeRegistry.fromOrdinal(dataAsBytes[0]);
        return type.createMetaData(buf);
    }

    @Override
View Full Code Here

        final int bodySize = 1 + metaData.getStorableSize();
        byte[] underlying = new byte[bodySize];
        underlying[0] = (byte) metaData.getType().ordinal();
        ByteBuffer buf = ByteBuffer.wrap(underlying);
        buf.position(1);
        buf = buf.slice();

        metaData.writeToBuffer(0, buf);
        tupleOutput.writeInt(bodySize);
        tupleOutput.writeFast(underlying);
    }
View Full Code Here

          throw new RuntimeException("you need to seekTo() before calling getValue()");
        }
        // TODO: Could this be done with one ByteBuffer rather than create two?
        ByteBuffer valueBuff = this.block.slice();
        valueBuff.position(this.currKeyLen);
        valueBuff = valueBuff.slice();
        valueBuff.limit(currValueLen);
        valueBuff.rewind();
        return valueBuff;
      }
View Full Code Here

                @Override
                public int getContent(int offsetInMessage, ByteBuffer dst)
                {
                    ByteBuffer buf = allData.duplicate();
                    buf.position(offsetInMessage);
                    buf = buf.slice();
                    int size;
                    if(dst.remaining()<buf.remaining())
                    {
                        buf.limit(dst.remaining());
                        size = dst.remaining();
View Full Code Here

                @Override
                public ByteBuffer getContent(int offsetInMessage, int size)
                {
                    ByteBuffer buf = allData.duplicate();
                    buf.position(offsetInMessage);
                    buf = buf.slice();
                    if(size < buf.remaining())
                    {
                        buf.limit(size);
                    }
                    return buf;
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.