Commit Graph

223 Commits

Author SHA1 Message Date
Doug Anderson444
0aa5de6d9f rm log, switch all to tracing 2025-02-11 09:03:36 -04:00
Pekka Enberg
d221f158cc Merge 'Add read implementation of user_version pragma with ReadCookie opcode' from Jonathan Webb
Just a bare bones implementation of ReadCookie and support for the
user_version pragma

Closes #909
2025-02-10 12:12:15 +02:00
Pekka Enberg
0638550be7 Merge 'Remove unnecessary reference counting from completion I/O callbacks' from Preston Thorpe
I am on a bit of a mission to revisit a lot of the ref counting, this
was an easy first win.
It seems to be a linear path of function calls or hashmaps which can own
the completions directly, no cloning needed.

Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #912
2025-02-10 12:11:30 +02:00
Pekka Enberg
604ca4085d Merge 'Make record values private' from Tiago
This is an attempt to move towards #881. I am not sure this is the
direction you want to take. In any case, I thought I would take a crack
at converting `values` from `Record` to private and see how bad it would
be.
In the end, as you can see, it is not so bad. I think performance-wise
it shouldn't be a bad hit with Rust's zero-cost abstraction. Also,
during the process I noticed a couple improvements that could be made
here and there but I honestly wanted to start with something small
enough that wouldn't be too hard to review.
Anyway, let me know if this is really how you would like to proceed.

Closes #962
2025-02-10 11:23:21 +02:00
Pekka Enberg
fcad8d125e Merge 'refactor: remove RC<String> requirement for build_text and new text' from Pedro Muniz
This PR aims to simplify text creation and to reduce allocation overhead
of creating a new OwnedValue::Text. Instead of creating Rc<String> every
time you need to create a text, you just pass the string slice and the
Rc<String> is created at the end. This change, at least on my machine,
has removed a lot of variability in the benchmarking performance, while
maintaining roughly the same performance.

