Make append buffer contiguous and update iterators

This commit is contained in:
2026-08-06 19:39:59 +01:00
parent 5722731c6a
commit 189b9ab6ca
19 changed files with 463 additions and 506 deletions
+11 -11
View File
@@ -5,19 +5,19 @@
#include "pch.h"
struct AppendBuffer : Buffer {
using TChunk = char[APPEND_CHUNK_SIZE];
std::vector<TChunk *> buf;
TChunk *t_current;
uint64_t current_offset{0};
uint64_t t_offset{0};
AppendBuffer();
char *buf = nullptr;
uint64_t allocated_capacity = 0;
uint64_t current_size = 0;
int fd = -1;
AppendBuffer(std::filesystem::path base_dir);
~AppendBuffer();
uint64_t append(char c);
uint64_t append(const char *text, uint64_t length);
uint64_t append(const char c);
uint64_t append(const char *text, uint64_t len);
const char *read(uint64_t pos) override;
uint64_t length() override;
const char *read(uint64_t pos, uint64_t *out_len);
inline uint64_t length();
private:
void grow(uint64_t len);
};