Esempio n. 1
0
    def get_range_tracker(self, start_position, stop_position):
        if start_position is None:
            start_position = 0
        if stop_position is None:
            stop_position = self._count

        return OffsetRangeTracker(start_position, stop_position)
Esempio n. 2
0
    def get_range_tracker(
        self,
        start_position: Union[int, str, ObjectId] = None,
        stop_position: Union[int, str, ObjectId] = None,
    ) -> Union[_ObjectIdRangeTracker, OffsetRangeTracker,
               LexicographicKeyRangeTracker]:
        """Returns a RangeTracker for a given position range depending on type.

    Args:
      start_position: starting position of the range. If 'None' default start
                      position of the source must be used.
      stop_position:  ending position of the range. If 'None' default stop
                      position of the source must be used.
    Returns:
      a ``_ObjectIdRangeTracker``, ``OffsetRangeTracker``
      or ``LexicographicKeyRangeTracker`` depending on the given position range.
    """
        start_position, stop_position = self._replace_none_positions(
            start_position, stop_position)

        if isinstance(start_position, ObjectId):
            return _ObjectIdRangeTracker(start_position, stop_position)

        if isinstance(start_position, int):
            return OffsetRangeTracker(start_position, stop_position)

        if isinstance(start_position, str):
            return LexicographicKeyRangeTracker(start_position, stop_position)

        raise NotImplementedError(
            f"RangeTracker for {type(start_position)} not implemented!")
Esempio n. 3
0
    def get_range_tracker(self, start_position, stop_position):
        if start_position is None:
            start_position = 0
        if stop_position is None:
            stop_position = OffsetRangeTracker.OFFSET_INFINITY

        return UnsplittableRangeTracker(
            OffsetRangeTracker(start_position, stop_position))
    def get_range_tracker(self, start_position, stop_position):
        self._populate_sources_lazily()
        if start_position is None:
            start_position = 0
        if stop_position is None:
            stop_position = len(self._sources)

        return OffsetRangeTracker(start_position, stop_position)
Esempio n. 5
0
 def setUp(self):
     self.initial_start_pos = 0
     self.initial_stop_pos = 4
     self.range_tracker = OffsetRangeTracker(self.initial_start_pos,
                                             self.initial_stop_pos)
     self.sdf_restriction_tracker = (iobase._SDFBoundedSourceWrapper.
                                     _SDFBoundedSourceRestrictionTracker(
                                         self.range_tracker))
 def get_range_tracker(self, start_position, stop_position):
     logger.info('get tracker start')
     if start_position is None:
         start_position = 0
     if stop_position is None:
         stop_position = self._count
     logger.info('get tracker end')
     return OffsetRangeTracker(start_position, stop_position)
Esempio n. 7
0
    def get_range_tracker(self, start_position, stop_position):
        if start_position is None:
            start_position = self._start_offset
        if stop_position is None:
            # If file is unsplittable we choose OFFSET_INFINITY as the default end
            # offset so that all data of the source gets read. Choosing size of the
            # file as end offset will be wrong for certain unsplittable source, for
            # e.g., compressed sources.
            stop_position = (self._stop_offset if self._splittable else
                             OffsetRangeTracker.OFFSET_INFINITY)

        range_tracker = OffsetRangeTracker(start_position, stop_position)
        if not self._splittable:
            range_tracker = UnsplittableRangeTracker(range_tracker)

        return range_tracker
Esempio n. 8
0
 def new_tracker(self):
     return OffsetRangeTracker(self.start, self.stop)