Skip to main content

Index

Struct Index 

Source
pub struct Index { /* private fields */ }

Implementations§

Source§

impl Index

Source

pub fn new( paths: List<u64>, children: VariableList<u16>, leaves: VariableList<u16>, values: VariableList<u16>, words: VariableList<u8>, map_keys: VariableList<u16>, map_vals: VariableList<u16>, args_keys: VariableList<u16>, args_vals: VariableList<u16>, ) -> Self

Source

pub fn traverse(&self, path: &str) -> Box<[LeafRef]>

Traverse to the path node matching path (dot-separated keywords), then collect all leaf descendants into a flat list.

use context_engine::{Tree, Index, dsl::Dsl};
let tree = Tree::Mapping(alloc::vec![(b"id".to_vec(), Tree::Null)]);
let (paths, children, leaves, values, words, map_keys, map_vals, args_keys, args_vals) = Dsl::compile(&tree, &[]).unwrap();
let index = Index::new(paths, children, leaves, values, words, map_keys, map_vals, args_keys, args_vals);
assert_eq!(index.traverse("id").len(), 1);
assert!(index.traverse("missing").is_empty());
Source

pub fn keyword_of(&self, path_id: u16) -> &[u8]

Return the keyword bytes for a path node.

use context_engine::{Tree, Index, dsl::Dsl};
let tree = Tree::Mapping(alloc::vec![(b"name".to_vec(), Tree::Null)]);
let (paths, children, leaves, values, words, map_keys, map_vals, args_keys, args_vals) = Dsl::compile(&tree, &[]).unwrap();
let index = Index::new(paths, children, leaves, values, words, map_keys, map_vals, args_keys, args_vals);
assert_eq!(index.keyword_of(1), b"name");
Source

pub fn get_meta( &self, leaf: &LeafRef, ) -> (u8, &[u16], &[u16], &[u16], &[u16], &[u16])

Extract _get meta for the given leaf. Returns (store_id, key_frags, map_keys, map_vals, args_keys, args_vals). store_id=0 means no _get configured; all slices are empty in that case. key_frags: VALUE_IS_PLACEHOLDER_MASK-flagged u16 fragments (same encoding as leaf values). map_keys: dst path_id列, map_vals: src word_id列. args_keys: arg name word_id列, args_vals: arg value values_id列 (each indexes into values).

Source

pub fn set_meta( &self, leaf: &LeafRef, ) -> (u8, &[u16], &[u16], &[u16], &[u16], &[u16])

Extract _set meta for the given leaf. Same layout as get_meta.

Source

pub fn leaf_fragments(&self, leaf: &LeafRef) -> Vec<(bool, &[u8])>

Return the value fragments encoded in the leaf.

Each element is (is_placeholder, bytes):

  • false — static string literal
  • true${path} reference whose bytes are the path string

An empty slice means the leaf has no value (Null).

use context_engine::{Tree, Index, dsl::Dsl};
let tree = Tree::Mapping(alloc::vec![
    (b"driver".to_vec(), Tree::Scalar(b"postgres".to_vec())),
]);
let (paths, children, leaves, values, words, map_keys, map_vals, args_keys, args_vals) = Dsl::compile(&tree, &[]).unwrap();
let index = Index::new(paths, children, leaves, values, words, map_keys, map_vals, args_keys, args_vals);
let leaves = index.traverse("driver");
let frags = index.leaf_fragments(&leaves[0]);
assert_eq!(frags.len(), 1);
assert_eq!(frags[0].0, false);
assert_eq!(frags[0].1, b"postgres");
Source

pub fn path_id_of_keyword( &self, leaf_path_id: u16, keyword: &[u8], ) -> Option<u16>

leaf の path_id と同じ親を持つ sibling を keyword で探して path_id を返す。 map dst の cache_set 先を特定するために使う。

Source§

impl Index

Source

pub fn values_slice(&self, id: usize) -> Option<&[u16]>

Source

pub fn word_bytes(&self, id: usize) -> &[u8]

Auto Trait Implementations§

§

impl Freeze for Index

§

impl RefUnwindSafe for Index

§

impl Send for Index

§

impl Sync for Index

§

impl Unpin for Index

§

impl UnsafeUnpin for Index

§

impl UnwindSafe for Index

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.