@ferrybig/cgeodata-reader
    Preparing search index...

    An open search index file (Appendix B). Opening reads and validates the header only. The list directory, each list, the table directory, and each table block are read the first time a query needs them, and kept behind WeakRefs, so an index that goes unused for weeks costs no memory beyond its header.

    Opening does NOT verify the source checksum -- CGeoDataReader's useSearchIndex() does that against the file it's attached to.

    Index
    name?: string

    The index file's name, when its source has one (ByteSource.name).

    sourceChecksum: bigint

    Checksum of the source it was built from (Section B.8): of its place table, or for RELEVANCE_AREA, of everything before its first chunk. A reader only accepts the index when it matches its own.

    placeCount: number

    N, the number of places in the source; every one is indexed.

    hashExp: number

    2^hashExp shared lists for non-Latin trigrams (Section B.3).

    topCount: number

    Places per short-query entry; 0 when the file has no table.

    topBlockExp: number

    2^topBlockExp short-query entries per table block (Section B.6).

    relevanceRule: number

    The order its short-query table is in: RELEVANCE_PLAIN (Section B.5) or RELEVANCE_AREA (Section B.5.1).

    • get listCount(): number

      L = 28^3 + 2^hashExp possible list indices.

      Returns number

    • Opens a search index file (read on demand, like a .bin), validating its header (Section B.10). Takes ownership of a ByteSource: close() closes it, as does a failed open.

      Parameters

      Returns Promise<SearchIndex>

    • Closes the index's source.

      Returns Promise<void>

    • Section B.9 steps 2-4: every place whose names could contain text, ascending -- a superset of the real matches, which the caller still has to confirm name by name. Undefined when text folds to fewer than 3 symbols, i.e. the lists can't rule anything out.

      Parameters

      • text: string

      Returns Promise<number[] | undefined>

    • Section B.9 step 1: the short-query table's entry for text -- its top topCount places in relevance order (Section B.5), or [] when nothing matches. Undefined when the file has no table or text isn't one or two code points long once folded.

      The key is foldDiacritics(text), so an accented query and its unaccented spelling land on the same entry -- which is only the right answer for a query that needed no folding in the first place. Callers MUST therefore apply Section B.9 step 1's own precondition (the query's folded form already equals its plain lowercase form) before trusting this; CGeoDataReader.searchRanked does.

      Parameters

      • text: string

      Returns Promise<number[] | undefined>