Example #1
0
    def approximate_size(self, ranges):
        ''' Given a collection of ranges, return the approximate
        size of the database between those ranges.

        :param ranges: dictionary or list of tuple ranges
        :returns: The size of the database between those ranges
        '''
        if isinstance(ranges, dict):
            ranges = ranges.items()

        collection = RangeCollection.create(ranges)
        LDB.leveldb_approximate_sizes(self.database, collection.count,
            collection.start_keys, collection.start_sizes,
            collection.end_keys, collection.end_sizes, collection.sizes)
        return list(collection.sizes)