當前位置: 首頁>>代碼示例>>Python>>正文


Python ThriftRecordWriter.write方法代碼示例

本文整理匯總了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
開發者ID:DikangGu,項目名稱:commons,代碼行數:15,代碼來源:thrift_recordio_test.py

示例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()
開發者ID:DikangGu,項目名稱:commons,代碼行數:16,代碼來源:thrift_recordio_test.py

示例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]
開發者ID:DikangGu,項目名稱:commons,代碼行數:20,代碼來源:thrift_recordio_test.py

示例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
開發者ID:DikangGu,項目名稱:commons,代碼行數:21,代碼來源:thrift_recordio_test.py


注:本文中的twitter.common.recordio.ThriftRecordWriter.write方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。