Skip to content

Table Detailed Design

wxd edited this page Sep 4, 2023 · 1 revision

the whole frame

The positive row index is stored in memory by row, and the fixed-length field and variable-length field are stored in two memory blocks respectively. The overall structure is as follows

Supported types

Name length bit negative length
INT 32 Yes
LONG 64 Yes
FLOAT 32 Yes
DOUBLE 64 Yes
STRING 64+16+str_len No

The front row index uses a whole block of memory storage. When the program starts, it applies for memory according to max_size and doc_size. max_size is the maximum number of documents, doc_size is the doc size of a fixed-length field, doc uses row storage, and each doc has a fixed length, which can be directly retrieved according to docid doc, variable length string is stored in a separate space, doc stores the starting position and length of the string

Insert doc

Find the last big docid according to max_docid, max_docid*doc_size is the insertion position of the doc, insert the doc, max_docid plus 1

Find doc

Calculate the memory offset according to docid*doc_size, fetch the doc, read the starting position and length of the variable length field in the doc, and read the content of the variable length field

Delete doc

Use mark deletion in the engine, no need to operate the front row

Clone this wiki locally