• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python fastproto.encode函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中thrift.protocol.fastproto.encode函数的典型用法代码示例。如果您正苦于以下问题:Python encode函数的具体用法?Python encode怎么用?Python encode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: write

 def write(self, oprot):
   if (isinstance(oprot, TBinaryProtocol.TBinaryProtocolAccelerated) or (isinstance(oprot, THeaderProtocol.THeaderProtocolAccelerate) and oprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_BINARY_PROTOCOL)) and self.thrift_spec is not None and fastproto is not None:
     oprot.trans.write(fastproto.encode(self, [self.__class__, self.thrift_spec, True], utf8strings=UTF8STRINGS, protoid=0))
     return
   if (isinstance(oprot, TCompactProtocol.TCompactProtocolAccelerated) or (isinstance(oprot, THeaderProtocol.THeaderProtocolAccelerate) and oprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_COMPACT_PROTOCOL)) and self.thrift_spec is not None and fastproto is not None:
     oprot.trans.write(fastproto.encode(self, [self.__class__, self.thrift_spec, True], utf8strings=UTF8STRINGS, protoid=2))
     return
   oprot.writeUnionBegin('union2')
   if self.field == 1:
     oprot.writeFieldBegin('i', TType.I32, 1)
     i = self.value
     oprot.writeI32(i)
     oprot.writeFieldEnd()
   if self.field == 2:
     oprot.writeFieldBegin('d', TType.DOUBLE, 2)
     d = self.value
     oprot.writeDouble(d)
     oprot.writeFieldEnd()
   if self.field == 3:
     oprot.writeFieldBegin('s', TType.STRUCT, 3)
     s = self.value
     s.write(oprot)
     oprot.writeFieldEnd()
   if self.field == 4:
     oprot.writeFieldBegin('u', TType.STRUCT, 4)
     u = self.value
     u.write(oprot)
     oprot.writeFieldEnd()
   oprot.writeFieldStop()
   oprot.writeUnionEnd()
开发者ID:facebook,项目名称:fbthrift,代码行数:30,代码来源:ttypes.py


示例2: write

 def write(self, oprot):
   if (isinstance(oprot, TBinaryProtocol.TBinaryProtocolAccelerated) or (isinstance(oprot, THeaderProtocol.THeaderProtocol) and oprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_BINARY_PROTOCOL)) and self.thrift_spec is not None and fastbinary is not None:
     oprot.trans.write(fastbinary.encode_binary(self, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS))
     return
   if (isinstance(oprot, TBinaryProtocol.TBinaryProtocolAccelerated) or (isinstance(oprot, THeaderProtocol.THeaderProtocol) and oprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_BINARY_PROTOCOL)) and self.thrift_spec is not None and fastproto is not None:
     oprot.trans.write(fastproto.encode(self, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=0))
     return
   if (isinstance(oprot, TCompactProtocol.TCompactProtocolAccelerated) or (isinstance(oprot, THeaderProtocol.THeaderProtocol) and oprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_COMPACT_PROTOCOL)) and self.thrift_spec is not None and fastproto is not None:
     oprot.trans.write(fastproto.encode(self, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=2))
     return
   oprot.writeStructBegin('Internship')
   if self.weeks != None:
     oprot.writeFieldBegin('weeks', TType.I32, 1)
     oprot.writeI32(self.weeks)
     oprot.writeFieldEnd()
   if self.title != None:
     oprot.writeFieldBegin('title', TType.STRING, 2)
     oprot.writeString(self.title.encode('utf-8')) if UTF8STRINGS and not isinstance(self.title, bytes) else oprot.writeString(self.title)
     oprot.writeFieldEnd()
   if self.employer != None:
     oprot.writeFieldBegin('employer', TType.I32, 3)
     oprot.writeI32(self.employer)
     oprot.writeFieldEnd()
   oprot.writeFieldStop()
   oprot.writeStructEnd()
开发者ID:nemith,项目名称:fbthrift,代码行数:25,代码来源:ttypes.py


