module

Xerp::Index::PostingsBuilder

Class methods

build(db : DB::Database, file_id : Int64, result : Tokenize::TokenizeResult) : Hash(String, Int64)

Builds postings from tokenize result and stores them in the database. Returns a hash of token -> token_id for later df updates.

Source
decode_lines(lines_blob : Bytes) : Array(Int32)

Decodes a posting's lines_blob back to line numbers.

Source
update_all_df(db : DB::Database) : Nil

Updates document frequency (df) for all tokens in the database. This should be called after indexing to ensure df values are accurate.

Source
update_df_for_tokens(db : DB::Database, token_ids : Enumerable(Int64)) : Nil

Updates df for a set of tokens (more efficient than updating all).

Source
update_token_df(db : DB::Database, token_id : Int64) : Nil

Updates df for a specific token by counting distinct files in postings.

Source