/// Write a new index to the store that contains the given datoms.
///
/// The datoms need not be sorted, so the same slice can be used to
/// construct multiple trees with different orderings. Large values
/// do need to be stored on the heap already though.
Write a new index to the store that contains the given datoms.
The datoms need not be sorted, so the same slice can be used to
construct multiple trees with different orderings. Large values
do need to be stored on the heap already though.
Write a new index to the store that contains the given datoms . The datoms need not be sorted so the same slice can be used to construct multiple trees with different orderings . Large values do need to be stored on the heap already though .
pub fn initialize(
        comparator: Cmp,
        store: Store,
        heap: Heap,
        datoms: &[Datom]
    ) -> io::Result<HTree<Cmp, Store, Heap>>
    where Store: store::StoreMut
    {
        let mut node = VecNode::from_slice(datoms);
        // TODO: Debug-assert that large values are on the heap.
        // Inserting datoms into the tree requires that they are sorted. Now
        // that we made a copy of the datoms slice anyway, we can sort it in
        // place before we insert it.
        node.datoms.sort_by(|x, y| comparator.cmp(x, y, &heap));
        let mut tree = HTree {
            root_page: PageId::max(), // Will be overwritten immediately.
            comparator: comparator,
            store: store,
            heap: heap,
        };
        tree.root_page = tree.write_root(node)?;
        Ok(tree)
    }
pub fn initialize ( comparator : Cmp , store : Store , heap : Heap , datoms : & [ Datom ] ) -> io :: Result < HTree < Cmp , Store , Heap > > where Store : store :: StoreMut { let mut node = VecNode :: from_slice ( datoms ) ; // TODO: Debug-assert that large values are on the heap. // Inserting datoms into the tree requires that they are sorted. Now // that we made a copy of the datoms slice anyway, we can sort it in // place before we insert it. node . datoms . sort_by ( | x , y | comparator . cmp ( x , y , & heap ) ) ; let mut tree = HTree { root_page : PageId :: max ( ) , // Will be overwritten immediately. comparator : comparator , store : store , heap : heap , } ; tree . root_page = tree . write_root ( node ) ? ; Ok ( tree ) }
Write a new index to the store that contains the given datoms.
Write a new index to the store that contains the given datoms .
comparator
Cmp
store
Store
heap
Heap
datoms
&[Datom]