示例3: write

 def write(self, oprot):
   if (isinstance(oprot, TBinaryProtocol.TBinaryProtocolAccelerated) or (isinstance(oprot, THeaderProtocol.THeaderProtocolAccelerate) and oprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_BINARY_PROTOCOL)) and self.thrift_spec is not None and fastproto is not None:
     oprot.trans.write(fastproto.encode(self, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=0))
     return
   if (isinstance(oprot, TCompactProtocol.TCompactProtocolAccelerated) or (isinstance(oprot, THeaderProtocol.THeaderProtocolAccelerate) and oprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_COMPACT_PROTOCOL)) and self.thrift_spec is not None and fastproto is not None:
     oprot.trans.write(fastproto.encode(self, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=2))
     return
   oprot.writeStructBegin('Foo')
   if self.mymap != None:
     oprot.writeFieldBegin('mymap', TType.MAP, 1)
     oprot.writeMapBegin(TType.STRING, TType.STRING, len(self.mymap))
     sorted18 = self.mymap.items()
     sorted18 = sorted(sorted18, key=lambda tuple19: tuple19[0])
     for kiter16,viter17 in sorted18:
       oprot.writeString(kiter16.encode('utf-8')) if UTF8STRINGS and not isinstance(kiter16, bytes) else oprot.writeString(kiter16)
       oprot.writeString(viter17.encode('utf-8')) if UTF8STRINGS and not isinstance(viter17, bytes) else oprot.writeString(viter17)
     oprot.writeMapEnd()
     oprot.writeFieldEnd()
   if self.myset != None:
     oprot.writeFieldBegin('myset', TType.SET, 2)
     oprot.writeSetBegin(TType.STRING, len(self.myset))
     for iter20 in sorted(self.myset):
       oprot.writeString(iter20.encode('utf-8')) if UTF8STRINGS and not isinstance(iter20, bytes) else oprot.writeString(iter20)
     oprot.writeSetEnd()
     oprot.writeFieldEnd()
   oprot.writeFieldStop()
   oprot.writeStructEnd()
开发者ID:facebook,项目名称:fbthrift,代码行数:27,代码来源:ttypes.py


示例4: write

 def write(self, oprot):
   if (isinstance(oprot, TBinaryProtocol.TBinaryProtocolAccelerated) or (isinstance(oprot, THeaderProtocol.THeaderProtocolAccelerate) and oprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_BINARY_PROTOCOL)) and self.thrift_spec is not None and fastproto is not None:
     oprot.trans.write(fastproto.encode(self, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=0))
     return
   if (isinstance(oprot, TCompactProtocol.TCompactProtocolAccelerated) or (isinstance(oprot, THeaderProtocol.THeaderProtocolAccelerate) and oprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_COMPACT_PROTOCOL)) and self.thrift_spec is not None and fastproto is not None:
     oprot.trans.write(fastproto.encode(self, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=2))
     return
   oprot.writeStructBegin('get500_result')
   if self.success != None:
     oprot.writeFieldBegin('success', TType.STRING, 0)
     oprot.writeString(self.success.encode('utf-8')) if UTF8STRINGS and not isinstance(self.success, bytes) else oprot.writeString(self.success)
     oprot.writeFieldEnd()
   if self.f != None:
     oprot.writeFieldBegin('f', TType.STRUCT, 1)
     self.f.write(oprot)
     oprot.writeFieldEnd()
   if self.b != None:
     oprot.writeFieldBegin('b', TType.STRUCT, 2)
     self.b.write(oprot)
     oprot.writeFieldEnd()
   if self.s != None:
     oprot.writeFieldBegin('s', TType.STRUCT, 3)
     self.s.write(oprot)
     oprot.writeFieldEnd()
   oprot.writeFieldStop()
   oprot.writeStructEnd()
开发者ID:facebook,项目名称:fbthrift,代码行数:26,代码来源:Raiser.py


