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
impl JournalEntry
Sourcepub fn new(
sequence: u64,
previous: Option<ContentId>,
kind: Symbol,
payloads: Vec<ContentId>,
) -> Self
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}Sourcepub fn canonical_datum(&self) -> Datum
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
impl Clone for JournalEntry
Source§fn clone(&self) -> JournalEntry
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)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for JournalEntry
impl Debug for JournalEntry
impl Eq for JournalEntry
Source§impl PartialEq for JournalEntry
impl PartialEq for JournalEntry
impl StructuralPartialEq for JournalEntry
Auto Trait Implementations§
impl Freeze for JournalEntry
impl RefUnwindSafe for JournalEntry
impl Send for JournalEntry
impl Sync for JournalEntry
impl Unpin for JournalEntry
impl UnsafeUnpin for JournalEntry
impl UnwindSafe for JournalEntry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more