本文整理汇总了Python中thrift.protocol.fastproto.decode函数的典型用法代码示例。如果您正苦于以下问题:Python decode函数的具体用法?Python decode怎么用?Python decode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了decode函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: read
def read(self, iprot):
if (isinstance(iprot, TBinaryProtocol.TBinaryProtocolAccelerated) or (isinstance(iprot, THeaderProtocol.THeaderProtocolAccelerate) and iprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_BINARY_PROTOCOL)) and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastproto is not None:
fastproto.decode(self, iprot.trans, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=0)
self.checkRequired()
return
if (isinstance(iprot, TCompactProtocol.TCompactProtocolAccelerated) or (isinstance(iprot, THeaderProtocol.THeaderProtocolAccelerate) and iprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_COMPACT_PROTOCOL)) and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastproto is not None:
fastproto.decode(self, iprot.trans, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=2)
self.checkRequired()
return
iprot.readStructBegin()
while True:
(fname, ftype, fid) = iprot.readFieldBegin()
if ftype == TType.STOP:
break
if fid == 0:
if ftype == TType.STRUCT:
self.success = TestStruct()
self.success.read(iprot)
else:
iprot.skip(ftype)
else:
iprot.skip(ftype)
iprot.readFieldEnd()
iprot.readStructEnd()
self.checkRequired()
开发者ID:facebook,项目名称:fbthrift,代码行数:25,代码来源:TestService.py
示例2: read
def read(self, iprot):
if (isinstance(iprot, TBinaryProtocol.TBinaryProtocolAccelerated) or (isinstance(iprot, THeaderProtocol.THeaderProtocol) and iprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_BINARY_PROTOCOL)) and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
fastbinary.decode_binary(self, iprot.trans, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS)
return
if (isinstance(iprot, TBinaryProtocol.TBinaryProtocolAccelerated) or (isinstance(iprot, THeaderProtocol.THeaderProtocol) and iprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_BINARY_PROTOCOL)) and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastproto is not None:
fastproto.decode(self, iprot.trans, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=0)
return
if (isinstance(iprot, TCompactProtocol.TCompactProtocolAccelerated) or (isinstance(iprot, THeaderProtocol.THeaderProtocol) and iprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_COMPACT_PROTOCOL)) and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastproto is not None:
fastproto.decode(self, iprot.trans, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=2)
return
iprot.readStructBegin()
while True:
(fname, ftype, fid) = iprot.readFieldBegin()
if ftype == TType.STOP:
break
if fid == 1:
if ftype == TType.I32:
self.weeks = iprot.readI32()
else:
iprot.skip(ftype)
elif fid == 2:
if ftype == TType.STRING:
self.title = iprot.readString().decode('utf-8') if UTF8STRINGS else iprot.readString()
else:
iprot.skip(ftype)
elif fid == 3:
if ftype == TType.I32:
self.employer = iprot.readI32()
else:
iprot.skip(ftype)
else:
iprot.skip(ftype)
iprot.readFieldEnd()
iprot.readStructEnd()
开发者ID:nemith,项目名称:fbthrift,代码行数:34,代码来源:ttypes.py
示例3: read
def read(self, iprot):
if (isinstance(iprot, TBinaryProtocol.TBinaryProtocolAccelerated) or (isinstance(iprot, THeaderProtocol.THeaderProtocol) and iprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_BINARY_PROTOCOL)) and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastproto is not None:
fastproto.decode(self, iprot.trans, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=0)
return
if (isinstance(iprot, TCompactProtocol.TCompactProtocolAccelerated) or (isinstance(iprot, THeaderProtocol.THeaderProtocol) and iprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_COMPACT_PROTOCOL)) and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastproto is not None:
fastproto.decode(self, iprot.trans, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=2)
return
iprot.readStructBegin()
while True:
(fname, ftype, fid) = iprot.readFieldBegin()
if ftype == TType.STOP:
break
if fid == 1:
if ftype == TType.I32:
self.weeks = iprot.readI32()
else:
iprot.skip(ftype)
elif fid == 2:
if ftype == TType.STRING:
self.title = iprot.readString().decode('utf-8') if UTF8STRINGS else iprot.readString()
else:
iprot.skip(ftype)
elif fid == 3:
if ftype == TType.I32:
self.employer = iprot.readI32()
else:
iprot.skip(ftype)
else:
iprot.skip(ftype)
iprot.readFieldEnd()
iprot.readStructEnd()
if self.weeks == None:
raise TProtocolException(TProtocolException.MISSING_REQUIRED_FIELD, "Required field 'weeks' was not found in serialized data! Struct: Internship")
开发者ID:JoesRain,项目名称:fbthrift,代码行数:33,代码来源:ttypes.py
示例4: read
def read(self, iprot):
self.field = 0
self.value = None
if (isinstance(iprot, TBinaryProtocol.TBinaryProtocolAccelerated) or (isinstance(iprot, THeaderProtocol.THeaderProtocolAccelerate) and iprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_BINARY_PROTOCOL)) and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastproto is not None:
fastproto.decode(self, iprot.trans, [self.__class__, self.thrift_spec, True], utf8strings=UTF8STRINGS, protoid=0)
self.checkRequired()
return
if (isinstance(iprot, TCompactProtocol.TCompactProtocolAccelerated) or (isinstance(iprot, THeaderProtocol.THeaderProtocolAccelerate) and iprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_COMPACT_PROTOCOL)) and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastproto is not None:
fastproto.decode(self, iprot.trans, [self.__class__, self.thrift_spec, True], utf8strings=UTF8STRINGS, protoid=2)
self.checkRequired()
return
iprot.readStructBegin()
while True:
(fname, ftype, fid) = iprot.readFieldBegin()
if ftype == TType.STOP:
break
if fid == 1:
if ftype == TType.I32:
i = iprot.readI32()
assert self.field == 0 and self.value is None
self.set_i(i)
else:
iprot.skip(ftype)
elif fid == 2:
if ftype == TType.DOUBLE:
d = iprot.readDouble()
assert self.field == 0 and self.value is None
self.set_d(d)
else:
iprot.skip(ftype)
else:
iprot.skip(ftype)
iprot.readFieldEnd()
iprot.readStructEnd()
开发者ID:facebook,项目名称:fbthrift,代码行数:35,代码来源:ttypes.py
示例5: read
def read(self, iprot):
if (iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated or (iprot.__class__ == THeaderProtocol.THeaderProtocol and iprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_BINARY_PROTOCOL)) and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
fastbinary.decode_binary(self, iprot.trans, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS)
return
if (iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated or (iprot.__class__ == THeaderProtocol.THeaderProtocol and iprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_BINARY_PROTOCOL)) and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastproto is not None:
fastproto.decode(self, iprot.trans, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=0)
return
if (iprot.__class__ == TCompactProtocol.TCompactProtocolAccelerated or (iprot.__class__ == THeaderProtocol.THeaderProtocol and iprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_COMPACT_PROTOCOL)) and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastproto is not None:
fastproto.decode(self, iprot.trans, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=2)
return
iprot.readStructBegin()
while True:
(fname, ftype, fid) = iprot.readFieldBegin()
if ftype == TType.STOP:
break
if fid == 1:
if ftype == TType.STRUCT:
self.MyIncludedField = includes.ttypes.Included()
self.MyIncludedField.read(iprot)
else:
iprot.skip(ftype)
else:
iprot.skip(ftype)
iprot.readFieldEnd()
iprot.readStructEnd()
开发者ID:radious,项目名称:fbthrift,代码行数:25,代码来源:ttypes.py
示例6: test_forward_compatibility_nested
def test_forward_compatibility_nested(self):
obj = OldStructureNested()
obj.features = [{}]
obj.features[0][1] = 314
obj.features[0][2] = 271
trans = TMemoryBuffer()
proto = self.createProto(trans)
obj.write(proto)
obj_new = NewStructureNested()
trans = TMemoryBuffer(trans.getvalue())
proto = proto.__class__(trans)
fastproto.decode(obj_new, trans, [obj_new.__class__, obj_new.thrift_spec,
obj_new.isUnion()], utf8strings=0,
protoid=self.PROTO,
forward_compatibility=True)
self.assertAlmostEqual(obj_new.features[0][1], 314.0)
self.assertAlmostEqual(obj_new.features[0][2], 271.0)
trans2 = TMemoryBuffer()
proto2 = self.createProto(trans2)
obj_new.write(proto2)
obj_new2 = NewStructureNested()
trans2 = TMemoryBuffer(trans2.getvalue())
proto2 = proto2.__class__(trans2)
fastproto.decode(obj_new2, trans2, [obj_new2.__class__, obj_new2.thrift_spec,
obj_new2.isUnion()], utf8strings=0,
protoid=self.PROTO)
self.assertAlmostEqual(obj_new2.features[0][1], 314.0)
self.assertAlmostEqual(obj_new2.features[0][2], 271.0)
开发者ID:facebook,项目名称:fbthrift,代码行数:34,代码来源:TestFastProto.py
示例7: read
def read(self, iprot):
if (isinstance(iprot, TBinaryProtocol.TBinaryProtocolAccelerated) or (isinstance(iprot, THeaderProtocol.THeaderProtocolAccelerate) and iprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_BINARY_PROTOCOL)) and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastproto is not None:
fastproto.decode(self, iprot.trans, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=0)
self.checkRequired()
return
if (isinstance(iprot, TCompactProtocol.TCompactProtocolAccelerated) or (isinstance(iprot, THeaderProtocol.THeaderProtocolAccelerate) and iprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_COMPACT_PROTOCOL)) and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastproto is not None:
fastproto.decode(self, iprot.trans, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=2)
self.checkRequired()
return
iprot.readStructBegin()
while True:
(fname, ftype, fid) = iprot.readFieldBegin()
if ftype == TType.STOP:
break
if fid == 1:
if ftype == TType.MAP:
self.mymap = {}
(_ktype1, _vtype2, _size0 ) = iprot.readMapBegin()
if _size0 >= 0:
for _i4 in six.moves.range(_size0):
_key5 = iprot.readString().decode('utf-8') if UTF8STRINGS else iprot.readString()
_val6 = iprot.readString().decode('utf-8') if UTF8STRINGS else iprot.readString()
self.mymap[_key5] = _val6
else:
while iprot.peekMap():
_key7 = iprot.readString().decode('utf-8') if UTF8STRINGS else iprot.readString()
_val8 = iprot.readString().decode('utf-8') if UTF8STRINGS else iprot.readString()
self.mymap[_key7] = _val8
iprot.readMapEnd()
else:
iprot.skip(ftype)
elif fid == 2:
if ftype == TType.SET:
self.myset = set()
(_etype12, _size9) = iprot.readSetBegin()
if _size9 >= 0:
for _i13 in six.moves.range(_size9):
_elem14 = iprot.readString().decode('utf-8') if UTF8STRINGS else iprot.readString()
self.myset.add(_elem14)
else:
while iprot.peekSet():
_elem15 = iprot.readString().decode('utf-8') if UTF8STRINGS else iprot.readString()
self.myset.add(_elem15)
iprot.readSetEnd()
else:
iprot.skip(ftype)
else:
iprot.skip(ftype)
iprot.readFieldEnd()
iprot.readStructEnd()
self.checkRequired()
开发者ID:facebook,项目名称:fbthrift,代码行数:51,代码来源:ttypes.py
示例8: decode_helper
def decode_helper(self, obj, split=1.0):
trans = TMemoryBuffer()
if self.PROTO == 0:
proto = TBinaryProtocol.TBinaryProtocol(trans)
else:
proto = TCompactProtocol.TCompactProtocol(trans)
obj.write(proto)
index = int(split * len(trans.getvalue()))
trans = ReadOnlyBufferWithRefill(index, trans.getvalue())
obj_new = obj.__class__()
fastproto.decode(obj_new, trans, [obj.__class__, obj.thrift_spec,
obj.isUnion()], utf8strings=0, protoid=self.PROTO)
self.assertEqual(obj, obj_new)
# Verify the entire buffer is read
self.assertEqual(len(trans._readBuffer.read()), 0)
if split != 1.0:
self.assertEqual(1, trans.refill_called)
开发者ID:ConfusedReality,项目名称:pkg_serialization_fbthrift,代码行数:18,代码来源:TestFastProto.py
示例9: read
def read(self, iprot):
if (isinstance(iprot, TBinaryProtocol.TBinaryProtocolAccelerated) or (isinstance(iprot, THeaderProtocol.THeaderProtocolAccelerate) and iprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_BINARY_PROTOCOL)) and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastproto is not None:
fastproto.decode(self, iprot.trans, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=0, forward_compatibility=True)
self.checkRequired()
return
if (isinstance(iprot, TCompactProtocol.TCompactProtocolAccelerated) or (isinstance(iprot, THeaderProtocol.THeaderProtocolAccelerate) and iprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_COMPACT_PROTOCOL)) and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastproto is not None:
fastproto.decode(self, iprot.trans, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=2, forward_compatibility=True)
self.checkRequired()
return
iprot.readStructBegin()
while True:
(fname, ftype, fid) = iprot.readFieldBegin()
if ftype == TType.STOP:
break
if fid == 1:
if ftype == TType.MAP:
self.features = {}
(_ktype23, _vtype24, _size22 ) = iprot.readMapBegin()
_ktype23 = _ktype23 if _ktype23 != TType.STOP else TType.I16
_vtype24 = _vtype24 if _vtype24 != TType.STOP else TType.FLOAT
if _size22 >= 0:
for _i26 in six.moves.range(_size22):
_key27 = iprot.readIntegral(_ktype23)
_val28 = iprot.readFloatingPoint(_vtype24)
self.features[_key27] = _val28
else:
while iprot.peekMap():
_key29 = iprot.readIntegral(_ktype23)
_val30 = iprot.readFloatingPoint(_vtype24)
self.features[_key29] = _val30
iprot.readMapEnd()
else:
iprot.skip(ftype)
else:
iprot.skip(ftype)
iprot.readFieldEnd()
iprot.readStructEnd()
self.checkRequired()
开发者ID:facebook,项目名称:fbthrift,代码行数:38,代码来源:ttypes.py
示例10: 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
示例11: fastproto_decode
def fastproto_decode(q, protoid):
hp = hpy()
p = psutil.Process(os.getpid())
before = hp.heap()
for i in range(iters):
trans = TTransport.TMemoryBuffer(
binary_buf if protoid == 0 else compact_buf)
ooe_local = OneOfEach()
fastproto.decode(
ooe_local,
trans,
[OneOfEach, OneOfEach.thrift_spec, False],
utf8strings=0,
protoid=protoid)
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,代码行数:23,代码来源:FastprotoBenchmark.py
示例12: read
def read(self, iprot):
if (isinstance(iprot, TBinaryProtocol.TBinaryProtocolAccelerated) or (isinstance(iprot, THeaderProtocol.THeaderProtocol) and iprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_BINARY_PROTOCOL)) and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
fastbinary.decode_binary(self, iprot.trans, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS)
return
if (isinstance(iprot, TBinaryProtocol.TBinaryProtocolAccelerated) or (isinstance(iprot, THeaderProtocol.THeaderProtocol) and iprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_BINARY_PROTOCOL)) and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastproto is not None:
fastproto.decode(self, iprot.trans, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=0)
return
if (isinstance(iprot, TCompactProtocol.TCompactProtocolAccelerated) or (isinstance(iprot, THeaderProtocol.THeaderProtocol) and iprot.get_protocol_id() == THeaderProtocol.THeaderProtocol.T_COMPACT_PROTOCOL)) and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastproto is not None:
fastproto.decode(self, iprot.trans, [self.__class__, self.thrift_spec, False], utf8strings=UTF8STRINGS, protoid=2)
return
iprot.readStructBegin()
while True:
(fname, ftype, fid) = iprot.readFieldBegin()
if ftype == TType.STOP:
break
if fid == 1:
if ftype == TType.I64:
self.int1 = iprot.readI64()
else:
iprot.skip(ftype)
elif fid == 2:
if ftype == TType.I64:
self.int2 = iprot.readI64()
else:
iprot.skip(ftype)
elif fid == 3:
if ftype == TType.I64:
self.int3 = iprot.readI64()
else:
iprot.skip(ftype)
elif fid == 4:
if ftype == TType.I64:
self.int4 = iprot.readI64()
else:
iprot.skip(ftype)
elif fid == 5:
if ftype == TType.I64:
self.int5 = iprot.readI64()
else:
iprot.skip(ftype)
elif fid == 6:
if ftype == TType.I64:
self.int6 = iprot.readI64()
else:
iprot.skip(ftype)
elif fid == 7:
if ftype == TType.I64:
self.int7 = iprot.readI64()
else:
iprot.skip(ftype)
elif fid == 8:
if ftype == TType.I64:
self.int8 = iprot.readI64()
else:
iprot.skip(ftype)
elif fid == 9:
if ftype == TType.I64:
self.int9 = iprot.readI64()
else:
iprot.skip(ftype)
elif fid == 10:
if ftype == TType.I64:
self.int10 = iprot.readI64()
else:
iprot.skip(ftype)
elif fid == 11:
if ftype == TType.I64:
self.int11 = iprot.readI64()
else:
iprot.skip(ftype)
elif fid == 12:
if ftype == TType.I64:
self.int12 = iprot.readI64()
else:
iprot.skip(ftype)
elif fid == 13:
if ftype == TType.I64:
self.int13 = iprot.readI64()
else:
iprot.skip(ftype)
elif fid == 14:
if ftype == TType.I64:
self.int14 = iprot.readI64()
else:
iprot.skip(ftype)
elif fid == 15:
if ftype == TType.I64:
self.int15 = iprot.readI64()
else:
iprot.skip(ftype)
elif fid == 16:
if ftype == TType.I64:
self.int16 = iprot.readI64()
else:
iprot.skip(ftype)
else:
iprot.skip(ftype)
iprot.readFieldEnd()
iprot.readStructEnd()
开发者ID:nemith,项目名称:fbthrift,代码行数:99,代码来源:TestService.py
注:本文中的thrift.protocol.fastproto.decode函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论