示例5: write

 def write(self, oprot):
   if (oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated or (oprot.__class__ == THeaderProtocol.THeaderProtocol and oprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_BINARY_PROTOCOL)) and self.thrift_spec is not None and fastbinary is not None:
     oprot.trans.write(fastbinary.encode_binary(self, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS))
     return
   if (oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated or (oprot.__class__ == THeaderProtocol.THeaderProtocol and oprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_BINARY_PROTOCOL)) and self.thrift_spec is not None and fastproto is not None:
     oprot.trans.write(fastproto.encode(self, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=0))
     return
   if (oprot.__class__ == TCompactProtocol.TCompactProtocolAccelerated or (oprot.__class__ == THeaderProtocol.THeaderProtocol and oprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_COMPACT_PROTOCOL)) and self.thrift_spec is not None and fastproto is not None:
     oprot.trans.write(fastproto.encode(self, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=2))
     return
   oprot.writeStructBegin('init_args')
   if self.int1 != None:
     oprot.writeFieldBegin('int1', TType.I64, 1)
     oprot.writeI64(self.int1)
     oprot.writeFieldEnd()
   if self.int2 != None:
     oprot.writeFieldBegin('int2', TType.I64, 2)
     oprot.writeI64(self.int2)
     oprot.writeFieldEnd()
   if self.int3 != None:
     oprot.writeFieldBegin('int3', TType.I64, 3)
     oprot.writeI64(self.int3)
     oprot.writeFieldEnd()
   if self.int4 != None:
     oprot.writeFieldBegin('int4', TType.I64, 4)
     oprot.writeI64(self.int4)
     oprot.writeFieldEnd()
   if self.int5 != None:
     oprot.writeFieldBegin('int5', TType.I64, 5)
     oprot.writeI64(self.int5)
     oprot.writeFieldEnd()
   if self.int6 != None:
     oprot.writeFieldBegin('int6', TType.I64, 6)
     oprot.writeI64(self.int6)
     oprot.writeFieldEnd()
   if self.int7 != None:
     oprot.writeFieldBegin('int7', TType.I64, 7)
     oprot.writeI64(self.int7)
     oprot.writeFieldEnd()
   if self.int8 != None:
     oprot.writeFieldBegin('int8', TType.I64, 8)
     oprot.writeI64(self.int8)
     oprot.writeFieldEnd()
   if self.int9 != None:
     oprot.writeFieldBegin('int9', TType.I64, 9)
     oprot.writeI64(self.int9)
     oprot.writeFieldEnd()
   if self.int10 != None:
     oprot.writeFieldBegin('int10', TType.I64, 10)
     oprot.writeI64(self.int10)
     oprot.writeFieldEnd()
   if self.int11 != None:
     oprot.writeFieldBegin('int11', TType.I64, 11)
     oprot.writeI64(self.int11)
     oprot.writeFieldEnd()
   oprot.writeFieldStop()
   oprot.writeStructEnd()
开发者ID:Bogon,项目名称:fbthrift,代码行数:57,代码来源:TestService.py


示例6: write

 def write(self, oprot):
   if (isinstance(oprot, TBinaryProtocol.TBinaryProtocolAccelerated) or (isinstance(oprot, THeaderProtocol.THeaderProtocol) and oprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_BINARY_PROTOCOL)) and self.thrift_spec is not None and fastproto is not None:
     oprot.trans.write(fastproto.encode(self, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=0))
     return
   if (isinstance(oprot, TCompactProtocol.TCompactProtocolAccelerated) or (isinstance(oprot, THeaderProtocol.THeaderProtocol) and oprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_COMPACT_PROTOCOL)) and self.thrift_spec is not None and fastproto is not None:
     oprot.trans.write(fastproto.encode(self, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=2))
     return
   oprot.writeStructBegin('getResult_args')
   oprot.writeFieldStop()
   oprot.writeStructEnd()
开发者ID:Patrick-Park,项目名称:fbthrift,代码行数:10,代码来源:TestService.py


