From e51f0f54669c40526b02977a4e65a66ab6b62f38 Mon Sep 17 00:00:00 2001 From: Jussi Saurio Date: Thu, 10 Jul 2025 13:08:35 +0300 Subject: [PATCH] btree/balance: improve comment --- core/storage/btree.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/storage/btree.rs b/core/storage/btree.rs index 0e64d7c6e..920aa4293 100644 --- a/core/storage/btree.rs +++ b/core/storage/btree.rs @@ -2488,9 +2488,11 @@ impl BTreeCursor { "overflow parent not yet implemented" ); - /* 1. Get divider cells and max_cells */ + // 1. Collect cell data from divider cells, and count the total number of cells to be distributed. + // The count includes: all cells and overflow cells from the sibling pages, and divider cells from the parent page, + // excluding the rightmost divider, which will not be dropped from the parent; instead it will be updated at the end. let mut max_cells = 0; - // we only need maximum 5 pages to balance 3 pages + // We only need maximum 5 pages to balance 3 pages, because we can guarantee that cells from 3 pages will fit in 5 pages. let mut pages_to_balance_new: [Option; 5] = [const { None }; 5]; for i in (0..balance_info.sibling_count).rev() { let sibling_page = balance_info.pages_to_balance[i].as_ref().unwrap();