Python thrift.Thrift.TType.SET Examples

The following are 24 code examples of thrift.Thrift.TType.SET(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module thrift.Thrift.TType , or try the search function .
Example #1
Source File: ttypes.py    From rift-python with Apache License 2.0 6 votes vote down vote up
def read(self, iprot):
        if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None:
            iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec))
            return
        iprot.readStructBegin()
        while True:
            (fname, ftype, fid) = iprot.readFieldBegin()
            if ftype == TType.STOP:
                break
            if fid == 1:
                if ftype == TType.SET:
                    self.headers = set()
                    (_etype10, _size7) = iprot.readSetBegin()
                    for _i11 in range(_size7):
                        _elem12 = TIEHeaderWithLifeTime()
                        _elem12.read(iprot)
                        self.headers.add(_elem12)
                    iprot.readSetEnd()
                else:
                    iprot.skip(ftype)
            else:
                iprot.skip(ftype)
            iprot.readFieldEnd()
        iprot.readStructEnd() 
Example #2
Source File: ttypes.py    From rift-python with Apache License 2.0 6 votes vote down vote up
def read(self, iprot):
        if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None:
            iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec))
            return
        iprot.readStructBegin()
        while True:
            (fname, ftype, fid) = iprot.readFieldBegin()
            if ftype == TType.STOP:
                break
            if fid == 1:
                if ftype == TType.SET:
                    self.headers = set()
                    (_etype10, _size7) = iprot.readSetBegin()
                    for _i11 in range(_size7):
                        _elem12 = TIEHeaderWithLifeTime()
                        _elem12.read(iprot)
                        self.headers.add(_elem12)
                    iprot.readSetEnd()
                else:
                    iprot.skip(ftype)
            else:
                iprot.skip(ftype)
            iprot.readFieldEnd()
        iprot.readStructEnd() 
Example #3
Source File: ttypes.py    From pymapd with Apache License 2.0 6 votes vote down vote up
def write(self, oprot):
        if oprot._fast_encode is not None and self.thrift_spec is not None:
            oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec]))
            return
        oprot.writeStructBegin('TCountDistinctSetStorage')
        if self.bitmap is not None:
            oprot.writeFieldBegin('bitmap', TType.STRING, 1)
            oprot.writeBinary(self.bitmap)
            oprot.writeFieldEnd()
        if self.sparse_set is not None:
            oprot.writeFieldBegin('sparse_set', TType.SET, 2)
            oprot.writeSetBegin(TType.I64, len(self.sparse_set))
            for iter48 in self.sparse_set:
                oprot.writeI64(iter48)
            oprot.writeSetEnd()
            oprot.writeFieldEnd()
        oprot.writeFieldStop()
        oprot.writeStructEnd() 
Example #4
Source File: ttypes.py    From rift-python with Apache License 2.0 5 votes vote down vote up
def write(self, oprot):
        if oprot._fast_encode is not None and self.thrift_spec is not None:
            oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec)))
            return
        oprot.writeStructBegin('TIREPacket')
        if self.headers is not None:
            oprot.writeFieldBegin('headers', TType.SET, 1)
            oprot.writeSetBegin(TType.STRUCT, len(self.headers))
            for iter13 in self.headers:
                iter13.write(oprot)
            oprot.writeSetEnd()
            oprot.writeFieldEnd()
        oprot.writeFieldStop()
        oprot.writeStructEnd() 
Example #5
Source File: TRecursive.py    From thrift with GNU Lesser General Public License v3.0 5 votes vote down vote up
def _fix_map(element_type):
    # For a map of key -> value type, ``element_type`` will be,
    # (TType.I16, None, TType.STRUCT, [RecMapBasic, None], False), None, )
    # which is just a normal struct definition.
    #
    # For a map of key -> list / set, ``element_type`` will be,
    # (TType.I16, None, TType.LIST, (TType.STRUCT, [RecMapList, None], False), False)
    # and we need to process the 3rd element as a list.
    #
    # For a map of key -> map, ``element_type`` will be,
    # (TType.I16, None, TType.MAP, (TType.I16, None, TType.STRUCT,
    #  [RecMapMap, None], False), False)
    # and need to process 3rd element as a map.

    # Is the map key a struct?
    if element_type[0] == TType.STRUCT:
        element_type[1][1] = element_type[1][0].thrift_spec
    elif element_type[0] in (TType.LIST, TType.SET):
        _fix_list_or_set(element_type[1])
    elif element_type[0] == TType.MAP:
        _fix_map(element_type[1])

    # Is the map value a struct?
    if element_type[2] == TType.STRUCT:
        element_type[3][1] = element_type[3][0].thrift_spec
    elif element_type[2] in (TType.LIST, TType.SET):
        _fix_list_or_set(element_type[3])
    elif element_type[2] == TType.MAP:
        _fix_map(element_type[3]) 