示例7: write

 def write(self, oprot):
     if (
         (
             oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated
             or (
                 oprot.__class__ == THeaderProtocol.THeaderProtocol
                 and oprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_BINARY_PROTOCOL
             )
         )
         and self.thrift_spec is not None
         and fastbinary is not None
     ):
         oprot.trans.write(
             fastbinary.encode_binary(self, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS)
         )
         return
     if (
         (
             oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated
             or (
                 oprot.__class__ == THeaderProtocol.THeaderProtocol
                 and oprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_BINARY_PROTOCOL
             )
         )
         and self.thrift_spec is not None
         and fastproto is not None
     ):
         oprot.trans.write(
             fastproto.encode(self, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=0)
         )
         return
     if (
         (
             oprot.__class__ == TCompactProtocol.TCompactProtocolAccelerated
             or (
                 oprot.__class__ == THeaderProtocol.THeaderProtocol
                 and oprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_COMPACT_PROTOCOL
             )
         )
         and self.thrift_spec is not None
         and fastproto is not None
     ):
         oprot.trans.write(
             fastproto.encode(self, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=2)
         )
         return
     oprot.writeStructBegin("init_result")
     if self.success != None:
         oprot.writeFieldBegin("success", TType.I64, 0)
         oprot.writeI64(self.success)
         oprot.writeFieldEnd()
     oprot.writeFieldStop()
     oprot.writeStructEnd()
开发者ID:redwardstern,项目名称:fbthrift,代码行数:53,代码来源:TestService.py


示例8: write

 def write(self, oprot):
   if (isinstance(oprot, TBinaryProtocol.TBinaryProtocolAccelerated) or (isinstance(oprot, THeaderProtocol.THeaderProtocolAccelerate) and oprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_BINARY_PROTOCOL)) and self.thrift_spec is not None and fastproto is not None:
     oprot.trans.write(fastproto.encode(self, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=0))
     return
   if (isinstance(oprot, TCompactProtocol.TCompactProtocolAccelerated) or (isinstance(oprot, THeaderProtocol.THeaderProtocolAccelerate) and oprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_COMPACT_PROTOCOL)) and self.thrift_spec is not None and fastproto is not None:
     oprot.trans.write(fastproto.encode(self, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=2))
     return
   oprot.writeStructBegin('isPrime_result')
   if self.success != None:
     oprot.writeFieldBegin('success', TType.BOOL, 0)
     oprot.writeBool(self.success)
     oprot.writeFieldEnd()
   oprot.writeFieldStop()
   oprot.writeStructEnd()
开发者ID:facebook,项目名称:fbthrift,代码行数:14,代码来源:TestService.py


示例9: write

 def write(self, oprot):
   if (isinstance(oprot, TBinaryProtocol.TBinaryProtocolAccelerated) or (isinstance(oprot, THeaderProtocol.THeaderProtocol) and oprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_BINARY_PROTOCOL)) and self.thrift_spec is not None and fastbinary is not None:
     oprot.trans.write(fastbinary.encode_binary(self, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS))
     return
   if (isinstance(oprot, TBinaryProtocol.TBinaryProtocolAccelerated) or (isinstance(oprot, THeaderProtocol.THeaderProtocol) and oprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_BINARY_PROTOCOL)) and self.thrift_spec is not None and fastproto is not None:
     oprot.trans.write(fastproto.encode(self, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=0))
     return
   if (isinstance(oprot, TCompactProtocol.TCompactProtocolAccelerated) or (isinstance(oprot, THeaderProtocol.THeaderProtocol) and oprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_COMPACT_PROTOCOL)) and self.thrift_spec is not None and fastproto is not None:
     oprot.trans.write(fastproto.encode(self, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=2))
     return
   oprot.writeStructBegin('Included')
   if self.MyIntField != None:
     oprot.writeFieldBegin('MyIntField', TType.I64, 1)
     oprot.writeI64(self.MyIntField)
     oprot.writeFieldEnd()
   oprot.writeFieldStop()
   oprot.writeStructEnd()
开发者ID:nemith,项目名称:fbthrift,代码行数:17,代码来源:ttypes.py


