Expire relations outside of a transaction #1168
-
The question here is if there is a way within ddlog to expire data (delete relations) outside of a "window" (e.g. We have some events being streamed. We alert on a simple detection. (This is cool, I love this.)
Next we have a more complex rule that relies on
My interest is in deleting
Thanks so much! |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
One way to do it would be to create a view on DependencyA which only has recent events and use that instead. |
Beta Was this translation helpful? Give feedback.
-
Yes, an output relation is a really a view. |
Beta Was this translation helpful? Give feedback.
-
This is working as I expect it to.
# AlertA fires
>> start;
>> insert EventA(0, 256);
>> commit dump_changes;
AlertA:
AlertA{.id = 0}: +1
MaxID:
MaxID{.event = "A", .max = 0}: +1
# AlertA drops
# DependencyA is created
# Max is updated
>> start;
>> insert EventA(1, 26);
>> commit dump_changes;
AlertA:
AlertA{.id = 0}: -1
DependencyA:
DependencyA{.id = 1, .value = 26}: +1
MaxID:
MaxID{.event = "A", .max = 0}: -1
MaxID{.event = "A", .max = 1}: +1
# No computation
>> start;
>> insert EventB(2, 100);
>> commit dump_changes;
# AlertAB fires
>> start;
>> insert EventB(3, 10);
>> commit dump_changes;
AlertAB:
AlertAB{.idA = 1, .idB = 3}: +1
# AlertAB drops
>> start;
>> insert EventA(4, 20);
>> commit dump_changes;
AlertAB:
AlertAB{.idA = 1, .idB = 3}: -1
MaxID:
MaxID{.event = "A", .max = 1}: -1
MaxID{.event = "A", .max = 4}: +1
# DependencyA drops
>> start;
>> insert EventA(14, 200);
>> commit dump_changes;
DependencyA:
DependencyA{.id = 1, .value = 26}: -1
MaxID:
MaxID{.event = "A", .max = 4}: -1
MaxID{.event = "A", .max = 14}: +1
# State looks good
>> dump;
AlertA:
AlertAB:
DependencyA:
MaxID:
MaxID{.event = "A", .max = 14} |
Beta Was this translation helpful? Give feedback.
One way to do it would be to create a view on DependencyA which only has recent events and use that instead.
But this may accumulate some garbage.
However, you can also use this view to tell you what to delete from the input relation: the negative changes in this view will be the keys that you have to delete.