Current situation:
The CompositionSet currently accessed by the dispatcher and the multinode code via the implementation of IntoIterator trait.
Calling into_iter (or just using for _ in <CompositionSet>) will result in an iterator with the item type usize, usize, Arc<Context>, which represent the set index, item index and the context from which to get the item.
The reason for this, is that the indices are need for the contexts transfer function.
Currently the composition set holds on to a set index, as well as a vector of tuples containing keys, item indices and the context references.
Possible change:
Simplify processing by converting the content of the Context into the CompositionSet.
By this I mean, take the Contexts content vector and allow the CompositonSet to directly own the item vector.
For each item we store it as a tuple with a Arc<Context> as we do now.
This simplifies the iterator, as it can simply iterate over the item context tuples, allowing easy access, with less unwraps etc.
We can store a Arc<Context> with each item, so we can still merge CompositionSets from different contexts, and we can still sort by item key, preserving all the Sharding iterators etc.
Possible follow up:
Since we would have each item hold the context only to access a specific range of it's context, we could think about partial release of contexts.
By this I mean, that when we convert a context into it's composition sets, free the parts of the context not owned by any of the items, and free space used by items, as they are dropped individually.
Current situation:
The
CompositionSetcurrently accessed by the dispatcher and the multinode code via the implementation ofIntoIteratortrait.Calling
into_iter(or just usingfor _ in <CompositionSet>) will result in an iterator with the item typeusize, usize, Arc<Context>, which represent the set index, item index and the context from which to get the item.The reason for this, is that the indices are need for the contexts transfer function.
Currently the composition set holds on to a set index, as well as a vector of tuples containing keys, item indices and the context references.
Possible change:
Simplify processing by converting the content of the
Contextinto theCompositionSet.By this I mean, take the
Contexts content vector and allow theCompositonSetto directly own the item vector.For each item we store it as a tuple with a
Arc<Context>as we do now.This simplifies the iterator, as it can simply iterate over the item context tuples, allowing easy access, with less unwraps etc.
We can store a
Arc<Context>with each item, so we can still mergeCompositionSets from different contexts, and we can still sort by item key, preserving all the Sharding iterators etc.Possible follow up:
Since we would have each item hold the context only to access a specific range of it's context, we could think about partial release of contexts.
By this I mean, that when we convert a context into it's composition sets, free the parts of the context not owned by any of the items, and free space used by items, as they are dropped individually.