How to use the pyignite.datatypes.String.parse function in pyignite

To help you get started, we’ve selected a few pyignite examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gridgain / gridgain / modules / platforms / python / pyignite / queries / __init__.py View on Github external
def parse(self, client: 'Client'):
        header_class = self.build_header()
        buffer = client.recv(ctypes.sizeof(header_class))
        header = header_class.from_buffer_copy(buffer)
        fields = []

        if header.status_code == OP_SUCCESS:
            for name, ignite_type in self.following:
                c_type, buffer_fragment = ignite_type.parse(client)
                buffer += buffer_fragment
                fields.append((name, c_type))
        else:
            c_type, buffer_fragment = String.parse(client)
            buffer += buffer_fragment
            fields.append(('error_message', c_type))

        response_class = type(
            'Response',
            (header_class,),
            {
                '_pack_': 1,
                '_fields_': fields,
            }
        )
        return response_class, buffer
github gridgain / gridgain / modules / platforms / python / pyignite / queries / __init__.py View on Github external
data_class = type(
                'SQLResponseData',
                (ctypes.LittleEndianStructure,),
                {
                    '_pack_': 1,
                    '_fields_': data_fields,
                }
            )
            fields += body_class._fields_ + [
                ('data', data_class),
                ('more', ctypes.c_bool),
            ]
            buffer += body_buffer + data_buffer
        else:
            c_type, buffer_fragment = String.parse(client)
            buffer += buffer_fragment
            fields.append(('error_message', c_type))

        final_class = type(
            'SQLResponse',
            (header_class,),
            {
                '_pack_': 1,
                '_fields_': fields,
            }
        )
        buffer += client.recv(ctypes.sizeof(final_class) - len(buffer))
        return final_class, buffer
github gridgain / gridgain / modules / platforms / python / pyignite / queries / response.py View on Github external
def parse(self, client: 'Client'):
        header_class = self.build_header()
        buffer = client.recv(ctypes.sizeof(header_class))
        header = header_class.from_buffer_copy(buffer)
        fields = []

        if header.status_code == OP_SUCCESS:
            for name, ignite_type in self.following:
                c_type, buffer_fragment = ignite_type.parse(client)
                buffer += buffer_fragment
                fields.append((name, c_type))
        else:
            c_type, buffer_fragment = String.parse(client)
            buffer += buffer_fragment
            fields.append(('error_message', c_type))

        response_class = type(
            'Response',
            (header_class,),
            {
                '_pack_': 1,
                '_fields_': fields,
            }
        )
        return response_class, buffer
github gridgain / gridgain / modules / platforms / python / pyignite / queries / response.py View on Github external
buffer = conn.recv(ctypes.sizeof(header_class))
        header = header_class.from_buffer_copy(buffer)
        fields = []

        if header.flags & RHF_TOPOLOGY_CHANGED:
            fields = [
                ('affinity_version', ctypes.c_longlong),
                ('affinity_minor', ctypes.c_int),
            ]

        if header.flags & RHF_ERROR:
            fields.append(('status_code', ctypes.c_int))
            buffer += conn.recv(
                sum([ctypes.sizeof(field[1]) for field in fields])
            )
            msg_type, buffer_fragment = String.parse(conn)
            buffer += buffer_fragment
            fields.append(('error_message', msg_type))

        else:
            buffer += conn.recv(
                sum([ctypes.sizeof(field[1]) for field in fields])
            )
            for name, ignite_type in self.following:
                c_type, buffer_fragment = ignite_type.parse(conn)
                buffer += buffer_fragment
                fields.append((name, c_type))

        response_class = type(
            'Response',
            (header_class,),
            {
github gridgain / gridgain / modules / platforms / python / pyignite / queries / response.py View on Github external
buffer = conn.recv(ctypes.sizeof(header_class))
        header = header_class.from_buffer_copy(buffer)
        fields = []

        if header.flags & RHF_TOPOLOGY_CHANGED:
            fields = [
                ('affinity_version', ctypes.c_longlong),
                ('affinity_minor', ctypes.c_int),
            ]

        if header.flags & RHF_ERROR:
            fields.append(('status_code', ctypes.c_int))
            buffer += conn.recv(
                sum([ctypes.sizeof(field[1]) for field in fields])
            )
            msg_type, buffer_fragment = String.parse(conn)
            buffer += buffer_fragment
            fields.append(('error_message', msg_type))
        else:
            buffer += conn.recv(
                sum([ctypes.sizeof(field[1]) for field in fields])
            )
            following = [
                self.fields_or_field_count(),
                ('row_count', Int),
            ]
            if self.has_cursor:
                following.insert(0, ('cursor', Long))
            body_struct = Struct(following)
            body_class, body_buffer = body_struct.parse(conn)
            body = body_class.from_buffer_copy(body_buffer)