Example #6
Source File: TRecursive.py    From thrift with GNU Lesser General Public License v3.0 5 votes vote down vote up
def _fix_list_or_set(element_type):
    # For a list or set, the thrift_spec entry looks like,
    # (1, TType.LIST, 'lister', (TType.STRUCT, [RecList, None], False), None, ),  # 1
    # so ``element_type`` will be,
    # (TType.STRUCT, [RecList, None], False)
    if element_type[0] == TType.STRUCT:
        element_type[1][1] = element_type[1][0].thrift_spec
    elif element_type[0] in (TType.LIST, TType.SET):
        _fix_list_or_set(element_type[1])
    elif element_type[0] == TType.MAP:
        _fix_map(element_type[1]) 
Example #7
Source File: TRecursive.py    From thrift with GNU Lesser General Public License v3.0 5 votes vote down vote up
def fix_spec(all_structs):
    """Wire up recursive references for all TStruct definitions inside of each thrift_spec."""
    for struc in all_structs:
        spec = struc.thrift_spec
        for thrift_spec in spec:
            if thrift_spec is None:
                continue
            elif thrift_spec[TYPE_IDX] == TType.STRUCT:
                other = thrift_spec[SPEC_ARGS_IDX][SPEC_ARGS_CLASS_REF_IDX].thrift_spec
                thrift_spec[SPEC_ARGS_IDX][SPEC_ARGS_THRIFT_SPEC_IDX] = other
            elif thrift_spec[TYPE_IDX] in (TType.LIST, TType.SET):
                _fix_list_or_set(thrift_spec[SPEC_ARGS_IDX])
            elif thrift_spec[TYPE_IDX] == TType.MAP:
                _fix_map(thrift_spec[SPEC_ARGS_IDX]) 
Example #8
Source File: TRecursive.py    From SOLO with GNU General Public License v3.0 5 votes vote down vote up
def _fix_map(element_type):
    # For a map of key -> value type, ``element_type`` will be,
    # (TType.I16, None, TType.STRUCT, [RecMapBasic, None], False), None, )
    # which is just a normal struct definition.
    #
    # For a map of key -> list / set, ``element_type`` will be,
    # (TType.I16, None, TType.LIST, (TType.STRUCT, [RecMapList, None], False), False)
    # and we need to process the 3rd element as a list.
    #
    # For a map of key -> map, ``element_type`` will be,
    # (TType.I16, None, TType.MAP, (TType.I16, None, TType.STRUCT,
    #  [RecMapMap, None], False), False)
    # and need to process 3rd element as a map.

    # Is the map key a struct?
    if element_type[0] == TType.STRUCT:
        element_type[1][1] = element_type[1][0].thrift_spec
    elif element_type[0] in (TType.LIST, TType.SET):
        _fix_list_or_set(element_type[1])
    elif element_type[0] == TType.MAP:
        _fix_map(element_type[1])

    # Is the map value a struct?
    if element_type[2] == TType.STRUCT:
        element_type[3][1] = element_type[3][0].thrift_spec
    elif element_type[2] in (TType.LIST, TType.SET):
        _fix_list_or_set(element_type[3])
    elif element_type[2] == TType.MAP:
        _fix_map(element_type[3]) 
