parquet-common/src/main/java/org/apache/parquet/bytes/CapacityByteArrayOutputStream.java
public void reset() {
    // readjust slab size.
    // 7 = 2^3 - 1 so that doubling the initial size 3 times will get to the same size
    this.initialSlabSize = max(bytesUsed / 7, initialSlabSize);
    LOG.debug("initial slab of size {}", initialSlabSize);
    for (ByteBuffer slab : slabs) {
      allocator.release(slab);
    }
    this.slabs.clear();
    this.bytesAllocated = 0;
    this.bytesUsed = 0;
    this.currentSlab = EMPTY_SLAB;
    this.currentSlabIndex = 0;
  }
public void reset() {
    // readjust slab size.
    // 7 = 2^3 - 1 so that doubling the initial size 3 times will get to the same size
    this.initialSlabSize = max(bytesUsed / 7, initialSlabSize);
    LOG.debug("initial slab of size {}", initialSlabSize);
    for (ByteBuffer slab : slabs) {
      allocator.release(slab);
    }
    this.slabs.clear();
    this.bytesAllocated = 0;
    this.bytesUsed = 0;
    this.currentSlab = EMPTY_SLAB;
    this.currentSlabIndex = 0;
  }
When re-using an instance with reset, it will adjust slab size based on previous data size.
The intent is to reuse the same instance for the same type of data (for example, the same column).
The assumption is that the size in the buffer will be consistent.