本文整理汇总了Python中apache_beam.io.filebasedsource._SingleFileSource.get_range_tracker方法的典型用法代码示例。如果您正苦于以下问题:Python _SingleFileSource.get_range_tracker方法的具体用法?Python _SingleFileSource.get_range_tracker怎么用?Python _SingleFileSource.get_range_tracker使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类apache_beam.io.filebasedsource._SingleFileSource
的用法示例。
在下文中一共展示了_SingleFileSource.get_range_tracker方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_read_range_at_middle
# 需要导入模块: from apache_beam.io.filebasedsource import _SingleFileSource [as 别名]
# 或者: from apache_beam.io.filebasedsource._SingleFileSource import get_range_tracker [as 别名]
def test_read_range_at_middle(self):
fbs = LineSource('dummy_pattern', validate=False)
file_name, expected_data = write_data(10)
assert len(expected_data) == 10
source = SingleFileSource(fbs, file_name, 0, 10 * 6)
range_tracker = source.get_range_tracker(20, 40)
read_data = [value for value in source.read(range_tracker)]
self.assertCountEqual(expected_data[4:7], read_data)
示例2: test_read_range_at_beginning
# 需要导入模块: from apache_beam.io.filebasedsource import _SingleFileSource [as 别名]
# 或者: from apache_beam.io.filebasedsource._SingleFileSource import get_range_tracker [as 别名]
def test_read_range_at_beginning(self):
fbs = LineSource('dummy_pattern', validate=False)
file_name, expected_data = write_data(10)
assert len(expected_data) == 10
source = SingleFileSource(fbs, file_name, 0, 10 * 6)
range_tracker = source.get_range_tracker(0, 20)
read_data = [value for value in source.read(range_tracker)]
self.assertItemsEqual(expected_data[:4], read_data)
示例3: test_produces_splits_desiredsize_smaller_than_size
# 需要导入模块: from apache_beam.io.filebasedsource import _SingleFileSource [as 别名]
# 或者: from apache_beam.io.filebasedsource._SingleFileSource import get_range_tracker [as 别名]
def test_produces_splits_desiredsize_smaller_than_size(self):
fbs = LineSource('dummy_pattern', validate=False)
file_name, expected_data = write_data(10)
assert len(expected_data) == 10
source = SingleFileSource(fbs, file_name, 0, 10 * 6)
splits = [split for split in source.split(desired_bundle_size=25)]
self.assertEquals(3, len(splits))
read_data = []
for split in splits:
source = split.source
range_tracker = source.get_range_tracker(split.start_position,
split.stop_position)
data_from_split = [data for data in source.read(range_tracker)]
read_data.extend(data_from_split)
self.assertCountEqual(expected_data, read_data)
示例4: test_produce_split_with_start_and_end_positions
# 需要导入模块: from apache_beam.io.filebasedsource import _SingleFileSource [as 别名]
# 或者: from apache_beam.io.filebasedsource._SingleFileSource import get_range_tracker [as 别名]
def test_produce_split_with_start_and_end_positions(self):
fbs = LineSource('dummy_pattern', validate=False)
file_name, expected_data = write_data(10)
assert len(expected_data) == 10
source = SingleFileSource(fbs, file_name, 0, 10 * 6)
splits = [split for split in
source.split(desired_bundle_size=15, start_offset=10,
stop_offset=50)]
self.assertEquals(3, len(splits))
read_data = []
for split in splits:
source = split.source
range_tracker = source.get_range_tracker(split.start_position,
split.stop_position)
data_from_split = [data for data in source.read(range_tracker)]
read_data.extend(data_from_split)
self.assertItemsEqual(expected_data[2:9], read_data)