pub struct Ackr { /* private fields */ }Expand description
Track tuple acks across multiple tasks with minimal memory requirements. The algorithm is from the stream-processing system Storm.
The only allocation needed is two 64-bit values per task (task_id, ack value) and scales to 2^64 tuples.
To track a tuple, you call tuple. The tuple’s id will be XORed with the previous
ack value. As tuples are acked (marked as arbitrarily completed), the ack value will
once again be XORed. Once all tuples are acked/completed, the ack value will be 0.
Implementations§
Source§impl Ackr
impl Ackr
Sourcepub fn insert(&mut self, source_id: Source, task_id: Task)
pub fn insert(&mut self, source_id: Source, task_id: Task)
Insert a new bucket entry with the Source id as the initial ack value.
Sourcepub fn add_tuple(&mut self, source_id: Source, tuple_id: Tuple)
pub fn add_tuple(&mut self, source_id: Source, tuple_id: Tuple)
Add a tuple to the Source’s ack value. This is essentially just the first XOR.
Sourcepub fn ack(&mut self, source_id: Source, tuple_id: Tuple) -> Option<()>
pub fn ack(&mut self, source_id: Source, tuple_id: Tuple) -> Option<()>
XOR the ack value for a given Source and the result is the new ack value. Acking once adds the tuple to the Source, acking it twice removes it.