Closes #961
2025-02-10 11:21:50 +02:00
Tiago Ribeiro
af12036e88 Update core/storage/btree.rs to use the new retrieval methods to access Record values. 2025-02-10 00:27:51 -07:00
Pekka Enberg
bad5f2cad3 Merge 'Fix a handful of typos' from Aarni Koskela
I noticed the README had a prominent typo ("workin on"), so I decided to
run [crate-ci/typos](https://github.com/crate-ci/typos) on the repo and
fix what it flagged.

Reviewed-by: Jussi Saurio <jussi.saurio@gmail.com>

Closes #952
2025-02-10 07:41:01 +02:00
Pekka Enberg
2eda8a54d9 Merge 'Fix various bugs in B-Tree handling' from Nikita Sivukhin
This PR introduce simple fuzz test for BTree insertion algorithm and
fixes few bugs found by fuzzer
- BTree algorithm returned early although there were overflow pages on
stack and more rebalances were needed
- BTree balancing algorithm worked under assumption that single page
will be enough for rebalance - although this is not always true (if page
were tightly packed with relatively big cells, insertion of new very big
cell can require 3 split pages to distribute the content between them)
- `overflow_cells` wasn't cleared properly during rebalancing
- insertions of dividers to the parent node were implemented incorrectly
- `defragment_page` didn't reset
`PAGE_HEADER_OFFSET_FRAGMENTED_BYTES_COUNT` field which can lead to
suboptimal usage of pages

Closes #951
2025-02-10 07:40:27 +02:00
pedrocarlo
fe453ecfc5 remove RC<String> requirement for build_text and new text 2025-02-09 13:44:39 -03:00
Aarni Koskela
eaea02c567 Fix a handful of typos 2025-02-09 18:08:29 +02:00
Nikita Sivukhin
1b9772e9ad fix clippy 2025-02-09 19:36:14 +04:00
Nikita Sivukhin
32b5b0d019 introduce additional condition for cells distribution in order to avoid almost empty pages 2025-02-09 19:26:03 +04:00
Nikita Sivukhin
bc289d314a adjust test a bit 2025-02-09 19:20:48 +04:00
Nikita Sivukhin
e23ea35993 add simple B-tree validation func 2025-02-09 19:20:37 +04:00
Nikita Sivukhin
a59589844d fix insertion to the parent 2025-02-09 19:19:36 +04:00
Nikita Sivukhin
6c40f52fc8 separate fuzz tests in categories 2025-02-09 18:37:04 +04:00
Nikita Sivukhin
9049c91863 find cell in parent node 2025-02-09 18:36:37 +04:00
Nikita Sivukhin
9e4afd1d13 relax assertion 2025-02-09 18:36:26 +04:00
Nikita Sivukhin
8e6569434a add fuzz 2025-02-09 18:10:59 +04:00
Nikita Sivukhin
a62265eef4 hanle balancing cases when more than 1 level is affected 2025-02-09 18:10:19 +04:00
Nikita Sivukhin
d2251b1dd1 fix 2025-02-09 18:09:53 +04:00
Nikita Sivukhin
e8a585f87a adjust logging 2025-02-09 18:09:43 +04:00
Nikita Sivukhin
8659dbba8e fix pointer structure in case of root split 2025-02-09 17:31:39 +04:00
Nikita Sivukhin
d4bbad161b handle case when we can't balance all cells between current page and one new allocated page
- if we have page which is tightly packed with relatively big cells, we
  will be unable to balance its content if we will insert very big
  (~page size) cell in the middle (because nothing can't be merged with
  new cell - so we will need to split 1 page into 3)
2025-02-09 17:31:39 +04:00
Nikita Sivukhin
ea61f31843 clear overflow_cells 2025-02-09 17:31:39 +04:00
Nikita Sivukhin
6aa10701a4 fix comment 2025-02-09 17:31:39 +04:00
Nikita Sivukhin
eec0493c60 remove misleading comment 2025-02-09 17:31:39 +04:00
Nikita Sivukhin
fc502b86c7 fix defragmentation code a bit 2025-02-09 17:31:39 +04:00
Nikita Sivukhin
5ce3d12f75 fix typo 2025-02-09 17:31:39 +04:00
Nikita Sivukhin
62b4787d3d simplify write_varint_to_vec function 2025-02-09 17:31:39 +04:00
Nikita Sivukhin
3557c8aada adjust fuzz test 2025-02-09 17:31:39 +04:00
Jorge López
83b158fb3a core: silence some unused warnings when building without default features 2025-02-09 01:13:12 +01:00
PThorpe92
75898027a0 Remove unnecessary reference counting from completion io callbacks 2025-02-08 08:20:19 -05:00
Nikita Sivukhin
75e2f01ec4 print btree for debugging 2025-02-08 13:03:38 +04:00
Nikita Sivukhin
55dd108878 setup simple insertion fuzz test 2025-02-08 12:38:32 +04:00
Jonathan Webb
98e9d33478 Add read implementation of user_version pragma with ReadCookie opcode 2025-02-07 09:23:48 -05:00
Krishna Vishal
7cb7eb4e65 Merge branch 'main' into delete-btree-row 2025-02-07 01:15:21 +05:30
krishvishal
349fd51559 Get db_header from Pager instead of BTreeCursor.
Fix page_cache in btree tests to use `parking_lot::RwLock`
2025-02-07 00:11:06 +05:30
krishvishal
ea174e32f1 chore: cargo fmt 2025-02-06 23:39:12 +05:30
krishvishal
c80007d8a0 Add local constants for free_page offsets for clarity. 2025-02-06 23:39:12 +05:30
krishvishal
f836ad7561 Remove write to PAGE_HEADER_OFFSET_CELL_CONTENT_AREA in insert_into_cell. This causes corruption when you reuse cell spaces from free_list. 2025-02-06 23:39:12 +05:30
krishvishal
7d67895306 1. Added frangmentation handling to find_free_cell
2. Added asserts and corruption error to `allocate_cell_space`
2025-02-06 23:39:09 +05:30
krishvishal
8263bd0482 Update page offsets in drop_cell and update cell pointer array after dropping a cell. 2025-02-06 23:36:27 +05:30
krishvishal
73dae3003d Implement block coalescing in free_cell_range to reduce fragmentation and also added fragmentation tracking. 2025-02-06 23:36:26 +05:30
krishvishal
95da2244bb Implemented delete(). Now we are able to delete a row. It handles both interior page and leaf page cell differently. 2025-02-06 23:34:27 +05:30
krishvishal
f62ec61694 Added a unit-test to test the case where clear_overflow_pages function is called on cell with no overflow pages 2025-02-06 23:34:26 +05:30
krishvishal
8c763780a8 Added free list and free_page functionality in Pager module. Now we can add dropped pages to free list, so pages can be reused in allocate_page. 2025-02-06 23:34:12 +05:30
krishvishal
83b214a4e3 Added clear_over_pages it deletes all the overflow pages related to a cell. 2025-02-06 23:27:07 +05:30
Pekka Enberg
f3902ef9b6 core: Rename OwnedRecord to Record
We only have one record type so let's call it `Record`.
2025-02-06 13:40:34 +02:00
Pekka Enberg
f9828e0e6f core: Parse UTF-8 strings lazily 2025-02-06 13:27:52 +02:00