mirror of
https://github.com/tursodatabase/limbo.git
synced 2025-08-04 18:18:03 +00:00
Merge 'Implement SQLite balancing algorithm' from Pere Diaz Bou
Beep boop. What happened you ask? I removed the dumb balancing algorithm I implemented in favor of SQLite's implementation based on B*Tree[1] where a page is 2/3 full instead of 1/2. It also tries to balance a page by taking a maximum 3 pages and distributing cells evenly between them. I've made some changes that are somewhat related: * Moved most operations on pages out of BTreeCursor because those operations are based on a page, not on a cursor, and it makes it easier to test. * Fixed `write_u16` and `read_u16` cases that didn't need a implicit offset calculation. Added: `write_u16_no_offset` and `read_u16_no_offset` to counter this. * Added some tests with fuzz testing too. * Fixed some important actions like: `compute_free_space`, `defragment_page` and `drop_cell`. [1] https://dl.acm.org/doi/10.1145/356770.356776 Closes #968
This commit is contained in:
commit
b4e8afa3c7
5 changed files with 2090 additions and 1029 deletions
|
@ -227,8 +227,8 @@ pub fn maybe_init_database_file(file: &Rc<dyn File>, io: &Arc<dyn IO>) -> Result
|
|||
btree_init_page(
|
||||
&page1,
|
||||
storage::sqlite3_ondisk::PageType::TableLeaf,
|
||||
&db_header,
|
||||
DATABASE_HEADER_SIZE,
|
||||
db_header.page_size - db_header.reserved_space as u16,
|
||||
);
|
||||
|
||||
let contents = page1.get().contents.as_mut().unwrap();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue