mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2026-05-18 01:00:40 +00:00
NOBUG Added comments.
This commit is contained in:
@@ -21,6 +21,14 @@ use super::pool::LeasedItem;
|
||||
|
||||
const NUM_SEARCHERS: usize = 12;
|
||||
|
||||
/// MetaInformation about the `Index`.
|
||||
///
|
||||
/// This object is serialized on disk in the `meta.json` file.
|
||||
/// It keeps information about
|
||||
/// * the searchable segments,
|
||||
/// * the index docstamp
|
||||
/// * the schema
|
||||
///
|
||||
#[derive(Clone,Debug,RustcDecodable,RustcEncodable)]
|
||||
pub struct IndexMeta {
|
||||
segments: Vec<SegmentId>,
|
||||
@@ -53,7 +61,7 @@ fn load_metas(directory: &Directory) -> Result<IndexMeta> {
|
||||
Ok(loaded_meta)
|
||||
}
|
||||
|
||||
|
||||
/// Tantivy's Search Index
|
||||
pub struct Index {
|
||||
metas: Arc<RwLock<IndexMeta>>,
|
||||
directory: Box<Directory>,
|
||||
@@ -62,8 +70,6 @@ pub struct Index {
|
||||
}
|
||||
|
||||
impl Index {
|
||||
|
||||
|
||||
/// Creates a new index using the `RAMDirectory`.
|
||||
///
|
||||
/// The index will be allocated in anonymous memory.
|
||||
|
||||
27
src/lib.rs
27
src/lib.rs
@@ -70,6 +70,9 @@ pub mod schema;
|
||||
|
||||
pub use directory::Directory;
|
||||
pub use core::searcher::Searcher;
|
||||
|
||||
|
||||
///
|
||||
pub use core::Index;
|
||||
pub use indexer::IndexWriter;
|
||||
pub use schema::Term;
|
||||
@@ -95,17 +98,6 @@ pub type Score = f32;
|
||||
/// It only makes sense for a given searcher.
|
||||
pub type SegmentLocalId = u32;
|
||||
|
||||
/// `DocAddress` contains all the necessary information
|
||||
/// to identify a document given a `Searcher` object.
|
||||
///
|
||||
/// It consists in an id identifying its segment, and
|
||||
/// its segment-local `DocId`.
|
||||
///
|
||||
/// The id used for the segment is actually an ordinal
|
||||
/// in the list of segment hold by a `Searcher`.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub struct DocAddress(pub SegmentLocalId, pub DocId);
|
||||
|
||||
impl DocAddress {
|
||||
|
||||
/// Return the segment ordinal.
|
||||
@@ -140,6 +132,19 @@ impl ScoredDoc {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// `DocAddress` contains all the necessary information
|
||||
/// to identify a document given a `Searcher` object.
|
||||
///
|
||||
/// It consists in an id identifying its segment, and
|
||||
/// its segment-local `DocId`.
|
||||
///
|
||||
/// The id used for the segment is actually an ordinal
|
||||
/// in the list of segment hold by a `Searcher`.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub struct DocAddress(pub SegmentLocalId, pub DocId);
|
||||
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
|
||||
@@ -4,16 +4,21 @@ use common::HasLen;
|
||||
|
||||
|
||||
|
||||
// Postings trait defines all of the information
|
||||
// associated with a term.
|
||||
//
|
||||
// List of docids, term freqs and positions.
|
||||
//
|
||||
// It's main implementation is SegmentPostings,
|
||||
// but some other implementation mocking SegmentPostings exists,
|
||||
// in order to help merging segment or for testing.
|
||||
/// Postings (also called inverted list)
|
||||
///
|
||||
/// For a given term, it is the list of doc ids of the doc
|
||||
/// containing the term. Optionally, for each document,
|
||||
/// it may also give access to the term frequency
|
||||
/// as well as the list of term positions.
|
||||
///
|
||||
/// Its main implementation is `SegmentPostings`,
|
||||
/// but some other implementation mocking SegmentPostings exists,
|
||||
/// in order to help merging segment or for testing.
|
||||
pub trait Postings: DocSet {
|
||||
/// Returns the term frequency
|
||||
fn term_freq(&self,) -> u32;
|
||||
/// Returns the list of positions of the term, expressed as a list of
|
||||
/// token ordinals.
|
||||
fn positions(&self) -> &[u32];
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user