Documentation
¶
Overview ¶
Package segment implements a custom binary segment file format (.spdx) for persisting inverted-index data to disk. Each segment has a fixed-size header, a postings region, a JSON dictionary, and a CRC32 footer. The Writer creates new segments atomically, and the Reader provides random-access search over them.
Index ¶
Constants ¶
const ( MagicBytes uint32 = 0x53504458 FormatVersion uint32 = 1 HeaderSize int = 64 )
MagicBytes identifies a valid .spdx segment file.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DictEntry ¶
type DictEntry struct {
Term string `json:"t"`
PostOffset int64 `json:"o"`
PostLen int `json:"l"`
DocFreq int `json:"d"`
}
DictEntry maps a term to its postings offset, length, and document frequency in the segment file.
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
Reader provides read-only access to a single .spdx segment file. It memory-maps the dictionary on open and performs random-access reads for posting lists.
func OpenReader ¶
OpenReader opens an existing segment file, validates the magic bytes, and loads the term dictionary into memory.
type SegmentHeader ¶
type SegmentHeader struct {
Magic uint32
Version uint32
TermCount uint32
DocCount uint32
CreatedAt int64
DictOffset int64
DictSize int64
PostOffset int64
PostSize int64
}
SegmentHeader is the 64-byte header written at the start of every segment.