mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2026-05-25 20:50:43 +00:00
NOBUG misc ...
This commit is contained in:
@@ -42,14 +42,24 @@ fn create_uuid() -> Uuid {
|
||||
}
|
||||
|
||||
impl SegmentId {
|
||||
#[doc(hidden)]
|
||||
pub fn generate_random() -> SegmentId {
|
||||
SegmentId(create_uuid())
|
||||
}
|
||||
|
||||
|
||||
/// Returns a shorter identifier of the segment.
|
||||
///
|
||||
/// We are using UUID4, so only 6 bits are fixed,
|
||||
/// and the rest is random.
|
||||
///
|
||||
/// Picking the first 8 chars is ok to identify
|
||||
/// segments in a display message.
|
||||
pub fn short_uuid_string(&self,) -> String {
|
||||
(&self.0.simple().to_string()[..8]).to_string()
|
||||
}
|
||||
|
||||
/// Returns a segment uuid string.
|
||||
pub fn uuid_string(&self,) -> String {
|
||||
self.0.simple().to_string()
|
||||
}
|
||||
|
||||
@@ -130,25 +130,6 @@ impl<'a> SegmentWriter<'a> {
|
||||
pub fn is_buffer_full(&self,) -> bool {
|
||||
self.heap.num_free_bytes() <= MARGIN_IN_BYTES
|
||||
}
|
||||
|
||||
// pub fn compute_doc_mapping_after_delete(&self, mut delete_queue_cursor: DeleteQueueCursor) -> Vec<Option<DocId>> {
|
||||
// let delete_docs = self.compute_delete_mask(&mut delete_queue_cursor);
|
||||
// let max_doc: usize = self.max_doc as usize;
|
||||
// let mut doc_autoinc = 0u32;
|
||||
// (0..max_doc)
|
||||
// .map(|doc| {
|
||||
// if delete_docs.contains(doc) {
|
||||
// None
|
||||
// }
|
||||
// else {
|
||||
// let new_doc = doc_autoinc;
|
||||
// doc_autoinc += 1;
|
||||
// Some(new_doc)
|
||||
// }
|
||||
// })
|
||||
// .collect::<Vec<_>>()
|
||||
// }
|
||||
|
||||
|
||||
/// Indexes a new document
|
||||
///
|
||||
|
||||
@@ -11,7 +11,7 @@ use itertools::Itertools;
|
||||
|
||||
/// Documents are really just a list of couple `(field, value)`.
|
||||
/// In this list, one field may appear more than once.
|
||||
#[derive(Debug, RustcEncodable, RustcDecodable)]
|
||||
#[derive(Debug, RustcEncodable, RustcDecodable, Default)]
|
||||
pub struct Document {
|
||||
field_values: Vec<FieldValue>,
|
||||
}
|
||||
@@ -31,6 +31,11 @@ impl Eq for Document {}
|
||||
|
||||
impl Document {
|
||||
|
||||
/// Creates a new, empty document object
|
||||
pub fn new() -> Document {
|
||||
Document::default()
|
||||
}
|
||||
|
||||
/// Returns the number of `(field, value)` pairs.
|
||||
pub fn len(&self,) -> usize {
|
||||
self.field_values.len()
|
||||
@@ -97,14 +102,6 @@ impl Document {
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Document {
|
||||
|
||||
fn default() -> Document {
|
||||
Document {
|
||||
field_values: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Vec<FieldValue>> for Document {
|
||||
fn from(field_values: Vec<FieldValue>) -> Document {
|
||||
|
||||
@@ -131,6 +131,8 @@ pub use self::text_options::STORED;
|
||||
|
||||
pub use self::u32_options::U32Options;
|
||||
pub use self::u32_options::FAST;
|
||||
pub use self::u32_options::U32_INDEXED;
|
||||
pub use self::u32_options::U32_STORED;
|
||||
|
||||
use regex::Regex;
|
||||
|
||||
|
||||
@@ -206,7 +206,7 @@ impl BitOr for TextOptions {
|
||||
fn bitor(self, other: TextOptions) -> TextOptions {
|
||||
let mut res = TextOptions::default();
|
||||
res.indexing = self.indexing | other.indexing;
|
||||
res.stored = self.stored || other.stored;
|
||||
res.stored = self.stored | other.stored;
|
||||
res
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
use std::ops::BitOr;
|
||||
|
||||
/// Define how a U32 field should be handled by tantivy.
|
||||
#[derive(Clone,Debug,PartialEq,Eq, RustcDecodable, RustcEncodable)]
|
||||
pub struct U32Options {
|
||||
@@ -65,9 +67,43 @@ impl Default for U32Options {
|
||||
}
|
||||
|
||||
|
||||
/// Shortcut for
|
||||
/// Shortcut for a u32 fast field.
|
||||
///
|
||||
/// Such a shortcut can be composed as follows `STORED | FAST | U32_INDEXED`
|
||||
pub const FAST: U32Options = U32Options {
|
||||
indexed: false,
|
||||
stored: false,
|
||||
fast: true,
|
||||
};
|
||||
|
||||
/// Shortcut for a u32 indexed field.
|
||||
///
|
||||
/// Such a shortcut can be composed as follows `STORED | FAST | U32_INDEXED`
|
||||
pub const U32_INDEXED: U32Options = U32Options {
|
||||
indexed: true,
|
||||
stored: false,
|
||||
fast: false,
|
||||
};
|
||||
|
||||
/// Shortcut for a u32 stored field.
|
||||
///
|
||||
/// Such a shortcut can be composed as follows `STORED | FAST | U32_INDEXED`
|
||||
pub const U32_STORED: U32Options = U32Options {
|
||||
indexed: false,
|
||||
stored: true,
|
||||
fast: false,
|
||||
};
|
||||
|
||||
|
||||
impl BitOr for U32Options {
|
||||
|
||||
type Output = U32Options;
|
||||
|
||||
fn bitor(self, other: U32Options) -> U32Options {
|
||||
let mut res = U32Options::default();
|
||||
res.indexed = self.indexed | other.indexed;
|
||||
res.stored = self.stored | other.stored;
|
||||
res.fast = self.fast | other.fast;
|
||||
res
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user