| 364 | } |
| 365 | |
| 366 | std::vector<BlockAppendingInfo> FactorizedTable::allocateFlatTupleBlocks( |
| 367 | uint64_t numTuplesToAppend) { |
| 368 | auto numBytesPerTuple = tableSchema.getNumBytesPerTuple(); |
| 369 | std::vector<BlockAppendingInfo> appendingInfos; |
| 370 | while (numTuplesToAppend > 0) { |
| 371 | if (flatTupleBlockCollection->needAllocation(numBytesPerTuple)) { |
| 372 | auto newBlock = std::make_unique<DataBlock>(memoryManager, flatTupleBlockSize); |
| 373 | flatTupleBlockCollection->append(std::move(newBlock)); |
| 374 | } |
| 375 | auto block = flatTupleBlockCollection->getLastBlock(); |
| 376 | auto numTuplesToAppendInCurBlock = |
| 377 | std::min(numTuplesToAppend, block->freeSize / numBytesPerTuple); |
| 378 | appendingInfos.emplace_back(block->getWritableData(), numTuplesToAppendInCurBlock); |
| 379 | block->freeSize -= numTuplesToAppendInCurBlock * numBytesPerTuple; |
| 380 | block->numTuples += numTuplesToAppendInCurBlock; |
| 381 | numTuplesToAppend -= numTuplesToAppendInCurBlock; |
| 382 | } |
| 383 | return appendingInfos; |
| 384 | } |
| 385 | |
| 386 | uint64_t getDataBlockSize(uint32_t numBytes) { |
| 387 | if (numBytes < TEMP_PAGE_SIZE) { |
no test coverage detected