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


Python _TextSource.read方法代码示例

本文整理汇总了Python中apache_beam.io.textio._TextSource.read方法的典型用法代码示例。如果您正苦于以下问题:Python _TextSource.read方法的具体用法?Python _TextSource.read怎么用?Python _TextSource.read使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在apache_beam.io.textio._TextSource的用法示例。


在下文中一共展示了_TextSource.read方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_read_single_file_without_striping_eol_crlf

# 需要导入模块: from apache_beam.io.textio import _TextSource [as 别名]
# 或者: from apache_beam.io.textio._TextSource import read [as 别名]
  def test_read_single_file_without_striping_eol_crlf(self):
    file_name, written_data = write_data(TextSourceTest.DEFAULT_NUM_RECORDS,
                                         eol=EOL.CRLF)
    assert len(written_data) == TextSourceTest.DEFAULT_NUM_RECORDS
    source = TextSource(file_name, 0, CompressionTypes.UNCOMPRESSED,
                        False, coders.StrUtf8Coder())

    range_tracker = source.get_range_tracker(None, None)
    read_data = list(source.read(range_tracker))
    self.assertCountEqual([line + '\r\n' for line in written_data], read_data)
开发者ID:dpmills,项目名称:incubator-beam,代码行数:12,代码来源:textio_test.py

示例2: _run_read_test

# 需要导入模块: from apache_beam.io.textio import _TextSource [as 别名]
# 或者: from apache_beam.io.textio._TextSource import read [as 别名]
 def _run_read_test(self, file_or_pattern, expected_data,
                    buffer_size=DEFAULT_NUM_RECORDS,
                    compression=CompressionTypes.UNCOMPRESSED):
   # Since each record usually takes more than 1 byte, default buffer size is
   # smaller than the total size of the file. This is done to
   # increase test coverage for cases that hit the buffer boundary.
   source = TextSource(file_or_pattern, 0, compression,
                       True, coders.StrUtf8Coder(), buffer_size)
   range_tracker = source.get_range_tracker(None, None)
   read_data = list(source.read(range_tracker))
   self.assertCountEqual(expected_data, read_data)
开发者ID:dpmills,项目名称:incubator-beam,代码行数:13,代码来源:textio_test.py

示例3: _read_skip_header_lines

# 需要导入模块: from apache_beam.io.textio import _TextSource [as 别名]
# 或者: from apache_beam.io.textio._TextSource import read [as 别名]
  def _read_skip_header_lines(self, file_or_pattern, skip_header_lines):
    """Simple wrapper function for instantiating TextSource."""
    source = TextSource(
        file_or_pattern,
        0,
        CompressionTypes.UNCOMPRESSED,
        True,
        coders.StrUtf8Coder(),
        skip_header_lines=skip_header_lines)

    range_tracker = source.get_range_tracker(None, None)
    return list(source.read(range_tracker))
开发者ID:dpmills,项目名称:incubator-beam,代码行数:14,代码来源:textio_test.py


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