Skip to content

Commit 1095543

Browse files
committed
cargo fmt
1 parent 672bf45 commit 1095543

5 files changed

Lines changed: 20 additions & 26 deletions

File tree

src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,10 @@ mod macros;
169169
mod future_result;
170170

171171
// Re-exports
172+
pub use columnar;
172173
pub use common::{ByteCount, DateTime};
173-
pub use {columnar, query_grammar, time};
174+
pub use query_grammar;
175+
pub use time;
174176

175177
pub use crate::error::TantivyError;
176178
pub use crate::future_result::FutureResult;

src/postings/block_segment_postings.rs

Lines changed: 8 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -248,28 +248,17 @@ impl BlockSegmentPostings {
248248
term_freqs: &mut [u32],
249249
) -> usize {
250250
debug_assert_eq!(docs.len(), term_freqs.len());
251-
let block_docs = self.docs();
252-
let remaining_docs_in_block = block_docs.len().saturating_sub(block_offset);
253-
let max_len = remaining_docs_in_block.min(docs.len());
254-
if max_len == 0 {
255-
return 0;
256-
}
257-
258-
let source_docs = &block_docs[block_offset..block_offset + max_len];
259-
let len = if source_docs[max_len - 1] < horizon {
260-
max_len
261-
} else {
262-
source_docs
263-
.iter()
264-
.position(|&doc| doc >= horizon)
265-
.unwrap_or(max_len)
266-
};
267251

252+
let source_docs = self.docs().get(block_offset..).unwrap_or(&[]);
253+
let source_docs = &source_docs[..source_docs.len().min(docs.len())];
254+
let len = source_docs.partition_point(|&doc| doc < horizon);
268255
docs[..len].copy_from_slice(&source_docs[..len]);
269256

270-
let block_freqs = self.freq_output_array();
271-
if block_freqs.len() >= block_offset + len {
272-
term_freqs[..len].copy_from_slice(&block_freqs[block_offset..block_offset + len]);
257+
if let Some(source_freqs) = self
258+
.freq_output_array()
259+
.get(block_offset..block_offset + len)
260+
{
261+
term_freqs[..len].copy_from_slice(source_freqs);
273262
} else {
274263
term_freqs[..len].fill(1);
275264
}

src/query/bm25.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,8 @@ thread_local! {
8383
/// The cache is shared across all [Bm25Weight] with the same average fieldnorm on the same thread.
8484
/// It is stored in a thread local LRU cache.
8585
///
86-
/// On one query all terms on the same field will share the same average fieldnorm, and thus the same cache.
87-
/// This will lower cache pressure.
86+
/// On one query all terms on the same field will share the same average fieldnorm, and thus the
87+
/// same cache. This will lower cache pressure.
8888
///
8989
/// Even between queries (on the same thread), the cache will be reused, which allows the cache to
9090
/// better learn the memory address of the cache and access patterns.

src/query/scorer.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ pub trait Scorer: downcast_rs::Downcast + DocSet + 'static {
2222

2323
/// Returns the score for `doc` with its term frequency.
2424
fn score_doc(&mut self, _doc: DocId, _term_freq: u32) -> Score {
25-
panic!("score_doc is not supported by this scorer. You need check can_score_doc() before calling this method.")
25+
panic!(
26+
"score_doc is not supported by this scorer. You need check can_score_doc() before \
27+
calling this method."
28+
)
2629
}
2730

2831
/// Fills docs and term frequencies up to `horizon`.

src/query/union/buffered_union.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,9 @@ fn insert_and_score_full_buffer<TScorer: Scorer, TScoreCombiner: ScoreCombiner>(
129129
for (&doc, &term_freq) in docs.iter().zip(term_freqs.iter()) {
130130
let delta = doc - min_doc;
131131
insert_delta(bitsets, delta);
132-
// TODO: score_doc access the field_norm reader for each _term_, instead of once per doc.
133-
// We could optimize this by caching the field norm for the doc, and reusing it for all
134-
// terms in the doc.
132+
// TODO: score_doc access the field_norm reader for each _term_, instead of once per
133+
// doc. We could optimize this by caching the field norm for the doc, and
134+
// reusing it for all terms in the doc.
135135
let score = scorer.score_doc(doc, term_freq);
136136
update_score_combiner(score_combiner, delta, doc, score);
137137
}

0 commit comments

Comments
 (0)