diff --git a/cpp/src/thrift/gen-py/__init__.py b/cpp/src/thrift/gen-py/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/cpp/src/thrift/gen-py/zilliz/VecService-remote b/cpp/src/thrift/gen-py/zilliz/VecService-remote new file mode 100755 index 0000000000..a4732586b2 --- /dev/null +++ b/cpp/src/thrift/gen-py/zilliz/VecService-remote @@ -0,0 +1,187 @@ +#!/usr/bin/env python +# +# Autogenerated by Thrift Compiler (0.12.0) +# +# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +# +# options string: py +# + +import sys +import pprint +if sys.version_info[0] > 2: + from urllib.parse import urlparse +else: + from urlparse import urlparse +from thrift.transport import TTransport, TSocket, TSSLSocket, THttpClient +from thrift.protocol.TBinaryProtocol import TBinaryProtocol + +from zilliz import VecService +from zilliz.ttypes import * + +if len(sys.argv) <= 1 or sys.argv[1] == '--help': + print('') + print('Usage: ' + sys.argv[0] + ' [-h host[:port]] [-u url] [-f[ramed]] [-s[sl]] [-novalidate] [-ca_certs certs] [-keyfile keyfile] [-certfile certfile] function [arg1 [arg2...]]') + print('') + print('Functions:') + print(' void add_group(VecGroup group)') + print(' VecGroup get_group(string group_id)') + print(' void del_group(string group_id)') + print(' void add_vector(string group_id, VecTensor tensor)') + print(' void add_vector_batch(string group_id, VecTensorList tensor_list)') + print(' void add_binary_vector(string group_id, VecBinaryTensor tensor)') + print(' void add_binary_vector_batch(string group_id, VecBinaryTensorList tensor_list)') + print(' VecSearchResult search_vector(string group_id, i64 top_k, VecTensor tensor, VecSearchFilter filter)') + print(' VecSearchResultList search_vector_batch(string group_id, i64 top_k, VecTensorList tensor_list, VecSearchFilter filter)') + print(' VecSearchResult search_binary_vector(string group_id, i64 top_k, VecBinaryTensor tensor, VecSearchFilter filter)') + print(' VecSearchResultList search_binary_vector_batch(string group_id, i64 top_k, VecBinaryTensorList tensor_list, VecSearchFilter filter)') + print('') + sys.exit(0) + +pp = pprint.PrettyPrinter(indent=2) +host = 'localhost' +port = 9090 +uri = '' +framed = False +ssl = False +validate = True +ca_certs = None +keyfile = None +certfile = None +http = False +argi = 1 + +if sys.argv[argi] == '-h': + parts = sys.argv[argi + 1].split(':') + host = parts[0] + if len(parts) > 1: + port = int(parts[1]) + argi += 2 + +if sys.argv[argi] == '-u': + url = urlparse(sys.argv[argi + 1]) + parts = url[1].split(':') + host = parts[0] + if len(parts) > 1: + port = int(parts[1]) + else: + port = 80 + uri = url[2] + if url[4]: + uri += '?%s' % url[4] + http = True + argi += 2 + +if sys.argv[argi] == '-f' or sys.argv[argi] == '-framed': + framed = True + argi += 1 + +if sys.argv[argi] == '-s' or sys.argv[argi] == '-ssl': + ssl = True + argi += 1 + +if sys.argv[argi] == '-novalidate': + validate = False + argi += 1 + +if sys.argv[argi] == '-ca_certs': + ca_certs = sys.argv[argi+1] + argi += 2 + +if sys.argv[argi] == '-keyfile': + keyfile = sys.argv[argi+1] + argi += 2 + +if sys.argv[argi] == '-certfile': + certfile = sys.argv[argi+1] + argi += 2 + +cmd = sys.argv[argi] +args = sys.argv[argi + 1:] + +if http: + transport = THttpClient.THttpClient(host, port, uri) +else: + if ssl: + socket = TSSLSocket.TSSLSocket(host, port, validate=validate, ca_certs=ca_certs, keyfile=keyfile, certfile=certfile) + else: + socket = TSocket.TSocket(host, port) + if framed: + transport = TTransport.TFramedTransport(socket) + else: + transport = TTransport.TBufferedTransport(socket) +protocol = TBinaryProtocol(transport) +client = VecService.Client(protocol) +transport.open() + +if cmd == 'add_group': + if len(args) != 1: + print('add_group requires 1 args') + sys.exit(1) + pp.pprint(client.add_group(eval(args[0]),)) + +elif cmd == 'get_group': + if len(args) != 1: + print('get_group requires 1 args') + sys.exit(1) + pp.pprint(client.get_group(args[0],)) + +elif cmd == 'del_group': + if len(args) != 1: + print('del_group requires 1 args') + sys.exit(1) + pp.pprint(client.del_group(args[0],)) + +elif cmd == 'add_vector': + if len(args) != 2: + print('add_vector requires 2 args') + sys.exit(1) + pp.pprint(client.add_vector(args[0], eval(args[1]),)) + +elif cmd == 'add_vector_batch': + if len(args) != 2: + print('add_vector_batch requires 2 args') + sys.exit(1) + pp.pprint(client.add_vector_batch(args[0], eval(args[1]),)) + +elif cmd == 'add_binary_vector': + if len(args) != 2: + print('add_binary_vector requires 2 args') + sys.exit(1) + pp.pprint(client.add_binary_vector(args[0], eval(args[1]),)) + +elif cmd == 'add_binary_vector_batch': + if len(args) != 2: + print('add_binary_vector_batch requires 2 args') + sys.exit(1) + pp.pprint(client.add_binary_vector_batch(args[0], eval(args[1]),)) + +elif cmd == 'search_vector': + if len(args) != 4: + print('search_vector requires 4 args') + sys.exit(1) + pp.pprint(client.search_vector(args[0], eval(args[1]), eval(args[2]), eval(args[3]),)) + +elif cmd == 'search_vector_batch': + if len(args) != 4: + print('search_vector_batch requires 4 args') + sys.exit(1) + pp.pprint(client.search_vector_batch(args[0], eval(args[1]), eval(args[2]), eval(args[3]),)) + +elif cmd == 'search_binary_vector': + if len(args) != 4: + print('search_binary_vector requires 4 args') + sys.exit(1) + pp.pprint(client.search_binary_vector(args[0], eval(args[1]), eval(args[2]), eval(args[3]),)) + +elif cmd == 'search_binary_vector_batch': + if len(args) != 4: + print('search_binary_vector_batch requires 4 args') + sys.exit(1) + pp.pprint(client.search_binary_vector_batch(args[0], eval(args[1]), eval(args[2]), eval(args[3]),)) + +else: + print('Unrecognized method %s' % cmd) + sys.exit(1) + +transport.close() diff --git a/cpp/src/thrift/gen-py/zilliz/VecService.py b/cpp/src/thrift/gen-py/zilliz/VecService.py new file mode 100644 index 0000000000..021dadc08d --- /dev/null +++ b/cpp/src/thrift/gen-py/zilliz/VecService.py @@ -0,0 +1,2524 @@ +# +# Autogenerated by Thrift Compiler (0.12.0) +# +# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +# +# options string: py +# + +from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, TApplicationException +from thrift.protocol.TProtocol import TProtocolException +from thrift.TRecursive import fix_spec + +import sys +import logging +from .ttypes import * +from thrift.Thrift import TProcessor +from thrift.transport import TTransport +all_structs = [] + + +class Iface(object): + def add_group(self, group): + """ + group interfaces + + Parameters: + - group + + """ + pass + + def get_group(self, group_id): + """ + Parameters: + - group_id + + """ + pass + + def del_group(self, group_id): + """ + Parameters: + - group_id + + """ + pass + + def add_vector(self, group_id, tensor): + """ + insert vector interfaces + + + Parameters: + - group_id + - tensor + + """ + pass + + def add_vector_batch(self, group_id, tensor_list): + """ + Parameters: + - group_id + - tensor_list + + """ + pass + + def add_binary_vector(self, group_id, tensor): + """ + Parameters: + - group_id + - tensor + + """ + pass + + def add_binary_vector_batch(self, group_id, tensor_list): + """ + Parameters: + - group_id + - tensor_list + + """ + pass + + def search_vector(self, group_id, top_k, tensor, filter): + """ + search interfaces + you can use filter to reduce search result + filter.attrib_filter can specify which attribute you need, for example: + set attrib_filter = {"color":""} means you want to get "color" attribute for result vector + set attrib_filter = {"color":"red"} means you want to get vectors which has attribute "color" equals "red" + if filter.time_range is empty, engine will search without time limit + + Parameters: + - group_id + - top_k + - tensor + - filter + + """ + pass + + def search_vector_batch(self, group_id, top_k, tensor_list, filter): + """ + Parameters: + - group_id + - top_k + - tensor_list + - filter + + """ + pass + + def search_binary_vector(self, group_id, top_k, tensor, filter): + """ + Parameters: + - group_id + - top_k + - tensor + - filter + + """ + pass + + def search_binary_vector_batch(self, group_id, top_k, tensor_list, filter): + """ + Parameters: + - group_id + - top_k + - tensor_list + - filter + + """ + pass + + +class Client(Iface): + def __init__(self, iprot, oprot=None): + self._iprot = self._oprot = iprot + if oprot is not None: + self._oprot = oprot + self._seqid = 0 + + def add_group(self, group): + """ + group interfaces + + Parameters: + - group + + """ + self.send_add_group(group) + self.recv_add_group() + + def send_add_group(self, group): + self._oprot.writeMessageBegin('add_group', TMessageType.CALL, self._seqid) + args = add_group_args() + args.group = group + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_add_group(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = add_group_result() + result.read(iprot) + iprot.readMessageEnd() + if result.e is not None: + raise result.e + return + + def get_group(self, group_id): + """ + Parameters: + - group_id + + """ + self.send_get_group(group_id) + return self.recv_get_group() + + def send_get_group(self, group_id): + self._oprot.writeMessageBegin('get_group', TMessageType.CALL, self._seqid) + args = get_group_args() + args.group_id = group_id + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_get_group(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = get_group_result() + result.read(iprot) + iprot.readMessageEnd() + if result.success is not None: + return result.success + if result.e is not None: + raise result.e + raise TApplicationException(TApplicationException.MISSING_RESULT, "get_group failed: unknown result") + + def del_group(self, group_id): + """ + Parameters: + - group_id + + """ + self.send_del_group(group_id) + self.recv_del_group() + + def send_del_group(self, group_id): + self._oprot.writeMessageBegin('del_group', TMessageType.CALL, self._seqid) + args = del_group_args() + args.group_id = group_id + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_del_group(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = del_group_result() + result.read(iprot) + iprot.readMessageEnd() + if result.e is not None: + raise result.e + return + + def add_vector(self, group_id, tensor): + """ + insert vector interfaces + + + Parameters: + - group_id + - tensor + + """ + self.send_add_vector(group_id, tensor) + self.recv_add_vector() + + def send_add_vector(self, group_id, tensor): + self._oprot.writeMessageBegin('add_vector', TMessageType.CALL, self._seqid) + args = add_vector_args() + args.group_id = group_id + args.tensor = tensor + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_add_vector(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = add_vector_result() + result.read(iprot) + iprot.readMessageEnd() + if result.e is not None: + raise result.e + return + + def add_vector_batch(self, group_id, tensor_list): + """ + Parameters: + - group_id + - tensor_list + + """ + self.send_add_vector_batch(group_id, tensor_list) + self.recv_add_vector_batch() + + def send_add_vector_batch(self, group_id, tensor_list): + self._oprot.writeMessageBegin('add_vector_batch', TMessageType.CALL, self._seqid) + args = add_vector_batch_args() + args.group_id = group_id + args.tensor_list = tensor_list + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_add_vector_batch(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = add_vector_batch_result() + result.read(iprot) + iprot.readMessageEnd() + if result.e is not None: + raise result.e + return + + def add_binary_vector(self, group_id, tensor): + """ + Parameters: + - group_id + - tensor + + """ + self.send_add_binary_vector(group_id, tensor) + self.recv_add_binary_vector() + + def send_add_binary_vector(self, group_id, tensor): + self._oprot.writeMessageBegin('add_binary_vector', TMessageType.CALL, self._seqid) + args = add_binary_vector_args() + args.group_id = group_id + args.tensor = tensor + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_add_binary_vector(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = add_binary_vector_result() + result.read(iprot) + iprot.readMessageEnd() + if result.e is not None: + raise result.e + return + + def add_binary_vector_batch(self, group_id, tensor_list): + """ + Parameters: + - group_id + - tensor_list + + """ + self.send_add_binary_vector_batch(group_id, tensor_list) + self.recv_add_binary_vector_batch() + + def send_add_binary_vector_batch(self, group_id, tensor_list): + self._oprot.writeMessageBegin('add_binary_vector_batch', TMessageType.CALL, self._seqid) + args = add_binary_vector_batch_args() + args.group_id = group_id + args.tensor_list = tensor_list + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_add_binary_vector_batch(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = add_binary_vector_batch_result() + result.read(iprot) + iprot.readMessageEnd() + if result.e is not None: + raise result.e + return + + def search_vector(self, group_id, top_k, tensor, filter): + """ + search interfaces + you can use filter to reduce search result + filter.attrib_filter can specify which attribute you need, for example: + set attrib_filter = {"color":""} means you want to get "color" attribute for result vector + set attrib_filter = {"color":"red"} means you want to get vectors which has attribute "color" equals "red" + if filter.time_range is empty, engine will search without time limit + + Parameters: + - group_id + - top_k + - tensor + - filter + + """ + self.send_search_vector(group_id, top_k, tensor, filter) + return self.recv_search_vector() + + def send_search_vector(self, group_id, top_k, tensor, filter): + self._oprot.writeMessageBegin('search_vector', TMessageType.CALL, self._seqid) + args = search_vector_args() + args.group_id = group_id + args.top_k = top_k + args.tensor = tensor + args.filter = filter + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_search_vector(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = search_vector_result() + result.read(iprot) + iprot.readMessageEnd() + if result.success is not None: + return result.success + if result.e is not None: + raise result.e + raise TApplicationException(TApplicationException.MISSING_RESULT, "search_vector failed: unknown result") + + def search_vector_batch(self, group_id, top_k, tensor_list, filter): + """ + Parameters: + - group_id + - top_k + - tensor_list + - filter + + """ + self.send_search_vector_batch(group_id, top_k, tensor_list, filter) + return self.recv_search_vector_batch() + + def send_search_vector_batch(self, group_id, top_k, tensor_list, filter): + self._oprot.writeMessageBegin('search_vector_batch', TMessageType.CALL, self._seqid) + args = search_vector_batch_args() + args.group_id = group_id + args.top_k = top_k + args.tensor_list = tensor_list + args.filter = filter + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_search_vector_batch(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = search_vector_batch_result() + result.read(iprot) + iprot.readMessageEnd() + if result.success is not None: + return result.success + if result.e is not None: + raise result.e + raise TApplicationException(TApplicationException.MISSING_RESULT, "search_vector_batch failed: unknown result") + + def search_binary_vector(self, group_id, top_k, tensor, filter): + """ + Parameters: + - group_id + - top_k + - tensor + - filter + + """ + self.send_search_binary_vector(group_id, top_k, tensor, filter) + return self.recv_search_binary_vector() + + def send_search_binary_vector(self, group_id, top_k, tensor, filter): + self._oprot.writeMessageBegin('search_binary_vector', TMessageType.CALL, self._seqid) + args = search_binary_vector_args() + args.group_id = group_id + args.top_k = top_k + args.tensor = tensor + args.filter = filter + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_search_binary_vector(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = search_binary_vector_result() + result.read(iprot) + iprot.readMessageEnd() + if result.success is not None: + return result.success + if result.e is not None: + raise result.e + raise TApplicationException(TApplicationException.MISSING_RESULT, "search_binary_vector failed: unknown result") + + def search_binary_vector_batch(self, group_id, top_k, tensor_list, filter): + """ + Parameters: + - group_id + - top_k + - tensor_list + - filter + + """ + self.send_search_binary_vector_batch(group_id, top_k, tensor_list, filter) + return self.recv_search_binary_vector_batch() + + def send_search_binary_vector_batch(self, group_id, top_k, tensor_list, filter): + self._oprot.writeMessageBegin('search_binary_vector_batch', TMessageType.CALL, self._seqid) + args = search_binary_vector_batch_args() + args.group_id = group_id + args.top_k = top_k + args.tensor_list = tensor_list + args.filter = filter + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_search_binary_vector_batch(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = search_binary_vector_batch_result() + result.read(iprot) + iprot.readMessageEnd() + if result.success is not None: + return result.success + if result.e is not None: + raise result.e + raise TApplicationException(TApplicationException.MISSING_RESULT, "search_binary_vector_batch failed: unknown result") + + +class Processor(Iface, TProcessor): + def __init__(self, handler): + self._handler = handler + self._processMap = {} + self._processMap["add_group"] = Processor.process_add_group + self._processMap["get_group"] = Processor.process_get_group + self._processMap["del_group"] = Processor.process_del_group + self._processMap["add_vector"] = Processor.process_add_vector + self._processMap["add_vector_batch"] = Processor.process_add_vector_batch + self._processMap["add_binary_vector"] = Processor.process_add_binary_vector + self._processMap["add_binary_vector_batch"] = Processor.process_add_binary_vector_batch + self._processMap["search_vector"] = Processor.process_search_vector + self._processMap["search_vector_batch"] = Processor.process_search_vector_batch + self._processMap["search_binary_vector"] = Processor.process_search_binary_vector + self._processMap["search_binary_vector_batch"] = Processor.process_search_binary_vector_batch + + def process(self, iprot, oprot): + (name, type, seqid) = iprot.readMessageBegin() + if name not in self._processMap: + iprot.skip(TType.STRUCT) + iprot.readMessageEnd() + x = TApplicationException(TApplicationException.UNKNOWN_METHOD, 'Unknown function %s' % (name)) + oprot.writeMessageBegin(name, TMessageType.EXCEPTION, seqid) + x.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + return + else: + self._processMap[name](self, seqid, iprot, oprot) + return True + + def process_add_group(self, seqid, iprot, oprot): + args = add_group_args() + args.read(iprot) + iprot.readMessageEnd() + result = add_group_result() + try: + self._handler.add_group(args.group) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except VecException as e: + msg_type = TMessageType.REPLY + result.e = e + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("add_group", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_get_group(self, seqid, iprot, oprot): + args = get_group_args() + args.read(iprot) + iprot.readMessageEnd() + result = get_group_result() + try: + result.success = self._handler.get_group(args.group_id) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except VecException as e: + msg_type = TMessageType.REPLY + result.e = e + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("get_group", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_del_group(self, seqid, iprot, oprot): + args = del_group_args() + args.read(iprot) + iprot.readMessageEnd() + result = del_group_result() + try: + self._handler.del_group(args.group_id) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except VecException as e: + msg_type = TMessageType.REPLY + result.e = e + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("del_group", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_add_vector(self, seqid, iprot, oprot): + args = add_vector_args() + args.read(iprot) + iprot.readMessageEnd() + result = add_vector_result() + try: + self._handler.add_vector(args.group_id, args.tensor) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except VecException as e: + msg_type = TMessageType.REPLY + result.e = e + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("add_vector", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_add_vector_batch(self, seqid, iprot, oprot): + args = add_vector_batch_args() + args.read(iprot) + iprot.readMessageEnd() + result = add_vector_batch_result() + try: + self._handler.add_vector_batch(args.group_id, args.tensor_list) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except VecException as e: + msg_type = TMessageType.REPLY + result.e = e + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("add_vector_batch", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_add_binary_vector(self, seqid, iprot, oprot): + args = add_binary_vector_args() + args.read(iprot) + iprot.readMessageEnd() + result = add_binary_vector_result() + try: + self._handler.add_binary_vector(args.group_id, args.tensor) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except VecException as e: + msg_type = TMessageType.REPLY + result.e = e + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("add_binary_vector", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_add_binary_vector_batch(self, seqid, iprot, oprot): + args = add_binary_vector_batch_args() + args.read(iprot) + iprot.readMessageEnd() + result = add_binary_vector_batch_result() + try: + self._handler.add_binary_vector_batch(args.group_id, args.tensor_list) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except VecException as e: + msg_type = TMessageType.REPLY + result.e = e + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("add_binary_vector_batch", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_search_vector(self, seqid, iprot, oprot): + args = search_vector_args() + args.read(iprot) + iprot.readMessageEnd() + result = search_vector_result() + try: + result.success = self._handler.search_vector(args.group_id, args.top_k, args.tensor, args.filter) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except VecException as e: + msg_type = TMessageType.REPLY + result.e = e + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("search_vector", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_search_vector_batch(self, seqid, iprot, oprot): + args = search_vector_batch_args() + args.read(iprot) + iprot.readMessageEnd() + result = search_vector_batch_result() + try: + result.success = self._handler.search_vector_batch(args.group_id, args.top_k, args.tensor_list, args.filter) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except VecException as e: + msg_type = TMessageType.REPLY + result.e = e + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("search_vector_batch", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_search_binary_vector(self, seqid, iprot, oprot): + args = search_binary_vector_args() + args.read(iprot) + iprot.readMessageEnd() + result = search_binary_vector_result() + try: + result.success = self._handler.search_binary_vector(args.group_id, args.top_k, args.tensor, args.filter) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except VecException as e: + msg_type = TMessageType.REPLY + result.e = e + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("search_binary_vector", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_search_binary_vector_batch(self, seqid, iprot, oprot): + args = search_binary_vector_batch_args() + args.read(iprot) + iprot.readMessageEnd() + result = search_binary_vector_batch_result() + try: + result.success = self._handler.search_binary_vector_batch(args.group_id, args.top_k, args.tensor_list, args.filter) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except VecException as e: + msg_type = TMessageType.REPLY + result.e = e + except TApplicationException as ex: + logging.exception('TApplication exception in handler') + msg_type = TMessageType.EXCEPTION + result = ex + except Exception: + logging.exception('Unexpected exception in handler') + msg_type = TMessageType.EXCEPTION + result = TApplicationException(TApplicationException.INTERNAL_ERROR, 'Internal error') + oprot.writeMessageBegin("search_binary_vector_batch", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + +# HELPER FUNCTIONS AND STRUCTURES + + +class add_group_args(object): + """ + Attributes: + - group + + """ + + + def __init__(self, group=None,): + self.group = group + + 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.STRUCT: + self.group = VecGroup() + self.group.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + 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('add_group_args') + if self.group is not None: + oprot.writeFieldBegin('group', TType.STRUCT, 2) + self.group.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(add_group_args) +add_group_args.thrift_spec = ( + None, # 0 + None, # 1 + (2, TType.STRUCT, 'group', [VecGroup, None], None, ), # 2 +) + + +class add_group_result(object): + """ + Attributes: + - e + + """ + + + def __init__(self, e=None,): + self.e = e + + 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.STRUCT: + self.e = VecException() + self.e.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + 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('add_group_result') + if self.e is not None: + oprot.writeFieldBegin('e', TType.STRUCT, 1) + self.e.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(add_group_result) +add_group_result.thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'e', [VecException, None], None, ), # 1 +) + + +class get_group_args(object): + """ + Attributes: + - group_id + + """ + + + def __init__(self, group_id=None,): + self.group_id = group_id + + 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.STRING: + self.group_id = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + 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('get_group_args') + if self.group_id is not None: + oprot.writeFieldBegin('group_id', TType.STRING, 2) + oprot.writeString(self.group_id.encode('utf-8') if sys.version_info[0] == 2 else self.group_id) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(get_group_args) +get_group_args.thrift_spec = ( + None, # 0 + None, # 1 + (2, TType.STRING, 'group_id', 'UTF8', None, ), # 2 +) + + +class get_group_result(object): + """ + Attributes: + - success + - e + + """ + + + def __init__(self, success=None, e=None,): + self.success = success + self.e = e + + 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 == 0: + if ftype == TType.STRUCT: + self.success = VecGroup() + self.success.read(iprot) + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.e = VecException() + self.e.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + 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('get_group_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.STRUCT, 0) + self.success.write(oprot) + oprot.writeFieldEnd() + if self.e is not None: + oprot.writeFieldBegin('e', TType.STRUCT, 1) + self.e.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(get_group_result) +get_group_result.thrift_spec = ( + (0, TType.STRUCT, 'success', [VecGroup, None], None, ), # 0 + (1, TType.STRUCT, 'e', [VecException, None], None, ), # 1 +) + + +class del_group_args(object): + """ + Attributes: + - group_id + + """ + + + def __init__(self, group_id=None,): + self.group_id = group_id + + 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.STRING: + self.group_id = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + 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('del_group_args') + if self.group_id is not None: + oprot.writeFieldBegin('group_id', TType.STRING, 2) + oprot.writeString(self.group_id.encode('utf-8') if sys.version_info[0] == 2 else self.group_id) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(del_group_args) +del_group_args.thrift_spec = ( + None, # 0 + None, # 1 + (2, TType.STRING, 'group_id', 'UTF8', None, ), # 2 +) + + +class del_group_result(object): + """ + Attributes: + - e + + """ + + + def __init__(self, e=None,): + self.e = e + + 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.STRUCT: + self.e = VecException() + self.e.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + 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('del_group_result') + if self.e is not None: + oprot.writeFieldBegin('e', TType.STRUCT, 1) + self.e.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(del_group_result) +del_group_result.thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'e', [VecException, None], None, ), # 1 +) + + +class add_vector_args(object): + """ + Attributes: + - group_id + - tensor + + """ + + + def __init__(self, group_id=None, tensor=None,): + self.group_id = group_id + self.tensor = tensor + + 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.STRING: + self.group_id = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.STRUCT: + self.tensor = VecTensor() + self.tensor.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + 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('add_vector_args') + if self.group_id is not None: + oprot.writeFieldBegin('group_id', TType.STRING, 2) + oprot.writeString(self.group_id.encode('utf-8') if sys.version_info[0] == 2 else self.group_id) + oprot.writeFieldEnd() + if self.tensor is not None: + oprot.writeFieldBegin('tensor', TType.STRUCT, 3) + self.tensor.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(add_vector_args) +add_vector_args.thrift_spec = ( + None, # 0 + None, # 1 + (2, TType.STRING, 'group_id', 'UTF8', None, ), # 2 + (3, TType.STRUCT, 'tensor', [VecTensor, None], None, ), # 3 +) + + +class add_vector_result(object): + """ + Attributes: + - e + + """ + + + def __init__(self, e=None,): + self.e = e + + 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.STRUCT: + self.e = VecException() + self.e.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + 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('add_vector_result') + if self.e is not None: + oprot.writeFieldBegin('e', TType.STRUCT, 1) + self.e.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(add_vector_result) +add_vector_result.thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'e', [VecException, None], None, ), # 1 +) + + +class add_vector_batch_args(object): + """ + Attributes: + - group_id + - tensor_list + + """ + + + def __init__(self, group_id=None, tensor_list=None,): + self.group_id = group_id + self.tensor_list = tensor_list + + 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.STRING: + self.group_id = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.STRUCT: + self.tensor_list = VecTensorList() + self.tensor_list.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + 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('add_vector_batch_args') + if self.group_id is not None: + oprot.writeFieldBegin('group_id', TType.STRING, 2) + oprot.writeString(self.group_id.encode('utf-8') if sys.version_info[0] == 2 else self.group_id) + oprot.writeFieldEnd() + if self.tensor_list is not None: + oprot.writeFieldBegin('tensor_list', TType.STRUCT, 3) + self.tensor_list.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(add_vector_batch_args) +add_vector_batch_args.thrift_spec = ( + None, # 0 + None, # 1 + (2, TType.STRING, 'group_id', 'UTF8', None, ), # 2 + (3, TType.STRUCT, 'tensor_list', [VecTensorList, None], None, ), # 3 +) + + +class add_vector_batch_result(object): + """ + Attributes: + - e + + """ + + + def __init__(self, e=None,): + self.e = e + + 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.STRUCT: + self.e = VecException() + self.e.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + 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('add_vector_batch_result') + if self.e is not None: + oprot.writeFieldBegin('e', TType.STRUCT, 1) + self.e.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(add_vector_batch_result) +add_vector_batch_result.thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'e', [VecException, None], None, ), # 1 +) + + +class add_binary_vector_args(object): + """ + Attributes: + - group_id + - tensor + + """ + + + def __init__(self, group_id=None, tensor=None,): + self.group_id = group_id + self.tensor = tensor + + 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.STRING: + self.group_id = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.STRUCT: + self.tensor = VecBinaryTensor() + self.tensor.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + 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('add_binary_vector_args') + if self.group_id is not None: + oprot.writeFieldBegin('group_id', TType.STRING, 2) + oprot.writeString(self.group_id.encode('utf-8') if sys.version_info[0] == 2 else self.group_id) + oprot.writeFieldEnd() + if self.tensor is not None: + oprot.writeFieldBegin('tensor', TType.STRUCT, 3) + self.tensor.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(add_binary_vector_args) +add_binary_vector_args.thrift_spec = ( + None, # 0 + None, # 1 + (2, TType.STRING, 'group_id', 'UTF8', None, ), # 2 + (3, TType.STRUCT, 'tensor', [VecBinaryTensor, None], None, ), # 3 +) + + +class add_binary_vector_result(object): + """ + Attributes: + - e + + """ + + + def __init__(self, e=None,): + self.e = e + + 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.STRUCT: + self.e = VecException() + self.e.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + 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('add_binary_vector_result') + if self.e is not None: + oprot.writeFieldBegin('e', TType.STRUCT, 1) + self.e.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(add_binary_vector_result) +add_binary_vector_result.thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'e', [VecException, None], None, ), # 1 +) + + +class add_binary_vector_batch_args(object): + """ + Attributes: + - group_id + - tensor_list + + """ + + + def __init__(self, group_id=None, tensor_list=None,): + self.group_id = group_id + self.tensor_list = tensor_list + + 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.STRING: + self.group_id = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.STRUCT: + self.tensor_list = VecBinaryTensorList() + self.tensor_list.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + 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('add_binary_vector_batch_args') + if self.group_id is not None: + oprot.writeFieldBegin('group_id', TType.STRING, 2) + oprot.writeString(self.group_id.encode('utf-8') if sys.version_info[0] == 2 else self.group_id) + oprot.writeFieldEnd() + if self.tensor_list is not None: + oprot.writeFieldBegin('tensor_list', TType.STRUCT, 3) + self.tensor_list.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(add_binary_vector_batch_args) +add_binary_vector_batch_args.thrift_spec = ( + None, # 0 + None, # 1 + (2, TType.STRING, 'group_id', 'UTF8', None, ), # 2 + (3, TType.STRUCT, 'tensor_list', [VecBinaryTensorList, None], None, ), # 3 +) + + +class add_binary_vector_batch_result(object): + """ + Attributes: + - e + + """ + + + def __init__(self, e=None,): + self.e = e + + 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.STRUCT: + self.e = VecException() + self.e.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + 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('add_binary_vector_batch_result') + if self.e is not None: + oprot.writeFieldBegin('e', TType.STRUCT, 1) + self.e.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(add_binary_vector_batch_result) +add_binary_vector_batch_result.thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'e', [VecException, None], None, ), # 1 +) + + +class search_vector_args(object): + """ + Attributes: + - group_id + - top_k + - tensor + - filter + + """ + + + def __init__(self, group_id=None, top_k=None, tensor=None, filter=None,): + self.group_id = group_id + self.top_k = top_k + self.tensor = tensor + self.filter = filter + + 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.STRING: + self.group_id = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.I64: + self.top_k = iprot.readI64() + else: + iprot.skip(ftype) + elif fid == 4: + if ftype == TType.STRUCT: + self.tensor = VecTensor() + self.tensor.read(iprot) + else: + iprot.skip(ftype) + elif fid == 5: + if ftype == TType.STRUCT: + self.filter = VecSearchFilter() + self.filter.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + 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('search_vector_args') + if self.group_id is not None: + oprot.writeFieldBegin('group_id', TType.STRING, 2) + oprot.writeString(self.group_id.encode('utf-8') if sys.version_info[0] == 2 else self.group_id) + oprot.writeFieldEnd() + if self.top_k is not None: + oprot.writeFieldBegin('top_k', TType.I64, 3) + oprot.writeI64(self.top_k) + oprot.writeFieldEnd() + if self.tensor is not None: + oprot.writeFieldBegin('tensor', TType.STRUCT, 4) + self.tensor.write(oprot) + oprot.writeFieldEnd() + if self.filter is not None: + oprot.writeFieldBegin('filter', TType.STRUCT, 5) + self.filter.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(search_vector_args) +search_vector_args.thrift_spec = ( + None, # 0 + None, # 1 + (2, TType.STRING, 'group_id', 'UTF8', None, ), # 2 + (3, TType.I64, 'top_k', None, None, ), # 3 + (4, TType.STRUCT, 'tensor', [VecTensor, None], None, ), # 4 + (5, TType.STRUCT, 'filter', [VecSearchFilter, None], None, ), # 5 +) + + +class search_vector_result(object): + """ + Attributes: + - success + - e + + """ + + + def __init__(self, success=None, e=None,): + self.success = success + self.e = e + + 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 == 0: + if ftype == TType.STRUCT: + self.success = VecSearchResult() + self.success.read(iprot) + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.e = VecException() + self.e.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + 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('search_vector_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.STRUCT, 0) + self.success.write(oprot) + oprot.writeFieldEnd() + if self.e is not None: + oprot.writeFieldBegin('e', TType.STRUCT, 1) + self.e.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(search_vector_result) +search_vector_result.thrift_spec = ( + (0, TType.STRUCT, 'success', [VecSearchResult, None], None, ), # 0 + (1, TType.STRUCT, 'e', [VecException, None], None, ), # 1 +) + + +class search_vector_batch_args(object): + """ + Attributes: + - group_id + - top_k + - tensor_list + - filter + + """ + + + def __init__(self, group_id=None, top_k=None, tensor_list=None, filter=None,): + self.group_id = group_id + self.top_k = top_k + self.tensor_list = tensor_list + self.filter = filter + + 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.STRING: + self.group_id = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.I64: + self.top_k = iprot.readI64() + else: + iprot.skip(ftype) + elif fid == 4: + if ftype == TType.STRUCT: + self.tensor_list = VecTensorList() + self.tensor_list.read(iprot) + else: + iprot.skip(ftype) + elif fid == 5: + if ftype == TType.STRUCT: + self.filter = VecSearchFilter() + self.filter.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + 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('search_vector_batch_args') + if self.group_id is not None: + oprot.writeFieldBegin('group_id', TType.STRING, 2) + oprot.writeString(self.group_id.encode('utf-8') if sys.version_info[0] == 2 else self.group_id) + oprot.writeFieldEnd() + if self.top_k is not None: + oprot.writeFieldBegin('top_k', TType.I64, 3) + oprot.writeI64(self.top_k) + oprot.writeFieldEnd() + if self.tensor_list is not None: + oprot.writeFieldBegin('tensor_list', TType.STRUCT, 4) + self.tensor_list.write(oprot) + oprot.writeFieldEnd() + if self.filter is not None: + oprot.writeFieldBegin('filter', TType.STRUCT, 5) + self.filter.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(search_vector_batch_args) +search_vector_batch_args.thrift_spec = ( + None, # 0 + None, # 1 + (2, TType.STRING, 'group_id', 'UTF8', None, ), # 2 + (3, TType.I64, 'top_k', None, None, ), # 3 + (4, TType.STRUCT, 'tensor_list', [VecTensorList, None], None, ), # 4 + (5, TType.STRUCT, 'filter', [VecSearchFilter, None], None, ), # 5 +) + + +class search_vector_batch_result(object): + """ + Attributes: + - success + - e + + """ + + + def __init__(self, success=None, e=None,): + self.success = success + self.e = e + + 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 == 0: + if ftype == TType.STRUCT: + self.success = VecSearchResultList() + self.success.read(iprot) + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.e = VecException() + self.e.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + 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('search_vector_batch_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.STRUCT, 0) + self.success.write(oprot) + oprot.writeFieldEnd() + if self.e is not None: + oprot.writeFieldBegin('e', TType.STRUCT, 1) + self.e.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(search_vector_batch_result) +search_vector_batch_result.thrift_spec = ( + (0, TType.STRUCT, 'success', [VecSearchResultList, None], None, ), # 0 + (1, TType.STRUCT, 'e', [VecException, None], None, ), # 1 +) + + +class search_binary_vector_args(object): + """ + Attributes: + - group_id + - top_k + - tensor + - filter + + """ + + + def __init__(self, group_id=None, top_k=None, tensor=None, filter=None,): + self.group_id = group_id + self.top_k = top_k + self.tensor = tensor + self.filter = filter + + 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.STRING: + self.group_id = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.I64: + self.top_k = iprot.readI64() + else: + iprot.skip(ftype) + elif fid == 4: + if ftype == TType.STRUCT: + self.tensor = VecBinaryTensor() + self.tensor.read(iprot) + else: + iprot.skip(ftype) + elif fid == 5: + if ftype == TType.STRUCT: + self.filter = VecSearchFilter() + self.filter.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + 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('search_binary_vector_args') + if self.group_id is not None: + oprot.writeFieldBegin('group_id', TType.STRING, 2) + oprot.writeString(self.group_id.encode('utf-8') if sys.version_info[0] == 2 else self.group_id) + oprot.writeFieldEnd() + if self.top_k is not None: + oprot.writeFieldBegin('top_k', TType.I64, 3) + oprot.writeI64(self.top_k) + oprot.writeFieldEnd() + if self.tensor is not None: + oprot.writeFieldBegin('tensor', TType.STRUCT, 4) + self.tensor.write(oprot) + oprot.writeFieldEnd() + if self.filter is not None: + oprot.writeFieldBegin('filter', TType.STRUCT, 5) + self.filter.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(search_binary_vector_args) +search_binary_vector_args.thrift_spec = ( + None, # 0 + None, # 1 + (2, TType.STRING, 'group_id', 'UTF8', None, ), # 2 + (3, TType.I64, 'top_k', None, None, ), # 3 + (4, TType.STRUCT, 'tensor', [VecBinaryTensor, None], None, ), # 4 + (5, TType.STRUCT, 'filter', [VecSearchFilter, None], None, ), # 5 +) + + +class search_binary_vector_result(object): + """ + Attributes: + - success + - e + + """ + + + def __init__(self, success=None, e=None,): + self.success = success + self.e = e + + 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 == 0: + if ftype == TType.STRUCT: + self.success = VecSearchResult() + self.success.read(iprot) + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.e = VecException() + self.e.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + 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('search_binary_vector_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.STRUCT, 0) + self.success.write(oprot) + oprot.writeFieldEnd() + if self.e is not None: + oprot.writeFieldBegin('e', TType.STRUCT, 1) + self.e.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(search_binary_vector_result) +search_binary_vector_result.thrift_spec = ( + (0, TType.STRUCT, 'success', [VecSearchResult, None], None, ), # 0 + (1, TType.STRUCT, 'e', [VecException, None], None, ), # 1 +) + + +class search_binary_vector_batch_args(object): + """ + Attributes: + - group_id + - top_k + - tensor_list + - filter + + """ + + + def __init__(self, group_id=None, top_k=None, tensor_list=None, filter=None,): + self.group_id = group_id + self.top_k = top_k + self.tensor_list = tensor_list + self.filter = filter + + 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.STRING: + self.group_id = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.I64: + self.top_k = iprot.readI64() + else: + iprot.skip(ftype) + elif fid == 4: + if ftype == TType.STRUCT: + self.tensor_list = VecBinaryTensorList() + self.tensor_list.read(iprot) + else: + iprot.skip(ftype) + elif fid == 5: + if ftype == TType.STRUCT: + self.filter = VecSearchFilter() + self.filter.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + 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('search_binary_vector_batch_args') + if self.group_id is not None: + oprot.writeFieldBegin('group_id', TType.STRING, 2) + oprot.writeString(self.group_id.encode('utf-8') if sys.version_info[0] == 2 else self.group_id) + oprot.writeFieldEnd() + if self.top_k is not None: + oprot.writeFieldBegin('top_k', TType.I64, 3) + oprot.writeI64(self.top_k) + oprot.writeFieldEnd() + if self.tensor_list is not None: + oprot.writeFieldBegin('tensor_list', TType.STRUCT, 4) + self.tensor_list.write(oprot) + oprot.writeFieldEnd() + if self.filter is not None: + oprot.writeFieldBegin('filter', TType.STRUCT, 5) + self.filter.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(search_binary_vector_batch_args) +search_binary_vector_batch_args.thrift_spec = ( + None, # 0 + None, # 1 + (2, TType.STRING, 'group_id', 'UTF8', None, ), # 2 + (3, TType.I64, 'top_k', None, None, ), # 3 + (4, TType.STRUCT, 'tensor_list', [VecBinaryTensorList, None], None, ), # 4 + (5, TType.STRUCT, 'filter', [VecSearchFilter, None], None, ), # 5 +) + + +class search_binary_vector_batch_result(object): + """ + Attributes: + - success + - e + + """ + + + def __init__(self, success=None, e=None,): + self.success = success + self.e = e + + 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 == 0: + if ftype == TType.STRUCT: + self.success = VecSearchResultList() + self.success.read(iprot) + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.e = VecException() + self.e.read(iprot) + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + 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('search_binary_vector_batch_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.STRUCT, 0) + self.success.write(oprot) + oprot.writeFieldEnd() + if self.e is not None: + oprot.writeFieldBegin('e', TType.STRUCT, 1) + self.e.write(oprot) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(search_binary_vector_batch_result) +search_binary_vector_batch_result.thrift_spec = ( + (0, TType.STRUCT, 'success', [VecSearchResultList, None], None, ), # 0 + (1, TType.STRUCT, 'e', [VecException, None], None, ), # 1 +) +fix_spec(all_structs) +del all_structs + diff --git a/cpp/src/thrift/gen-py/zilliz/__init__.py b/cpp/src/thrift/gen-py/zilliz/__init__.py new file mode 100644 index 0000000000..fa8ce63771 --- /dev/null +++ b/cpp/src/thrift/gen-py/zilliz/__init__.py @@ -0,0 +1 @@ +__all__ = ['ttypes', 'constants', 'VecService'] diff --git a/cpp/src/thrift/gen-py/zilliz/constants.py b/cpp/src/thrift/gen-py/zilliz/constants.py new file mode 100644 index 0000000000..c59352d09f --- /dev/null +++ b/cpp/src/thrift/gen-py/zilliz/constants.py @@ -0,0 +1,14 @@ +# +# Autogenerated by Thrift Compiler (0.12.0) +# +# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +# +# options string: py +# + +from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, TApplicationException +from thrift.protocol.TProtocol import TProtocolException +from thrift.TRecursive import fix_spec + +import sys +from .ttypes import * diff --git a/cpp/src/thrift/gen-py/zilliz/ttypes.py b/cpp/src/thrift/gen-py/zilliz/ttypes.py new file mode 100644 index 0000000000..2c85d22c3f --- /dev/null +++ b/cpp/src/thrift/gen-py/zilliz/ttypes.py @@ -0,0 +1,1141 @@ +# +# Autogenerated by Thrift Compiler (0.12.0) +# +# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING +# +# options string: py +# + +from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, TApplicationException +from thrift.protocol.TProtocol import TProtocolException +from thrift.TRecursive import fix_spec + +import sys + +from thrift.transport import TTransport +all_structs = [] + + +class VecErrCode(object): + SUCCESS = 0 + ILLEGAL_ARGUMENT = 1 + GROUP_NOT_EXISTS = 2 + ILLEGAL_TIME_RANGE = 3 + ILLEGAL_VECTOR_DIMENSION = 4 + OUT_OF_MEMORY = 5 + + _VALUES_TO_NAMES = { + 0: "SUCCESS", + 1: "ILLEGAL_ARGUMENT", + 2: "GROUP_NOT_EXISTS", + 3: "ILLEGAL_TIME_RANGE", + 4: "ILLEGAL_VECTOR_DIMENSION", + 5: "OUT_OF_MEMORY", + } + + _NAMES_TO_VALUES = { + "SUCCESS": 0, + "ILLEGAL_ARGUMENT": 1, + "GROUP_NOT_EXISTS": 2, + "ILLEGAL_TIME_RANGE": 3, + "ILLEGAL_VECTOR_DIMENSION": 4, + "OUT_OF_MEMORY": 5, + } + + +class VecException(TException): + """ + Attributes: + - code + - reason + + """ + + + def __init__(self, code=None, reason=None,): + self.code = code + self.reason = reason + + 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.I32: + self.code = iprot.readI32() + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.STRING: + self.reason = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + 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('VecException') + if self.code is not None: + oprot.writeFieldBegin('code', TType.I32, 1) + oprot.writeI32(self.code) + oprot.writeFieldEnd() + if self.reason is not None: + oprot.writeFieldBegin('reason', TType.STRING, 2) + oprot.writeString(self.reason.encode('utf-8') if sys.version_info[0] == 2 else self.reason) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __str__(self): + return repr(self) + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + + +class VecGroup(object): + """ + Attributes: + - id + - dimension + - index_type + + """ + + + def __init__(self, id=None, dimension=None, index_type=None,): + self.id = id + self.dimension = dimension + self.index_type = index_type + + 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.id = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.I32: + self.dimension = iprot.readI32() + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.I32: + self.index_type = iprot.readI32() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + 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('VecGroup') + if self.id is not None: + oprot.writeFieldBegin('id', TType.STRING, 1) + oprot.writeString(self.id.encode('utf-8') if sys.version_info[0] == 2 else self.id) + oprot.writeFieldEnd() + if self.dimension is not None: + oprot.writeFieldBegin('dimension', TType.I32, 2) + oprot.writeI32(self.dimension) + oprot.writeFieldEnd() + if self.index_type is not None: + oprot.writeFieldBegin('index_type', TType.I32, 3) + oprot.writeI32(self.index_type) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + if self.id is None: + raise TProtocolException(message='Required field id is unset!') + if self.dimension is None: + raise TProtocolException(message='Required field dimension is unset!') + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + + +class VecTensor(object): + """ + Attributes: + - uid + - tensor + - attrib + + """ + + + def __init__(self, uid=None, tensor=None, attrib=None,): + self.uid = uid + self.tensor = tensor + self.attrib = attrib + + 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.uid = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.LIST: + self.tensor = [] + (_etype3, _size0) = iprot.readListBegin() + for _i4 in range(_size0): + _elem5 = iprot.readDouble() + self.tensor.append(_elem5) + iprot.readListEnd() + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.MAP: + self.attrib = {} + (_ktype7, _vtype8, _size6) = iprot.readMapBegin() + for _i10 in range(_size6): + _key11 = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + _val12 = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + self.attrib[_key11] = _val12 + iprot.readMapEnd() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + 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('VecTensor') + if self.uid is not None: + oprot.writeFieldBegin('uid', TType.STRING, 1) + oprot.writeString(self.uid.encode('utf-8') if sys.version_info[0] == 2 else self.uid) + oprot.writeFieldEnd() + if self.tensor is not None: + oprot.writeFieldBegin('tensor', TType.LIST, 2) + oprot.writeListBegin(TType.DOUBLE, len(self.tensor)) + for iter13 in self.tensor: + oprot.writeDouble(iter13) + oprot.writeListEnd() + oprot.writeFieldEnd() + if self.attrib is not None: + oprot.writeFieldBegin('attrib', TType.MAP, 3) + oprot.writeMapBegin(TType.STRING, TType.STRING, len(self.attrib)) + for kiter14, viter15 in self.attrib.items(): + oprot.writeString(kiter14.encode('utf-8') if sys.version_info[0] == 2 else kiter14) + oprot.writeString(viter15.encode('utf-8') if sys.version_info[0] == 2 else viter15) + oprot.writeMapEnd() + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + if self.uid is None: + raise TProtocolException(message='Required field uid is unset!') + if self.tensor is None: + raise TProtocolException(message='Required field tensor is unset!') + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + + +class VecTensorList(object): + """ + Attributes: + - tensor_list + + """ + + + def __init__(self, tensor_list=None,): + self.tensor_list = tensor_list + + 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.LIST: + self.tensor_list = [] + (_etype19, _size16) = iprot.readListBegin() + for _i20 in range(_size16): + _elem21 = VecTensor() + _elem21.read(iprot) + self.tensor_list.append(_elem21) + iprot.readListEnd() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + 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('VecTensorList') + if self.tensor_list is not None: + oprot.writeFieldBegin('tensor_list', TType.LIST, 1) + oprot.writeListBegin(TType.STRUCT, len(self.tensor_list)) + for iter22 in self.tensor_list: + iter22.write(oprot) + oprot.writeListEnd() + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + if self.tensor_list is None: + raise TProtocolException(message='Required field tensor_list is unset!') + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + + +class VecBinaryTensor(object): + """ + Attributes: + - uid + - tensor + - attrib + + """ + + + def __init__(self, uid=None, tensor=None, attrib=None,): + self.uid = uid + self.tensor = tensor + self.attrib = attrib + + 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.uid = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.STRING: + self.tensor = iprot.readBinary() + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.MAP: + self.attrib = {} + (_ktype24, _vtype25, _size23) = iprot.readMapBegin() + for _i27 in range(_size23): + _key28 = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + _val29 = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + self.attrib[_key28] = _val29 + iprot.readMapEnd() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + 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('VecBinaryTensor') + if self.uid is not None: + oprot.writeFieldBegin('uid', TType.STRING, 1) + oprot.writeString(self.uid.encode('utf-8') if sys.version_info[0] == 2 else self.uid) + oprot.writeFieldEnd() + if self.tensor is not None: + oprot.writeFieldBegin('tensor', TType.STRING, 2) + oprot.writeBinary(self.tensor) + oprot.writeFieldEnd() + if self.attrib is not None: + oprot.writeFieldBegin('attrib', TType.MAP, 3) + oprot.writeMapBegin(TType.STRING, TType.STRING, len(self.attrib)) + for kiter30, viter31 in self.attrib.items(): + oprot.writeString(kiter30.encode('utf-8') if sys.version_info[0] == 2 else kiter30) + oprot.writeString(viter31.encode('utf-8') if sys.version_info[0] == 2 else viter31) + oprot.writeMapEnd() + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + if self.uid is None: + raise TProtocolException(message='Required field uid is unset!') + if self.tensor is None: + raise TProtocolException(message='Required field tensor is unset!') + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + + +class VecBinaryTensorList(object): + """ + Attributes: + - tensor_list + + """ + + + def __init__(self, tensor_list=None,): + self.tensor_list = tensor_list + + 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.LIST: + self.tensor_list = [] + (_etype35, _size32) = iprot.readListBegin() + for _i36 in range(_size32): + _elem37 = VecBinaryTensor() + _elem37.read(iprot) + self.tensor_list.append(_elem37) + iprot.readListEnd() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + 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('VecBinaryTensorList') + if self.tensor_list is not None: + oprot.writeFieldBegin('tensor_list', TType.LIST, 1) + oprot.writeListBegin(TType.STRUCT, len(self.tensor_list)) + for iter38 in self.tensor_list: + iter38.write(oprot) + oprot.writeListEnd() + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + if self.tensor_list is None: + raise TProtocolException(message='Required field tensor_list is unset!') + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + + +class VecSearchResultItem(object): + """ + Attributes: + - uid + - distance + - attrib + + """ + + + def __init__(self, uid=None, distance=None, attrib=None,): + self.uid = uid + self.distance = distance + self.attrib = attrib + + 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.uid = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.DOUBLE: + self.distance = iprot.readDouble() + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.MAP: + self.attrib = {} + (_ktype40, _vtype41, _size39) = iprot.readMapBegin() + for _i43 in range(_size39): + _key44 = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + _val45 = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + self.attrib[_key44] = _val45 + iprot.readMapEnd() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + 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('VecSearchResultItem') + if self.uid is not None: + oprot.writeFieldBegin('uid', TType.STRING, 1) + oprot.writeString(self.uid.encode('utf-8') if sys.version_info[0] == 2 else self.uid) + oprot.writeFieldEnd() + if self.distance is not None: + oprot.writeFieldBegin('distance', TType.DOUBLE, 2) + oprot.writeDouble(self.distance) + oprot.writeFieldEnd() + if self.attrib is not None: + oprot.writeFieldBegin('attrib', TType.MAP, 3) + oprot.writeMapBegin(TType.STRING, TType.STRING, len(self.attrib)) + for kiter46, viter47 in self.attrib.items(): + oprot.writeString(kiter46.encode('utf-8') if sys.version_info[0] == 2 else kiter46) + oprot.writeString(viter47.encode('utf-8') if sys.version_info[0] == 2 else viter47) + oprot.writeMapEnd() + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + if self.uid is None: + raise TProtocolException(message='Required field uid is unset!') + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + + +class VecSearchResult(object): + """ + Attributes: + - result_list + + """ + + + def __init__(self, result_list=None,): + self.result_list = result_list + + 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.LIST: + self.result_list = [] + (_etype51, _size48) = iprot.readListBegin() + for _i52 in range(_size48): + _elem53 = VecSearchResultItem() + _elem53.read(iprot) + self.result_list.append(_elem53) + iprot.readListEnd() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + 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('VecSearchResult') + if self.result_list is not None: + oprot.writeFieldBegin('result_list', TType.LIST, 1) + oprot.writeListBegin(TType.STRUCT, len(self.result_list)) + for iter54 in self.result_list: + iter54.write(oprot) + oprot.writeListEnd() + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + + +class VecSearchResultList(object): + """ + Attributes: + - result_list + + """ + + + def __init__(self, result_list=None,): + self.result_list = result_list + + 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.LIST: + self.result_list = [] + (_etype58, _size55) = iprot.readListBegin() + for _i59 in range(_size55): + _elem60 = VecSearchResult() + _elem60.read(iprot) + self.result_list.append(_elem60) + iprot.readListEnd() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + 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('VecSearchResultList') + if self.result_list is not None: + oprot.writeFieldBegin('result_list', TType.LIST, 1) + oprot.writeListBegin(TType.STRUCT, len(self.result_list)) + for iter61 in self.result_list: + iter61.write(oprot) + oprot.writeListEnd() + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + + +class VecDateTime(object): + """ + Attributes: + - year + - month + - day + - hour + - minute + - second + + """ + + + def __init__(self, year=None, month=None, day=None, hour=None, minute=None, second=None,): + self.year = year + self.month = month + self.day = day + self.hour = hour + self.minute = minute + self.second = second + + 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.I32: + self.year = iprot.readI32() + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.I32: + self.month = iprot.readI32() + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.I32: + self.day = iprot.readI32() + else: + iprot.skip(ftype) + elif fid == 4: + if ftype == TType.I32: + self.hour = iprot.readI32() + else: + iprot.skip(ftype) + elif fid == 5: + if ftype == TType.I32: + self.minute = iprot.readI32() + else: + iprot.skip(ftype) + elif fid == 6: + if ftype == TType.I32: + self.second = iprot.readI32() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + 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('VecDateTime') + if self.year is not None: + oprot.writeFieldBegin('year', TType.I32, 1) + oprot.writeI32(self.year) + oprot.writeFieldEnd() + if self.month is not None: + oprot.writeFieldBegin('month', TType.I32, 2) + oprot.writeI32(self.month) + oprot.writeFieldEnd() + if self.day is not None: + oprot.writeFieldBegin('day', TType.I32, 3) + oprot.writeI32(self.day) + oprot.writeFieldEnd() + if self.hour is not None: + oprot.writeFieldBegin('hour', TType.I32, 4) + oprot.writeI32(self.hour) + oprot.writeFieldEnd() + if self.minute is not None: + oprot.writeFieldBegin('minute', TType.I32, 5) + oprot.writeI32(self.minute) + oprot.writeFieldEnd() + if self.second is not None: + oprot.writeFieldBegin('second', TType.I32, 6) + oprot.writeI32(self.second) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + if self.year is None: + raise TProtocolException(message='Required field year is unset!') + if self.month is None: + raise TProtocolException(message='Required field month is unset!') + if self.day is None: + raise TProtocolException(message='Required field day is unset!') + if self.hour is None: + raise TProtocolException(message='Required field hour is unset!') + if self.minute is None: + raise TProtocolException(message='Required field minute is unset!') + if self.second is None: + raise TProtocolException(message='Required field second is unset!') + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + + +class VecTimeRange(object): + """ + Attributes: + - time_begin + - begine_closed + - time_end + - end_closed + + """ + + + def __init__(self, time_begin=None, begine_closed=None, time_end=None, end_closed=None,): + self.time_begin = time_begin + self.begine_closed = begine_closed + self.time_end = time_end + self.end_closed = end_closed + + 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.STRUCT: + self.time_begin = VecDateTime() + self.time_begin.read(iprot) + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.BOOL: + self.begine_closed = iprot.readBool() + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.STRUCT: + self.time_end = VecDateTime() + self.time_end.read(iprot) + else: + iprot.skip(ftype) + elif fid == 4: + if ftype == TType.BOOL: + self.end_closed = iprot.readBool() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + 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('VecTimeRange') + if self.time_begin is not None: + oprot.writeFieldBegin('time_begin', TType.STRUCT, 1) + self.time_begin.write(oprot) + oprot.writeFieldEnd() + if self.begine_closed is not None: + oprot.writeFieldBegin('begine_closed', TType.BOOL, 2) + oprot.writeBool(self.begine_closed) + oprot.writeFieldEnd() + if self.time_end is not None: + oprot.writeFieldBegin('time_end', TType.STRUCT, 3) + self.time_end.write(oprot) + oprot.writeFieldEnd() + if self.end_closed is not None: + oprot.writeFieldBegin('end_closed', TType.BOOL, 4) + oprot.writeBool(self.end_closed) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + if self.time_begin is None: + raise TProtocolException(message='Required field time_begin is unset!') + if self.begine_closed is None: + raise TProtocolException(message='Required field begine_closed is unset!') + if self.time_end is None: + raise TProtocolException(message='Required field time_end is unset!') + if self.end_closed is None: + raise TProtocolException(message='Required field end_closed is unset!') + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) + + +class VecSearchFilter(object): + """ + Attributes: + - attrib_filter + - time_ranges + + """ + + + def __init__(self, attrib_filter=None, time_ranges=None,): + self.attrib_filter = attrib_filter + self.time_ranges = time_ranges + + 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.MAP: + self.attrib_filter = {} + (_ktype63, _vtype64, _size62) = iprot.readMapBegin() + for _i66 in range(_size62): + _key67 = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + _val68 = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + self.attrib_filter[_key67] = _val68 + iprot.readMapEnd() + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.LIST: + self.time_ranges = [] + (_etype72, _size69) = iprot.readListBegin() + for _i73 in range(_size69): + _elem74 = VecTimeRange() + _elem74.read(iprot) + self.time_ranges.append(_elem74) + iprot.readListEnd() + else: + iprot.skip(ftype) + else: + iprot.skip(ftype) + iprot.readFieldEnd() + iprot.readStructEnd() + + 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('VecSearchFilter') + if self.attrib_filter is not None: + oprot.writeFieldBegin('attrib_filter', TType.MAP, 1) + oprot.writeMapBegin(TType.STRING, TType.STRING, len(self.attrib_filter)) + for kiter75, viter76 in self.attrib_filter.items(): + oprot.writeString(kiter75.encode('utf-8') if sys.version_info[0] == 2 else kiter75) + oprot.writeString(viter76.encode('utf-8') if sys.version_info[0] == 2 else viter76) + oprot.writeMapEnd() + oprot.writeFieldEnd() + if self.time_ranges is not None: + oprot.writeFieldBegin('time_ranges', TType.LIST, 2) + oprot.writeListBegin(TType.STRUCT, len(self.time_ranges)) + for iter77 in self.time_ranges: + iter77.write(oprot) + oprot.writeListEnd() + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + return + + def __repr__(self): + L = ['%s=%r' % (key, value) + for key, value in self.__dict__.items()] + return '%s(%s)' % (self.__class__.__name__, ', '.join(L)) + + def __eq__(self, other): + return isinstance(other, self.__class__) and self.__dict__ == other.__dict__ + + def __ne__(self, other): + return not (self == other) +all_structs.append(VecException) +VecException.thrift_spec = ( + None, # 0 + (1, TType.I32, 'code', None, None, ), # 1 + (2, TType.STRING, 'reason', 'UTF8', None, ), # 2 +) +all_structs.append(VecGroup) +VecGroup.thrift_spec = ( + None, # 0 + (1, TType.STRING, 'id', 'UTF8', None, ), # 1 + (2, TType.I32, 'dimension', None, None, ), # 2 + (3, TType.I32, 'index_type', None, None, ), # 3 +) +all_structs.append(VecTensor) +VecTensor.thrift_spec = ( + None, # 0 + (1, TType.STRING, 'uid', 'UTF8', None, ), # 1 + (2, TType.LIST, 'tensor', (TType.DOUBLE, None, False), None, ), # 2 + (3, TType.MAP, 'attrib', (TType.STRING, 'UTF8', TType.STRING, 'UTF8', False), None, ), # 3 +) +all_structs.append(VecTensorList) +VecTensorList.thrift_spec = ( + None, # 0 + (1, TType.LIST, 'tensor_list', (TType.STRUCT, [VecTensor, None], False), None, ), # 1 +) +all_structs.append(VecBinaryTensor) +VecBinaryTensor.thrift_spec = ( + None, # 0 + (1, TType.STRING, 'uid', 'UTF8', None, ), # 1 + (2, TType.STRING, 'tensor', 'BINARY', None, ), # 2 + (3, TType.MAP, 'attrib', (TType.STRING, 'UTF8', TType.STRING, 'UTF8', False), None, ), # 3 +) +all_structs.append(VecBinaryTensorList) +VecBinaryTensorList.thrift_spec = ( + None, # 0 + (1, TType.LIST, 'tensor_list', (TType.STRUCT, [VecBinaryTensor, None], False), None, ), # 1 +) +all_structs.append(VecSearchResultItem) +VecSearchResultItem.thrift_spec = ( + None, # 0 + (1, TType.STRING, 'uid', 'UTF8', None, ), # 1 + (2, TType.DOUBLE, 'distance', None, None, ), # 2 + (3, TType.MAP, 'attrib', (TType.STRING, 'UTF8', TType.STRING, 'UTF8', False), None, ), # 3 +) +all_structs.append(VecSearchResult) +VecSearchResult.thrift_spec = ( + None, # 0 + (1, TType.LIST, 'result_list', (TType.STRUCT, [VecSearchResultItem, None], False), None, ), # 1 +) +all_structs.append(VecSearchResultList) +VecSearchResultList.thrift_spec = ( + None, # 0 + (1, TType.LIST, 'result_list', (TType.STRUCT, [VecSearchResult, None], False), None, ), # 1 +) +all_structs.append(VecDateTime) +VecDateTime.thrift_spec = ( + None, # 0 + (1, TType.I32, 'year', None, None, ), # 1 + (2, TType.I32, 'month', None, None, ), # 2 + (3, TType.I32, 'day', None, None, ), # 3 + (4, TType.I32, 'hour', None, None, ), # 4 + (5, TType.I32, 'minute', None, None, ), # 5 + (6, TType.I32, 'second', None, None, ), # 6 +) +all_structs.append(VecTimeRange) +VecTimeRange.thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'time_begin', [VecDateTime, None], None, ), # 1 + (2, TType.BOOL, 'begine_closed', None, None, ), # 2 + (3, TType.STRUCT, 'time_end', [VecDateTime, None], None, ), # 3 + (4, TType.BOOL, 'end_closed', None, None, ), # 4 +) +all_structs.append(VecSearchFilter) +VecSearchFilter.thrift_spec = ( + None, # 0 + (1, TType.MAP, 'attrib_filter', (TType.STRING, 'UTF8', TType.STRING, 'UTF8', False), None, ), # 1 + (2, TType.LIST, 'time_ranges', (TType.STRUCT, [VecTimeRange, None], False), None, ), # 2 +) +fix_spec(all_structs) +del all_structs diff --git a/cpp/src/thrift/py_gen.sh b/cpp/src/thrift/py_gen.sh new file mode 100755 index 0000000000..adf2eb04b9 --- /dev/null +++ b/cpp/src/thrift/py_gen.sh @@ -0,0 +1,4 @@ +#!/bin/bash + +../../third_party/build/bin/thrift -r --gen py ./VectorService.thrift +