CatgirlIntelligenceAgency/code/features-index/index-reverse
Viktor Lofgren d0aa754252 (long-array) Implement java.lang.foreign.Arena based lifecycle control for LongArray.
Further de-ByteBuffer:ing of these classes is to be done, but this is the smallest most urgently needed benefit.

This commit is a WIP but in a fully working state, pushing due to the importance of the changes to offer lifecycle control over mmaps.
2023-09-24 10:40:06 +02:00
..
src (long-array) Implement java.lang.foreign.Arena based lifecycle control for LongArray. 2023-09-24 10:40:06 +02:00
build.gradle (*) Upgrade to JDK21 with preview enabled. 2023-09-24 10:38:59 +02:00
index.svg (index-reverse) Add documentation and clean up code. 2023-08-29 11:35:54 +02:00
merging.svg (index-reverse) Add documentation and clean up code. 2023-08-29 11:35:54 +02:00
preindex.svg (index-reverse) Add documentation and clean up code. 2023-08-29 11:35:54 +02:00
readme.md (index-reverse) Add documentation and clean up code. 2023-08-29 11:35:54 +02:00

Reverse Index

The reverse index contains a mapping from word to document id.

There are two tiers of this index.

  • A priority index which only indexes terms that are flagged with priority flags1.
  • A full index that indexes all terms.

The full index also provides access to term-level metadata, while the priority index is a binary index that only offers information about which documents has a specific word.

[1] See WordFlags in common/model and KeywordMetadata in features-convert/keyword-extraction.

Construction

The reverse index is constructed by first building a series of preindexes. Preindexes consist of a Segment and a Documents object. The segment contains information about which word identifiers are present and how many, and the documents contain information about in which documents the words can be found.

Memory layout illustrations

These would typically not fit in RAM, so the index journal is paged and the preindexes are constructed small enough to fit in memory, and then merged. Merging sorted arrays is a very fast operation that does not require additional RAM.

Illustration of successively merged preindex files

Once merged into one large preindex, indexes are added to the preindex data to form a finalized reverse index.

Illustration of the data layout of the finalized index

Central Classes

See Also