TimelyDataflow / differential-dataflow

An implementation of differential dataflow using timely dataflow on Rust.
MIT License
2.53k stars 182 forks source link

Canonicalize `PointStamp` representation #458

Closed frankmcsherry closed 6 months ago

frankmcsherry commented 6 months ago

PointStamp represents an infinite vector of T elements, extending a maintained vector with T::minimum(). This allows multiple representations of the same vector when the vector is allowed to end with T::minimum(), which was documented as acceptable. However, it does mean that e.g. the derived Eq implementation, among others, would report two logically identical pointstamps as different, and imo the position that there can be multiple unequal representations of the same state is untenable.

This PR removes that ability, short of direct manipulation by users, through an enforce method that is called by a constructor, and use of that constructor whenever we mint new PointStamps. Demonstration uses that manipulate vector directly are followed by enforce calls.

We could go further and make the field private, and prevent direct manipulation and require clones (or at least into_vec and from_vec patterns). That might increase confidence even further.

cc: @antiguru