本文整理匯總了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