1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
pub mod memory;
use document::Document;
use schema::{Schema, FieldType, FieldRef, AddFieldError};
pub trait IndexReader<'a> {
type AllDocRefIterator: DocRefIterator<'a>;
type TermDocRefIterator: DocRefIterator<'a>;
fn schema(&self) -> &Schema;
fn get_document_by_key(&self, doc_key: &str) -> Option<&Document>;
fn get_document_by_id(&self, doc_id: &u64) -> Option<&Document>;
fn contains_document_key(&self, doc_key: &str) -> bool;
fn num_docs(&self) -> usize;
fn iter_all_docs(&'a self) -> Self::AllDocRefIterator;
fn iter_docs_with_term(&'a self, term: &[u8], field_ref: &FieldRef) -> Option<Self::TermDocRefIterator>;
fn iter_all_terms(&'a self, field_ref: &FieldRef) -> Option<Box<Iterator<Item=&'a [u8]> + 'a>>;
fn num_docs_with_term(&'a self, term: &[u8], field_ref: &FieldRef) -> u64;
fn total_tokens(&'a self, field_ref: &FieldRef) -> u64;
}
pub trait DocRefIterator<'a>: Iterator<Item=u64> {
}
pub trait IndexStore<'a> {
type Reader: IndexReader<'a>;
fn reader(&'a self) -> Self::Reader;
fn add_field(&mut self, name: String, field_type: FieldType) -> Result<FieldRef, AddFieldError>;
fn remove_field(&mut self, field_ref: &FieldRef) -> bool;
fn insert_or_update_document(&mut self, doc: Document);
fn remove_document_by_key(&mut self, doc_key: &str) -> bool;
}