Example #9
Source File: TRecursive.py    From SOLO with GNU General Public License v3.0 5 votes vote down vote up
def _fix_list_or_set(element_type):
    # For a list or set, the thrift_spec entry looks like,
    # (1, TType.LIST, 'lister', (TType.STRUCT, [RecList, None], False), None, ),  # 1
    # so ``element_type`` will be,
    # (TType.STRUCT, [RecList, None], False)
    if element_type[0] == TType.STRUCT:
        element_type[1][1] = element_type[1][0].thrift_spec
    elif element_type[0] in (TType.LIST, TType.SET):
        _fix_list_or_set(element_type[1])
    elif element_type[0] == TType.MAP:
        _fix_map(element_type[1]) 
Example #10
Source File: TRecursive.py    From SOLO with GNU General Public License v3.0 5 votes vote down vote up
def fix_spec(all_structs):
    """Wire up recursive references for all TStruct definitions inside of each thrift_spec."""
    for struc in all_structs:
        spec = struc.thrift_spec
        for thrift_spec in spec:
            if thrift_spec is None:
                continue
            elif thrift_spec[TYPE_IDX] == TType.STRUCT:
                other = thrift_spec[SPEC_ARGS_IDX][SPEC_ARGS_CLASS_REF_IDX].thrift_spec
                thrift_spec[SPEC_ARGS_IDX][SPEC_ARGS_THRIFT_SPEC_IDX] = other
            elif thrift_spec[TYPE_IDX] in (TType.LIST, TType.SET):
                _fix_list_or_set(thrift_spec[SPEC_ARGS_IDX])
            elif thrift_spec[TYPE_IDX] == TType.MAP:
                _fix_map(thrift_spec[SPEC_ARGS_IDX]) 
Example #11
Source File: thrift_struct.py    From thrift-tools with Apache License 2.0 5 votes vote down vote up
def field_type_to_str(ftype):
        if ftype == TType.STOP:
            return 'stop'
        elif ftype == TType.VOID:
            return 'void'
        elif ftype == TType.BOOL:
            return 'bool'
        elif ftype == TType.BYTE:
            return 'byte'
        elif ftype == TType.I08:
            return 'i08'
        elif ftype == TType.DOUBLE:
            return 'double'
        elif ftype == TType.I16:
            return 'i16'
        elif ftype == TType.I32:
            return 'i32'
        elif ftype == TType.I64:
            return 'i64'
        elif ftype == TType.STRING:
            return 'string'
        elif ftype == TType.UTF7:
            return 'utf7'
        elif ftype == TType.STRUCT:
            return 'struct'
        elif ftype == TType.MAP:
            return 'map'
        elif ftype == TType.SET:
            return 'set'
        elif ftype == TType.LIST:
            return 'list'
        elif ftype == TType.UTF8:
            return 'utf8'
        elif ftype == TType.UTF16:
            return 'utf16'
        else:
            raise ValueError('Unknown type: %s' % ftype) 
Example #12
Source File: ttypes.py    From pymapd with Apache License 2.0 5 votes vote down vote up
def read(self, iprot):
        if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None:
            iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec])
            return
        iprot.readStructBegin()
        while True:
            (fname, ftype, fid) = iprot.readFieldBegin()
            if ftype == TType.STOP:
                break
            if fid == 1:
                if ftype == TType.STRING:
                    self.bitmap = iprot.readBinary()
                else:
                    iprot.skip(ftype)
            elif fid == 2:
                if ftype == TType.SET:
                    self.sparse_set = set()
                    (_etype45, _size42) = iprot.readSetBegin()
                    for _i46 in range(_size42):
                        _elem47 = iprot.readI64()
                        self.sparse_set.add(_elem47)
                    iprot.readSetEnd()
                else:
                    iprot.skip(ftype)
            else:
                iprot.skip(ftype)
            iprot.readFieldEnd()
        iprot.readStructEnd() 
