- Make original buffer use a disk backed mapping to save memory.
- rearrange api function headers for search etc.
- fix bugs with iterators.
- support uint64_t for all byte and line offsets to allow for much larger files to be opened.
- and more minor bug fixes.
This commit is contained in:
2026-08-04 07:48:26 +01:00
parent 72d0ff85a3
commit 0bfa9300db
19 changed files with 612 additions and 396 deletions
+10 -9
View File
@@ -14,12 +14,12 @@ struct Shard {
uint8_t height;
uint32_t length;
uint32_t lines;
uint64_t length;
uint64_t lines;
std::atomic_uint32_t refs;
std::atomic_uint64_t refs;
Shard(ShardKind kind, uint32_t length, uint32_t lines, uint8_t height)
Shard(ShardKind kind, uint64_t length, uint64_t lines, uint8_t height)
: kind(kind), height(height), length(length), lines(lines), refs(1) {};
static void retain(Shard *n);
@@ -46,18 +46,19 @@ struct Branch : Shard {
struct Petal : Shard {
Buffer *source;
uint32_t pos;
uint64_t pos;
Petal(uint32_t length, uint32_t lines, Buffer *source, uint32_t pos)
Petal(uint64_t length, uint64_t lines, Buffer *source, uint64_t pos)
: Shard(ShardKind::Petal, length, lines, 1),
source(source), pos(pos) {};
};
Shard *create_shards(Buffer *o);
Shard *create_file_shards(std::string &path, OriginalBuffer *b);
Shard *create_swap_shards(std::string &path, OriginalBuffer *b);
std::pair<Shard *, Shard *> split_shard(Shard *n, uint32_t offset);
std::pair<Shard *, Shard *> split_shard(Shard *n, uint64_t offset);
Shard *concat_shard(Shard *left, Shard *right);
Shard *merge(Shard *a, Shard *b);
Shard *merge_leaves(Shard *a, Shard *b);
Shard *append_leaf(Shard *root, Shard *leaf);
Shard *build_balanced(Shard **pieces, uint32_t lo, uint32_t hi);
Shard *build_balanced(Shard **pieces, uint64_t lo, uint64_t hi);