- 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
+6 -6
View File
@@ -8,16 +8,16 @@ struct AppendBuffer : Buffer {
using TChunk = char[APPEND_CHUNK_SIZE];
std::vector<TChunk *> buf;
TChunk *t_current;
uint32_t current_offset{0};
uint32_t t_offset{0};
uint64_t current_offset{0};
uint64_t t_offset{0};
AppendBuffer();
~AppendBuffer();
uint32_t key(char c);
uint32_t append(const char *text, uint32_t length);
uint64_t append(char c);
uint64_t append(const char *text, uint64_t length);
const char *read(uint32_t pos, uint32_t *out_len);
inline uint32_t length();
const char *read(uint64_t pos, uint64_t *out_len);
inline uint64_t length();
};
+2 -2
View File
@@ -3,7 +3,7 @@
#include "pch.h"
struct Buffer {
virtual const char *read(uint32_t pos, uint32_t *out_len) = 0;
virtual inline uint32_t length() = 0;
virtual const char *read(uint64_t pos, uint64_t *out_len) = 0;
virtual inline uint64_t length() = 0;
virtual ~Buffer() = default;
};
+7 -7
View File
@@ -4,14 +4,14 @@
#include "pch.h"
struct OriginalBuffer : Buffer {
char *buf;
uint32_t len;
// Add 2 modes here, normal and lazy, lazy copies the file to a safe location and uses mmap.
OriginalBuffer(std::string path);
const char *buf;
uint64_t len;
int fd = -1;
OriginalBuffer();
~OriginalBuffer();
const char *read(uint32_t pos, uint32_t *out_len);
uint32_t length();
void initialize();
const char *read(uint64_t pos, uint64_t *out_len);
uint64_t length();
};