mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2025-12-27 12:32:55 +00:00
Various minor code cleanup (#1909)
This commit is contained in:
@@ -29,7 +29,7 @@ pub enum DatePrecision {
|
|||||||
/// All constructors and conversions are provided as explicit
|
/// All constructors and conversions are provided as explicit
|
||||||
/// functions and not by implementing any `From`/`Into` traits
|
/// functions and not by implementing any `From`/`Into` traits
|
||||||
/// to prevent unintended usage.
|
/// to prevent unintended usage.
|
||||||
#[derive(Clone, Default, Copy, PartialEq, Eq, PartialOrd, Ord)]
|
#[derive(Clone, Default, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
|
||||||
pub struct DateTime {
|
pub struct DateTime {
|
||||||
// Timestamp in microseconds.
|
// Timestamp in microseconds.
|
||||||
pub(crate) timestamp_micros: i64,
|
pub(crate) timestamp_micros: i64,
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ pub struct SegmentReader {
|
|||||||
termdict_composite: CompositeFile,
|
termdict_composite: CompositeFile,
|
||||||
postings_composite: CompositeFile,
|
postings_composite: CompositeFile,
|
||||||
positions_composite: CompositeFile,
|
positions_composite: CompositeFile,
|
||||||
fast_fields_readers: Arc<FastFieldReaders>,
|
fast_fields_readers: FastFieldReaders,
|
||||||
fieldnorm_readers: FieldNormReaders,
|
fieldnorm_readers: FieldNormReaders,
|
||||||
|
|
||||||
store_file: FileSlice,
|
store_file: FileSlice,
|
||||||
@@ -167,7 +167,7 @@ impl SegmentReader {
|
|||||||
let schema = segment.schema();
|
let schema = segment.schema();
|
||||||
|
|
||||||
let fast_fields_data = segment.open_read(SegmentComponent::FastFields)?;
|
let fast_fields_data = segment.open_read(SegmentComponent::FastFields)?;
|
||||||
let fast_fields_readers = Arc::new(FastFieldReaders::open(fast_fields_data)?);
|
let fast_fields_readers = FastFieldReaders::open(fast_fields_data)?;
|
||||||
let fieldnorm_data = segment.open_read(SegmentComponent::FieldNorms)?;
|
let fieldnorm_data = segment.open_read(SegmentComponent::FieldNorms)?;
|
||||||
let fieldnorm_readers = FieldNormReaders::open(fieldnorm_data)?;
|
let fieldnorm_readers = FieldNormReaders::open(fieldnorm_data)?;
|
||||||
|
|
||||||
|
|||||||
@@ -366,7 +366,7 @@ impl<'a> JsonTermWriter<'a> {
|
|||||||
&self.term().value_bytes()[..end_of_path - 1]
|
&self.term().value_bytes()[..end_of_path - 1]
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_fast_value<T: FastValue>(&mut self, val: T) {
|
pub(crate) fn set_fast_value<T: FastValue>(&mut self, val: T) {
|
||||||
self.close_path_and_set_type(T::to_type());
|
self.close_path_and_set_type(T::to_type());
|
||||||
let value = if T::to_type() == Type::Date {
|
let value = if T::to_type() == Type::Date {
|
||||||
DateTime::from_u64(val.to_u64())
|
DateTime::from_u64(val.to_u64())
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ use std::ops::RangeInclusive;
|
|||||||
|
|
||||||
use columnar::Column;
|
use columnar::Column;
|
||||||
|
|
||||||
use crate::fastfield::MakeZero;
|
|
||||||
use crate::{DocId, DocSet, TERMINATED};
|
use crate::{DocId, DocSet, TERMINATED};
|
||||||
|
|
||||||
/// Helper to have a cursor over a vec of docids
|
/// Helper to have a cursor over a vec of docids
|
||||||
@@ -40,7 +39,7 @@ impl VecCursor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) struct RangeDocSet<T: MakeZero> {
|
pub(crate) struct RangeDocSet<T> {
|
||||||
/// The range filter on the values.
|
/// The range filter on the values.
|
||||||
value_range: RangeInclusive<T>,
|
value_range: RangeInclusive<T>,
|
||||||
column: Column<T>,
|
column: Column<T>,
|
||||||
@@ -61,7 +60,7 @@ pub(crate) struct RangeDocSet<T: MakeZero> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const DEFAULT_FETCH_HORIZON: u32 = 128;
|
const DEFAULT_FETCH_HORIZON: u32 = 128;
|
||||||
impl<T: MakeZero + Send + Sync + PartialOrd + Copy + Debug + 'static> RangeDocSet<T> {
|
impl<T: Send + Sync + PartialOrd + Copy + Debug + 'static> RangeDocSet<T> {
|
||||||
pub(crate) fn new(value_range: RangeInclusive<T>, column: Column<T>) -> Self {
|
pub(crate) fn new(value_range: RangeInclusive<T>, column: Column<T>) -> Self {
|
||||||
let mut range_docset = Self {
|
let mut range_docset = Self {
|
||||||
value_range,
|
value_range,
|
||||||
@@ -131,7 +130,7 @@ impl<T: MakeZero + Send + Sync + PartialOrd + Copy + Debug + 'static> RangeDocSe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: MakeZero + Send + Sync + PartialOrd + Copy + Debug + 'static> DocSet for RangeDocSet<T> {
|
impl<T: Send + Sync + PartialOrd + Copy + Debug + 'static> DocSet for RangeDocSet<T> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn advance(&mut self) -> DocId {
|
fn advance(&mut self) -> DocId {
|
||||||
if let Some(docid) = self.loaded_docs.next() {
|
if let Some(docid) = self.loaded_docs.next() {
|
||||||
|
|||||||
@@ -57,14 +57,6 @@ impl<'a> TermMerger<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn matching_segments<'b: 'a>(
|
|
||||||
&'b self,
|
|
||||||
) -> impl 'b + Iterator<Item = (usize, TermOrdinal)> {
|
|
||||||
self.current_streamers
|
|
||||||
.iter()
|
|
||||||
.map(|heap_item| (heap_item.segment_ord, heap_item.streamer.term_ord()))
|
|
||||||
}
|
|
||||||
|
|
||||||
fn advance_segments(&mut self) {
|
fn advance_segments(&mut self) {
|
||||||
let streamers = &mut self.current_streamers;
|
let streamers = &mut self.current_streamers;
|
||||||
let heap = &mut self.heap;
|
let heap = &mut self.heap;
|
||||||
@@ -80,19 +72,18 @@ impl<'a> TermMerger<'a> {
|
|||||||
/// False if there is none.
|
/// False if there is none.
|
||||||
pub fn advance(&mut self) -> bool {
|
pub fn advance(&mut self) -> bool {
|
||||||
self.advance_segments();
|
self.advance_segments();
|
||||||
if let Some(head) = self.heap.pop() {
|
let Some(head) = self.heap.pop() else {
|
||||||
self.current_streamers.push(head);
|
return false;
|
||||||
while let Some(next_streamer) = self.heap.peek() {
|
};
|
||||||
if self.current_streamers[0].streamer.key() != next_streamer.streamer.key() {
|
self.current_streamers.push(head);
|
||||||
break;
|
while let Some(next_streamer) = self.heap.peek() {
|
||||||
}
|
if self.current_streamers[0].streamer.key() != next_streamer.streamer.key() {
|
||||||
let next_heap_it = self.heap.pop().unwrap(); // safe : we peeked beforehand
|
break;
|
||||||
self.current_streamers.push(next_heap_it);
|
|
||||||
}
|
}
|
||||||
true
|
let next_heap_it = self.heap.pop().unwrap(); // safe : we peeked beforehand
|
||||||
} else {
|
self.current_streamers.push(next_heap_it);
|
||||||
false
|
|
||||||
}
|
}
|
||||||
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the current term.
|
/// Returns the current term.
|
||||||
|
|||||||
Reference in New Issue
Block a user