Пример #1
0
    def test_cloud_position_to_reader_position_byte_offset(self):
        cloud_position = dataflow.Position()
        cloud_position.byteOffset = 9999

        reader_position = apiclient.cloud_position_to_reader_position(
            cloud_position)
        self.assertIsNotNone(reader_position)
        self.assertIsInstance(reader_position, iobase.ReaderPosition)
        self.assertEqual(9999, reader_position.byte_offset)
Пример #2
0
    def test_cloud_progress_to_reader_progress_index_position(self):
        cloud_progress = dataflow.ApproximateProgress()
        cloud_progress.position = dataflow.Position()
        cloud_progress.position.byteOffset = 9999

        reader_progress = apiclient.cloud_progress_to_reader_progress(
            cloud_progress)
        self.assertIsNotNone(reader_progress.position)
        self.assertIsInstance(reader_progress.position, iobase.ReaderPosition)
        self.assertEqual(9999, reader_progress.position.byte_offset)
Пример #3
0
def reader_position_to_cloud_position(reader_position):
    """Converts a given 'ReaderPosition' to corresponding cloud format."""

    cloud_position = dataflow.Position()
    if reader_position.end is not None:
        cloud_position.end = reader_position.end
    if reader_position.key is not None:
        cloud_position.key = reader_position.key
    if reader_position.byte_offset is not None:
        cloud_position.byteOffset = reader_position.byte_offset
    if reader_position.record_index is not None:
        cloud_position.recordIndex = reader_position.record_index
    if reader_position.shuffle_position is not None:
        cloud_position.shufflePosition = reader_position.shuffle_position
    if reader_position.concat_position is not None:
        concat_position = dataflow.ConcatPosition()
        concat_position.index = reader_position.concat_position.index
        concat_position.position = reader_position_to_cloud_position(
            reader_position.concat_position.position)
        cloud_position.concatPosition = concat_position

    return cloud_position