mirror of
https://github.com/quickwit-oss/tantivy.git
synced 2026-05-27 05:30:45 +00:00
issue/67 First stab. Iterator working.
This commit is contained in:
@@ -8,7 +8,8 @@ use common::BinarySerializable;
|
||||
/// The schema is in charge of holding mapping between field names
|
||||
/// to `Field` objects.
|
||||
///
|
||||
/// Because the field id is a `u8`, tantivy can only have at most `256` fields
|
||||
/// Because the field id is a `u8`, tantivy can only have at most `255` fields.
|
||||
/// Value 255 is reserved.
|
||||
#[derive(Copy,Clone,Debug,PartialEq,PartialOrd,Eq,Ord,Hash, RustcEncodable, RustcDecodable)]
|
||||
pub struct Field(pub u8);
|
||||
|
||||
|
||||
@@ -8,9 +8,11 @@ use super::Field;
|
||||
/// Term represents the value that the token can take.
|
||||
///
|
||||
/// It actually wraps a `Vec<u8>`.
|
||||
/// TODO remove pub
|
||||
#[derive(Clone, PartialEq, PartialOrd, Ord, Eq, Hash)]
|
||||
pub struct Term(Vec<u8>);
|
||||
|
||||
|
||||
impl Term {
|
||||
|
||||
/// Pre-allocate a term buffer.
|
||||
@@ -63,6 +65,14 @@ impl Term {
|
||||
Term(buffer)
|
||||
}
|
||||
|
||||
/// Returns the serialized value associated to the field.
|
||||
/// If the term is a string, its value is utf-8 encoded.
|
||||
/// If the term is a u32, its value is encoded according
|
||||
/// to `byteorder::LittleEndian`.
|
||||
pub fn value(&self) -> &[u8] {
|
||||
&self.0[1..]
|
||||
}
|
||||
|
||||
/// Set the texts only, keeping the field untouched.
|
||||
pub fn set_text(&mut self, text: &str) {
|
||||
self.0.resize(1, 0u8);
|
||||
|
||||
Reference in New Issue
Block a user