Skip to main content

JournalEntry

Struct JournalEntry 

Source
pub struct JournalEntry {
    pub id: ContentId,
    pub sequence: u64,
    pub previous: Option<ContentId>,
    pub kind: Symbol,
    pub payloads: Vec<ContentId>,
}
Expand description

One immutable journal fact whose identity is the canonical semantic Datum.

Fields§

§id: ContentId§sequence: u64§previous: Option<ContentId>§kind: Symbol§payloads: Vec<ContentId>

Implementations§

Source§

impl JournalEntry

Source

pub fn new( sequence: u64, previous: Option<ContentId>, kind: Symbol, payloads: Vec<ContentId>, ) -> Self

Constructs a canonical journal/entry-v2 value.

Examples found in repository?
examples/cold_replay.rs (lines 15-20)
6fn main() -> ExitCode {
7    let records = std::env::args()
8        .nth(1)
9        .and_then(|value| value.parse::<u64>().ok())
10        .unwrap_or(100_000);
11    let mut state = StoredState::default();
12    let mut previous = None;
13    for sequence in 0..records {
14        let object = JournalObject::from_bytes(sequence.to_be_bytes());
15        let entry = JournalEntry::new(
16            sequence,
17            previous.clone(),
18            Symbol::qualified("benchmark", "cold-replay-record"),
19            vec![object.id.clone()],
20        );
21        let datum = object.datum().clone();
22        state.objects.insert(object.id.clone(), object.bytes);
23        state.datums.insert(object.id, datum);
24        previous = Some(entry.id.clone());
25        state.entries.insert(sequence, entry);
26    }
27    state.head = state
28        .entries
29        .last_key_value()
30        .map(|(_, entry)| JournalHead {
31            sequence: entry.sequence,
32            entry: entry.id.clone(),
33        });
34
35    // Rebuild the maps to discard construction locality before timing the
36    // complete verification and reducer-facing replay materialization.
37    state.objects = BTreeMap::from_iter(state.objects);
38    state.datums = BTreeMap::from_iter(state.datums);
39    state.entries = BTreeMap::from_iter(state.entries);
40    let started = Instant::now();
41    let replayed = match replay(state) {
42        Ok(replay) => replay.count(),
43        Err(error) => {
44            eprintln!("cold replay failed: {error}");
45            return ExitCode::FAILURE;
46        }
47    };
48    let elapsed = started.elapsed();
49    if replayed != records as usize {
50        eprintln!("cold replay count mismatch: expected {records}, observed {replayed}");
51        return ExitCode::FAILURE;
52    }
53    println!(
54        "records={records} elapsed_ns={} elapsed_ms={:.3}",
55        elapsed.as_nanos(),
56        elapsed.as_secs_f64() * 1_000.0
57    );
58    ExitCode::SUCCESS
59}
Source

pub fn canonical_datum(&self) -> Datum

Returns the exact semantic value whose content id is this entry’s id.

Trait Implementations§

Source§

impl Clone for JournalEntry

Source§

fn clone(&self) -> JournalEntry

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for JournalEntry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for JournalEntry

Source§

impl PartialEq for JournalEntry

Source§

fn eq(&self, other: &JournalEntry) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for JournalEntry

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.