MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / build_table_cell_overflow

Function build_table_cell_overflow

internal/cbm/sqlite_writer.c:848–868  ·  view source on GitHub ↗

Build a table leaf cell with overflow: stores only the first local_len bytes of payload inline, followed by a 4-byte overflow page number. total_payload_len is the FULL original payload length (written as the payload-size varint so SQLite knows the real record size).

Source from the content-addressed store, hash-verified

846// total_payload_len is the FULL original payload length (written as the payload-size
847// varint so SQLite knows the real record size).
848static uint8_t *build_table_cell_overflow(int64_t rowid, const uint8_t *payload,
849 int total_payload_len, int local_len,
850 uint32_t overflow_page, int *out_cell_len) {
851 int rl = varint_len(total_payload_len);
852 int kl = varint_len(rowid);
853 // cell = varint(total_payload_len) + varint(rowid) + payload[0..local_len) + uint32(overflow)
854 int total = rl + kl + local_len + BTREE_PTR_SIZE;
855 uint8_t *cell = (uint8_t *)malloc(total);
856 if (!cell) {
857 return NULL;
858 }
859 int pos = 0;
860 pos += put_varint(cell + pos, total_payload_len);
861 pos += put_varint(cell + pos, rowid);
862 memcpy(cell + pos, payload, local_len);
863 pos += local_len;
864 put_u32(cell + pos, overflow_page);
865 pos += BTREE_PTR_SIZE;
866 *out_cell_len = pos;
867 return cell;
868}
869
870// --- Overflow page writer ---
871// Writes overflow pages for payload bytes that exceed local storage.

Callers 1

Calls 3

varint_lenFunction · 0.85
put_varintFunction · 0.85
put_u32Function · 0.85

Tested by

no test coverage detected