public void initBuffer(int estimatedValueSize) {
    sharedBufferOffset = 0;

    // if buffer is already allocated, keep using it, don't re-allocate
    if (sharedBuffer != null) {
      // Free up any previously allocated buffers that are referenced by vector
      if (bufferAllocationCount > 0) {
        for (int idx = 0; idx < vector.length; ++idx) {
          vector[idx] = null;
          length[idx] = 0;
        }
      }
    } else {
      // allocate a little extra space to limit need to re-allocate
      long bufferSize = (long) (this.vector.length * estimatedValueSize * EXTRA_SPACE_FACTOR);
      if (bufferSize < DEFAULT_BUFFER_SIZE) {
        bufferSize = DEFAULT_BUFFER_SIZE;
      }
      if (bufferSize > MAX_SIZE_FOR_SHARED_BUFFER) {
        bufferSize = MAX_SIZE_FOR_SHARED_BUFFER;
      }
      sharedBuffer = new byte[(int) bufferSize];
    }
    bufferAllocationCount = 0;
  }
You must call initBuffer first before using setVal().
Provide the estimated number of bytes needed to hold
a full column vector worth of byte string data.

@param estimatedValueSize  Estimated size of buffer space needed per row
storage-api/src/java/org/apache/hadoop/hive/ql/exec/vector/BytesColumnVector.java