Example #13
Source File: ttypes.py    From rift-python with Apache License 2.0 5 votes vote down vote up
def write(self, oprot):
        if oprot._fast_encode is not None and self.thrift_spec is not None:
            oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec)))
            return
        oprot.writeStructBegin('PrefixAttributes')
        if self.metric is not None:
            oprot.writeFieldBegin('metric', TType.I32, 2)
            oprot.writeI32(self.metric)
            oprot.writeFieldEnd()
        if self.tags is not None:
            oprot.writeFieldBegin('tags', TType.SET, 3)
            oprot.writeSetBegin(TType.I64, len(self.tags))
            for iter43 in self.tags:
                oprot.writeI64(iter43)
            oprot.writeSetEnd()
            oprot.writeFieldEnd()
        if self.monotonic_clock is not None:
            oprot.writeFieldBegin('monotonic_clock', TType.STRUCT, 4)
            self.monotonic_clock.write(oprot)
            oprot.writeFieldEnd()
        if self.loopback is not None:
            oprot.writeFieldBegin('loopback', TType.BOOL, 6)
            oprot.writeBool(self.loopback)
            oprot.writeFieldEnd()
        if self.directly_attached is not None:
            oprot.writeFieldBegin('directly_attached', TType.BOOL, 7)
            oprot.writeBool(self.directly_attached)
            oprot.writeFieldEnd()
        if self.from_link is not None:
            oprot.writeFieldBegin('from_link', TType.I32, 10)
            oprot.writeI32(self.from_link)
            oprot.writeFieldEnd()
        oprot.writeFieldStop()
        oprot.writeStructEnd() 
Example #14
Source File: ttypes.py    From rift-python with Apache License 2.0 5 votes vote down vote up
def write(self, oprot):
        if oprot._fast_encode is not None and self.thrift_spec is not None:
            oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec)))
            return
        oprot.writeStructBegin('NodeNeighborsTIEElement')
        if self.level is not None:
            oprot.writeFieldBegin('level', TType.BYTE, 1)
            oprot.writeByte(self.level)
            oprot.writeFieldEnd()
        if self.cost is not None:
            oprot.writeFieldBegin('cost', TType.I32, 3)
            oprot.writeI32(self.cost)
            oprot.writeFieldEnd()
        if self.link_ids is not None:
            oprot.writeFieldBegin('link_ids', TType.SET, 4)
            oprot.writeSetBegin(TType.STRUCT, len(self.link_ids))
            for iter20 in self.link_ids:
                iter20.write(oprot)
            oprot.writeSetEnd()
            oprot.writeFieldEnd()
        if self.bandwidth is not None:
            oprot.writeFieldBegin('bandwidth', TType.I32, 5)
            oprot.writeI32(self.bandwidth)
            oprot.writeFieldEnd()
        oprot.writeFieldStop()
        oprot.writeStructEnd() 
Example #15
Source File: ttypes.py    From rift-python with Apache License 2.0 5 votes vote down vote up
def read(self, iprot):
        if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None:
            iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec))
            return
        iprot.readStructBegin()
        while True:
            (fname, ftype, fid) = iprot.readFieldBegin()
            if ftype == TType.STOP:
                break
            if fid == 1:
                if ftype == TType.BYTE:
                    self.level = iprot.readByte()
                else:
                    iprot.skip(ftype)
            elif fid == 3:
                if ftype == TType.I32:
                    self.cost = iprot.readI32()
                else:
                    iprot.skip(ftype)
            elif fid == 4:
                if ftype == TType.SET:
                    self.link_ids = set()
                    (_etype17, _size14) = iprot.readSetBegin()
                    for _i18 in range(_size14):
                        _elem19 = LinkIDPair()
                        _elem19.read(iprot)
                        self.link_ids.add(_elem19)
                    iprot.readSetEnd()
                else:
                    iprot.skip(ftype)
            elif fid == 5:
                if ftype == TType.I32:
                    self.bandwidth = iprot.readI32()
                else:
                    iprot.skip(ftype)
            else:
                iprot.skip(ftype)
            iprot.readFieldEnd()
        iprot.readStructEnd() 
Example #16
Source File: ttypes.py    From rift-python with Apache License 2.0 5 votes vote down vote up
def write(self, oprot):
        if oprot._fast_encode is not None and self.thrift_spec is not None:
            oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec)))
            return
        oprot.writeStructBegin('TIREPacket')
        if self.headers is not None:
            oprot.writeFieldBegin('headers', TType.SET, 1)
            oprot.writeSetBegin(TType.STRUCT, len(self.headers))
            for iter13 in self.headers:
                iter13.write(oprot)
            oprot.writeSetEnd()
            oprot.writeFieldEnd()
        oprot.writeFieldStop()
        oprot.writeStructEnd() 
