pub struct SearchView { /* private fields */ }Expand description
A .rete opened for search only: the dictionary’s chunk directories, and
the TEXT_INDEX / pyramid deferred behind their lazy slots. Nothing else.
What makes this cheap is skipping dictionary sections 2 and 3 (object-only
and predicates) — NOT skipping the index. Measured on the published
epfl-infoscience.rete (1.64 GB), a full Rete::open_ranged_lazy reads
536,947,344 B, of which the six permutation tile directories are 49,940 B
in 40 reads and the dictionary is 536,896,380 B in 36 reads: the
object-only chunk directory alone is 234,400,728 B, because that file stores
every chunk’s first term verbatim. Files built since #198 key it by the
shortest separator (~600 KB on this graph); the published one still does
not, and only a rebuild changes that. This view opens sections 0 and 1
only — both search modes return subject IRIs — and costs 21,554 B in 9
reads on the same file. It also skips the index container and defers the
TEXT_INDEX and pyramid, so it pays only for what it reads: the token table
on the first search, then one range per posting list and per dictionary
chunk holding a matched subject. This is what backs rete search-url.
On a file with a LABEL_INDEX section (kind 8) the dictionary is not opened at all until a full-text search needs it: the section stores each subject’s term, so a prefix search costs the header, the section head, one directory node per level and one data block.
Implementations§
Source§impl SearchView
impl SearchView
Sourcepub fn open_ranged<R>(reader: R) -> Result<SearchView, FileError>
pub fn open_ranged<R>(reader: R) -> Result<SearchView, FileError>
Open for search over any RangeReader (HTTP or local): header +
dictionary chunk directories only (none at all on a file with a
LABEL_INDEX, until a text search needs them), with the text index,
label index and pyramid faulting in on first use.
Sourcepub fn has_labels(&self) -> bool
pub fn has_labels(&self) -> bool
Whether the file can answer a prefix search: it carries a LABEL_INDEX section or a pyramid (whose meta may hold the legacy label block). A header read, no fault.
Sourcepub fn has_label_index(&self) -> bool
pub fn has_label_index(&self) -> bool
Whether the file carries a LABEL_INDEX section (kind 8).
Sourcepub fn header(&self) -> &Header
pub fn header(&self) -> &Header
The file header (already fetched by open_ranged).
Sourcepub fn has_text_index(&self) -> bool
pub fn has_text_index(&self) -> bool
Whether the file carries a TEXT_INDEX section — a header read, no fault.
Sourcepub fn has_pyramid(&self) -> bool
pub fn has_pyramid(&self) -> bool
Whether the file carries a pyramid (where the label index lives) — a header read, no fault.
Sourcepub fn text_search(
&self,
words: &[&str],
prefix: Option<&str>,
limit: usize,
) -> Vec<String>
pub fn text_search( &self, words: &[&str], prefix: Option<&str>, limit: usize, ) -> Vec<String>
Full-text search — see Rete::text_search for the semantics. Faults
the token table on the first call, then only the queried postings.
Sourcepub fn text_index_token_table_len(&self) -> Option<u64>
pub fn text_index_token_table_len(&self) -> Option<u64>
What that first search will cost — see
Rete::text_index_token_table_len. One ≤10-byte range read, so a
caller can quote the figure before deciding to search.
Sourcepub fn prefix_search(&self, prefix: &str, limit: usize) -> Vec<(String, String)>
pub fn prefix_search(&self, prefix: &str, limit: usize) -> Vec<(String, String)>
Label-prefix search — see Rete::prefix_search. Reads the
LABEL_INDEX section when the file has one; otherwise faults the pyramid
(which carries the legacy label block), the pricier path.