Commit Graph

68 Commits

Author SHA1 Message Date
PThorpe92
2c526c4c37 Add io_yield_x macros to reduce boilerplate 2025-08-16 16:14:00 -04:00
pedrocarlo
c381fe3844 bubble completions in Sorter 2025-08-13 10:24:55 +03:00
pedrocarlo
85e86d427b cleanups - use io.block in many functions and return_if_io 2025-08-13 08:32:38 +03:00
pedrocarlo
f25f51b8aa do not need wait_for_read_complete anymore 2025-08-09 21:50:18 -03:00
pedrocarlo
76d6c4a28d only open 1 file for sorter so chunks just reuse that file 2025-08-09 21:50:18 -03:00
pedrocarlo
4a3408003a wait for flush to complete 2025-08-09 21:50:18 -03:00
pedrocarlo
5924274d61 adjust state machine transition 2025-08-09 21:50:18 -03:00
pedrocarlo
6fe19e4ef4 adjust external sort init_chunk_heap and next_from_chunk_heap 2025-08-09 21:50:18 -03:00
pedrocarlo
c02936eb30 state machine for insert 2025-08-09 21:50:18 -03:00
pedrocarlo
2ec58b0264 state machine for sort 2025-08-09 21:50:18 -03:00
pedrocarlo
c91c22a6a8 state machine for next 2025-08-09 21:50:18 -03:00
pedrocarlo
2ffc5ee423 SorterChunk read and write should return completions 2025-08-09 21:50:18 -03:00
PThorpe92
27113885a9 Update sorter to use new buffer api 2025-08-08 10:55:26 -04:00
PThorpe92
f6a68cffc2 Remove RefCell from IO and Page apis 2025-08-05 16:24:49 -04:00
pedrocarlo
543cdb3e2c underscoring completions and IOResult to avoid warning messages 2025-07-31 11:51:17 -03:00
pedrocarlo
3831e0db39 convert must_use compile warnings to unused_variables to track locations where we need to refactor in the future 2025-07-28 16:09:26 -03:00
pedrocarlo
d30c7d54c8 change all Arc<Completion> to Completion 2025-07-28 15:32:45 -03:00
Iaroslav Zeigerman
1e51d23bd6 store the key deserialization error instead of panicking 2025-07-23 11:22:01 -07:00
Iaroslav Zeigerman
d847c88df6 cosmetic 2025-07-22 06:37:50 +02:00
Iaroslav Zeigerman
d75e26eee4 Deserialize keys incrementally 2025-07-21 19:25:27 +02:00
Iaroslav Zeigerman
18d66b3539 Deserialize keys only once when sorting immutable records 2025-07-21 18:09:37 +02:00
Jussi Saurio
9936748132 Merge 'Avoid redundant decoding of record headers when reading sorted chunk files' from Iaroslav Zeigerman
Currently, each record header is decoded at least twice: once to
determine the record size within the read buffer (in order to construct
the `ImmutableRecord` instance), and again later when decoding the
record for comparison. This redundant decoding can have a noticeable
negative impact on performance when records are wide (eg. contain
multiple columns).
This update modifies the (de)serialization format for sorted chunk files
by prepending a record size varint to each record payload. As a result,
only a single varint needs to be decoded to determine the record size,
eliminating the need to decode the full record header during reads.

Closes #2176
2025-07-20 23:54:54 +03:00
Iaroslav Zeigerman
10a848fbc5 address nit 2025-07-19 18:40:43 +02:00
Iaroslav Zeigerman
5d47502e3a Avoid redundant decoding of record headers when reading sorted chunk files 2025-07-19 06:08:27 +02:00
Jussi Saurio
4d15725b6f sorter: fix sorter panic on SortedChunkIOState::WaitingForRead
The following sequence of events is possible:

- init_chunk_heap() called
- chunk A status is WriteComplete, so chunk.read() gets called on chunk A
- some other chunk B is in WaitingForWrite status after flush()
- init_chunk_heap() returns IOResult::IO
- init_chunk_heap() is called again
- we panic because chunk A is in WaitingForRead status

So - we just allow WaitingForRead status in init_chunk_heap() instead.

This panic was caught thanks to Pedro's IO latency enhancement to the sim!
2025-07-18 14:18:51 +03:00
Iaroslav Zeigerman
28ff170e14 improve sorter settings in the fuzz test 2025-07-18 07:41:15 +02:00
Iaroslav Zeigerman
76e748146b rebase 2025-07-18 07:30:08 +02:00
Iaroslav Zeigerman
f6f1d076da verify that records remain unchanged after sorting 2025-07-18 07:28:37 +02:00
Iaroslav Zeigerman
d9751212d7 make a fuzz sorter test 2025-07-18 07:28:37 +02:00
Iaroslav Zeigerman
20bdbd5ca5 address suggestions 2025-07-18 07:28:37 +02:00
Iaroslav Zeigerman
edf2be1432 fix conflicts 2025-07-18 07:28:37 +02:00
Iaroslav Zeigerman
6a609398fe cosmetic fix 2025-07-18 07:28:37 +02:00
Iaroslav Zeigerman
fd042ac4c8 Use IOResult insteaed of CursorResult 2025-07-18 07:28:36 +02:00
Iaroslav Zeigerman
78f3bf3475 Core: Introduce external sorting 2025-07-18 07:28:36 +02:00
Jussi Saurio
e8199cb26c btree/vdbe: fold index key info (sort order, collations) into a single struct
These are nearly always used together in some form, so it makes sense to colocate
them, and it also makes many code paths simpler.
2025-07-17 10:58:43 +03:00
Krishna Vishal
515712b7f2 Fix sorter 2025-07-14 03:28:54 +05:30
Pekka Enberg
725c3e4ddc Rename limbo_sqlite3_parser crate to turso_sqlite3_parser 2025-06-29 12:34:46 +03:00
pedrocarlo
4a3119786e refactor BtreeCursor and Sorter to accept Vec of collations 2025-05-19 15:22:55 -03:00
pedrocarlo
bf1fe9e0b3 Actually fixed group by and order by collation 2025-05-19 15:22:15 -03:00
Jussi Saurio
3798b4aa8b use SortOrder in sorters always 2025-04-24 10:34:06 +03:00
Jussi Saurio
f53448ae75 Fix bug: we cant remove order by terms from the head of the list 2025-04-24 10:34:06 +03:00
Pere Diaz Bou
d9f5cd870d clippy 2025-03-29 22:04:08 +01:00
Pere Diaz Bou
bf37fd3314 wip 2025-03-29 22:02:49 +01:00
Tiago Ribeiro
295691d81b Update core/vdbe to use the new retrieval methods to access Record values. 2025-02-10 00:27:51 -07:00
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
Jussi Saurio
9e32ce6c77 Add Cursor enum and store a single BTreeMap of cursors in ProgramState 2025-01-26 12:57:15 +02:00
Jussi Saurio
bf48c0ae72 Remove trait Cursor 2025-01-11 17:19:25 +02:00
김선우
9a8b94ef93 First successful implementation of delete planning 2024-12-22 13:16:16 +09:00
krishvishal
7e2928a5f1 Feature: last_insert_rowid()
- Changed `Cursor` trait to be able to get access to `root_page`
- SQLite only updates last_insert_rowid for non-schema inserts. So we check if the `InsertAwait` is not for `root_page` before
  updating rowid
2024-12-09 22:48:42 +05:30
limeng.1
8cca659052 impl order by desc 2024-11-19 11:39:07 +08:00