@Override
  public void write(byte[] b, int off, int len) {
    if (writePos.bufferIndex == -1) {
      nextBufferToWrite();
    }
    int srcOffset = 0;
    while (srcOffset < len) {
      int toWrite = Math.min(len - srcOffset, wbSize - writePos.offset);
      System.arraycopy(b, srcOffset + off, writePos.buffer, writePos.offset, toWrite);
      writePos.offset += toWrite;
      srcOffset += toWrite;
      if (writePos.offset == wbSize) {
        nextBufferToWrite();
      }
    }
  }
THIS METHOD IS NOT THREAD-SAFE. Use only at load time (or be mindful of thread safety).
serde/src/java/org/apache/hadoop/hive/serde2/WriteBuffers.java