/// Commit a transaction to storage, and advance the tip of the database.
///
/// Given the transaction, which contains the datoms to be committed, and
/// updated counters for entity id allocation, commit proceeds in three
/// stages:
///
/// * Persist large values that occur in new datoms, to the large value heap.
/// * Persist the new datoms themselves, to the index trees.
/// * Write the new head (tree roots and fresh id counters).
///
/// In case of an IO error, some data may have been persisted, but the
/// transaction will not be visible.
Commit a transaction to storage, and advance the tip of the database.
Given the transaction, which contains the datoms to be committed, and
updated counters for entity id allocation, commit proceeds in three
stages.

Persist large values that occur in new datoms, to the large value heap.
Persist the new datoms themselves, to the index trees.
Write the new head (tree roots and fresh id counters).

In case of an IO error, some data may have been persisted, but the
transaction will not be visible.
Commit a transaction to storage and advance the tip of the database . Given the transaction which contains the datoms to be committed and updated counters for entity id allocation commit proceeds in three stages . Persist large values that occur in new datoms to the large value heap . Persist the new datoms themselves to the index trees . Write the new head ( tree roots and fresh id counters ) . In case of an IO error some data may have been persisted but the transaction will not be visible .
pub fn commit(&mut self, temporaries: &Temporaries, transaction: Transaction) -> io::Result<()>
    where Store: store::StoreMut, Heap: heap::HeapMut {
        // TODO: Return error instead of panicking.
        assert_eq!(self.head, transaction.base, "Transaction was not based on current tip.");
        // First persist temporaries in the new datoms to the heap. This updates
        // the datoms in-place.
        let mut datoms = transaction.datoms;
        self.persist_temporaries(temporaries, &mut datoms)?;
        // Then insert the new datoms into the index trees. We get the new
        // roots to the trees that include the datoms we just inserted.
        let new_roots = self.insert(&transaction.base.roots, datoms)?;
        // Sanity check: the transaction base was the current head, so the
        // current roots must precede the new roots.
        assert!(self.head.roots.precedes(&new_roots), "Old index roots must precede new roots.");
        // TODO also check the id generator.
        // Also, possibly include a generation number to double check.
        self.head = Head {
            roots: new_roots,
            id_gen: transaction.id_gen,
        };
        // TODO: Have some abstraction for storing the head.
        Ok(())
    }
pub fn commit ( & mut self , temporaries : & Temporaries , transaction : Transaction ) -> io :: Result < ( ) > where Store : store :: StoreMut , Heap : heap :: HeapMut { // TODO: Return error instead of panicking. assert_eq ! ( self head transaction base " " ) ; // First persist temporaries in the new datoms to the heap. This updates // the datoms in-place. let mut datoms = transaction . datoms ; self . persist_temporaries ( temporaries , & mut datoms ) ? ; // Then insert the new datoms into the index trees. We get the new // roots to the trees that include the datoms we just inserted. let new_roots = self . insert ( & transaction . base . roots , datoms ) ? ; // Sanity check: the transaction base was the current head, so the // current roots must precede the new roots. assert ! ( self head roots precedes ( new_roots ) " " ) ; // TODO also check the id generator. // Also, possibly include a generation number to double check. self . head = Head { roots : new_roots , id_gen : transaction . id_gen , } ; // TODO: Have some abstraction for storing the head. Ok ( ( ) ) }
Commit a transaction to storage, and advance the tip of the database.
Commit a transaction to storage and advance the tip of the database .
&mut self
temporaries
&Temporaries
transaction
Transaction