Example #17
Source File: ttypes.py    From rift-python with Apache License 2.0 5 votes vote down vote up
def write(self, oprot):
        if oprot._fast_encode is not None and self.thrift_spec is not None:
            oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec)))
            return
        oprot.writeStructBegin('PrefixAttributes')
        if self.metric is not None:
            oprot.writeFieldBegin('metric', TType.I32, 2)
            oprot.writeI32(self.metric)
            oprot.writeFieldEnd()
        if self.tags is not None:
            oprot.writeFieldBegin('tags', TType.SET, 3)
            oprot.writeSetBegin(TType.I64, len(self.tags))
            for iter43 in self.tags:
                oprot.writeI64(iter43)
            oprot.writeSetEnd()
            oprot.writeFieldEnd()
        if self.monotonic_clock is not None:
            oprot.writeFieldBegin('monotonic_clock', TType.STRUCT, 4)
            self.monotonic_clock.write(oprot)
            oprot.writeFieldEnd()
        if self.loopback is not None:
            oprot.writeFieldBegin('loopback', TType.BOOL, 6)
            oprot.writeBool(self.loopback)
            oprot.writeFieldEnd()
        if self.directly_attached is not None:
            oprot.writeFieldBegin('directly_attached', TType.BOOL, 7)
            oprot.writeBool(self.directly_attached)
            oprot.writeFieldEnd()
        if self.from_link is not None:
            oprot.writeFieldBegin('from_link', TType.I32, 10)
            oprot.writeI32(self.from_link)
            oprot.writeFieldEnd()
        oprot.writeFieldStop()
        oprot.writeStructEnd() 
Example #18
Source File: ttypes.py    From rift-python with Apache License 2.0 5 votes vote down vote up
def write(self, oprot):
        if oprot._fast_encode is not None and self.thrift_spec is not None:
            oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec)))
            return
        oprot.writeStructBegin('NodeNeighborsTIEElement')
        if self.level is not None:
            oprot.writeFieldBegin('level', TType.BYTE, 1)
            oprot.writeByte(self.level)
            oprot.writeFieldEnd()
        if self.cost is not None:
            oprot.writeFieldBegin('cost', TType.I32, 3)
            oprot.writeI32(self.cost)
            oprot.writeFieldEnd()
        if self.link_ids is not None:
            oprot.writeFieldBegin('link_ids', TType.SET, 4)
            oprot.writeSetBegin(TType.STRUCT, len(self.link_ids))
            for iter20 in self.link_ids:
                iter20.write(oprot)
            oprot.writeSetEnd()
            oprot.writeFieldEnd()
        if self.bandwidth is not None:
            oprot.writeFieldBegin('bandwidth', TType.I32, 5)
            oprot.writeI32(self.bandwidth)
            oprot.writeFieldEnd()
        oprot.writeFieldStop()
        oprot.writeStructEnd() 
Example #19
Source File: ttypes.py    From rift-python with Apache License 2.0 5 votes vote down vote up
def read(self, iprot):
        if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None:
            iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec))
            return
        iprot.readStructBegin()
        while True:
            (fname, ftype, fid) = iprot.readFieldBegin()
            if ftype == TType.STOP:
                break
            if fid == 1:
                if ftype == TType.BYTE:
                    self.level = iprot.readByte()
                else:
                    iprot.skip(ftype)
            elif fid == 3:
                if ftype == TType.I32:
                    self.cost = iprot.readI32()
                else:
                    iprot.skip(ftype)
            elif fid == 4:
                if ftype == TType.SET:
                    self.link_ids = set()
                    (_etype17, _size14) = iprot.readSetBegin()
                    for _i18 in range(_size14):
                        _elem19 = LinkIDPair()
                        _elem19.read(iprot)
                        self.link_ids.add(_elem19)
                    iprot.readSetEnd()
                else:
                    iprot.skip(ftype)
            elif fid == 5:
                if ftype == TType.I32:
                    self.bandwidth = iprot.readI32()
                else:
                    iprot.skip(ftype)
            else:
                iprot.skip(ftype)
            iprot.readFieldEnd()
        iprot.readStructEnd() 
