Skip to main content

Module changelog

Module changelog 

Source
Expand description

§Changelog and Retraction Support

Z-set style changelog records with integer weights for incremental computation. This is the foundation for exactly-once sinks, cascading materialized views, and CDC connectors.

§Key Concepts

  • Z-sets: Elements have integer weights. Weight > 0 → insert, weight < 0 → delete.
  • Retraction: Emitting (-old, +new) pairs to correct previous results.
  • CDC Envelope: Debezium-compatible format for downstream systems.

§Ring Architecture

  • Ring 0: ChangelogRef and ChangelogBuffer for zero-allocation hot path
  • Ring 1: LateDataRetractionGenerator and CdcEnvelope serialization
  • Ring 2: Changelog configuration and CDC format selection

§Example

use laminar_core::operator::changelog::{
    ChangelogBuffer, ChangelogRef, RetractableCountAccumulator,
    RetractableAccumulator, CdcEnvelope, CdcSource,
};
use laminar_core::operator::window::CdcOperation;

// Ring 0: Zero-allocation changelog tracking
let mut buffer = ChangelogBuffer::with_capacity(1024);
buffer.push(ChangelogRef::insert(0, 0));
buffer.push(ChangelogRef::delete(0, 1));

// Ring 1: Retractable aggregation
let mut agg = RetractableCountAccumulator::default();
agg.add(());
agg.add(());
assert_eq!(agg.result(), 2);
agg.retract(&());
assert_eq!(agg.result(), 1);

// CDC envelope for sinks
let source = CdcSource::new("laminardb", "default", "orders");
let envelope = CdcEnvelope::insert(serde_json::json!({"id": 1}), source, 1000);

Structs§

ArchivedRetractableAvgAccumulator
An archived RetractableAvgAccumulator
ArchivedRetractableCountAccumulator
An archived RetractableCountAccumulator
ArchivedRetractableSumAccumulator
An archived RetractableSumAccumulator
CdcEnvelope
CDC envelope for sink serialization.
CdcSource
Source metadata for CDC envelope.
ChangelogBuffer
Ring 0 changelog buffer (pre-allocated, reused per epoch).
ChangelogRef
Zero-allocation changelog reference for Ring 0 hot path.
LateDataRetractionGenerator
Generates retractions for late data corrections.
RetractableAvgAccumulator
Retractable average accumulator.
RetractableAvgAccumulatorResolver
The resolver for an archived RetractableAvgAccumulator
RetractableCountAccumulator
Retractable count accumulator.
RetractableCountAccumulatorResolver
The resolver for an archived RetractableCountAccumulator
RetractableFirstValueAccumulator
Retractable FIRST_VALUE accumulator for changelog/retraction mode.
RetractableFirstValueF64Accumulator
Retractable FIRST_VALUE accumulator for f64 values.
RetractableLastValueAccumulator
Retractable LAST_VALUE accumulator for changelog/retraction mode.
RetractableLastValueF64Accumulator
Retractable LAST_VALUE accumulator for f64 values.
RetractableMaxAccumulator
Retractable max accumulator with counted value tracking.
RetractableMinAccumulator
Retractable min accumulator with counted value tracking.
RetractableSumAccumulator
Retractable sum accumulator.
RetractableSumAccumulatorResolver
The resolver for an archived RetractableSumAccumulator

Traits§

RetractableAccumulator
Extension trait for accumulators that support retractions.