Examples of slice()


Examples of java.nio.ByteBuffer.slice()

     * without the length prefix.
     */
    ByteBuffer result = readBuffer.duplicate();
    result.limit(messageLen);
    result.position(PREFIX_LENGTH);
                set(result.slice().asReadOnlyBuffer());
                return null;
            } else {
    if (logger.isLoggable(Level.FINER)) {
        logger.log(Level.FINER, "{0} read incomplete {1}:{2}",
             this, messageLen, readBuffer.position());
View Full Code Here

Examples of java.nio.ByteBuffer.slice()

    @Override
    public ByteBuffer read(int position, int length) {
        ByteBuffer entry = buffer.asReadOnlyBuffer();
        entry.position(position);
        entry.limit(position + length);
        return entry.slice();
    }

    @Override
    public synchronized void write(
            int position, byte[] b, int offset, int length)
View Full Code Here

Examples of java.nio.ByteBuffer.slice()

            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

Examples of java.nio.ByteBuffer.slice()

                case Leader.REQUEST:
                    bb = ByteBuffer.wrap(qp.getData());
                    sessionId = bb.getLong();
                    cxid = bb.getInt();
                    type = bb.getInt();
                    bb = bb.slice();
                    if(type == OpCode.sync){
                       leader.zk.submitRequest(new FollowerSyncRequest(this, sessionId, cxid, type, bb,
                                qp.getAuthinfo()));
                    } else {
                    leader.zk.submitRequest(null, sessionId, type, cxid, bb,
View Full Code Here

Examples of java.nio.ByteBuffer.slice()

      }

      // TODO: Could this be done with one ByteBuffer rather than create two?
      ByteBuffer valueBuff = blockBuffer.slice();
      valueBuff.position(currKeyLen);
      valueBuff = valueBuff.slice();
      valueBuff.limit(currValueLen);
      valueBuff.rewind();
      return valueBuff;
    }
View Full Code Here

Examples of java.nio.ByteBuffer.slice()

  public int charAt(int position) {
    if (position > this.length) return -1; // too long
    if (position < 0) return -1; // duh.
     
    ByteBuffer bb = (ByteBuffer)ByteBuffer.wrap(bytes).position(position);
    return bytesToCodePoint(bb.slice());
  }
 
  public int find(String what) {
    return find(what, 0);
  }
View Full Code Here

Examples of java.nio.ByteBuffer.slice()

            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

Examples of java.nio.ByteBuffer.slice()

            ByteBuffer data = ByteBuffer.wrap(cb.getData());
            if(offset+written >= pos && offset < pos + data.limit())
            {
                ByteBuffer src = data.duplicate();
                src.position(offset+written - pos);
                src = src.slice();

                if(buf.remaining() < src.limit())
                {
                    src.limit(buf.remaining());
                }
View Full Code Here

Examples of java.nio.ByteBuffer.slice()

                        switch (streamSourceFrameChannel.getType()) {
                            case PING:
                                final ByteBuffer[] payload = new ByteBuffer[buffers.length];
                                for (int i = 0; i < buffers.length; i++) {
                                    ByteBuffer buf = buffers[i];
                                    payload[i] = buf.slice();
                                }
                                if (session.executeInIoThread) {
                                    handler.onPingFrame(session, payload);
                                    session.sendPong(buffers, new SendCallback() {
                                        @Override
View Full Code Here

Examples of java.nio.ByteBuffer.slice()

        if (buffer == null) {
            return;
        }
        ByteBuffer buf = buffer;
        buf.position((int) fileOffset);
        buf = (ByteBuffer) buf.slice().limit(destBuf.remaining());
        destBuf.put(buf);
    }

    public long getLength() {
        refresh();
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.