Making more things public for quickwit. (#2005)

This commit is contained in:
Paul Masurel
2023-04-20 11:37:45 +09:00
committed by GitHub
parent c1defdda05
commit fbda511a1a
6 changed files with 32 additions and 4 deletions

View File

@@ -201,7 +201,7 @@ fn infer_type_from_str(text: &str) -> TextOrDateTime {
}
// Tries to infer a JSON type from a string.
pub(crate) fn convert_to_fast_value_and_get_term(
pub fn convert_to_fast_value_and_get_term(
json_term_writer: &mut JsonTermWriter,
phrase: &str,
) -> Option<Term> {
@@ -405,8 +405,7 @@ impl<'a> JsonTermWriter<'a> {
.append_bytes(value.to_be_bytes().as_slice());
}
#[cfg(test)]
pub(crate) fn set_str(&mut self, text: &str) {
pub fn set_str(&mut self, text: &str) {
self.close_path_and_set_type(Type::Str);
self.term_buffer.append_bytes(text.as_bytes());
}

View File

@@ -2,6 +2,7 @@ mod executor;
pub mod index;
mod index_meta;
mod inverted_index_reader;
#[doc(hidden)]
pub mod json_utils;
pub mod searcher;
mod segment;

View File

@@ -173,6 +173,8 @@ use once_cell::sync::Lazy;
use serde::{Deserialize, Serialize};
pub use self::docset::{DocSet, TERMINATED};
#[doc(hidden)]
pub use crate::core::json_utils;
pub use crate::core::{
Executor, Index, IndexBuilder, IndexMeta, IndexSettings, IndexSortByField, InvertedIndexReader,
Order, Searcher, SearcherGeneration, Segment, SegmentComponent, SegmentId, SegmentMeta,

View File

@@ -1,4 +1,5 @@
use std::io;
use std::net::Ipv6Addr;
use std::ops::{Bound, Range};
use common::{BinarySerializable, BitSet};
@@ -196,6 +197,29 @@ impl RangeQuery {
}
}
/// Create a new `RangeQuery` over a `ip` field.
///
/// If the field is not of the type `ip`, tantivy
/// will panic when the `Weight` object is created.
pub fn new_ip_bounds(
field: String,
left_bound: Bound<Ipv6Addr>,
right_bound: Bound<Ipv6Addr>,
) -> RangeQuery {
let make_term_val = |val: &Ipv6Addr| {
Term::from_field_ip_addr(Field::from_field_id(0), *val)
.value_bytes()
.to_owned()
};
RangeQuery {
field,
value_type: Type::IpAddr,
left_bound: map_bound(&left_bound, &make_term_val),
right_bound: map_bound(&right_bound, &make_term_val),
limit: None,
}
}
/// Create a new `RangeQuery` over a `u64` field.
///
/// If the field is not of the type `u64`, tantivy

View File

@@ -30,7 +30,8 @@ where B: AsRef<[u8]>;
const TERM_METADATA_LENGTH: usize = 5;
impl Term {
pub(crate) fn with_capacity(capacity: usize) -> Term {
/// Create a new Term with a buffer with a given capacity.
pub fn with_capacity(capacity: usize) -> Term {
let mut data = Vec::with_capacity(TERM_METADATA_LENGTH + capacity);
data.resize(TERM_METADATA_LENGTH, 0u8);
Term(data)

View File

@@ -6,6 +6,7 @@ use super::{Token, TokenStream, Tokenizer};
#[derive(Clone)]
pub struct SimpleTokenizer;
/// TokenStream produced by the `SimpleTokenizer`.
pub struct SimpleTokenStream<'a> {
text: &'a str,
chars: CharIndices<'a>,