本文整理汇总了Python中twitter.common.recordio.ThriftRecordWriter.write方法的典型用法代码示例。如果您正苦于以下问题:Python ThriftRecordWriter.write方法的具体用法?Python ThriftRecordWriter.write怎么用?Python ThriftRecordWriter.write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类twitter.common.recordio.ThriftRecordWriter
的用法示例。
在下文中一共展示了ThriftRecordWriter.write方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_basic_thriftrecordwriter_write
# 需要导入模块: from twitter.common.recordio import ThriftRecordWriter [as 别名]
# 或者: from twitter.common.recordio.ThriftRecordWriter import write [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
示例2: test_thrift_recordwriter_type_mismatch
# 需要导入模块: from twitter.common.recordio import ThriftRecordWriter [as 别名]
# 或者: from twitter.common.recordio.ThriftRecordWriter import write [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()
示例3: test_thriftrecordreader_iteration
# 需要导入模块: from twitter.common.recordio import ThriftRecordWriter [as 别名]
# 或者: from twitter.common.recordio.ThriftRecordWriter import write [as 别名]
def test_thriftrecordreader_iteration():
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.write(test_string_2)
rw.close()
with open(fn) as fpr:
rr = ThriftRecordReader(fpr, StringType)
records = []
for record in rr:
records.append(record)
assert records == [test_string_1, test_string_2]
示例4: test_thriftrecordwriter_framing
# 需要导入模块: from twitter.common.recordio import ThriftRecordWriter [as 别名]
# 或者: from twitter.common.recordio.ThriftRecordWriter import write [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