@@ -107,8 +107,10 @@ class BTreeGeneric : public leanstore::storage::BufferManagedTree {
107
107
// / Called by buffer manager before eviction
108
108
virtual SpaceCheckResult checkSpaceUtilization (BufferFrame& bf) override ;
109
109
110
- // pre: source buffer frame is shared latched
111
- virtual void checkpoint (BufferFrame& bf, u8* dest) override ;
110
+ // / Flush the page content in the buffer frame to disk
111
+ // /
112
+ // / NOTE: The source buffer frame should be shared latched
113
+ virtual void Checkpoint (BufferFrame& bf, void * dest) override ;
112
114
113
115
virtual void undo (const u8*, const u64) override {
114
116
LOG (FATAL) << " undo is unsupported" ;
@@ -386,22 +388,23 @@ inline SpaceCheckResult BTreeGeneric::checkSpaceUtilization(BufferFrame& bf) {
386
388
}
387
389
}
388
390
389
- inline void BTreeGeneric::checkpoint (BufferFrame& bf, u8* dest) {
390
- std::memcpy (dest, bf.page .mPayload , EFFECTIVE_PAGE_SIZE);
391
- auto & destNode = *reinterpret_cast <BTreeNode*>(dest);
391
+ inline void BTreeGeneric::Checkpoint (BufferFrame& bf, void * dest) {
392
+ std::memcpy (dest, &bf.page , PAGE_SIZE);
393
+ auto destPage = reinterpret_cast <Page*>(dest);
394
+ auto destNode = reinterpret_cast <BTreeNode*>(destPage->mPayload );
392
395
393
- if (!destNode. mIsLeaf ) {
396
+ if (!destNode-> mIsLeaf ) {
394
397
// Replace all child swip to their page ID
395
- for (u64 i = 0 ; i < destNode. mNumSeps ; i++) {
396
- if (!destNode. getChild (i).isEVICTED ()) {
397
- auto & childBf = destNode. getChild (i).asBufferFrameMasked ();
398
- destNode. getChild (i).evict (childBf.header .mPageId );
398
+ for (u64 i = 0 ; i < destNode-> mNumSeps ; i++) {
399
+ if (!destNode-> getChild (i).isEVICTED ()) {
400
+ auto & childBf = destNode-> getChild (i).asBufferFrameMasked ();
401
+ destNode-> getChild (i).evict (childBf.header .mPageId );
399
402
}
400
403
}
401
404
// Replace right most child swip to page id
402
- if (!destNode. mRightMostChildSwip .isEVICTED ()) {
403
- auto & childBf = destNode. mRightMostChildSwip .asBufferFrameMasked ();
404
- destNode. mRightMostChildSwip .evict (childBf.header .mPageId );
405
+ if (!destNode-> mRightMostChildSwip .isEVICTED ()) {
406
+ auto & childBf = destNode-> mRightMostChildSwip .asBufferFrameMasked ();
407
+ destNode-> mRightMostChildSwip .evict (childBf.header .mPageId );
405
408
}
406
409
}
407
410
}
0 commit comments