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:
ChangelogRefandChangelogBufferfor zero-allocation hot path - Ring 1:
LateDataRetractionGeneratorandCdcEnvelopeserialization - 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§
- Archived
Retractable AvgAccumulator - An archived
RetractableAvgAccumulator - Archived
Retractable Count Accumulator - An archived
RetractableCountAccumulator - Archived
Retractable SumAccumulator - An archived
RetractableSumAccumulator - CdcEnvelope
- CDC envelope for sink serialization.
- CdcSource
- Source metadata for CDC envelope.
- Changelog
Buffer - Ring 0 changelog buffer (pre-allocated, reused per epoch).
- Changelog
Ref - Zero-allocation changelog reference for Ring 0 hot path.
- Late
Data Retraction Generator - Generates retractions for late data corrections.
- Retractable
AvgAccumulator - Retractable average accumulator.
- Retractable
AvgAccumulator Resolver - The resolver for an archived
RetractableAvgAccumulator - Retractable
Count Accumulator - Retractable count accumulator.
- Retractable
Count Accumulator Resolver - The resolver for an archived
RetractableCountAccumulator - Retractable
First Value Accumulator - Retractable
FIRST_VALUEaccumulator for changelog/retraction mode. - Retractable
First Value F64Accumulator - Retractable
FIRST_VALUEaccumulator for f64 values. - Retractable
Last Value Accumulator - Retractable
LAST_VALUEaccumulator for changelog/retraction mode. - Retractable
Last Value F64Accumulator - Retractable
LAST_VALUEaccumulator for f64 values. - Retractable
MaxAccumulator - Retractable max accumulator with counted value tracking.
- Retractable
MinAccumulator - Retractable min accumulator with counted value tracking.
- Retractable
SumAccumulator - Retractable sum accumulator.
- Retractable
SumAccumulator Resolver - The resolver for an archived
RetractableSumAccumulator
Traits§
- Retractable
Accumulator - Extension trait for accumulators that support retractions.