mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2026-01-06 17:22:54 +00:00
Compare commits
1 Commits
use_column
...
expose-min
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4c454d752d |
@@ -46,6 +46,24 @@ impl<Item: FastValue> MultiValuedFastFieldReader<Item> {
|
|||||||
self.vals_reader.get_range_u64(range.start, &mut vals[..]);
|
self.vals_reader.get_range_u64(range.start, &mut vals[..]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the minimum value for this fast field.
|
||||||
|
///
|
||||||
|
/// The min value does not take in account of possible
|
||||||
|
/// deleted document, and should be considered as a lower bound
|
||||||
|
/// of the actual mimimum value.
|
||||||
|
pub fn min_value(&self) -> Item {
|
||||||
|
self.vals_reader.min_value()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Returns the maximum value for this fast field.
|
||||||
|
///
|
||||||
|
/// The max value does not take in account of possible
|
||||||
|
/// deleted document, and should be considered as an upper bound
|
||||||
|
/// of the actual maximum value.
|
||||||
|
pub fn max_value(&self) -> Item {
|
||||||
|
self.vals_reader.max_value()
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns the number of values associated with the document `DocId`.
|
/// Returns the number of values associated with the document `DocId`.
|
||||||
pub fn num_vals(&self, doc: DocId) -> usize {
|
pub fn num_vals(&self, doc: DocId) -> usize {
|
||||||
let range = self.range(doc);
|
let range = self.range(doc);
|
||||||
@@ -71,7 +89,7 @@ impl<Item: FastValue> MultiValueLength for MultiValuedFastFieldReader<Item> {
|
|||||||
mod tests {
|
mod tests {
|
||||||
|
|
||||||
use crate::core::Index;
|
use crate::core::Index;
|
||||||
use crate::schema::{Facet, Schema, INDEXED};
|
use crate::schema::{Cardinality, Facet, IntOptions, Schema, INDEXED};
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_multifastfield_reader() {
|
fn test_multifastfield_reader() {
|
||||||
@@ -126,4 +144,32 @@ mod tests {
|
|||||||
assert_eq!(&vals[..], &[4]);
|
assert_eq!(&vals[..], &[4]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_multifastfield_reader_min_max() {
|
||||||
|
let mut schema_builder = Schema::builder();
|
||||||
|
let field_options = IntOptions::default()
|
||||||
|
.set_indexed()
|
||||||
|
.set_fast(Cardinality::MultiValues);
|
||||||
|
let item_field = schema_builder.add_i64_field("items", field_options);
|
||||||
|
let schema = schema_builder.build();
|
||||||
|
let index = Index::create_in_ram(schema);
|
||||||
|
let mut index_writer = index
|
||||||
|
.writer_for_tests()
|
||||||
|
.expect("Failed to create index writer.");
|
||||||
|
index_writer.add_document(doc!(
|
||||||
|
item_field => 2i64,
|
||||||
|
item_field => 3i64,
|
||||||
|
item_field => -2i64,
|
||||||
|
));
|
||||||
|
index_writer.add_document(doc!(item_field => 6i64, item_field => 3i64));
|
||||||
|
index_writer.add_document(doc!(item_field => 4i64));
|
||||||
|
index_writer.commit().expect("Commit failed");
|
||||||
|
let searcher = index.reader().unwrap().searcher();
|
||||||
|
let segment_reader = searcher.segment_reader(0);
|
||||||
|
let field_reader = segment_reader.fast_fields().i64s(item_field).unwrap();
|
||||||
|
|
||||||
|
assert_eq!(field_reader.min_value(), -2);
|
||||||
|
assert_eq!(field_reader.max_value(), 6);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,9 +48,9 @@ pub trait FastFieldReader<Item: FastValue>: Clone {
|
|||||||
|
|
||||||
/// Returns the minimum value for this fast field.
|
/// Returns the minimum value for this fast field.
|
||||||
///
|
///
|
||||||
/// The max value does not take in account of possible
|
/// The min value does not take in account of possible
|
||||||
/// deleted document, and should be considered as an upper bound
|
/// deleted document, and should be considered as a lower bound
|
||||||
/// of the actual maximum value.
|
/// of the actual mimimum value.
|
||||||
fn min_value(&self) -> Item;
|
fn min_value(&self) -> Item;
|
||||||
|
|
||||||
/// Returns the maximum value for this fast field.
|
/// Returns the maximum value for this fast field.
|
||||||
|
|||||||
Reference in New Issue
Block a user