当前位置: 首页>>代码示例>>Python>>正文


Python _SingleFileSource.get_range_tracker方法代码示例

本文整理汇总了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)
开发者ID:eralmas7,项目名称:beam,代码行数:12,代码来源:filebasedsource_test.py

示例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)
开发者ID:ocadotechnology,项目名称:incubator-beam,代码行数:12,代码来源:filebasedsource_test.py

示例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)
开发者ID:eralmas7,项目名称:beam,代码行数:19,代码来源:filebasedsource_test.py

示例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)
开发者ID:ocadotechnology,项目名称:incubator-beam,代码行数:21,代码来源:filebasedsource_test.py


注:本文中的apache_beam.io.filebasedsource._SingleFileSource.get_range_tracker方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。