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


Python ThriftRecordReader.read方法代码示例

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


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

示例1: test_thrift_garbage

# 需要导入模块: from twitter.common.recordio import ThriftRecordReader [as 别名]
# 或者: from twitter.common.recordio.ThriftRecordReader import read [as 别名]
def test_thrift_garbage():
  with EphemeralFile('w') as fp:
    fn = fp.name

    fp.write(struct.pack('>L', 2))
    fp.write('ab')
    fp.close()

    with open(fn) as fpr:
      rr = ThriftRecordReader(fpr, StringType)
      with pytest.raises(RecordIO.PrematureEndOfStream):
        rr.read()
开发者ID:DikangGu,项目名称:commons,代码行数:14,代码来源:thrift_recordio_test.py

示例2: wait_for_rc

# 需要导入模块: from twitter.common.recordio import ThriftRecordReader [as 别名]
# 或者: from twitter.common.recordio.ThriftRecordReader import read [as 别名]
def wait_for_rc(checkpoint, timeout=5.0):
  start = time.time()
  trr = ThriftRecordReader(open(checkpoint), RunnerCkpt)
  while time.time() < start + timeout:
    record = trr.read()
    if record and record.process_status and record.process_status.return_code is not None:
      return record.process_status.return_code
    else:
      time.sleep(0.1)
开发者ID:MustafaOrkunAcar,项目名称:incubator-aurora,代码行数:11,代码来源:test_process.py

示例3: test_basic_thriftrecordwriter_write

# 需要导入模块: from twitter.common.recordio import ThriftRecordReader [as 别名]
# 或者: from twitter.common.recordio.ThriftRecordReader import read [as 别名]
def test_basic_thriftrecordwriter_write():
  test_string = StringType("hello world")

  with EphemeralFile('w') as fp:
    fn = fp.name

    rw = ThriftRecordWriter(fp)
    rw.write(test_string)
    rw.close()

    with open(fn) as fpr:
      rr = ThriftRecordReader(fpr, StringType)
      assert rr.read() == test_string
开发者ID:DikangGu,项目名称:commons,代码行数:15,代码来源:thrift_recordio_test.py

示例4: test_thrift_recordwriter_type_mismatch

# 需要导入模块: from twitter.common.recordio import ThriftRecordReader [as 别名]
# 或者: from twitter.common.recordio.ThriftRecordReader import read [as 别名]
def test_thrift_recordwriter_type_mismatch():
  test_string = StringType("hello world")
  with EphemeralFile('w') as fp:
    fn = fp.name

    rw = ThriftRecordWriter(fp)
    rw.write(test_string)
    rw.close()

    with open(fn) as fpr:
      rr = ThriftRecordReader(fpr, IntType)
      # This is a peculiar behavior of Thrift in that it just returns
      # ThriftType() with no serialization applied
      assert rr.read() == IntType()
开发者ID:DikangGu,项目名称:commons,代码行数:16,代码来源:thrift_recordio_test.py

示例5: test_paranoid_thrift_append_framing

# 需要导入模块: from twitter.common.recordio import ThriftRecordReader [as 别名]
# 或者: from twitter.common.recordio.ThriftRecordReader import read [as 别名]
def test_paranoid_thrift_append_framing():
  test_string_1 = StringType("hello world")
  test_string_2 = StringType("ahoy ahoy, bonjour")

  with EphemeralFile('w') as fp:
    fn = fp.name

    ThriftRecordWriter.append(fn, test_string_1)
    ThriftRecordWriter.append(fn, test_string_2)

    with open(fn) as fpr:
      rr = ThriftRecordReader(fpr, StringType)
      assert rr.read() == test_string_1
      assert rr.read() == test_string_2
开发者ID:DikangGu,项目名称:commons,代码行数:16,代码来源:thrift_recordio_test.py

示例6: test_thriftrecordwriter_framing

# 需要导入模块: from twitter.common.recordio import ThriftRecordReader [as 别名]
# 或者: from twitter.common.recordio.ThriftRecordReader import read [as 别名]
def test_thriftrecordwriter_framing():
  test_string_1 = StringType("hello world")
  test_string_2 = StringType("ahoy ahoy, bonjour")

  with EphemeralFile('w') as fp:
    fn = fp.name

    rw = ThriftRecordWriter(fp)
    rw.write(test_string_1)
    rw.close()

    with open(fn, 'a') as fpa:
      rw = ThriftRecordWriter(fpa)
      rw.write(test_string_2)

    with open(fn) as fpr:
      rr = ThriftRecordReader(fpr, StringType)
      assert rr.read() == test_string_1
      assert rr.read() == test_string_2
开发者ID:DikangGu,项目名称:commons,代码行数:21,代码来源:thrift_recordio_test.py


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