Struct tantivy::fieldnorm::FieldNormReader
source · [−]pub struct FieldNormReader(_);
Expand description
Reads the fieldnorm associated to a document. The fieldnorm represents the length associated to a given Field of a given document.
This metric is important to compute the score of a document : a document having a query word in one its short fields (e.g. title) is likely to be more relevant than in one of its longer field (e.g. body).
tantivy encodes fieldnorm
on one byte with some precision loss,
using the same scheme as Lucene. Each value is place on a log-scale
that takes values from 0
to 255
.
A value on this scale is identified by a fieldnorm_id
.
Apart from compression, this scale also makes it possible to
precompute computationally expensive functions of the fieldnorm
in a very short array.
Implementations
sourceimpl FieldNormReader
impl FieldNormReader
sourcepub fn constant(num_docs: u32, fieldnorm: u32) -> FieldNormReader
pub fn constant(num_docs: u32, fieldnorm: u32) -> FieldNormReader
Creates a FieldNormReader
with a constant fieldnorm.
The fieldnorm will be subjected to compression as if it was coming from an array-backed fieldnorm reader.
sourcepub fn open(fieldnorm_file: FileSlice) -> Result<Self>
pub fn open(fieldnorm_file: FileSlice) -> Result<Self>
Opens a field norm reader given its file.
sourcepub fn fieldnorm(&self, doc_id: DocId) -> u32
pub fn fieldnorm(&self, doc_id: DocId) -> u32
Returns the fieldnorm
associated to a doc id.
The fieldnorm is a value approximating the number
of tokens in a given field of the doc_id
.
It is imprecise, and equal or lower than the actual number of tokens.
The fieldnorm is effectively decoded from the
fieldnorm_id
by doing a simple table lookup.
sourcepub fn fieldnorm_id(&self, doc_id: DocId) -> u8
pub fn fieldnorm_id(&self, doc_id: DocId) -> u8
Returns the fieldnorm_id
associated to a document.
sourcepub fn id_to_fieldnorm(id: u8) -> u32
pub fn id_to_fieldnorm(id: u8) -> u32
Converts a fieldnorm_id
into a fieldnorm.
sourcepub fn fieldnorm_to_id(fieldnorm: u32) -> u8
pub fn fieldnorm_to_id(fieldnorm: u32) -> u8
Converts a fieldnorm
into a fieldnorm_id
.
(This function is not injective).
Trait Implementations
sourceimpl Clone for FieldNormReader
impl Clone for FieldNormReader
sourcefn clone(&self) -> FieldNormReader
fn clone(&self) -> FieldNormReader
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
Auto Trait Implementations
impl !RefUnwindSafe for FieldNormReader
impl Send for FieldNormReader
impl Sync for FieldNormReader
impl Unpin for FieldNormReader
impl !UnwindSafe for FieldNormReader
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Downcast for T where
T: Any,
impl<T> Downcast for T where
T: Any,
sourcefn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>
Convert Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
. Read more
sourcefn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any + 'static>
Convert Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
. Read more
sourcefn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert &Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s. Read more
sourcefn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert &mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s. Read more
sourceimpl<T> DowncastSync for T where
T: Any + Send + Sync,
impl<T> DowncastSync for T where
T: Any + Send + Sync,
impl<T> Pointable for T
impl<T> Pointable for T
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more