示例10: write

 def write(self, oprot):
   if (isinstance(oprot, TBinaryProtocol.TBinaryProtocolAccelerated) or (isinstance(oprot, THeaderProtocol.THeaderProtocol) and oprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_BINARY_PROTOCOL)) and self.thrift_spec is not None and fastproto is not None:
     oprot.trans.write(fastproto.encode(self, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=0))
     return
   if (isinstance(oprot, TCompactProtocol.TCompactProtocolAccelerated) or (isinstance(oprot, THeaderProtocol.THeaderProtocol) and oprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_COMPACT_PROTOCOL)) and self.thrift_spec is not None and fastproto is not None:
     oprot.trans.write(fastproto.encode(self, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=2))
     return
   oprot.writeStructBegin('Range')
   if self.min != None:
     oprot.writeFieldBegin('min', TType.I32, 1)
     oprot.writeI32(self.min)
     oprot.writeFieldEnd()
   if self.max != None:
     oprot.writeFieldBegin('max', TType.I32, 2)
     oprot.writeI32(self.max)
     oprot.writeFieldEnd()
   oprot.writeFieldStop()
   oprot.writeStructEnd()
开发者ID:JoesRain,项目名称:fbthrift,代码行数:18,代码来源:ttypes.py


示例11: write

 def write(self, oprot):
   if (isinstance(oprot, TBinaryProtocol.TBinaryProtocolAccelerated) or (isinstance(oprot, THeaderProtocol.THeaderProtocolAccelerate) and oprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_BINARY_PROTOCOL)) and self.thrift_spec is not None and fastproto is not None:
     oprot.trans.write(fastproto.encode(self, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=0))
     return
   if (isinstance(oprot, TCompactProtocol.TCompactProtocolAccelerated) or (isinstance(oprot, THeaderProtocol.THeaderProtocolAccelerate) and oprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_COMPACT_PROTOCOL)) and self.thrift_spec is not None and fastproto is not None:
     oprot.trans.write(fastproto.encode(self, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=2))
     return
   oprot.writeStructBegin('OldStructure')
   if self.features != None:
     oprot.writeFieldBegin('features', TType.MAP, 1)
     oprot.writeMapBegin(TType.I16, TType.DOUBLE, len(self.features))
     for kiter9,viter10 in self.features.items():
       oprot.writeI16(kiter9)
       oprot.writeDouble(viter10)
     oprot.writeMapEnd()
     oprot.writeFieldEnd()
   oprot.writeFieldStop()
   oprot.writeStructEnd()
开发者ID:facebook,项目名称:fbthrift,代码行数:18,代码来源:ttypes.py


示例12: write

 def write(self, oprot):
   if (isinstance(oprot, TBinaryProtocol.TBinaryProtocolAccelerated) or (isinstance(oprot, THeaderProtocol.THeaderProtocol) and oprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_BINARY_PROTOCOL)) and self.thrift_spec is not None and fastproto is not None:
     oprot.trans.write(fastproto.encode(self, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=0))
     return
   if (isinstance(oprot, TCompactProtocol.TCompactProtocolAccelerated) or (isinstance(oprot, THeaderProtocol.THeaderProtocol) and oprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_COMPACT_PROTOCOL)) and self.thrift_spec is not None and fastproto is not None:
     oprot.trans.write(fastproto.encode(self, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=2))
     return
   oprot.writeStructBegin('TestStruct')
   if self.aLong != None:
     oprot.writeFieldBegin('aLong', TType.I64, 1)
     oprot.writeI64(self.aLong)
     oprot.writeFieldEnd()
   if self.aString != None:
     oprot.writeFieldBegin('aString', TType.STRING, 2)
     oprot.writeString(self.aString.encode('utf-8')) if UTF8STRINGS and not isinstance(self.aString, bytes) else oprot.writeString(self.aString)
     oprot.writeFieldEnd()
   oprot.writeFieldStop()
   oprot.writeStructEnd()
开发者ID:Bklyn,项目名称:fbthrift,代码行数:18,代码来源:ttypes.py


示例13: encode_helper

    def encode_helper(self, obj):
        buf = fastproto.encode(obj, [obj.__class__, obj.thrift_spec, obj.isUnion()], utf8strings=0, protoid=self.PROTO)

        trans = TMemoryBuffer(buf)
        if self.PROTO == 0:
            proto = TBinaryProtocol.TBinaryProtocol(trans)
        else:
            proto = TCompactProtocol.TCompactProtocol(trans)

        obj_new = obj.__class__()
        obj_new.read(proto)
        self.assertEqual(obj, obj_new)