Example #20
Source File: TProtocol.py    From Protect4 with GNU General Public License v3.0 4 votes vote down vote up
def skip(self, ttype):
        if ttype == TType.STOP:
            return
        elif ttype == TType.BOOL:
            self.readBool()
        elif ttype == TType.BYTE:
            self.readByte()
        elif ttype == TType.I16:
            self.readI16()
        elif ttype == TType.I32:
            self.readI32()
        elif ttype == TType.I64:
            self.readI64()
        elif ttype == TType.DOUBLE:
            self.readDouble()
        elif ttype == TType.STRING:
            self.readString()
        elif ttype == TType.STRUCT:
            name = self.readStructBegin()
            while True:
                (name, ttype, id) = self.readFieldBegin()
                if ttype == TType.STOP:
                    break
                self.skip(ttype)
                self.readFieldEnd()
            self.readStructEnd()
        elif ttype == TType.MAP:
            (ktype, vtype, size) = self.readMapBegin()
            for i in range(size):
                self.skip(ktype)
                self.skip(vtype)
            self.readMapEnd()
        elif ttype == TType.SET:
            (etype, size) = self.readSetBegin()
            for i in range(size):
                self.skip(etype)
            self.readSetEnd()
        elif ttype == TType.LIST:
            (etype, size) = self.readListBegin()
            for i in range(size):
                self.skip(etype)
            self.readListEnd()

    # tuple of: ( 'reader method' name, is_container bool, 'writer_method' name ) 
Example #21
Source File: TProtocol.py    From Aditmadzs2 with GNU General Public License v3.0 4 votes vote down vote up
def skip(self, ttype):
        if ttype == TType.STOP:
            return
        elif ttype == TType.BOOL:
            self.readBool()
        elif ttype == TType.BYTE:
            self.readByte()
        elif ttype == TType.I16:
            self.readI16()
        elif ttype == TType.I32:
            self.readI32()
        elif ttype == TType.I64:
            self.readI64()
        elif ttype == TType.DOUBLE:
            self.readDouble()
        elif ttype == TType.STRING:
            self.readString()
        elif ttype == TType.STRUCT:
            name = self.readStructBegin()
            while True:
                (name, ttype, id) = self.readFieldBegin()
                if ttype == TType.STOP:
                    break
                self.skip(ttype)
                self.readFieldEnd()
            self.readStructEnd()
        elif ttype == TType.MAP:
            (ktype, vtype, size) = self.readMapBegin()
            for i in range(size):
                self.skip(ktype)
                self.skip(vtype)
            self.readMapEnd()
        elif ttype == TType.SET:
            (etype, size) = self.readSetBegin()
            for i in range(size):
                self.skip(etype)
            self.readSetEnd()
        elif ttype == TType.LIST:
            (etype, size) = self.readListBegin()
            for i in range(size):
                self.skip(etype)
            self.readListEnd()

    # tuple of: ( 'reader method' name, is_container bool, 'writer_method' name ) 
Example #22
Source File: ttypes.py    From rift-python with Apache License 2.0 4 votes vote down vote up
def read(self, iprot):
        if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None:
            iprot._fast_decode(self, iprot, (self.__class__, self.thrift_spec))
            return
        iprot.readStructBegin()
        while True:
            (fname, ftype, fid) = iprot.readFieldBegin()
            if ftype == TType.STOP:
                break
            if fid == 2:
                if ftype == TType.I32:
                    self.metric = iprot.readI32()
                else:
                    iprot.skip(ftype)
            elif fid == 3:
                if ftype == TType.SET:
                    self.tags = set()
                    (_etype40, _size37) = iprot.readSetBegin()
                    for _i41 in range(_size37):
                        _elem42 = iprot.readI64()
                        self.tags.add(_elem42)
                    iprot.readSetEnd()
                else:
                    iprot.skip(ftype)
            elif fid == 4:
                if ftype == TType.STRUCT:
                    self.monotonic_clock = common.ttypes.PrefixSequenceType()
                    self.monotonic_clock.read(iprot)
                else:
                    iprot.skip(ftype)
            elif fid == 6:
                if ftype == TType.BOOL:
                    self.loopback = iprot.readBool()
                else:
                    iprot.skip(ftype)
            elif fid == 7:
                if ftype == TType.BOOL:
                    self.directly_attached = iprot.readBool()
                else:
                    iprot.skip(ftype)
            elif fid == 10:
                if ftype == TType.I32:
                    self.from_link = iprot.readI32()
                else:
                    iprot.skip(ftype)
            else:
                iprot.skip(ftype)
            iprot.readFieldEnd()
        iprot.readStructEnd() 
