parquet-common/src/main/java/org/apache/parquet/bytes/CapacityByteArrayOutputStream.java
public static CapacityByteArrayOutputStream withTargetNumSlabs(
      int minSlabSize, int maxCapacityHint, int targetNumSlabs, ByteBufferAllocator allocator) {

    return new CapacityByteArrayOutputStream(
        initialSlabSizeHeuristic(minSlabSize, maxCapacityHint, targetNumSlabs),
        maxCapacityHint, allocator);
  }
public static CapacityByteArrayOutputStream withTargetNumSlabs(
      int minSlabSize, int maxCapacityHint, int targetNumSlabs, ByteBufferAllocator allocator) {

    return new CapacityByteArrayOutputStream(
        initialSlabSizeHeuristic(minSlabSize, maxCapacityHint, targetNumSlabs),
        maxCapacityHint, allocator);
  }
Construct a CapacityByteArrayOutputStream configured such that its initial slab size is
determined by {@link #initialSlabSizeHeuristic}, with targetCapacity == maxCapacityHint

@param minSlabSize a minimum slab size
@param maxCapacityHint a hint for the maximum required capacity
@param targetNumSlabs the target number of slabs
@param allocator an allocator to use when creating byte buffers for slabs
@return a capacity baos