mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2026-01-06 09:12:55 +00:00
clippy
This commit is contained in:
@@ -69,7 +69,7 @@ impl Searcher {
|
||||
/// the searcher.
|
||||
///
|
||||
/// This includes all of the fields from all of the segment_readers.
|
||||
/// See [TermIterator](struct.TermIterator.html).
|
||||
/// See [`TermIterator`](struct.TermIterator.html).
|
||||
///
|
||||
/// # Warning
|
||||
/// This API is very likely to change in the future.
|
||||
|
||||
@@ -257,7 +257,7 @@ impl IndexMerger {
|
||||
let segment_reader = &self.readers[heap_item.segment_ord];
|
||||
let mut segment_postings =
|
||||
segment_reader
|
||||
.read_postings_from_terminfo(&term_info, segment_postings_option);
|
||||
.read_postings_from_terminfo(term_info, segment_postings_option);
|
||||
if segment_postings.advance() {
|
||||
Some((segment_ord, segment_postings))
|
||||
} else {
|
||||
|
||||
@@ -34,7 +34,7 @@ impl Query for PhraseQuery {
|
||||
|
||||
/// Create the weight associated to a query.
|
||||
///
|
||||
/// See [Weight](./trait.Weight.html).
|
||||
/// See [`Weight`](./trait.Weight.html).
|
||||
fn weight(&self, _searcher: &Searcher) -> Result<Box<Weight>> {
|
||||
Ok(box PhraseWeight::from(self.phrase_terms.clone()))
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ pub trait Query: fmt::Debug {
|
||||
|
||||
/// Create the weight associated to a query.
|
||||
///
|
||||
/// See [Weight](./trait.Weight.html).
|
||||
/// See [`Weight`](./trait.Weight.html).
|
||||
fn weight(&self, searcher: &Searcher) -> Result<Box<Weight>>;
|
||||
|
||||
/// Search works as follows :
|
||||
|
||||
@@ -6,7 +6,7 @@ use std::ops::{Deref, DerefMut};
|
||||
|
||||
/// Scored set of documents matching a query within a specific segment.
|
||||
///
|
||||
/// See [Query](./trait.Query.html).
|
||||
/// See [`Query`](./trait.Query.html).
|
||||
pub trait Scorer: DocSet {
|
||||
/// Returns the score.
|
||||
///
|
||||
|
||||
@@ -6,9 +6,9 @@ use core::SegmentReader;
|
||||
/// A Weight is the specialization of a Query
|
||||
/// for a given set of segments.
|
||||
///
|
||||
/// See [Query](./trait.Query.html).
|
||||
/// See [`Query`](./trait.Query.html).
|
||||
pub trait Weight {
|
||||
/// Returns the scorer for the given segment.
|
||||
/// See [Query](./trait.Query.html).
|
||||
/// See [`Query`](./trait.Query.html).
|
||||
fn scorer<'a>(&'a self, reader: &'a SegmentReader) -> Result<Box<Scorer + 'a>>;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ use common::BinarySerializable;
|
||||
use super::TermDictionaryImpl;
|
||||
use termdict::{TermStreamerBuilder, TermStreamer};
|
||||
|
||||
/// See [TermStreamerBuilder](./trait.TermStreamerBuilder.html)
|
||||
/// See [`TermStreamerBuilder`](./trait.TermStreamerBuilder.html)
|
||||
pub struct TermStreamerBuilderImpl<'a, V>
|
||||
where V: 'a + BinarySerializable + Default
|
||||
{
|
||||
@@ -62,7 +62,7 @@ impl<'a, V> TermStreamerBuilder<V> for TermStreamerBuilderImpl<'a, V>
|
||||
}
|
||||
|
||||
|
||||
/// See [TermStreamer](./trait.TermStreamer.html)
|
||||
/// See [`TermStreamer`](./trait.TermStreamer.html)
|
||||
pub struct TermStreamerImpl<'a, V>
|
||||
where V: 'a + BinarySerializable + Default
|
||||
{
|
||||
|
||||
@@ -12,7 +12,7 @@ fn convert_fst_error(e: fst::Error) -> io::Error {
|
||||
io::Error::new(io::ErrorKind::Other, e)
|
||||
}
|
||||
|
||||
/// See [TermDictionaryBuilder](./trait.TermDictionaryBuilder.html)
|
||||
/// See [`TermDictionaryBuilder`](./trait.TermDictionaryBuilder.html)
|
||||
pub struct TermDictionaryBuilderImpl<W, V = TermInfo>
|
||||
where W: Write,
|
||||
V: BinarySerializable + Default
|
||||
@@ -94,7 +94,7 @@ fn open_fst_index(source: ReadOnlySource) -> io::Result<fst::Map> {
|
||||
Ok(fst::Map::from(fst))
|
||||
}
|
||||
|
||||
/// See [TermDictionary](./trait.TermDictionary.html)
|
||||
/// See [`TermDictionary`](./trait.TermDictionary.html)
|
||||
pub struct TermDictionaryImpl<V = TermInfo>
|
||||
where V: BinarySerializable + Default
|
||||
{
|
||||
|
||||
@@ -190,7 +190,7 @@ pub trait TermStreamer<V>: Sized {
|
||||
fn value(&self) -> &V;
|
||||
|
||||
/// Return the next `(key, value)` pair.
|
||||
fn next<'b>(&'b mut self) -> Option<(&'b [u8], &'b V)> {
|
||||
fn next(&mut self) -> Option<(&[u8], &V)> {
|
||||
if self.advance() {
|
||||
Some((self.key(), self.value()))
|
||||
} else {
|
||||
|
||||
@@ -21,7 +21,7 @@ pub(crate) fn stream_before<'a, V>(term_dictionary: &'a TermDictionaryImpl<V>,
|
||||
}
|
||||
}
|
||||
|
||||
/// See [TermStreamerBuilder](./trait.TermStreamerBuilder.html)
|
||||
/// See [`TermStreamerBuilder`](./trait.TermStreamerBuilder.html)
|
||||
pub struct TermStreamerBuilderImpl<'a, V>
|
||||
where V: 'a + BinarySerializable + Default
|
||||
{
|
||||
@@ -40,7 +40,7 @@ impl<'a, V> TermStreamerBuilder<V> for TermStreamerBuilderImpl<'a, V>
|
||||
/// Limit the range to terms greater or equal to the bound
|
||||
fn ge<T: AsRef<[u8]>>(mut self, bound: T) -> Self {
|
||||
let target_key = bound.as_ref();
|
||||
let streamer = stream_before(&self.term_dictionary, target_key.as_ref());
|
||||
let streamer = stream_before(self.term_dictionary, target_key.as_ref());
|
||||
let smaller_than = |k: &[u8]| k.lt(target_key);
|
||||
let (offset_before, current_key) = get_offset(smaller_than, streamer);
|
||||
self.current_key = current_key;
|
||||
@@ -113,7 +113,7 @@ fn get_offset<'a, V, P: Fn(&[u8]) -> bool>(predicate: P,
|
||||
prev_data.clear();
|
||||
prev_data.extend_from_slice(iter_key);
|
||||
}
|
||||
return (prev.as_ptr() as usize, prev_data);
|
||||
(prev.as_ptr() as usize, prev_data)
|
||||
}
|
||||
|
||||
impl<'a, V> TermStreamerBuilderImpl<'a, V>
|
||||
@@ -132,7 +132,7 @@ impl<'a, V> TermStreamerBuilderImpl<'a, V>
|
||||
}
|
||||
}
|
||||
|
||||
/// See [TermStreamer](./trait.TermStreamer.html)
|
||||
/// See [`TermStreamer`](./trait.TermStreamer.html)
|
||||
pub struct TermStreamerImpl<'a, V>
|
||||
where V: 'a + BinarySerializable + Default
|
||||
{
|
||||
@@ -154,7 +154,7 @@ impl<'a, V> TermStreamer<V> for TermStreamerImpl<'a, V>
|
||||
where V: BinarySerializable + Default
|
||||
{
|
||||
fn advance(&mut self) -> bool {
|
||||
if self.cursor.len() == 0 {
|
||||
if self.cursor.is_empty() {
|
||||
return false;
|
||||
}
|
||||
let common_length: usize = VInt::deserialize(&mut self.cursor).unwrap().0 as usize;
|
||||
@@ -168,7 +168,7 @@ impl<'a, V> TermStreamer<V> for TermStreamerImpl<'a, V>
|
||||
.read_exact(&mut self.current_key[common_length..new_length])
|
||||
.unwrap();
|
||||
self.current_value = V::deserialize(&mut self.cursor).unwrap();
|
||||
return true;
|
||||
true
|
||||
}
|
||||
|
||||
fn key(&self) -> &[u8] {
|
||||
|
||||
@@ -21,7 +21,7 @@ fn convert_fst_error(e: fst::Error) -> io::Error {
|
||||
io::Error::new(io::ErrorKind::Other, e)
|
||||
}
|
||||
|
||||
/// See [TermDictionaryBuilder](./trait.TermDictionaryBuilder.html)
|
||||
/// See [`TermDictionaryBuilder`](./trait.TermDictionaryBuilder.html)
|
||||
pub struct TermDictionaryBuilderImpl<W, V = TermInfo>
|
||||
where W: Write,
|
||||
V: BinarySerializable + Default
|
||||
@@ -42,13 +42,9 @@ fn common_prefix_length(left: &[u8], right: &[u8]) -> usize {
|
||||
}
|
||||
|
||||
fn fill_last<'a>(fst: &'a Fst, mut node: Node<'a>, buffer: &mut Vec<u8>) {
|
||||
loop {
|
||||
if let Some(transition) = node.transitions().last() {
|
||||
buffer.push(transition.inp);
|
||||
node = fst.node(transition.addr);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
while let Some(transition) = node.transitions().last() {
|
||||
buffer.push(transition.inp);
|
||||
node = fst.node(transition.addr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,7 +117,7 @@ impl<W, V> TermDictionaryBuilder<W, V> for TermDictionaryBuilderImpl<W, V>
|
||||
self.add_index_entry();
|
||||
let (mut w, split_len) = self.write.finish()?;
|
||||
let fst_write = self.block_index.into_inner().map_err(convert_fst_error)?;
|
||||
w.write(&fst_write)?;
|
||||
w.write_all(&fst_write)?;
|
||||
(split_len as u64).serialize(&mut w)?;
|
||||
w.flush()?;
|
||||
Ok(w)
|
||||
@@ -141,7 +137,7 @@ fn open_fst_index(source: ReadOnlySource) -> io::Result<fst::Map> {
|
||||
}))
|
||||
}
|
||||
|
||||
/// See [TermDictionary](./trait.TermDictionary.html)
|
||||
/// See [`TermDictionary`](./trait.TermDictionary.html)
|
||||
pub struct TermDictionaryImpl<V = TermInfo>
|
||||
where V: BinarySerializable + Default
|
||||
{
|
||||
@@ -161,7 +157,7 @@ impl<V> TermDictionaryImpl<V>
|
||||
let fst_map = &self.fst_index;
|
||||
let fst = fst_map.as_fst();
|
||||
let mut node = fst.root();
|
||||
let mut node_stack: Vec<Node> = vec![node.clone()];
|
||||
let mut node_stack: Vec<Node> = vec![node];
|
||||
|
||||
// first check the longest prefix.
|
||||
for &b in &key[..key.len() - 1] {
|
||||
@@ -199,8 +195,7 @@ impl<V> TermDictionaryImpl<V>
|
||||
return (result_buffer, val);
|
||||
}
|
||||
}
|
||||
|
||||
return (vec![], 0);
|
||||
(vec![], 0)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -244,7 +239,7 @@ impl<'a, V> TermDictionary<'a, V> for TermDictionaryImpl<V>
|
||||
}
|
||||
}
|
||||
}
|
||||
return None;
|
||||
None
|
||||
}
|
||||
|
||||
/// Returns a range builder, to stream all of the terms
|
||||
|
||||
Reference in New Issue
Block a user