Source:
<code>public PagePartitioner( PartitionFunction partitionFunction, List<Integer> partitionChannels, List<Optional<ConstantExpression>> partitionConstants, boolean replicatesAnyRow, OptionalInt nullChannel, OutputBuffer outputBuffer, PagesSerdeFactory serdeFactory, List<Type> sourceTypes, DataSize maxMemory, Lifespan lifespan) { this.partitionFunction = requireNonNull(partitionFunction, "partitionFunction is null"); this.partitionChannels = requireNonNull(partitionChannels, "partitionChannels is null"); this.partitionConstants = requireNonNull(partitionConstants, "partitionConstants is null").stream() .map(constant -> constant.map(ConstantExpression::getValueBlock)) .collect(toImmutableList()); this.replicatesAnyRow = replicatesAnyRow; this.nullChannel = requireNonNull(nullChannel, "nullChannel is null"); this.outputBuffer = requireNonNull(outputBuffer, "outputBuffer is null"); this.sourceTypes = requireNonNull(sourceTypes, "sourceTypes is null"); this.serde = requireNonNull(serdeFactory, "serdeFactory is null").createPagesSerde(); int partitionCount = partitionFunction.getPartitionCount(); <START> int capacity = min(DEFAULT_MAX_PAGE_SIZE_IN_BYTES, ((int) maxMemory.toBytes()) / partitionCount); <END> capacity = max(1, capacity); partitionData = new PartitionData[partitionCount]; for (int i = 0; i < partitionCount; i++) { partitionData[i] = new PartitionData(i, sourceTypes.size(), capacity, pagesAdded, rowsAdded, serde, lifespan); } if (sourceTypes.size() > 0) { this.flattener = new BlockFlattener(new SimpleArrayAllocator(sourceTypes.size())); } calculateRowSizeForFixedWidthBlocks(); }</code><technical_language>toIntExact: int capacity = min(DEFAULT_MAX_PAGE_SIZE_IN_BYTES, toIntExact(maxMemory.toBytes()) / partitionCount);</technical_language>

Target:
public PagePartitioner( PartitionFunction partitionFunction, List<Integer> partitionChannels, List<Optional<ConstantExpression>> partitionConstants, boolean replicatesAnyRow, OptionalInt nullChannel, OutputBuffer outputBuffer, PagesSerdeFactory serdeFactory, List<Type> sourceTypes, DataSize maxMemory, Lifespan lifespan) { this.partitionFunction = requireNonNull(partitionFunction, "partitionFunction is null"); this.partitionChannels = requireNonNull(partitionChannels, "partitionChannels is null"); this.partitionConstants = requireNonNull(partitionConstants, "partitionConstants is null").stream() .map(constant -> constant.map(ConstantExpression::getValueBlock)) .collect(toImmutableList()); this.replicatesAnyRow = replicatesAnyRow; this.nullChannel = requireNonNull(nullChannel, "nullChannel is null"); this.outputBuffer = requireNonNull(outputBuffer, "outputBuffer is null"); this.serde = requireNonNull(serdeFactory, "serdeFactory is null").createPagesSerde(); int partitionCount = partitionFunction.getPartitionCount(); int pageSize = max(1, min(DEFAULT_MAX_PAGE_SIZE_IN_BYTES, toIntExact(maxMemory.toBytes()) / partitionCount)); partitionData = new PartitionData[partitionCount]; for (int i = 0; i < partitionCount; i++) { partitionData[i] = new PartitionData(i, sourceTypes.size(), pageSize, pagesAdded, rowsAdded, serde, lifespan); } this.sourceTypes = sourceTypes; flattener = new BlockFlattener(new SimpleArrayAllocator(MAX_FLATTENER_OUTSTANDING_ARRAYS)); decodedBlocks = new DecodedBlockNode[sourceTypes.size()]; int fixedWidthRowSize = 0; for (int i = 0; i < sourceTypes.size(); i++) { int bytesPerPosition = getFixedWidthTypeSize(i); fixedWidthRowSize += bytesPerPosition; if (bytesPerPosition == 0) { variableWidthChannels.add(i); } } this.fixedWidthRowSize = fixedWidthRowSize; }