Puts the contents of the given byte buffer at the given offset in the given block.
196793
private static int put(byte[] block, int offset, ByteBuffer buf) {
    int len = Math.min(block.length - offset, buf.remaining());
    buf.get(block, offset, len);
    return len;
  }
105033
void storeBlock(BlockId blockId, ByteBuffer block) throws IOException {
        synchronized (m_accessLock) {
            if (m_blockPathMap.containsKey(blockId)) {
                throw new IllegalArgumentException("Request to store block that is already stored: "
                                                    + blockId.toString());
            }

            int origPosition = block.position();
            block.position(0);
            Path blockPath = makeBlockPath(blockId);
            try (SeekableByteChannel channel = Files.newByteChannel(blockPath, OPEN_OPTIONS, PERMISSIONS)) {
                channel.write(block);
            }
            finally {
                block.position(origPosition);
            }

            m_blockPathMap.put(blockId, blockPath);
        }
    }
1007397
public void writeBytes (Object from, long offset, int count) throws KryoException {
		int copyCount = Math.min(capacity - position, count);
		while (true) {
			unsafe.copyMemory(from, offset, null, bufferAddress + position, copyCount);
			position += copyCount;
			count -= copyCount;
			if (count == 0) break;
			offset += copyCount;
			copyCount = Math.min(capacity, count);
			require(copyCount);
		}
		byteBuffer.position(position);
	}
451106
@Override
  public void write(byte []buffer, int offset, int length)
    throws IOException
  {
    while (length > 0) {
      if (_bufferEnd <= _offset) {
        flushBlock(false);
      }

      int sublen = Math.min(_bufferEnd - _offset, length);

      System.arraycopy(buffer, offset, _buffer, _offset, sublen);

      offset += sublen;
      _offset += sublen;

      length -= sublen;
    }
  }
394005
public void write(byte[] buffer, int offset, int length)
        throws IOException
    {
        OutputStream os = getOutputStream();

        for (; length > 0x8000; length -= 0x8000) {
            os.write('D');
            os.write(0x80);
            os.write(0x00);
            os.write(buffer, offset, 0x8000);

            offset += 0x8000;
        }

        os.write('D');
        os.write(length >> 8);
        os.write(length);
        os.write(buffer, offset, length);
    }
249050
def read_block(self, block):
        
        self.seek(block.file_offset)
        return self._fhandle.read(block.size)
1245917
private void writeBlock() throws IOException {
    if (buffer.position() == 0) {
      return;
    }
    // Make sure there's no stale data
    Arrays.fill(compressedBuffer, (byte) 0);

    int compressedLength = compressor.compress(buffer.array(), 0, buffer.position(), compressedBuffer, 0);
    final byte[] bufferToWrite;
    final int compressMethod;

    // Store block uncompressed if compressed length is greater (incompressible)
    if (compressedLength >= buffer.position()) {
      compressedLength = buffer.position();
      bufferToWrite = Arrays.copyOf(buffer.array(), compressedLength);
      compressMethod = LZ4_FRAME_INCOMPRESSIBLE_MASK;
    } else {
      bufferToWrite = compressedBuffer;
      compressMethod = 0;
    }

    // Write content
    intLEBuffer.putInt(0, compressedLength | compressMethod);
    out.write(intLEBuffer.array());
    out.write(bufferToWrite, 0, compressedLength);

    // Calculate and write block checksum
    if (frameInfo.isEnabled(FLG.Bits.BLOCK_CHECKSUM)) {
      intLEBuffer.putInt(0, checksum.hash(bufferToWrite, 0, compressedLength, 0));
      out.write(intLEBuffer.array());
    }
    buffer.rewind();
  }
1328289
void moveBlock()
    {
        int offset = _bufferOffset + _pos - _keepSizeBefore;
        // we need one additional byte, since movePos moves on 1 byte.
        if (offset > 0)
        {
            offset--;
        }

        int numBytes = _bufferOffset + _streamPos - offset;

        // check negative offset ????
        System.arraycopy(_bufferBase, offset, _bufferBase, 0, numBytes);
        _bufferOffset -= offset;
    }
393667
public static void writeBytes(byte b[], int offset, byte[] value) {
    System.arraycopy(value, 0, b, offset, value.length);
  }
1351400
@Override
	protected void readDataBlock(byte[] data, int offset, int len, int blockHandle) throws DataStoreException
    {
		try
		{
	        dataRandomAccessFile.seek((long)blockHandle*blockSize);
	        if (dataRandomAccessFile.read(data,offset,len) != len)
	            throw new DataStoreException("Cannot read "+len+" bytes from store file");
		}
		catch (DataStoreException e)
		{
		    throw e;
		}
        catch (IOException e)
        {
            throw new DataStoreException("Could not read data block "+blockHandle+" : "+dataFile.getAbsolutePath(),e);
        }
    }
540975
@Override
	public int read(byte[] buffer, int offset, int len) throws IOException {
		return this.in.read(buffer, offset, len);
	}
200139
public void setBytes(long memoryOffset, byte[] buffer, int bufferOffset, int count)
    {
        if (buffer == null)
            throw new NullPointerException();
        else if (bufferOffset < 0
                 || count < 0
                 || bufferOffset + count > buffer.length)
            throw new IndexOutOfBoundsException();
        else if (count == 0)
            return;

        long end = memoryOffset + count;
        checkBounds(memoryOffset, end);

        unsafe.copyMemory(buffer, BYTE_ARRAY_BASE_OFFSET + bufferOffset, null, peer + memoryOffset, count);
    }
739997
public void write(byte[] bytes, int offset, int len)
    {
        if (bytes == null)
        {
            return;
        }
        if ((offset < 0) || (offset > bytes.length) || (len < 0) || ((offset + len) - bytes.length > 0))
        {
            throw new IndexOutOfBoundsException("offset=" + offset + ", len=" + len + ", bytes.length=" + bytes.length);
        }
        ensureCapacity(size + len);
        System.arraycopy(bytes, offset, buffer, size, len);
        size += len;
    }
117477
@Override
  public BytesImpl set(int pos, byte []buffer, int offset, int length)
  {
    System.arraycopy(buffer, offset, _data, pos, length);

    return this;
  }
220579
public void setBuffer (byte[] bytes, int offset, int count) {
		if (bytes == null) throw new IllegalArgumentException("bytes cannot be null.");
		buffer = bytes;
		position = offset;
		limit = offset + count;
		capacity = bytes.length;
		total = 0;
		inputStream = null;
	}
1026150
@Override
	protected synchronized void read(long offset, byte[] b) throws IOException {
		if (byteBuffer != null) {
			byteBuffer.position((int) offset);
			byteBuffer.get(b);
		} else {
			throw new IOException("Read failed, file " + getPath() + " not mapped for I/O");
		}
	}
576374
public void write(byte[] b, int offset, int length)
        throws IOException
    {
        int o=offset;
        int l=length;
        while (l>0)
        {
            int c=capacity();
            
            if (_bypassBuffer && isCommitted() && size()==0 && l>c)
            {
                // Bypass buffer
                bypassWrite(b,o,l);
                break;
            }

            if (l<c || !isFixed())
            {
                // Write all
                super.write(b,o,l);
                break;
            }
            else
            {
                // Write a block
                super.write(b,o,c);
                flush();
                l-=c;
                o+=c;
            }
        }
    }