Package java.nio

Examples of java.nio.ByteBuffer.limit()


     
      ByteBuffer tmpData = Misc.getByteBuffer(BLOCK_SIZE);
     
      byte_count = decompressor.inflate(tmpData.array());
   
      tmpData.limit(byte_count);
     
      vector.add(tmpData);
     
      capacity += byte_count;
     
View Full Code Here


                b.get();
            }
        }
       
        //We have finished filling the new bytebuffer, so set the limit, and rewind
        bb.limit(bb.position());
        bb.rewind();
       
        return bb;
    }
View Full Code Here

      throws IOException
    {
      ByteBuffer buf = ByteBuffer.wrap(data);

      // Don't fill the spare slot in data:
      buf.limit(nodeSize);

      int bytesRead = fileChannel.read(buf, nodeID2offset(id));
      assert bytesRead == nodeSize : "Read operation didn't read the entire node (" + bytesRead + " of "
          + nodeSize + " bytes)";
View Full Code Here

      throws IOException
    {
      ByteBuffer buf = ByteBuffer.wrap(data);

      // Don't write the spare slot in data to the file:
      buf.limit(nodeSize);

      int bytesWritten = fileChannel.write(buf, nodeID2offset(id));
      assert bytesWritten == nodeSize : "Write operation didn't write the entire node (" + bytesWritten
          + " of " + nodeSize + " bytes)";
View Full Code Here

    if (arr.getElementType() == ByteBuffer.class) { // turn OPAQUE into BYTE
      int totalLen = 0;
      arr.resetLocalIterator();
      while (arr.hasNext()) {
        ByteBuffer bb = (ByteBuffer) arr.next();
        totalLen += bb.limit();
      }
      byte[] ba = new byte[totalLen];
      int pos = 0;
      arr.resetLocalIterator();
      while (arr.hasNext()) {
View Full Code Here

      byte[] ba = new byte[totalLen];
      int pos = 0;
      arr.resetLocalIterator();
      while (arr.hasNext()) {
        ByteBuffer bb = (ByteBuffer) arr.next();
        System.arraycopy(bb.array(), 0, ba, pos, bb.limit());
        pos += bb.limit();
      }
      arr = Array.factory(DataType.BYTE, new int[]{totalLen}, ba);
    }
View Full Code Here

      int pos = 0;
      arr.resetLocalIterator();
      while (arr.hasNext()) {
        ByteBuffer bb = (ByteBuffer) arr.next();
        System.arraycopy(bb.array(), 0, ba, pos, bb.limit());
        pos += bb.limit();
      }
      arr = Array.factory(DataType.BYTE, new int[]{totalLen}, ba);
    }

    if (arr.getRank() > 1)
View Full Code Here

      }
    }

    bb.flip();
    wbc.write(bb);
    return bb.limit();
  }

  static int writeVLong(OutputStream out, long i) throws IOException {
    int count = 0;
    while ((i & ~0x7F) != 0) {
View Full Code Here

                // clear for next time
                buffer.clear();

                if (completeBuffer.position() >= Message.HEADER_SIZE + length) {
                    completeBuffer.limit(Message.HEADER_SIZE + length);
                    // Skip Header, got OpCode, now create function
                    completeBuffer.position(Message.HEADER_SIZE);
                    finished = true;
                    break;
                }
View Full Code Here

            // Correct header and correct length ?
            if (channBuffer.position() >= Message.HEADER_SIZE + length) {
                // set the limit (specified in the length), else we have a
                // default buffer limit
                channBuffer.limit(Message.HEADER_SIZE + length);

                // duplicate this buffer
                ByteBuffer dataBuffer = channBuffer.duplicate();

                // skip header (already analyzed)
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.