MCPcopy Create free account
hub / github.com/LadybugDB/ladybug / checkpointColumnChunkOutOfPlace

Method checkpointColumnChunkOutOfPlace

src/storage/table/column.cpp:448–478  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

446}
447
448std::vector<std::unique_ptr<ColumnChunkData>> Column::checkpointColumnChunkOutOfPlace(
449 const SegmentState& state, const ColumnCheckpointState& checkpointState,
450 PageAllocator& pageAllocator, bool canSplitSegment) const {
451 const auto numRows = std::max(checkpointState.endRowIdxToWrite, state.metadata.numValues);
452 checkpointState.persistentData.setToInMemory();
453 checkpointState.persistentData.resize(numRows);
454 DASSERT(checkpointState.persistentData.getNumValues() == 0);
455 scanSegment(state, &checkpointState.persistentData, 0, state.metadata.numValues);
456 state.reclaimAllocatedPages(pageAllocator);
457 // TODO(bmwinger): for simple compression types, we can predict whether or not we will need to
458 // split the segment and avoid having to re-write it multiple times
459 for (auto& segmentCheckpointState : checkpointState.segmentCheckpointStates) {
460 checkpointState.persistentData.write(&segmentCheckpointState.chunkData,
461 segmentCheckpointState.startRowInData, segmentCheckpointState.offsetInSegment,
462 segmentCheckpointState.numRows);
463 }
464 // Finalize is necessary prior to splitting for strings and lists so that pruned values don't
465 // have an impact on the number/size of segments It should not be necessary after splitting
466 // since the function is used to prune unused values (or duplicated dictionary entries in the
467 // case of strings) and those will never be introduced when splitting.
468 checkpointState.persistentData.finalize();
469 if (canSplitSegment && checkpointState.persistentData.shouldSplit()) {
470 auto newSegments = checkpointState.persistentData.split();
471 for (auto& segment : newSegments) {
472 segment->flush(pageAllocator);
473 }
474 return newSegments;
475 }
476 checkpointState.persistentData.flush(pageAllocator);
477 return {};
478}
479
480bool Column::canCheckpointInPlace(const SegmentState& state,
481 const ColumnCheckpointState& checkpointState) const {

Callers

nothing calls this directly

Calls 8

setToInMemoryMethod · 0.45
resizeMethod · 0.45
getNumValuesMethod · 0.45
reclaimAllocatedPagesMethod · 0.45
writeMethod · 0.45
finalizeMethod · 0.45
splitMethod · 0.45
flushMethod · 0.45

Tested by

no test coverage detected