本文整理匯總了Python中apache_beam.io.filebasedsource._SingleFileSource.split方法的典型用法代碼示例。如果您正苦於以下問題:Python _SingleFileSource.split方法的具體用法?Python _SingleFileSource.split怎麽用?Python _SingleFileSource.split使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類apache_beam.io.filebasedsource._SingleFileSource
的用法示例。
在下文中一共展示了_SingleFileSource.split方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_produces_splits_desiredsize_large_than_size
# 需要導入模塊: from apache_beam.io.filebasedsource import _SingleFileSource [as 別名]
# 或者: from apache_beam.io.filebasedsource._SingleFileSource import split [as 別名]
def test_produces_splits_desiredsize_large_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=100)]
self.assertEquals(1, len(splits))
self.assertEquals(60, splits[0].weight)
self.assertEquals(0, splits[0].start_position)
self.assertEquals(60, splits[0].stop_position)
range_tracker = splits[0].source.get_range_tracker(None, None)
read_data = [value for value in splits[0].source.read(range_tracker)]
self.assertCountEqual(expected_data, read_data)
示例2: test_produces_splits_desiredsize_smaller_than_size
# 需要導入模塊: from apache_beam.io.filebasedsource import _SingleFileSource [as 別名]
# 或者: from apache_beam.io.filebasedsource._SingleFileSource import split [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)
示例3: test_produce_split_with_start_and_end_positions
# 需要導入模塊: from apache_beam.io.filebasedsource import _SingleFileSource [as 別名]
# 或者: from apache_beam.io.filebasedsource._SingleFileSource import split [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)