pub trait TrieArray {
fn build(token_ids: Vec<usize>, pointers: Vec<usize>) -> Box<Self>;
fn serialize_into<W: Write>(&self, writer: W) -> Result<usize>;
fn deserialize_from<R: Read>(reader: R) -> Result<Box<Self>>;
fn size_in_bytes(&self) -> usize;
fn memory_statistics(&self) -> Value;
fn token_id(&self, i: usize) -> usize;
fn range(&self, pos: usize) -> (usize, usize);
fn find_token(&self, pos: usize, id: usize) -> Option<usize>;
fn num_tokens(&self) -> usize;
fn num_pointers(&self) -> usize;
}
Expand description
Trait for a data structure for sorted arrays of each trie level.
Required methods
Builds a TrieArray
from sequences of token ids and pointers.
fn serialize_into<W: Write>(&self, writer: W) -> Result<usize>
fn serialize_into<W: Write>(&self, writer: W) -> Result<usize>
Serializes the data structure into the writer.
fn deserialize_from<R: Read>(reader: R) -> Result<Box<Self>>
fn deserialize_from<R: Read>(reader: R) -> Result<Box<Self>>
Deserializes the data structure from the reader.
fn size_in_bytes(&self) -> usize
fn size_in_bytes(&self) -> usize
Gets the number of bytes to serialize the data structure.
fn memory_statistics(&self) -> Value
fn memory_statistics(&self) -> Value
Gets breakdowns of memory usages for components.
Finds the position i
such that token_id(i) = id
and i in range(pos)
.
fn num_tokens(&self) -> usize
fn num_tokens(&self) -> usize
Gets the number of tokens stored.
fn num_pointers(&self) -> usize
fn num_pointers(&self) -> usize
Gets the number of pointers stored.