コード例 #1
0
    def __init__(self, iterable=(), key=None):
        """ constructor, sets key of SortedCollection to chunk.range, then call superclass' __init__. """
        key = lambda chunk: chunk.range
        SortedCollection.__init__(self, iterable=iterable, key=key)

        self.time = None
        self.applied_change = None
コード例 #2
0
    def build_full_history(self, namespace):
        """ Builds an initial ChunkDistribution from the config.chunks collection, then walks
            the changelog backwards and creates a new ChunkDistribution for each step (either 
            a split or a move). All these ChunkDistributions are inserted into a SortedCollection
            and returned.
        """

        history = SortedCollection(key=lambda dist: dist.time)

        for chunk_dist in self.walk_distributions(namespace):
            history.insert(chunk_dist)

        return history