Example #23
Source File: TProtocol.py    From ajs2 with GNU General Public License v3.0 4 votes vote down vote up
def skip(self, ttype):
        if ttype == TType.STOP:
            return
        elif ttype == TType.BOOL:
            self.readBool()
        elif ttype == TType.BYTE:
            self.readByte()
        elif ttype == TType.I16:
            self.readI16()
        elif ttype == TType.I32:
            self.readI32()
        elif ttype == TType.I64:
            self.readI64()
        elif ttype == TType.DOUBLE:
            self.readDouble()
        elif ttype == TType.STRING:
            self.readString()
        elif ttype == TType.STRUCT:
            name = self.readStructBegin()
            while True:
                (name, ttype, id) = self.readFieldBegin()
                if ttype == TType.STOP:
                    break
                self.skip(ttype)
                self.readFieldEnd()
            self.readStructEnd()
        elif ttype == TType.MAP:
            (ktype, vtype, size) = self.readMapBegin()
            for i in range(size):
                self.skip(ktype)
                self.skip(vtype)
            self.readMapEnd()
        elif ttype == TType.SET:
            (etype, size) = self.readSetBegin()
            for i in range(size):
                self.skip(etype)
            self.readSetEnd()
        elif ttype == TType.LIST:
            (etype, size) = self.readListBegin()
            for i in range(size):
                self.skip(etype)
            self.readListEnd()

    # tuple of: ( 'reader method' name, is_container bool, 'writer_method' name ) 
Example #24
Source File: ttypes.py    From rift-python with Apache License 2.0 4 votes vote down vote up
def write(self, oprot):
        if oprot._fast_encode is not None and self.thrift_spec is not None:
            oprot.trans.write(oprot._fast_encode(self, (self.__class__, self.thrift_spec)))
            return
        oprot.writeStructBegin('NodeTIEElement')
        if self.level is not None:
            oprot.writeFieldBegin('level', TType.BYTE, 1)
            oprot.writeByte(self.level)
            oprot.writeFieldEnd()
        if self.neighbors is not None:
            oprot.writeFieldBegin('neighbors', TType.MAP, 2)
            oprot.writeMapBegin(TType.I64, TType.STRUCT, len(self.neighbors))
            for kiter34, viter35 in self.neighbors.items():
                oprot.writeI64(kiter34)
                viter35.write(oprot)
            oprot.writeMapEnd()
            oprot.writeFieldEnd()
        if self.capabilities is not None:
            oprot.writeFieldBegin('capabilities', TType.STRUCT, 3)
            self.capabilities.write(oprot)
            oprot.writeFieldEnd()
        if self.flags is not None:
            oprot.writeFieldBegin('flags', TType.STRUCT, 4)
            self.flags.write(oprot)
            oprot.writeFieldEnd()
        if self.name is not None:
            oprot.writeFieldBegin('name', TType.STRING, 5)
            oprot.writeString(self.name.encode('utf-8') if sys.version_info[0] == 2 else self.name)
            oprot.writeFieldEnd()
        if self.pod is not None:
            oprot.writeFieldBegin('pod', TType.I32, 6)
            oprot.writeI32(self.pod)
            oprot.writeFieldEnd()
        if self.miscabled_links is not None:
            oprot.writeFieldBegin('miscabled_links', TType.SET, 10)
            oprot.writeSetBegin(TType.I32, len(self.miscabled_links))
            for iter36 in self.miscabled_links:
                oprot.writeI32(iter36)
            oprot.writeSetEnd()
            oprot.writeFieldEnd()
        oprot.writeFieldStop()
        oprot.writeStructEnd()