diff --git a/python/sdk/client/Client.py b/python/sdk/client/Client.py index cc3d69bad7858aef6398489edd861ebd0abfa893..d2d4930fbd2330d4ff77583b9377efc2c52d5d81 100644 --- a/python/sdk/client/Client.py +++ b/python/sdk/client/Client.py @@ -5,8 +5,8 @@ from thrift.transport import TTransport from thrift.protocol import TBinaryProtocol from thrift.Thrift import TException, TApplicationException -from megasearch.thrift import MegasearchService -from megasearch.thrift import ttypes +from milvus.thrift import MilvusService +from milvus.thrift import ttypes from client.Abstract import ( ConnectIntf, TableSchema, @@ -77,7 +77,7 @@ class Prepare(object): return ttypes.RowRecord(vector_data=temp.vector_data) -class MegaSearch(ConnectIntf): +class Milvus(ConnectIntf): def __init__(self): self.status = None @@ -95,7 +95,7 @@ class MegaSearch(ConnectIntf): transport = TSocket.TSocket(host=host, port=port) self._transport = TTransport.TBufferedTransport(transport) protocol = TBinaryProtocol.TBinaryProtocol(transport) - self._client = MegasearchService.Client(protocol) + self._client = MilvusService.Client(protocol) try: transport.open() diff --git a/python/sdk/client/__init__.py b/python/sdk/client/__init__.py index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..38a3ed8e534a1630009cefa904c9d00da73185b3 100644 --- a/python/sdk/client/__init__.py +++ b/python/sdk/client/__init__.py @@ -0,0 +1 @@ +"""client module""" diff --git a/python/sdk/documents/client.Abstract.html b/python/sdk/documents/client.Abstract.html new file mode 100644 index 0000000000000000000000000000000000000000..f2391700f38ee8a976918faf015d843e3950f6ae --- /dev/null +++ b/python/sdk/documents/client.Abstract.html @@ -0,0 +1,353 @@ + +Python: module Abstract + + + + + +
 
+ 
Abstract
index
/home/yangxuan/vecwise_engine/python/sdk/client/Abstract.py
+

+

+ + + + + +
 
+Classes
       
+
builtins.object +
+
+
ConnectIntf +
QueryResult +
Range +
RowRecord +
TableSchema +
TopKQueryResult +
+
+
enum.IntEnum(builtins.int, enum.Enum) +
+
+
IndexType +
+
+
+

+ + + + + + + +
 
+class ConnectIntf(builtins.object)
   SDK client abstract class

+Connection is a abstract class
 
 Methods defined here:
+
add_vectors(self, table_name, records)
Add vectors to table
+Should be implemented

+:type  table_name: str
+:param table_name: table name been inserted

+:type  records: list[RowRecord]
+:param records: list of vectors been inserted

+:returns
+    Status : indicate if vectors inserted successfully
+    ids :list of id, after inserted every vector is given a id
+ +
client_version(self)
Provide client version
+should be implemented

+:return: str, client version
+ +
connect(self, host=None, port=None, uri=None)
Connect method should be called before any operations
+Server will be connected after connect return OK
+Should be implemented

+:type  host: str
+:param host: host

+:type  port: str
+:param port: port

+:type  uri: str
+:param uri: (Optional) uri

+:return Status,  indicate if connect is successful
+ +
connected(self)
connected, connection status
+Should be implemented

+:return Status,  indicate if connect is successful
+ +
create_table(self, param)
Create table
+Should be implemented

+:type  param: TableSchema
+:param param: provide table information to be created

+:return Status, indicate if connect is successful
+ +
delete_table(self, table_name)
Delete table
+Should be implemented

+:type  table_name: str
+:param table_name: table_name of the deleting table

+:return Status, indicate if connect is successful
+ +
describe_table(self, table_name)
Show table information
+Should be implemented

+:type  table_name: str
+:param table_name: which table to be shown

+:returns
+    Status: indicate if query is successful
+    table_schema: TableSchema, given when operation is successful
+ +
disconnect(self)
Disconnect, server will be disconnected after disconnect return SUCCESS
+Should be implemented

+:return Status,  indicate if connect is successful
+ +
get_table_row_count(self, table_name)
Get table row count
+Should be implemented

+:type  table_name, str
+:param table_name, target table name.

+:returns
+    Status: indicate if operation is successful
+    count: int, table row count
+ +
search_vectors(self, table_name, query_records, query_ranges, top_k)
Query vectors in a table
+Should be implemented

+:type  table_name: str
+:param table_name: table name been queried

+:type  query_records: list[RowRecord]
+:param query_records: all vectors going to be queried

+:type  query_ranges: list[Range]
+:param query_ranges: Optional ranges for conditional search.
+    If not specified, search whole table

+:type  top_k: int
+:param top_k: how many similar vectors will be searched

+:returns
+    Status:  indicate if query is successful
+    query_results: list[TopKQueryResult]
+ +
server_status(self, cmd)
Provide server status
+should be implemented
+:type cmd, str

+:return: str, server status
+ +
server_version(self)
Provide server version
+should be implemented

+:return: str, server version
+ +
show_tables(self)
Show all tables in database
+should be implemented

+:return
+    Status: indicate if this operation is successful
+    tables: list[str], list of table names
+ +
+Data descriptors defined here:
+
__dict__
+
dictionary for instance variables (if defined)
+
+
__weakref__
+
list of weak references to the object (if defined)
+
+

+ + + + + + + +
 
+class IndexType(enum.IntEnum)
   An enumeration.
 
 
Method resolution order:
+
IndexType
+
enum.IntEnum
+
builtins.int
+
enum.Enum
+
builtins.object
+
+
+Data and other attributes defined here:
+
IDMAP = <IndexType.IDMAP: 1>
+ +
INVALIDE = <IndexType.INVALIDE: 0>
+ +
IVFLAT = <IndexType.IVFLAT: 2>
+ +
+Data descriptors inherited from enum.Enum:
+
name
+
The name of the Enum member.
+
+
value
+
The value of the Enum member.
+
+
+Data descriptors inherited from enum.EnumMeta:
+
__members__
+
Returns a mapping of member name->value.

+This mapping lists all enum members, including aliases. Note that this
+is a read-only view of the internal mapping.
+
+

+ + + + + + + +
 
+class QueryResult(builtins.object)
   Query result

+:type  id: int64
+:param id: id of the vector

+:type  score: float
+:param score: Vector similarity 0 <= score <= 100
 
 Methods defined here:
+
__init__(self, id, score)
Initialize self.  See help(type(self)) for accurate signature.
+ +
__repr__(self)
Return repr(self).
+ +
+Data descriptors defined here:
+
__dict__
+
dictionary for instance variables (if defined)
+
+
__weakref__
+
list of weak references to the object (if defined)
+
+

+ + + + + + + +
 
+class Range(builtins.object)
   Range information

+:type  start: str
+:param start: Range start value

+:type  end: str
+:param end: Range end value
 
 Methods defined here:
+
__init__(self, start, end)
Initialize self.  See help(type(self)) for accurate signature.
+ +
+Data descriptors defined here:
+
__dict__
+
dictionary for instance variables (if defined)
+
+
__weakref__
+
list of weak references to the object (if defined)
+
+

+ + + + + + + +
 
+class RowRecord(builtins.object)
   Record inserted

+:type  vector_data: binary str
+:param vector_data: (Required) a vector
 
 Methods defined here:
+
__init__(self, vector_data)
Initialize self.  See help(type(self)) for accurate signature.
+ +
+Data descriptors defined here:
+
__dict__
+
dictionary for instance variables (if defined)
+
+
__weakref__
+
list of weak references to the object (if defined)
+
+

+ + + + + + + +
 
+class TableSchema(builtins.object)
   Table Schema

+:type  table_name: str
+:param table_name: (Required) name of table

+:type  index_type: IndexType
+:param index_type: (Optional) index type, default = 0

+    `IndexType`: 0-invalid, 1-idmap, 2-ivflat

+:type  dimension: int64
+:param dimension: (Required) dimension of vector

+:type  store_raw_vector: bool
+:param store_raw_vector: (Optional) default = False
 
 Methods defined here:
+
__init__(self, table_name, dimension=0, index_type=<IndexType.INVALIDE: 0>, store_raw_vector=False)
Initialize self.  See help(type(self)) for accurate signature.
+ +
+Data descriptors defined here:
+
__dict__
+
dictionary for instance variables (if defined)
+
+
__weakref__
+
list of weak references to the object (if defined)
+
+

+ + + + + + + +
 
+class TopKQueryResult(builtins.object)
   TopK query results

+:type  query_results: list[QueryResult]
+:param query_results: TopK query results
 
 Methods defined here:
+
__init__(self, query_results)
Initialize self.  See help(type(self)) for accurate signature.
+ +
__repr__(self)
Return repr(self).
+ +
+Data descriptors defined here:
+
__dict__
+
dictionary for instance variables (if defined)
+
+
__weakref__
+
list of weak references to the object (if defined)
+
+

+ \ No newline at end of file diff --git a/python/sdk/documents/client.Client.html b/python/sdk/documents/client.Client.html new file mode 100644 index 0000000000000000000000000000000000000000..9586756765cef31b5fa49dc4c7e55601de569768 --- /dev/null +++ b/python/sdk/documents/client.Client.html @@ -0,0 +1,218 @@ + +Python: module Client + + + + + +
 
+ 
Client
index
/home/yangxuan/vecwise_engine/python/sdk/client/Client.py
+

+

+ + + + + +
 
+Modules
       
milvus.thrift.MilvusService
+thrift.protocol.TBinaryProtocol
+
thrift.transport.TSocket
+thrift.transport.TTransport
+
logging
+milvus.thrift.ttypes
+

+ + + + + +
 
+Classes
       
+
builtins.object +
+
+
Prepare +
+
+
client.Abstract.ConnectIntf(builtins.object) +
+
+
Milvus +
+
+
+

+ + + + + + + +
 
+class Milvus(client.Abstract.ConnectIntf)
   SDK client abstract class

+Connection is a abstract class
 
 
Method resolution order:
+
Milvus
+
client.Abstract.ConnectIntf
+
builtins.object
+
+
+Methods defined here:
+
__init__(self)
Initialize self.  See help(type(self)) for accurate signature.
+ +
__repr__(self)
Return repr(self).
+ +
add_vectors(self, table_name, records)
Add vectors to table

+:param table_name: table name been inserted
+:param records: List[RowRecord], list of vectors been inserted

+        `Please use Prepare.row_record generate records`

+:returns:
+    Status : indicate if vectors inserted successfully
+    ids :list of id, after inserted every vector is given a id
+ +
client_version(self)
Provide client version

+:return: Client version
+ +
connect(self, host='localhost', port='9090', uri=None)
Connect method should be called before any operations
+Server will be connected after connect return OK
+Should be implemented

+:type  host: str
+:param host: host

+:type  port: str
+:param port: port

+:type  uri: str
+:param uri: (Optional) uri

+:return Status,  indicate if connect is successful
+ +
create_table(self, param)
Create table

+:param param: Provide table information to be created,

+        `Please use Prepare.table_schema generate param`

+:return: Status, indicate if operation is successful
+ +
delete_table(self, table_name)
Delete table

+:param table_name: Name of the table being deleted

+:return: Status, indicate if operation is successful
+ +
describe_table(self, table_name)
Show table information

+:param table_name: str, which table to be shown

+:returns:
+    Status: indicate if query is successful
+    table_schema: TableSchema, return when operation is successful
+ +
disconnect(self)
Disconnect, server will be disconnected after disconnect return SUCCESS
+Should be implemented

+:return Status,  indicate if connect is successful
+ +
get_table_row_count(self, table_name)
Get table row count

+:type  table_name, str
+:param table_name, target table name.

+:returns:
+    Status: indicate if operation is successful
+    res: int, table row count
+ +
search_vectors(self, table_name, top_k, query_records, query_ranges=None)
Query vectors in a table

+:param table_name: str, table name been queried
+:param query_records: list[QueryRecord], all vectors going to be queried

+        `Please use Prepare.query_record generate QueryRecord`

+:param top_k: int, how many similar vectors will be searched
+:param query_ranges, (Optional) list[Range], search range

+:returns:
+    Status:  indicate if query is successful
+    res: list[TopKQueryResult], return when operation is successful
+ +
server_status(self, cmd=None)
Provide server status

+:return: Server status
+ +
server_version(self)
Provide server version

+:return: Server version
+ +
show_tables(self)
Show all tables in database

+:return:
+    Status: indicate if this operation is successful
+    tables: list[str], list of table names, return when operation
+            is successful
+ +
+Data descriptors defined here:
+
connected
+
+
+Data descriptors inherited from client.Abstract.ConnectIntf:
+
__dict__
+
dictionary for instance variables (if defined)
+
+
__weakref__
+
list of weak references to the object (if defined)
+
+

+ + + + + +
 
+class Prepare(builtins.object)
    Class methods defined here:
+
range(start, end) from builtins.type
:param start: str, (Required) range start
+:param end: str (Required) range end

+:return Range
+ +
row_record(vector_data) from builtins.type
Record inserted

+:param vector_data: float binary str, (Required) a binary str
+ +
table_schema(table_name, dimension, index_type=<IndexType.INVALIDE: 0>, store_raw_vector=False) from builtins.type
:param table_name: str, (Required) name of table
+:param index_type: IndexType, (Required) index type, default = IndexType.INVALID
+:param dimension: int64, (Optional) dimension of the table
+:param store_raw_vector: bool, (Optional) default = False

+:return: TableSchema
+ +
+Data descriptors defined here:
+
__dict__
+
dictionary for instance variables (if defined)
+
+
__weakref__
+
list of weak references to the object (if defined)
+
+

+ + + + + +
 
+Data
       LOGGER = <Logger Client (WARNING)>
+__NAME__ = 'Thrift_Client'
+__VERSION__ = '0.0.1'
+ \ No newline at end of file diff --git a/python/sdk/documents/client.Exceptions.html b/python/sdk/documents/client.Exceptions.html new file mode 100644 index 0000000000000000000000000000000000000000..75d81c4440740d027dc31e45f40f5010395dccff --- /dev/null +++ b/python/sdk/documents/client.Exceptions.html @@ -0,0 +1,349 @@ + +Python: module Exceptions + + + + + +
 
+ 
Exceptions
index
/home/yangxuan/vecwise_engine/python/sdk/client/Exceptions.py
+

+

+ + + + + +
 
+Classes
       
+
builtins.ValueError(builtins.Exception) +
+
+
ConnectError +
+
+
NotConnectError +
RepeatingConnectError +
+
+
DisconnectNotConnectedClientError +
ParamError +
+
+
+

+ + + + + + + +
 
+class ConnectError(builtins.ValueError)
   Inappropriate argument value (of correct type).
 
 
Method resolution order:
+
ConnectError
+
builtins.ValueError
+
builtins.Exception
+
builtins.BaseException
+
builtins.object
+
+
+Data descriptors defined here:
+
__weakref__
+
list of weak references to the object (if defined)
+
+
+Methods inherited from builtins.ValueError:
+
__init__(self, /, *args, **kwargs)
Initialize self.  See help(type(self)) for accurate signature.
+ +
__new__(*args, **kwargs) from builtins.type
Create and return a new object.  See help(type) for accurate signature.
+ +
+Methods inherited from builtins.BaseException:
+
__delattr__(self, name, /)
Implement delattr(self, name).
+ +
__getattribute__(self, name, /)
Return getattr(self, name).
+ +
__reduce__(...)
helper for pickle
+ +
__repr__(self, /)
Return repr(self).
+ +
__setattr__(self, name, value, /)
Implement setattr(self, name, value).
+ +
__setstate__(...)
+ +
__str__(self, /)
Return str(self).
+ +
with_traceback(...)
Exception.with_traceback(tb) --
+set self.__traceback__ to tb and return self.
+ +
+Data descriptors inherited from builtins.BaseException:
+
__cause__
+
exception cause
+
+
__context__
+
exception context
+
+
__dict__
+
+
__suppress_context__
+
+
__traceback__
+
+
args
+
+

+ + + + + + + +
 
+class DisconnectNotConnectedClientError(builtins.ValueError)
   Inappropriate argument value (of correct type).
 
 
Method resolution order:
+
DisconnectNotConnectedClientError
+
builtins.ValueError
+
builtins.Exception
+
builtins.BaseException
+
builtins.object
+
+
+Data descriptors defined here:
+
__weakref__
+
list of weak references to the object (if defined)
+
+
+Methods inherited from builtins.ValueError:
+
__init__(self, /, *args, **kwargs)
Initialize self.  See help(type(self)) for accurate signature.
+ +
__new__(*args, **kwargs) from builtins.type
Create and return a new object.  See help(type) for accurate signature.
+ +
+Methods inherited from builtins.BaseException:
+
__delattr__(self, name, /)
Implement delattr(self, name).
+ +
__getattribute__(self, name, /)
Return getattr(self, name).
+ +
__reduce__(...)
helper for pickle
+ +
__repr__(self, /)
Return repr(self).
+ +
__setattr__(self, name, value, /)
Implement setattr(self, name, value).
+ +
__setstate__(...)
+ +
__str__(self, /)
Return str(self).
+ +
with_traceback(...)
Exception.with_traceback(tb) --
+set self.__traceback__ to tb and return self.
+ +
+Data descriptors inherited from builtins.BaseException:
+
__cause__
+
exception cause
+
+
__context__
+
exception context
+
+
__dict__
+
+
__suppress_context__
+
+
__traceback__
+
+
args
+
+

+ + + + + + + +
 
+class NotConnectError(ConnectError)
   Inappropriate argument value (of correct type).
 
 
Method resolution order:
+
NotConnectError
+
ConnectError
+
builtins.ValueError
+
builtins.Exception
+
builtins.BaseException
+
builtins.object
+
+
+Data descriptors inherited from ConnectError:
+
__weakref__
+
list of weak references to the object (if defined)
+
+
+Methods inherited from builtins.ValueError:
+
__init__(self, /, *args, **kwargs)
Initialize self.  See help(type(self)) for accurate signature.
+ +
__new__(*args, **kwargs) from builtins.type
Create and return a new object.  See help(type) for accurate signature.
+ +
+Methods inherited from builtins.BaseException:
+
__delattr__(self, name, /)
Implement delattr(self, name).
+ +
__getattribute__(self, name, /)
Return getattr(self, name).
+ +
__reduce__(...)
helper for pickle
+ +
__repr__(self, /)
Return repr(self).
+ +
__setattr__(self, name, value, /)
Implement setattr(self, name, value).
+ +
__setstate__(...)
+ +
__str__(self, /)
Return str(self).
+ +
with_traceback(...)
Exception.with_traceback(tb) --
+set self.__traceback__ to tb and return self.
+ +
+Data descriptors inherited from builtins.BaseException:
+
__cause__
+
exception cause
+
+
__context__
+
exception context
+
+
__dict__
+
+
__suppress_context__
+
+
__traceback__
+
+
args
+
+

+ + + + + + + +
 
+class ParamError(builtins.ValueError)
   Inappropriate argument value (of correct type).
 
 
Method resolution order:
+
ParamError
+
builtins.ValueError
+
builtins.Exception
+
builtins.BaseException
+
builtins.object
+
+
+Data descriptors defined here:
+
__weakref__
+
list of weak references to the object (if defined)
+
+
+Methods inherited from builtins.ValueError:
+
__init__(self, /, *args, **kwargs)
Initialize self.  See help(type(self)) for accurate signature.
+ +
__new__(*args, **kwargs) from builtins.type
Create and return a new object.  See help(type) for accurate signature.
+ +
+Methods inherited from builtins.BaseException:
+
__delattr__(self, name, /)
Implement delattr(self, name).
+ +
__getattribute__(self, name, /)
Return getattr(self, name).
+ +
__reduce__(...)
helper for pickle
+ +
__repr__(self, /)
Return repr(self).
+ +
__setattr__(self, name, value, /)
Implement setattr(self, name, value).
+ +
__setstate__(...)
+ +
__str__(self, /)
Return str(self).
+ +
with_traceback(...)
Exception.with_traceback(tb) --
+set self.__traceback__ to tb and return self.
+ +
+Data descriptors inherited from builtins.BaseException:
+
__cause__
+
exception cause
+
+
__context__
+
exception context
+
+
__dict__
+
+
__suppress_context__
+
+
__traceback__
+
+
args
+
+

+ + + + + + + +
 
+class RepeatingConnectError(ConnectError)
   Inappropriate argument value (of correct type).
 
 
Method resolution order:
+
RepeatingConnectError
+
ConnectError
+
builtins.ValueError
+
builtins.Exception
+
builtins.BaseException
+
builtins.object
+
+
+Data descriptors inherited from ConnectError:
+
__weakref__
+
list of weak references to the object (if defined)
+
+
+Methods inherited from builtins.ValueError:
+
__init__(self, /, *args, **kwargs)
Initialize self.  See help(type(self)) for accurate signature.
+ +
__new__(*args, **kwargs) from builtins.type
Create and return a new object.  See help(type) for accurate signature.
+ +
+Methods inherited from builtins.BaseException:
+
__delattr__(self, name, /)
Implement delattr(self, name).
+ +
__getattribute__(self, name, /)
Return getattr(self, name).
+ +
__reduce__(...)
helper for pickle
+ +
__repr__(self, /)
Return repr(self).
+ +
__setattr__(self, name, value, /)
Implement setattr(self, name, value).
+ +
__setstate__(...)
+ +
__str__(self, /)
Return str(self).
+ +
with_traceback(...)
Exception.with_traceback(tb) --
+set self.__traceback__ to tb and return self.
+ +
+Data descriptors inherited from builtins.BaseException:
+
__cause__
+
exception cause
+
+
__context__
+
exception context
+
+
__dict__
+
+
__suppress_context__
+
+
__traceback__
+
+
args
+
+

+ \ No newline at end of file diff --git a/python/sdk/documents/client.Status.html b/python/sdk/documents/client.Status.html new file mode 100644 index 0000000000000000000000000000000000000000..9f51f679787e99e38430568b3e6c50123e2ad573 --- /dev/null +++ b/python/sdk/documents/client.Status.html @@ -0,0 +1,74 @@ + +Python: module Status + + + + + +
 
+ 
Status
index
/home/yangxuan/vecwise_engine/python/sdk/client/Status.py
+

+

+ + + + + +
 
+Classes
       
+
builtins.object +
+
+
Status +
+
+
+

+ + + + + + + +
 
+class Status(builtins.object)
   :attribute code : int (optional) default as ok
+:attribute message : str (optional) current status message
 
 Methods defined here:
+
__eq__(self, other)
Make Status comparable with self by code
+ +
__init__(self, code=0, message=None)
Initialize self.  See help(type(self)) for accurate signature.
+ +
__ne__(self, other)
Return self!=value.
+ +
__repr__(self)
Return repr(self).
+ +
+Data descriptors defined here:
+
__dict__
+
dictionary for instance variables (if defined)
+
+
__weakref__
+
list of weak references to the object (if defined)
+
+
+Data and other attributes defined here:
+
CONNECT_FAILED = 1
+ +
ILLEGAL_ARGUMENT = 4
+ +
ILLEGAL_DIMENSION = 6
+ +
ILLEGAL_RANGE = 5
+ +
PERMISSION_DENIED = 2
+ +
SUCCESS = 0
+ +
TABLE_NOT_EXISTS = 3
+ +
__hash__ = None
+ +

+ \ No newline at end of file diff --git a/python/sdk/documents/index.html b/python/sdk/documents/index.html new file mode 100644 index 0000000000000000000000000000000000000000..7948cdc4a92f6ff8d914401b143dd79c348799ce --- /dev/null +++ b/python/sdk/documents/index.html @@ -0,0 +1,25 @@ + +Python: package client + + + + + +
 
+ 
client
index
/home/yangxuan/vecwise_engine/python/sdk/client/__init__.py
+

client module

+

+ + + + + +
 
+Package Contents
       
Abstract
+
Client
+
Exceptions
+
Status
+
+ \ No newline at end of file diff --git a/python/sdk/examples/example.py b/python/sdk/examples/example.py index ec478edc04583b3e9efc3ff03bead74cd741abfd..0e2589db1e0526a105969095e15fcee7678bed27 100644 --- a/python/sdk/examples/example.py +++ b/python/sdk/examples/example.py @@ -1,4 +1,4 @@ -from client.Client import MegaSearch, Prepare, IndexType +from client.Client import Milvus, Prepare, IndexType import random import struct from pprint import pprint @@ -6,24 +6,24 @@ from pprint import pprint def main(): # Get client version - mega = MegaSearch() - print('# Client version: {}'.format(mega.client_version())) + milvus = Milvus() + print('# Client version: {}'.format(milvus.client_version())) # Connect # Please change HOST and PORT to correct one param = {'host': 'HOST', 'port': 'PORT'} - cnn_status = mega.connect(**param) + cnn_status = milvus.connect(**param) print('# Connect Status: {}'.format(cnn_status)) # Check if connected - is_connected = mega.connected + is_connected = milvus.connected print('# Is connected: {}'.format(is_connected)) # Get server version - print('# Server version: {}'.format(mega.server_version())) + print('# Server version: {}'.format(milvus.server_version())) # Show tables and their description - status, tables = mega.show_tables() + status, tables = milvus.show_tables() print('# Show tables: {}'.format(tables)) # Create table @@ -36,12 +36,12 @@ def main(): } # 02.Create table - res_status = mega.create_table(Prepare.table_schema(**param)) + res_status = milvus.create_table(Prepare.table_schema(**param)) print('# Create table status: {}'.format(res_status)) # Describe table table_name = 'test01' - res_status, table = mega.describe_table(table_name) + res_status, table = milvus.describe_table(table_name) print('# Describe table status: {}'.format(res_status)) print('# Describe table:{}'.format(table)) @@ -53,7 +53,7 @@ def main(): *[random.random()for _ in range(dim)])) for _ in range(20)] # 02. Add vectors - status, ids = mega.add_vectors(table_name=table_name, records=vectors) + status, ids = milvus.add_vectors(table_name=table_name, records=vectors) print('# Add vector status: {}'.format(status)) pprint(ids) @@ -67,21 +67,21 @@ def main(): 'top_k': 10, # 'query_ranges': None # Optional } - sta, results = mega.search_vectors(**param) + sta, results = milvus.search_vectors(**param) print('# Search vectors status: {}'.format(sta)) pprint(results) # Get table row count - sta, result = mega.get_table_row_count(table_name) + sta, result = milvus.get_table_row_count(table_name) print('# Status: {}'.format(sta)) print('# Count: {}'.format(result)) # Delete table 'test01' - res_status = mega.delete_table(table_name) + res_status = milvus.delete_table(table_name) print('# Delete table status: {}'.format(res_status)) # Disconnect - discnn_status = mega.disconnect() + discnn_status = milvus.disconnect() print('# Disconnect Status: {}'.format(discnn_status)) diff --git a/python/sdk/milvus/__init__.py b/python/sdk/milvus/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/python/sdk/milvus/thrift/MilvusService-remote b/python/sdk/milvus/thrift/MilvusService-remote new file mode 100755 index 0000000000000000000000000000000000000000..d111f13730b6362e889f506aa4d5dd9b72704058 --- /dev/null +++ b/python/sdk/milvus/thrift/MilvusService-remote @@ -0,0 +1,166 @@ +#!/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 milvus.thrift import MilvusService +from milvus.thrift.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 CreateTable(TableSchema param)') + print(' void DeleteTable(string table_name)') + print(' AddVector(string table_name, record_array)') + print(' SearchVector(string table_name, query_record_array, query_range_array, i64 topk)') + print(' TableSchema DescribeTable(string table_name)') + print(' i64 GetTableRowCount(string table_name)') + print(' ShowTables()') + print(' string Ping(string cmd)') + 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 = MilvusService.Client(protocol) +transport.open() + +if cmd == 'CreateTable': + if len(args) != 1: + print('CreateTable requires 1 args') + sys.exit(1) + pp.pprint(client.CreateTable(eval(args[0]),)) + +elif cmd == 'DeleteTable': + if len(args) != 1: + print('DeleteTable requires 1 args') + sys.exit(1) + pp.pprint(client.DeleteTable(args[0],)) + +elif cmd == 'AddVector': + if len(args) != 2: + print('AddVector requires 2 args') + sys.exit(1) + pp.pprint(client.AddVector(args[0], eval(args[1]),)) + +elif cmd == 'SearchVector': + if len(args) != 4: + print('SearchVector requires 4 args') + sys.exit(1) + pp.pprint(client.SearchVector(args[0], eval(args[1]), eval(args[2]), eval(args[3]),)) + +elif cmd == 'DescribeTable': + if len(args) != 1: + print('DescribeTable requires 1 args') + sys.exit(1) + pp.pprint(client.DescribeTable(args[0],)) + +elif cmd == 'GetTableRowCount': + if len(args) != 1: + print('GetTableRowCount requires 1 args') + sys.exit(1) + pp.pprint(client.GetTableRowCount(args[0],)) + +elif cmd == 'ShowTables': + if len(args) != 0: + print('ShowTables requires 0 args') + sys.exit(1) + pp.pprint(client.ShowTables()) + +elif cmd == 'Ping': + if len(args) != 1: + print('Ping requires 1 args') + sys.exit(1) + pp.pprint(client.Ping(args[0],)) + +else: + print('Unrecognized method %s' % cmd) + sys.exit(1) + +transport.close() diff --git a/python/sdk/milvus/thrift/MilvusService.py b/python/sdk/milvus/thrift/MilvusService.py new file mode 100644 index 0000000000000000000000000000000000000000..23b0120bed18a745bc0c7ff4082b3c26544909b7 --- /dev/null +++ b/python/sdk/milvus/thrift/MilvusService.py @@ -0,0 +1,1889 @@ +# +# 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 CreateTable(self, param): + """ + @brief Create table method + + This method is used to create table + + @param param, use to provide table information to be created. + + + Parameters: + - param + + """ + pass + + def DeleteTable(self, table_name): + """ + @brief Delete table method + + This method is used to delete table. + + @param table_name, table name is going to be deleted. + + + Parameters: + - table_name + + """ + pass + + def AddVector(self, table_name, record_array): + """ + @brief Add vector array to table + + This method is used to add vector array to table. + + @param table_name, table_name is inserted. + @param record_array, vector array is inserted. + + @return vector id array + + Parameters: + - table_name + - record_array + + """ + pass + + def SearchVector(self, table_name, query_record_array, query_range_array, topk): + """ + @brief Query vector + + This method is used to query vector in table. + + @param table_name, table_name is queried. + @param query_record_array, all vector are going to be queried. + @param query_range_array, optional ranges for conditional search. If not specified, search whole table + @param topk, how many similarity vectors will be searched. + + @return query result array. + + Parameters: + - table_name + - query_record_array + - query_range_array + - topk + + """ + pass + + def DescribeTable(self, table_name): + """ + @brief Get table schema + + This method is used to get table schema. + + @param table_name, target table name. + + @return table schema + + Parameters: + - table_name + + """ + pass + + def GetTableRowCount(self, table_name): + """ + @brief Get table row count + + This method is used to get table row count. + + @param table_name, target table name. + + @return table row count + + Parameters: + - table_name + + """ + pass + + def ShowTables(self): + """ + @brief List all tables in database + + This method is used to list all tables. + + + @return table names. + + """ + pass + + def Ping(self, cmd): + """ + @brief Give the server status + + This method is used to give the server status. + + @return Server status. + + Parameters: + - cmd + + """ + 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 CreateTable(self, param): + """ + @brief Create table method + + This method is used to create table + + @param param, use to provide table information to be created. + + + Parameters: + - param + + """ + self.send_CreateTable(param) + self.recv_CreateTable() + + def send_CreateTable(self, param): + self._oprot.writeMessageBegin('CreateTable', TMessageType.CALL, self._seqid) + args = CreateTable_args() + args.param = param + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_CreateTable(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = CreateTable_result() + result.read(iprot) + iprot.readMessageEnd() + if result.e is not None: + raise result.e + return + + def DeleteTable(self, table_name): + """ + @brief Delete table method + + This method is used to delete table. + + @param table_name, table name is going to be deleted. + + + Parameters: + - table_name + + """ + self.send_DeleteTable(table_name) + self.recv_DeleteTable() + + def send_DeleteTable(self, table_name): + self._oprot.writeMessageBegin('DeleteTable', TMessageType.CALL, self._seqid) + args = DeleteTable_args() + args.table_name = table_name + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_DeleteTable(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = DeleteTable_result() + result.read(iprot) + iprot.readMessageEnd() + if result.e is not None: + raise result.e + return + + def AddVector(self, table_name, record_array): + """ + @brief Add vector array to table + + This method is used to add vector array to table. + + @param table_name, table_name is inserted. + @param record_array, vector array is inserted. + + @return vector id array + + Parameters: + - table_name + - record_array + + """ + self.send_AddVector(table_name, record_array) + return self.recv_AddVector() + + def send_AddVector(self, table_name, record_array): + self._oprot.writeMessageBegin('AddVector', TMessageType.CALL, self._seqid) + args = AddVector_args() + args.table_name = table_name + args.record_array = record_array + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_AddVector(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = AddVector_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, "AddVector failed: unknown result") + + def SearchVector(self, table_name, query_record_array, query_range_array, topk): + """ + @brief Query vector + + This method is used to query vector in table. + + @param table_name, table_name is queried. + @param query_record_array, all vector are going to be queried. + @param query_range_array, optional ranges for conditional search. If not specified, search whole table + @param topk, how many similarity vectors will be searched. + + @return query result array. + + Parameters: + - table_name + - query_record_array + - query_range_array + - topk + + """ + self.send_SearchVector(table_name, query_record_array, query_range_array, topk) + return self.recv_SearchVector() + + def send_SearchVector(self, table_name, query_record_array, query_range_array, topk): + self._oprot.writeMessageBegin('SearchVector', TMessageType.CALL, self._seqid) + args = SearchVector_args() + args.table_name = table_name + args.query_record_array = query_record_array + args.query_range_array = query_range_array + args.topk = topk + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_SearchVector(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = SearchVector_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, "SearchVector failed: unknown result") + + def DescribeTable(self, table_name): + """ + @brief Get table schema + + This method is used to get table schema. + + @param table_name, target table name. + + @return table schema + + Parameters: + - table_name + + """ + self.send_DescribeTable(table_name) + return self.recv_DescribeTable() + + def send_DescribeTable(self, table_name): + self._oprot.writeMessageBegin('DescribeTable', TMessageType.CALL, self._seqid) + args = DescribeTable_args() + args.table_name = table_name + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_DescribeTable(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = DescribeTable_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, "DescribeTable failed: unknown result") + + def GetTableRowCount(self, table_name): + """ + @brief Get table row count + + This method is used to get table row count. + + @param table_name, target table name. + + @return table row count + + Parameters: + - table_name + + """ + self.send_GetTableRowCount(table_name) + return self.recv_GetTableRowCount() + + def send_GetTableRowCount(self, table_name): + self._oprot.writeMessageBegin('GetTableRowCount', TMessageType.CALL, self._seqid) + args = GetTableRowCount_args() + args.table_name = table_name + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_GetTableRowCount(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = GetTableRowCount_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, "GetTableRowCount failed: unknown result") + + def ShowTables(self): + """ + @brief List all tables in database + + This method is used to list all tables. + + + @return table names. + + """ + self.send_ShowTables() + return self.recv_ShowTables() + + def send_ShowTables(self): + self._oprot.writeMessageBegin('ShowTables', TMessageType.CALL, self._seqid) + args = ShowTables_args() + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_ShowTables(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = ShowTables_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, "ShowTables failed: unknown result") + + def Ping(self, cmd): + """ + @brief Give the server status + + This method is used to give the server status. + + @return Server status. + + Parameters: + - cmd + + """ + self.send_Ping(cmd) + return self.recv_Ping() + + def send_Ping(self, cmd): + self._oprot.writeMessageBegin('Ping', TMessageType.CALL, self._seqid) + args = Ping_args() + args.cmd = cmd + args.write(self._oprot) + self._oprot.writeMessageEnd() + self._oprot.trans.flush() + + def recv_Ping(self): + iprot = self._iprot + (fname, mtype, rseqid) = iprot.readMessageBegin() + if mtype == TMessageType.EXCEPTION: + x = TApplicationException() + x.read(iprot) + iprot.readMessageEnd() + raise x + result = Ping_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, "Ping failed: unknown result") + + +class Processor(Iface, TProcessor): + def __init__(self, handler): + self._handler = handler + self._processMap = {} + self._processMap["CreateTable"] = Processor.process_CreateTable + self._processMap["DeleteTable"] = Processor.process_DeleteTable + self._processMap["AddVector"] = Processor.process_AddVector + self._processMap["SearchVector"] = Processor.process_SearchVector + self._processMap["DescribeTable"] = Processor.process_DescribeTable + self._processMap["GetTableRowCount"] = Processor.process_GetTableRowCount + self._processMap["ShowTables"] = Processor.process_ShowTables + self._processMap["Ping"] = Processor.process_Ping + + 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_CreateTable(self, seqid, iprot, oprot): + args = CreateTable_args() + args.read(iprot) + iprot.readMessageEnd() + result = CreateTable_result() + try: + self._handler.CreateTable(args.param) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except Exception 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("CreateTable", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_DeleteTable(self, seqid, iprot, oprot): + args = DeleteTable_args() + args.read(iprot) + iprot.readMessageEnd() + result = DeleteTable_result() + try: + self._handler.DeleteTable(args.table_name) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except Exception 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("DeleteTable", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_AddVector(self, seqid, iprot, oprot): + args = AddVector_args() + args.read(iprot) + iprot.readMessageEnd() + result = AddVector_result() + try: + result.success = self._handler.AddVector(args.table_name, args.record_array) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except Exception 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("AddVector", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_SearchVector(self, seqid, iprot, oprot): + args = SearchVector_args() + args.read(iprot) + iprot.readMessageEnd() + result = SearchVector_result() + try: + result.success = self._handler.SearchVector(args.table_name, args.query_record_array, args.query_range_array, args.topk) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except Exception 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("SearchVector", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_DescribeTable(self, seqid, iprot, oprot): + args = DescribeTable_args() + args.read(iprot) + iprot.readMessageEnd() + result = DescribeTable_result() + try: + result.success = self._handler.DescribeTable(args.table_name) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except Exception 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("DescribeTable", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_GetTableRowCount(self, seqid, iprot, oprot): + args = GetTableRowCount_args() + args.read(iprot) + iprot.readMessageEnd() + result = GetTableRowCount_result() + try: + result.success = self._handler.GetTableRowCount(args.table_name) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except Exception 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("GetTableRowCount", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_ShowTables(self, seqid, iprot, oprot): + args = ShowTables_args() + args.read(iprot) + iprot.readMessageEnd() + result = ShowTables_result() + try: + result.success = self._handler.ShowTables() + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except Exception 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("ShowTables", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + + def process_Ping(self, seqid, iprot, oprot): + args = Ping_args() + args.read(iprot) + iprot.readMessageEnd() + result = Ping_result() + try: + result.success = self._handler.Ping(args.cmd) + msg_type = TMessageType.REPLY + except TTransport.TTransportException: + raise + except Exception 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("Ping", msg_type, seqid) + result.write(oprot) + oprot.writeMessageEnd() + oprot.trans.flush() + +# HELPER FUNCTIONS AND STRUCTURES + + +class CreateTable_args(object): + """ + Attributes: + - param + + """ + + + def __init__(self, param=None,): + self.param = param + + 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.param = TableSchema() + self.param.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('CreateTable_args') + if self.param is not None: + oprot.writeFieldBegin('param', TType.STRUCT, 2) + self.param.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(CreateTable_args) +CreateTable_args.thrift_spec = ( + None, # 0 + None, # 1 + (2, TType.STRUCT, 'param', [TableSchema, None], None, ), # 2 +) + + +class CreateTable_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 = Exception() + 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('CreateTable_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(CreateTable_result) +CreateTable_result.thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'e', [Exception, None], None, ), # 1 +) + + +class DeleteTable_args(object): + """ + Attributes: + - table_name + + """ + + + def __init__(self, table_name=None,): + self.table_name = table_name + + 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.table_name = 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('DeleteTable_args') + if self.table_name is not None: + oprot.writeFieldBegin('table_name', TType.STRING, 2) + oprot.writeString(self.table_name.encode('utf-8') if sys.version_info[0] == 2 else self.table_name) + 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(DeleteTable_args) +DeleteTable_args.thrift_spec = ( + None, # 0 + None, # 1 + (2, TType.STRING, 'table_name', 'UTF8', None, ), # 2 +) + + +class DeleteTable_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 = Exception() + 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('DeleteTable_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(DeleteTable_result) +DeleteTable_result.thrift_spec = ( + None, # 0 + (1, TType.STRUCT, 'e', [Exception, None], None, ), # 1 +) + + +class AddVector_args(object): + """ + Attributes: + - table_name + - record_array + + """ + + + def __init__(self, table_name=None, record_array=None,): + self.table_name = table_name + self.record_array = record_array + + 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.table_name = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.LIST: + self.record_array = [] + (_etype10, _size7) = iprot.readListBegin() + for _i11 in range(_size7): + _elem12 = RowRecord() + _elem12.read(iprot) + self.record_array.append(_elem12) + 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('AddVector_args') + if self.table_name is not None: + oprot.writeFieldBegin('table_name', TType.STRING, 2) + oprot.writeString(self.table_name.encode('utf-8') if sys.version_info[0] == 2 else self.table_name) + oprot.writeFieldEnd() + if self.record_array is not None: + oprot.writeFieldBegin('record_array', TType.LIST, 3) + oprot.writeListBegin(TType.STRUCT, len(self.record_array)) + for iter13 in self.record_array: + iter13.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(AddVector_args) +AddVector_args.thrift_spec = ( + None, # 0 + None, # 1 + (2, TType.STRING, 'table_name', 'UTF8', None, ), # 2 + (3, TType.LIST, 'record_array', (TType.STRUCT, [RowRecord, None], False), None, ), # 3 +) + + +class AddVector_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.LIST: + self.success = [] + (_etype17, _size14) = iprot.readListBegin() + for _i18 in range(_size14): + _elem19 = iprot.readI64() + self.success.append(_elem19) + iprot.readListEnd() + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.e = Exception() + 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('AddVector_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.LIST, 0) + oprot.writeListBegin(TType.I64, len(self.success)) + for iter20 in self.success: + oprot.writeI64(iter20) + oprot.writeListEnd() + 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(AddVector_result) +AddVector_result.thrift_spec = ( + (0, TType.LIST, 'success', (TType.I64, None, False), None, ), # 0 + (1, TType.STRUCT, 'e', [Exception, None], None, ), # 1 +) + + +class SearchVector_args(object): + """ + Attributes: + - table_name + - query_record_array + - query_range_array + - topk + + """ + + + def __init__(self, table_name=None, query_record_array=None, query_range_array=None, topk=None,): + self.table_name = table_name + self.query_record_array = query_record_array + self.query_range_array = query_range_array + self.topk = topk + + 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.table_name = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.LIST: + self.query_record_array = [] + (_etype24, _size21) = iprot.readListBegin() + for _i25 in range(_size21): + _elem26 = RowRecord() + _elem26.read(iprot) + self.query_record_array.append(_elem26) + iprot.readListEnd() + else: + iprot.skip(ftype) + elif fid == 4: + if ftype == TType.LIST: + self.query_range_array = [] + (_etype30, _size27) = iprot.readListBegin() + for _i31 in range(_size27): + _elem32 = Range() + _elem32.read(iprot) + self.query_range_array.append(_elem32) + iprot.readListEnd() + else: + iprot.skip(ftype) + elif fid == 5: + if ftype == TType.I64: + self.topk = iprot.readI64() + 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('SearchVector_args') + if self.table_name is not None: + oprot.writeFieldBegin('table_name', TType.STRING, 2) + oprot.writeString(self.table_name.encode('utf-8') if sys.version_info[0] == 2 else self.table_name) + oprot.writeFieldEnd() + if self.query_record_array is not None: + oprot.writeFieldBegin('query_record_array', TType.LIST, 3) + oprot.writeListBegin(TType.STRUCT, len(self.query_record_array)) + for iter33 in self.query_record_array: + iter33.write(oprot) + oprot.writeListEnd() + oprot.writeFieldEnd() + if self.query_range_array is not None: + oprot.writeFieldBegin('query_range_array', TType.LIST, 4) + oprot.writeListBegin(TType.STRUCT, len(self.query_range_array)) + for iter34 in self.query_range_array: + iter34.write(oprot) + oprot.writeListEnd() + oprot.writeFieldEnd() + if self.topk is not None: + oprot.writeFieldBegin('topk', TType.I64, 5) + oprot.writeI64(self.topk) + 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(SearchVector_args) +SearchVector_args.thrift_spec = ( + None, # 0 + None, # 1 + (2, TType.STRING, 'table_name', 'UTF8', None, ), # 2 + (3, TType.LIST, 'query_record_array', (TType.STRUCT, [RowRecord, None], False), None, ), # 3 + (4, TType.LIST, 'query_range_array', (TType.STRUCT, [Range, None], False), None, ), # 4 + (5, TType.I64, 'topk', None, None, ), # 5 +) + + +class SearchVector_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.LIST: + self.success = [] + (_etype38, _size35) = iprot.readListBegin() + for _i39 in range(_size35): + _elem40 = TopKQueryResult() + _elem40.read(iprot) + self.success.append(_elem40) + iprot.readListEnd() + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.e = Exception() + 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('SearchVector_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.LIST, 0) + oprot.writeListBegin(TType.STRUCT, len(self.success)) + for iter41 in self.success: + iter41.write(oprot) + oprot.writeListEnd() + 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(SearchVector_result) +SearchVector_result.thrift_spec = ( + (0, TType.LIST, 'success', (TType.STRUCT, [TopKQueryResult, None], False), None, ), # 0 + (1, TType.STRUCT, 'e', [Exception, None], None, ), # 1 +) + + +class DescribeTable_args(object): + """ + Attributes: + - table_name + + """ + + + def __init__(self, table_name=None,): + self.table_name = table_name + + 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.table_name = 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('DescribeTable_args') + if self.table_name is not None: + oprot.writeFieldBegin('table_name', TType.STRING, 2) + oprot.writeString(self.table_name.encode('utf-8') if sys.version_info[0] == 2 else self.table_name) + 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(DescribeTable_args) +DescribeTable_args.thrift_spec = ( + None, # 0 + None, # 1 + (2, TType.STRING, 'table_name', 'UTF8', None, ), # 2 +) + + +class DescribeTable_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 = TableSchema() + self.success.read(iprot) + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.e = Exception() + 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('DescribeTable_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(DescribeTable_result) +DescribeTable_result.thrift_spec = ( + (0, TType.STRUCT, 'success', [TableSchema, None], None, ), # 0 + (1, TType.STRUCT, 'e', [Exception, None], None, ), # 1 +) + + +class GetTableRowCount_args(object): + """ + Attributes: + - table_name + + """ + + + def __init__(self, table_name=None,): + self.table_name = table_name + + 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.table_name = 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('GetTableRowCount_args') + if self.table_name is not None: + oprot.writeFieldBegin('table_name', TType.STRING, 2) + oprot.writeString(self.table_name.encode('utf-8') if sys.version_info[0] == 2 else self.table_name) + 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(GetTableRowCount_args) +GetTableRowCount_args.thrift_spec = ( + None, # 0 + None, # 1 + (2, TType.STRING, 'table_name', 'UTF8', None, ), # 2 +) + + +class GetTableRowCount_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.I64: + self.success = iprot.readI64() + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.e = Exception() + 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('GetTableRowCount_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.I64, 0) + oprot.writeI64(self.success) + 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(GetTableRowCount_result) +GetTableRowCount_result.thrift_spec = ( + (0, TType.I64, 'success', None, None, ), # 0 + (1, TType.STRUCT, 'e', [Exception, None], None, ), # 1 +) + + +class ShowTables_args(object): + + + 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 + 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('ShowTables_args') + 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(ShowTables_args) +ShowTables_args.thrift_spec = ( +) + + +class ShowTables_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.LIST: + self.success = [] + (_etype45, _size42) = iprot.readListBegin() + for _i46 in range(_size42): + _elem47 = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + self.success.append(_elem47) + iprot.readListEnd() + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.e = Exception() + 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('ShowTables_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.LIST, 0) + oprot.writeListBegin(TType.STRING, len(self.success)) + for iter48 in self.success: + oprot.writeString(iter48.encode('utf-8') if sys.version_info[0] == 2 else iter48) + oprot.writeListEnd() + 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(ShowTables_result) +ShowTables_result.thrift_spec = ( + (0, TType.LIST, 'success', (TType.STRING, 'UTF8', False), None, ), # 0 + (1, TType.STRUCT, 'e', [Exception, None], None, ), # 1 +) + + +class Ping_args(object): + """ + Attributes: + - cmd + + """ + + + def __init__(self, cmd=None,): + self.cmd = cmd + + 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.cmd = 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('Ping_args') + if self.cmd is not None: + oprot.writeFieldBegin('cmd', TType.STRING, 2) + oprot.writeString(self.cmd.encode('utf-8') if sys.version_info[0] == 2 else self.cmd) + 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(Ping_args) +Ping_args.thrift_spec = ( + None, # 0 + None, # 1 + (2, TType.STRING, 'cmd', 'UTF8', None, ), # 2 +) + + +class Ping_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.STRING: + self.success = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString() + else: + iprot.skip(ftype) + elif fid == 1: + if ftype == TType.STRUCT: + self.e = Exception() + 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('Ping_result') + if self.success is not None: + oprot.writeFieldBegin('success', TType.STRING, 0) + oprot.writeString(self.success.encode('utf-8') if sys.version_info[0] == 2 else self.success) + 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(Ping_result) +Ping_result.thrift_spec = ( + (0, TType.STRING, 'success', 'UTF8', None, ), # 0 + (1, TType.STRUCT, 'e', [Exception, None], None, ), # 1 +) +fix_spec(all_structs) +del all_structs + diff --git a/python/sdk/milvus/thrift/__init__.py b/python/sdk/milvus/thrift/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..47629e6c880ddc27d914ad1a6d799d97be40d784 --- /dev/null +++ b/python/sdk/milvus/thrift/__init__.py @@ -0,0 +1 @@ +__all__ = ['ttypes', 'constants', 'MilvusService.py'] diff --git a/python/sdk/milvus/thrift/constants.py b/python/sdk/milvus/thrift/constants.py new file mode 100644 index 0000000000000000000000000000000000000000..c59352d09f1807e564bfcc1fab3849b5954405ba --- /dev/null +++ b/python/sdk/milvus/thrift/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/python/sdk/milvus/thrift/ttypes.py b/python/sdk/milvus/thrift/ttypes.py new file mode 100644 index 0000000000000000000000000000000000000000..2e49e8f27f226cbd070ea2b601b17325a864ee13 --- /dev/null +++ b/python/sdk/milvus/thrift/ttypes.py @@ -0,0 +1,518 @@ +# +# 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 ErrorCode(object): + SUCCESS = 0 + CONNECT_FAILED = 1 + PERMISSION_DENIED = 2 + TABLE_NOT_EXISTS = 3 + ILLEGAL_ARGUMENT = 4 + ILLEGAL_RANGE = 5 + ILLEGAL_DIMENSION = 6 + + _VALUES_TO_NAMES = { + 0: "SUCCESS", + 1: "CONNECT_FAILED", + 2: "PERMISSION_DENIED", + 3: "TABLE_NOT_EXISTS", + 4: "ILLEGAL_ARGUMENT", + 5: "ILLEGAL_RANGE", + 6: "ILLEGAL_DIMENSION", + } + + _NAMES_TO_VALUES = { + "SUCCESS": 0, + "CONNECT_FAILED": 1, + "PERMISSION_DENIED": 2, + "TABLE_NOT_EXISTS": 3, + "ILLEGAL_ARGUMENT": 4, + "ILLEGAL_RANGE": 5, + "ILLEGAL_DIMENSION": 6, + } + + +class Exception(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('Exception') + 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 TableSchema(object): + """ + @brief Table Schema + + Attributes: + - table_name + - index_type + - dimension + - store_raw_vector + + """ + + + def __init__(self, table_name=None, index_type=0, dimension=0, store_raw_vector=False,): + self.table_name = table_name + self.index_type = index_type + self.dimension = dimension + self.store_raw_vector = store_raw_vector + + 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.table_name = 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.index_type = iprot.readI32() + else: + iprot.skip(ftype) + elif fid == 3: + if ftype == TType.I64: + self.dimension = iprot.readI64() + else: + iprot.skip(ftype) + elif fid == 4: + if ftype == TType.BOOL: + self.store_raw_vector = 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('TableSchema') + if self.table_name is not None: + oprot.writeFieldBegin('table_name', TType.STRING, 1) + oprot.writeString(self.table_name.encode('utf-8') if sys.version_info[0] == 2 else self.table_name) + oprot.writeFieldEnd() + if self.index_type is not None: + oprot.writeFieldBegin('index_type', TType.I32, 2) + oprot.writeI32(self.index_type) + oprot.writeFieldEnd() + if self.dimension is not None: + oprot.writeFieldBegin('dimension', TType.I64, 3) + oprot.writeI64(self.dimension) + oprot.writeFieldEnd() + if self.store_raw_vector is not None: + oprot.writeFieldBegin('store_raw_vector', TType.BOOL, 4) + oprot.writeBool(self.store_raw_vector) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + if self.table_name is None: + raise TProtocolException(message='Required field table_name 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 Range(object): + """ + @brief Range Schema + + Attributes: + - start_value + - end_value + + """ + + + def __init__(self, start_value=None, end_value=None,): + self.start_value = start_value + self.end_value = end_value + + 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.start_value = 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.end_value = 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('Range') + if self.start_value is not None: + oprot.writeFieldBegin('start_value', TType.STRING, 1) + oprot.writeString(self.start_value.encode('utf-8') if sys.version_info[0] == 2 else self.start_value) + oprot.writeFieldEnd() + if self.end_value is not None: + oprot.writeFieldBegin('end_value', TType.STRING, 2) + oprot.writeString(self.end_value.encode('utf-8') if sys.version_info[0] == 2 else self.end_value) + 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 RowRecord(object): + """ + @brief Record inserted + + Attributes: + - vector_data + + """ + + + def __init__(self, vector_data=None,): + self.vector_data = vector_data + + 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.vector_data = iprot.readBinary() + 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('RowRecord') + if self.vector_data is not None: + oprot.writeFieldBegin('vector_data', TType.STRING, 1) + oprot.writeBinary(self.vector_data) + oprot.writeFieldEnd() + oprot.writeFieldStop() + oprot.writeStructEnd() + + def validate(self): + if self.vector_data is None: + raise TProtocolException(message='Required field vector_data 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 QueryResult(object): + """ + @brief Query result + + Attributes: + - id + - score + + """ + + + def __init__(self, id=None, score=None,): + self.id = id + self.score = score + + 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.I64: + self.id = iprot.readI64() + else: + iprot.skip(ftype) + elif fid == 2: + if ftype == TType.DOUBLE: + self.score = iprot.readDouble() + 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('QueryResult') + if self.id is not None: + oprot.writeFieldBegin('id', TType.I64, 1) + oprot.writeI64(self.id) + oprot.writeFieldEnd() + if self.score is not None: + oprot.writeFieldBegin('score', TType.DOUBLE, 2) + oprot.writeDouble(self.score) + 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 TopKQueryResult(object): + """ + @brief TopK query result + + Attributes: + - query_result_arrays + + """ + + + def __init__(self, query_result_arrays=None,): + self.query_result_arrays = query_result_arrays + + 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.query_result_arrays = [] + (_etype3, _size0) = iprot.readListBegin() + for _i4 in range(_size0): + _elem5 = QueryResult() + _elem5.read(iprot) + self.query_result_arrays.append(_elem5) + 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('TopKQueryResult') + if self.query_result_arrays is not None: + oprot.writeFieldBegin('query_result_arrays', TType.LIST, 1) + oprot.writeListBegin(TType.STRUCT, len(self.query_result_arrays)) + for iter6 in self.query_result_arrays: + iter6.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(Exception) +Exception.thrift_spec = ( + None, # 0 + (1, TType.I32, 'code', None, None, ), # 1 + (2, TType.STRING, 'reason', 'UTF8', None, ), # 2 +) +all_structs.append(TableSchema) +TableSchema.thrift_spec = ( + None, # 0 + (1, TType.STRING, 'table_name', 'UTF8', None, ), # 1 + (2, TType.I32, 'index_type', None, 0, ), # 2 + (3, TType.I64, 'dimension', None, 0, ), # 3 + (4, TType.BOOL, 'store_raw_vector', None, False, ), # 4 +) +all_structs.append(Range) +Range.thrift_spec = ( + None, # 0 + (1, TType.STRING, 'start_value', 'UTF8', None, ), # 1 + (2, TType.STRING, 'end_value', 'UTF8', None, ), # 2 +) +all_structs.append(RowRecord) +RowRecord.thrift_spec = ( + None, # 0 + (1, TType.STRING, 'vector_data', 'BINARY', None, ), # 1 +) +all_structs.append(QueryResult) +QueryResult.thrift_spec = ( + None, # 0 + (1, TType.I64, 'id', None, None, ), # 1 + (2, TType.DOUBLE, 'score', None, None, ), # 2 +) +all_structs.append(TopKQueryResult) +TopKQueryResult.thrift_spec = ( + None, # 0 + (1, TType.LIST, 'query_result_arrays', (TType.STRUCT, [QueryResult, None], False), None, ), # 1 +) +fix_spec(all_structs) +del all_structs diff --git a/python/sdk/tests/TestClient.py b/python/sdk/tests/TestClient.py index aef507bb033da233d2982c2b5d92f4ce23034639..e803d5a5abfa6b7e39e8cc320b9f34ba93ca2139 100644 --- a/python/sdk/tests/TestClient.py +++ b/python/sdk/tests/TestClient.py @@ -6,14 +6,14 @@ import random import struct from faker.providers import BaseProvider -from client.Client import MegaSearch, Prepare +from client.Client import Milvus, Prepare from client.Abstract import IndexType, TableSchema from client.Status import Status from client.Exceptions import ( RepeatingConnectError, DisconnectNotConnectedClientError ) -from megasearch.thrift import ttypes, MegasearchService +from milvus.thrift import ttypes, MilvusService from thrift.transport.TSocket import TSocket from thrift.transport import TTransport @@ -77,7 +77,7 @@ class TestConnection: @mock.patch.object(TSocket, 'open') def test_true_connect(self, open): open.return_value = None - cnn = MegaSearch() + cnn = Milvus() cnn.connect(**self.param) assert cnn.status == Status.SUCCESS @@ -88,7 +88,7 @@ class TestConnection: cnn.connect() def test_false_connect(self): - cnn = MegaSearch() + cnn = Milvus() cnn.connect(**self.param) assert cnn.status != Status.SUCCESS @@ -99,13 +99,13 @@ class TestConnection: close.return_value = None open.return_value = None - cnn = MegaSearch() + cnn = Milvus() cnn.connect(**self.param) assert cnn.disconnect() == Status.SUCCESS def test_disconnected_error(self): - cnn = MegaSearch() + cnn = Milvus() cnn.connect_status = Status(Status.PERMISSION_DENIED) with pytest.raises(DisconnectNotConnectedClientError): cnn.disconnect() @@ -119,11 +119,11 @@ class TestTable: param = {'host': 'localhost', 'port': '5000'} open.return_value = None - cnn = MegaSearch() + cnn = Milvus() cnn.connect(**param) return cnn - @mock.patch.object(MegasearchService.Client, 'CreateTable') + @mock.patch.object(MilvusService.Client, 'CreateTable') def test_create_table(self, CreateTable, client): CreateTable.return_value = None @@ -138,7 +138,7 @@ class TestTable: LOGGER.error('{}'.format(res)) assert res != Status.SUCCESS - @mock.patch.object(MegasearchService.Client, 'DeleteTable') + @mock.patch.object(MilvusService.Client, 'DeleteTable') def test_delete_table(self, DeleteTable, client): DeleteTable.return_value = None table_name = 'fake_table_name' @@ -159,11 +159,11 @@ class TestVector: param = {'host': 'localhost', 'port': '5000'} open.return_value = None - cnn = MegaSearch() + cnn = Milvus() cnn.connect(**param) return cnn - @mock.patch.object(MegasearchService.Client, 'AddVector') + @mock.patch.object(MilvusService.Client, 'AddVector') def test_add_vector(self, AddVector, client): AddVector.return_value = None @@ -182,7 +182,7 @@ class TestVector: res, ids = client.add_vectors(**param) assert res != Status.SUCCESS - @mock.patch.object(MegasearchService.Client, 'SearchVector') + @mock.patch.object(MilvusService.Client, 'SearchVector') def test_search_vector(self, SearchVector, client): SearchVector.return_value = None, None param = { @@ -204,7 +204,7 @@ class TestVector: res, results = client.search_vectors(**param) assert res != Status.SUCCESS - @mock.patch.object(MegasearchService.Client, 'DescribeTable') + @mock.patch.object(MilvusService.Client, 'DescribeTable') def test_describe_table(self, DescribeTable, client): DescribeTable.return_value = table_schema_factory() @@ -219,7 +219,7 @@ class TestVector: assert res != Status.SUCCESS assert not table_schema - @mock.patch.object(MegasearchService.Client, 'ShowTables') + @mock.patch.object(MilvusService.Client, 'ShowTables') def test_show_tables(self, ShowTables, client): ShowTables.return_value = [fake.table_name() for _ in range(10)], None res, tables = client.show_tables() @@ -231,7 +231,7 @@ class TestVector: assert res != Status.SUCCESS assert not tables - @mock.patch.object(MegasearchService.Client, 'GetTableRowCount') + @mock.patch.object(MilvusService.Client, 'GetTableRowCount') def test_get_table_row_count(self, GetTableRowCount, client): GetTableRowCount.return_value = 22, None res, count = client.get_table_row_count('fake_table')