开发者ID:assad2012,项目名称:fbthrift,代码行数:12,代码来源:TestFastProto.py


示例14: write

 def write(self, oprot):
   if (isinstance(oprot, TBinaryProtocol.TBinaryProtocolAccelerated) or (isinstance(oprot, THeaderProtocol.THeaderProtocol) and oprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_BINARY_PROTOCOL)) and self.thrift_spec is not None and fastbinary is not None:
     oprot.trans.write(fastbinary.encode_binary(self, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS))
     return
   if (isinstance(oprot, TBinaryProtocol.TBinaryProtocolAccelerated) or (isinstance(oprot, THeaderProtocol.THeaderProtocol) and oprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_BINARY_PROTOCOL)) and self.thrift_spec is not None and fastproto is not None:
     oprot.trans.write(fastproto.encode(self, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=0))
     return
   if (isinstance(oprot, TCompactProtocol.TCompactProtocolAccelerated) or (isinstance(oprot, THeaderProtocol.THeaderProtocol) and oprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_COMPACT_PROTOCOL)) and self.thrift_spec is not None and fastproto is not None:
     oprot.trans.write(fastproto.encode(self, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=2))
     return
   oprot.writeStructBegin('ActivityInfo')
   if self.count != None:
     oprot.writeFieldBegin('count', TType.I32, 1)
     oprot.writeI32(self.count)
     oprot.writeFieldEnd()
   if self.is_fuzzed != None:
     oprot.writeFieldBegin('is_fuzzed', TType.BOOL, 2)
     oprot.writeBool(self.is_fuzzed)
     oprot.writeFieldEnd()
   oprot.writeFieldStop()
   oprot.writeStructEnd()
开发者ID:mewald55,项目名称:BlockPath,代码行数:21,代码来源:ttypes.py


示例15: fastproto_encode

def fastproto_encode(q, protoid):
    hp = hpy()
    trans = TDevNullTransport()
    p = psutil.Process(os.getpid())

    global ooe
    before = hp.heap()
    for i in range(iters):
        buf = fastproto.encode(
                ooe,
                [OneOfEach, OneOfEach.thrift_spec, False],
                utf8strings=0,
                protoid=protoid)
        trans.write(buf)
        if (i + 1) % 100000 == 0:
            q.put((i + 1, p.memory_info()))

    gc.collect()
    after = hp.heap()
    leftover = after - before
    q.put("Memory leftover in Python after {} times: {}".format(
        iters, leftover))
开发者ID:facebook,项目名称:fbthrift,代码行数:22,代码来源:FastprotoBenchmark.py


示例16: memory_usage_fastproto

def memory_usage_fastproto():
    hp = hpy()
    trans = TDevNullTransport()
    global ooe
    for pid in (0, 2):
        before = hp.heap()
        for i in range(iters):
            buf = fastproto.encode(
                    ooe,
                    [OneOfEach, OneOfEach.thrift_spec, False],
                    utf8strings=0,
                    protoid=pid)
            trans.write(buf)
        gc.collect()
        after = hp.heap()
        leftover = after - before
        print("Memory leftover after running fastproto.encode with "
                "protocol id {0} for {1} times".format(pid, iters))
        print(leftover)

    for pid in (0, 2):
        before = hp.heap()
        for i in range(iters):
            trans = TTransport.TMemoryBuffer(
                    binary_buf if pid == 0 else compact_buf)
            ooe_local = OneOfEach()
            fastproto.decode(
                    ooe_local,
                    trans,
                    [OneOfEach, OneOfEach.thrift_spec, False],
                    utf8strings=0,
                    protoid=pid)
        gc.collect()
        after = hp.heap()
        leftover = after - before
        print("Memory leftover after running fastproto.decode with "
                "protocol id {0} for {1} times".format(pid, iters))
        print(leftover)
开发者ID:ningshuo0529,项目名称:fbthrift,代码行数:38,代码来源:FastprotoBenchmark.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python THeaderTransport.THeaderTransport类代码示例发布时间:2022-05-27
下一篇:
Python fastproto.decode函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap