mirror of https://github.com/milvus-io/milvus.git
edit(python): change name to milvus
Former-commit-id: 35bf1219af291c16b31c23d017e1d5d4b8a136f2pull/191/head
parent
50003059b4
commit
2a027bff6f
|
@ -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()
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
"""client module"""
|
|
@ -0,0 +1,353 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><title>Python: module Abstract</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
</head><body bgcolor="#f0f0f8">
|
||||
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
|
||||
<tr bgcolor="#7799ee">
|
||||
<td valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>Abstract</strong></big></big></font></td
|
||||
><td align=right valign=bottom
|
||||
><font color="#ffffff" face="helvetica, arial"><a href="../..">index</a><br><a href="file:/home/yangxuan/vecwise_engine/python/sdk/client/Abstract.py">/home/yangxuan/vecwise_engine/python/sdk/client/Abstract.py</a></font></td></tr></table>
|
||||
<p></p>
|
||||
<p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#ee77aa">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
|
||||
|
||||
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
|
||||
<td width="100%"><dl>
|
||||
<dt><font face="helvetica, arial"><a href="builtins.html#object">builtins.object</a>
|
||||
</font></dt><dd>
|
||||
<dl>
|
||||
<dt><font face="helvetica, arial"><a href="client.Abstract.html#ConnectIntf">ConnectIntf</a>
|
||||
</font></dt><dt><font face="helvetica, arial"><a href="client.Abstract.html#QueryResult">QueryResult</a>
|
||||
</font></dt><dt><font face="helvetica, arial"><a href="client.Abstract.html#Range">Range</a>
|
||||
</font></dt><dt><font face="helvetica, arial"><a href="client.Abstract.html#RowRecord">RowRecord</a>
|
||||
</font></dt><dt><font face="helvetica, arial"><a href="client.Abstract.html#TableSchema">TableSchema</a>
|
||||
</font></dt><dt><font face="helvetica, arial"><a href="client.Abstract.html#TopKQueryResult">TopKQueryResult</a>
|
||||
</font></dt></dl>
|
||||
</dd>
|
||||
<dt><font face="helvetica, arial"><a href="enum.html#IntEnum">enum.IntEnum</a>(<a href="builtins.html#int">builtins.int</a>, <a href="enum.html#Enum">enum.Enum</a>)
|
||||
</font></dt><dd>
|
||||
<dl>
|
||||
<dt><font face="helvetica, arial"><a href="client.Abstract.html#IndexType">IndexType</a>
|
||||
</font></dt></dl>
|
||||
</dd>
|
||||
</dl>
|
||||
<p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#ffc8d8">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#000000" face="helvetica, arial"><a name="ConnectIntf">class <strong>ConnectIntf</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
|
||||
|
||||
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
||||
<td colspan=2><tt>SDK client abstract class<br>
|
||||
<br>
|
||||
Connection is a abstract class<br> </tt></td></tr>
|
||||
<tr><td> </td>
|
||||
<td width="100%">Methods defined here:<br>
|
||||
<dl><dt><a name="ConnectIntf-add_vectors"><strong>add_vectors</strong></a>(self, table_name, records)</dt><dd><tt>Add vectors to table<br>
|
||||
Should be implemented<br>
|
||||
<br>
|
||||
:type table_name: str<br>
|
||||
:param table_name: table name been inserted<br>
|
||||
<br>
|
||||
:type records: list[<a href="#RowRecord">RowRecord</a>]<br>
|
||||
:param records: list of vectors been inserted<br>
|
||||
<br>
|
||||
:returns<br>
|
||||
Status : indicate if vectors inserted successfully<br>
|
||||
ids :list of id, after inserted every vector is given a id</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="ConnectIntf-client_version"><strong>client_version</strong></a>(self)</dt><dd><tt>Provide client version<br>
|
||||
should be implemented<br>
|
||||
<br>
|
||||
:return: str, client version</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="ConnectIntf-connect"><strong>connect</strong></a>(self, host=None, port=None, uri=None)</dt><dd><tt>Connect method should be called before any operations<br>
|
||||
Server will be connected after connect return OK<br>
|
||||
Should be implemented<br>
|
||||
<br>
|
||||
:type host: str<br>
|
||||
:param host: host<br>
|
||||
<br>
|
||||
:type port: str<br>
|
||||
:param port: port<br>
|
||||
<br>
|
||||
:type uri: str<br>
|
||||
:param uri: (Optional) uri<br>
|
||||
<br>
|
||||
:return Status, indicate if connect is successful</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="ConnectIntf-connected"><strong>connected</strong></a>(self)</dt><dd><tt>connected, connection status<br>
|
||||
Should be implemented<br>
|
||||
<br>
|
||||
:return Status, indicate if connect is successful</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="ConnectIntf-create_table"><strong>create_table</strong></a>(self, param)</dt><dd><tt>Create table<br>
|
||||
Should be implemented<br>
|
||||
<br>
|
||||
:type param: <a href="#TableSchema">TableSchema</a><br>
|
||||
:param param: provide table information to be created<br>
|
||||
<br>
|
||||
:return Status, indicate if connect is successful</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="ConnectIntf-delete_table"><strong>delete_table</strong></a>(self, table_name)</dt><dd><tt>Delete table<br>
|
||||
Should be implemented<br>
|
||||
<br>
|
||||
:type table_name: str<br>
|
||||
:param table_name: table_name of the deleting table<br>
|
||||
<br>
|
||||
:return Status, indicate if connect is successful</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="ConnectIntf-describe_table"><strong>describe_table</strong></a>(self, table_name)</dt><dd><tt>Show table information<br>
|
||||
Should be implemented<br>
|
||||
<br>
|
||||
:type table_name: str<br>
|
||||
:param table_name: which table to be shown<br>
|
||||
<br>
|
||||
:returns<br>
|
||||
Status: indicate if query is successful<br>
|
||||
table_schema: <a href="#TableSchema">TableSchema</a>, given when operation is successful</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="ConnectIntf-disconnect"><strong>disconnect</strong></a>(self)</dt><dd><tt>Disconnect, server will be disconnected after disconnect return SUCCESS<br>
|
||||
Should be implemented<br>
|
||||
<br>
|
||||
:return Status, indicate if connect is successful</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="ConnectIntf-get_table_row_count"><strong>get_table_row_count</strong></a>(self, table_name)</dt><dd><tt>Get table row count<br>
|
||||
Should be implemented<br>
|
||||
<br>
|
||||
:type table_name, str<br>
|
||||
:param table_name, target table name.<br>
|
||||
<br>
|
||||
:returns<br>
|
||||
Status: indicate if operation is successful<br>
|
||||
count: int, table row count</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="ConnectIntf-search_vectors"><strong>search_vectors</strong></a>(self, table_name, query_records, query_ranges, top_k)</dt><dd><tt>Query vectors in a table<br>
|
||||
Should be implemented<br>
|
||||
<br>
|
||||
:type table_name: str<br>
|
||||
:param table_name: table name been queried<br>
|
||||
<br>
|
||||
:type query_records: list[<a href="#RowRecord">RowRecord</a>]<br>
|
||||
:param query_records: all vectors going to be queried<br>
|
||||
<br>
|
||||
:type query_ranges: list[<a href="#Range">Range</a>]<br>
|
||||
:param query_ranges: Optional ranges for conditional search.<br>
|
||||
If not specified, search whole table<br>
|
||||
<br>
|
||||
:type top_k: int<br>
|
||||
:param top_k: how many similar vectors will be searched<br>
|
||||
<br>
|
||||
:returns<br>
|
||||
Status: indicate if query is successful<br>
|
||||
query_results: list[<a href="#TopKQueryResult">TopKQueryResult</a>]</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="ConnectIntf-server_status"><strong>server_status</strong></a>(self, cmd)</dt><dd><tt>Provide server status<br>
|
||||
should be implemented<br>
|
||||
:type cmd, str<br>
|
||||
<br>
|
||||
:return: str, server status</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="ConnectIntf-server_version"><strong>server_version</strong></a>(self)</dt><dd><tt>Provide server version<br>
|
||||
should be implemented<br>
|
||||
<br>
|
||||
:return: str, server version</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="ConnectIntf-show_tables"><strong>show_tables</strong></a>(self)</dt><dd><tt>Show all tables in database<br>
|
||||
should be implemented<br>
|
||||
<br>
|
||||
:return<br>
|
||||
Status: indicate if this operation is successful<br>
|
||||
tables: list[str], list of table names</tt></dd></dl>
|
||||
|
||||
<hr>
|
||||
Data descriptors defined here:<br>
|
||||
<dl><dt><strong>__dict__</strong></dt>
|
||||
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
|
||||
</dl>
|
||||
<dl><dt><strong>__weakref__</strong></dt>
|
||||
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
||||
</dl>
|
||||
</td></tr></table> <p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#ffc8d8">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#000000" face="helvetica, arial"><a name="IndexType">class <strong>IndexType</strong></a>(<a href="enum.html#IntEnum">enum.IntEnum</a>)</font></td></tr>
|
||||
|
||||
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
||||
<td colspan=2><tt>An enumeration.<br> </tt></td></tr>
|
||||
<tr><td> </td>
|
||||
<td width="100%"><dl><dt>Method resolution order:</dt>
|
||||
<dd><a href="client.Abstract.html#IndexType">IndexType</a></dd>
|
||||
<dd><a href="enum.html#IntEnum">enum.IntEnum</a></dd>
|
||||
<dd><a href="builtins.html#int">builtins.int</a></dd>
|
||||
<dd><a href="enum.html#Enum">enum.Enum</a></dd>
|
||||
<dd><a href="builtins.html#object">builtins.object</a></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
Data and other attributes defined here:<br>
|
||||
<dl><dt><strong>IDMAP</strong> = <IndexType.IDMAP: 1></dl>
|
||||
|
||||
<dl><dt><strong>INVALIDE</strong> = <IndexType.INVALIDE: 0></dl>
|
||||
|
||||
<dl><dt><strong>IVFLAT</strong> = <IndexType.IVFLAT: 2></dl>
|
||||
|
||||
<hr>
|
||||
Data descriptors inherited from <a href="enum.html#Enum">enum.Enum</a>:<br>
|
||||
<dl><dt><strong>name</strong></dt>
|
||||
<dd><tt>The name of the Enum member.</tt></dd>
|
||||
</dl>
|
||||
<dl><dt><strong>value</strong></dt>
|
||||
<dd><tt>The value of the Enum member.</tt></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
Data descriptors inherited from <a href="enum.html#EnumMeta">enum.EnumMeta</a>:<br>
|
||||
<dl><dt><strong>__members__</strong></dt>
|
||||
<dd><tt>Returns a mapping of member name->value.<br>
|
||||
<br>
|
||||
This mapping lists all enum members, including aliases. Note that this<br>
|
||||
is a read-only view of the internal mapping.</tt></dd>
|
||||
</dl>
|
||||
</td></tr></table> <p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#ffc8d8">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#000000" face="helvetica, arial"><a name="QueryResult">class <strong>QueryResult</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
|
||||
|
||||
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
||||
<td colspan=2><tt>Query result<br>
|
||||
<br>
|
||||
:type id: int64<br>
|
||||
:param id: id of the vector<br>
|
||||
<br>
|
||||
:type score: float<br>
|
||||
:param score: Vector similarity 0 <= score <= 100<br> </tt></td></tr>
|
||||
<tr><td> </td>
|
||||
<td width="100%">Methods defined here:<br>
|
||||
<dl><dt><a name="QueryResult-__init__"><strong>__init__</strong></a>(self, id, score)</dt><dd><tt>Initialize self. See help(type(self)) for accurate signature.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="QueryResult-__repr__"><strong>__repr__</strong></a>(self)</dt><dd><tt>Return repr(self).</tt></dd></dl>
|
||||
|
||||
<hr>
|
||||
Data descriptors defined here:<br>
|
||||
<dl><dt><strong>__dict__</strong></dt>
|
||||
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
|
||||
</dl>
|
||||
<dl><dt><strong>__weakref__</strong></dt>
|
||||
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
||||
</dl>
|
||||
</td></tr></table> <p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#ffc8d8">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#000000" face="helvetica, arial"><a name="Range">class <strong>Range</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
|
||||
|
||||
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
||||
<td colspan=2><tt><a href="#Range">Range</a> information<br>
|
||||
<br>
|
||||
:type start: str<br>
|
||||
:param start: <a href="#Range">Range</a> start value<br>
|
||||
<br>
|
||||
:type end: str<br>
|
||||
:param end: <a href="#Range">Range</a> end value<br> </tt></td></tr>
|
||||
<tr><td> </td>
|
||||
<td width="100%">Methods defined here:<br>
|
||||
<dl><dt><a name="Range-__init__"><strong>__init__</strong></a>(self, start, end)</dt><dd><tt>Initialize self. See help(type(self)) for accurate signature.</tt></dd></dl>
|
||||
|
||||
<hr>
|
||||
Data descriptors defined here:<br>
|
||||
<dl><dt><strong>__dict__</strong></dt>
|
||||
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
|
||||
</dl>
|
||||
<dl><dt><strong>__weakref__</strong></dt>
|
||||
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
||||
</dl>
|
||||
</td></tr></table> <p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#ffc8d8">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#000000" face="helvetica, arial"><a name="RowRecord">class <strong>RowRecord</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
|
||||
|
||||
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
||||
<td colspan=2><tt>Record inserted<br>
|
||||
<br>
|
||||
:type vector_data: binary str<br>
|
||||
:param vector_data: (Required) a vector<br> </tt></td></tr>
|
||||
<tr><td> </td>
|
||||
<td width="100%">Methods defined here:<br>
|
||||
<dl><dt><a name="RowRecord-__init__"><strong>__init__</strong></a>(self, vector_data)</dt><dd><tt>Initialize self. See help(type(self)) for accurate signature.</tt></dd></dl>
|
||||
|
||||
<hr>
|
||||
Data descriptors defined here:<br>
|
||||
<dl><dt><strong>__dict__</strong></dt>
|
||||
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
|
||||
</dl>
|
||||
<dl><dt><strong>__weakref__</strong></dt>
|
||||
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
||||
</dl>
|
||||
</td></tr></table> <p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#ffc8d8">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#000000" face="helvetica, arial"><a name="TableSchema">class <strong>TableSchema</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
|
||||
|
||||
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
||||
<td colspan=2><tt>Table Schema<br>
|
||||
<br>
|
||||
:type table_name: str<br>
|
||||
:param table_name: (Required) name of table<br>
|
||||
<br>
|
||||
:type index_type: <a href="#IndexType">IndexType</a><br>
|
||||
:param index_type: (Optional) index type, default = 0<br>
|
||||
<br>
|
||||
`<a href="#IndexType">IndexType</a>`: 0-invalid, 1-idmap, 2-ivflat<br>
|
||||
<br>
|
||||
:type dimension: int64<br>
|
||||
:param dimension: (Required) dimension of vector<br>
|
||||
<br>
|
||||
:type store_raw_vector: bool<br>
|
||||
:param store_raw_vector: (Optional) default = False<br> </tt></td></tr>
|
||||
<tr><td> </td>
|
||||
<td width="100%">Methods defined here:<br>
|
||||
<dl><dt><a name="TableSchema-__init__"><strong>__init__</strong></a>(self, table_name, dimension=0, index_type=<IndexType.INVALIDE: 0>, store_raw_vector=False)</dt><dd><tt>Initialize self. See help(type(self)) for accurate signature.</tt></dd></dl>
|
||||
|
||||
<hr>
|
||||
Data descriptors defined here:<br>
|
||||
<dl><dt><strong>__dict__</strong></dt>
|
||||
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
|
||||
</dl>
|
||||
<dl><dt><strong>__weakref__</strong></dt>
|
||||
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
||||
</dl>
|
||||
</td></tr></table> <p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#ffc8d8">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#000000" face="helvetica, arial"><a name="TopKQueryResult">class <strong>TopKQueryResult</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
|
||||
|
||||
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
||||
<td colspan=2><tt>TopK query results<br>
|
||||
<br>
|
||||
:type query_results: list[<a href="#QueryResult">QueryResult</a>]<br>
|
||||
:param query_results: TopK query results<br> </tt></td></tr>
|
||||
<tr><td> </td>
|
||||
<td width="100%">Methods defined here:<br>
|
||||
<dl><dt><a name="TopKQueryResult-__init__"><strong>__init__</strong></a>(self, query_results)</dt><dd><tt>Initialize self. See help(type(self)) for accurate signature.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="TopKQueryResult-__repr__"><strong>__repr__</strong></a>(self)</dt><dd><tt>Return repr(self).</tt></dd></dl>
|
||||
|
||||
<hr>
|
||||
Data descriptors defined here:<br>
|
||||
<dl><dt><strong>__dict__</strong></dt>
|
||||
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
|
||||
</dl>
|
||||
<dl><dt><strong>__weakref__</strong></dt>
|
||||
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
||||
</dl>
|
||||
</td></tr></table></td></tr></table>
|
||||
</body></html>
|
|
@ -0,0 +1,218 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><title>Python: module Client</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
</head><body bgcolor="#f0f0f8">
|
||||
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
|
||||
<tr bgcolor="#7799ee">
|
||||
<td valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>Client</strong></big></big></font></td
|
||||
><td align=right valign=bottom
|
||||
><font color="#ffffff" face="helvetica, arial"><a href="../..">index</a><br><a href="file:/home/yangxuan/vecwise_engine/python/sdk/client/Client.py">/home/yangxuan/vecwise_engine/python/sdk/client/Client.py</a></font></td></tr></table>
|
||||
<p></p>
|
||||
<p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#aa55cc">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"><big><strong>Modules</strong></big></font></td></tr>
|
||||
|
||||
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
|
||||
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="milvus.thrift.MilvusService.html">milvus.thrift.MilvusService</a><br>
|
||||
<a href="thrift.protocol.TBinaryProtocol.html">thrift.protocol.TBinaryProtocol</a><br>
|
||||
</td><td width="25%" valign=top><a href="thrift.transport.TSocket.html">thrift.transport.TSocket</a><br>
|
||||
<a href="thrift.transport.TTransport.html">thrift.transport.TTransport</a><br>
|
||||
</td><td width="25%" valign=top><a href="logging.html">logging</a><br>
|
||||
<a href="milvus.thrift.ttypes.html">milvus.thrift.ttypes</a><br>
|
||||
</td><td width="25%" valign=top></td></tr></table></td></tr></table><p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#ee77aa">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
|
||||
|
||||
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
|
||||
<td width="100%"><dl>
|
||||
<dt><font face="helvetica, arial"><a href="builtins.html#object">builtins.object</a>
|
||||
</font></dt><dd>
|
||||
<dl>
|
||||
<dt><font face="helvetica, arial"><a href="client.Client.html#Prepare">Prepare</a>
|
||||
</font></dt></dl>
|
||||
</dd>
|
||||
<dt><font face="helvetica, arial"><a href="client.Abstract.html#ConnectIntf">client.Abstract.ConnectIntf</a>(<a href="builtins.html#object">builtins.object</a>)
|
||||
</font></dt><dd>
|
||||
<dl>
|
||||
<dt><font face="helvetica, arial"><a href="client.Client.html#Milvus">Milvus</a>
|
||||
</font></dt></dl>
|
||||
</dd>
|
||||
</dl>
|
||||
<p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#ffc8d8">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#000000" face="helvetica, arial"><a name="Milvus">class <strong>Milvus</strong></a>(<a href="client.Abstract.html#ConnectIntf">client.Abstract.ConnectIntf</a>)</font></td></tr>
|
||||
|
||||
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
||||
<td colspan=2><tt>SDK client abstract class<br>
|
||||
<br>
|
||||
Connection is a abstract class<br> </tt></td></tr>
|
||||
<tr><td> </td>
|
||||
<td width="100%"><dl><dt>Method resolution order:</dt>
|
||||
<dd><a href="client.Client.html#Milvus">Milvus</a></dd>
|
||||
<dd><a href="client.Abstract.html#ConnectIntf">client.Abstract.ConnectIntf</a></dd>
|
||||
<dd><a href="builtins.html#object">builtins.object</a></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
Methods defined here:<br>
|
||||
<dl><dt><a name="Milvus-__init__"><strong>__init__</strong></a>(self)</dt><dd><tt>Initialize self. See help(type(self)) for accurate signature.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="Milvus-__repr__"><strong>__repr__</strong></a>(self)</dt><dd><tt>Return repr(self).</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="Milvus-add_vectors"><strong>add_vectors</strong></a>(self, table_name, records)</dt><dd><tt>Add vectors to table<br>
|
||||
<br>
|
||||
:param table_name: table name been inserted<br>
|
||||
:param records: List[RowRecord], list of vectors been inserted<br>
|
||||
<br>
|
||||
`Please use <a href="#Prepare">Prepare</a>.row_record generate records`<br>
|
||||
<br>
|
||||
:returns:<br>
|
||||
Status : indicate if vectors inserted successfully<br>
|
||||
ids :list of id, after inserted every vector is given a id</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="Milvus-client_version"><strong>client_version</strong></a>(self)</dt><dd><tt>Provide client version<br>
|
||||
<br>
|
||||
:return: Client version</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="Milvus-connect"><strong>connect</strong></a>(self, host='localhost', port='9090', uri=None)</dt><dd><tt>Connect method should be called before any operations<br>
|
||||
Server will be connected after connect return OK<br>
|
||||
Should be implemented<br>
|
||||
<br>
|
||||
:type host: str<br>
|
||||
:param host: host<br>
|
||||
<br>
|
||||
:type port: str<br>
|
||||
:param port: port<br>
|
||||
<br>
|
||||
:type uri: str<br>
|
||||
:param uri: (Optional) uri<br>
|
||||
<br>
|
||||
:return Status, indicate if connect is successful</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="Milvus-create_table"><strong>create_table</strong></a>(self, param)</dt><dd><tt>Create table<br>
|
||||
<br>
|
||||
:param param: Provide table information to be created,<br>
|
||||
<br>
|
||||
`Please use <a href="#Prepare">Prepare</a>.table_schema generate param`<br>
|
||||
<br>
|
||||
:return: Status, indicate if operation is successful</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="Milvus-delete_table"><strong>delete_table</strong></a>(self, table_name)</dt><dd><tt>Delete table<br>
|
||||
<br>
|
||||
:param table_name: Name of the table being deleted<br>
|
||||
<br>
|
||||
:return: Status, indicate if operation is successful</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="Milvus-describe_table"><strong>describe_table</strong></a>(self, table_name)</dt><dd><tt>Show table information<br>
|
||||
<br>
|
||||
:param table_name: str, which table to be shown<br>
|
||||
<br>
|
||||
:returns:<br>
|
||||
Status: indicate if query is successful<br>
|
||||
table_schema: TableSchema, return when operation is successful</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="Milvus-disconnect"><strong>disconnect</strong></a>(self)</dt><dd><tt>Disconnect, server will be disconnected after disconnect return SUCCESS<br>
|
||||
Should be implemented<br>
|
||||
<br>
|
||||
:return Status, indicate if connect is successful</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="Milvus-get_table_row_count"><strong>get_table_row_count</strong></a>(self, table_name)</dt><dd><tt>Get table row count<br>
|
||||
<br>
|
||||
:type table_name, str<br>
|
||||
:param table_name, target table name.<br>
|
||||
<br>
|
||||
:returns:<br>
|
||||
Status: indicate if operation is successful<br>
|
||||
res: int, table row count</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="Milvus-search_vectors"><strong>search_vectors</strong></a>(self, table_name, top_k, query_records, query_ranges=None)</dt><dd><tt>Query vectors in a table<br>
|
||||
<br>
|
||||
:param table_name: str, table name been queried<br>
|
||||
:param query_records: list[QueryRecord], all vectors going to be queried<br>
|
||||
<br>
|
||||
`Please use <a href="#Prepare">Prepare</a>.query_record generate QueryRecord`<br>
|
||||
<br>
|
||||
:param top_k: int, how many similar vectors will be searched<br>
|
||||
:param query_ranges, (Optional) list[Range], search range<br>
|
||||
<br>
|
||||
:returns:<br>
|
||||
Status: indicate if query is successful<br>
|
||||
res: list[TopKQueryResult], return when operation is successful</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="Milvus-server_status"><strong>server_status</strong></a>(self, cmd=None)</dt><dd><tt>Provide server status<br>
|
||||
<br>
|
||||
:return: Server status</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="Milvus-server_version"><strong>server_version</strong></a>(self)</dt><dd><tt>Provide server version<br>
|
||||
<br>
|
||||
:return: Server version</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="Milvus-show_tables"><strong>show_tables</strong></a>(self)</dt><dd><tt>Show all tables in database<br>
|
||||
<br>
|
||||
:return:<br>
|
||||
Status: indicate if this operation is successful<br>
|
||||
tables: list[str], list of table names, return when operation<br>
|
||||
is successful</tt></dd></dl>
|
||||
|
||||
<hr>
|
||||
Data descriptors defined here:<br>
|
||||
<dl><dt><strong>connected</strong></dt>
|
||||
</dl>
|
||||
<hr>
|
||||
Data descriptors inherited from <a href="client.Abstract.html#ConnectIntf">client.Abstract.ConnectIntf</a>:<br>
|
||||
<dl><dt><strong>__dict__</strong></dt>
|
||||
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
|
||||
</dl>
|
||||
<dl><dt><strong>__weakref__</strong></dt>
|
||||
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
||||
</dl>
|
||||
</td></tr></table> <p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#ffc8d8">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#000000" face="helvetica, arial"><a name="Prepare">class <strong>Prepare</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
|
||||
|
||||
<tr><td bgcolor="#ffc8d8"><tt> </tt></td><td> </td>
|
||||
<td width="100%">Class methods defined here:<br>
|
||||
<dl><dt><a name="Prepare-range"><strong>range</strong></a>(start, end)<font color="#909090"><font face="helvetica, arial"> from <a href="builtins.html#type">builtins.type</a></font></font></dt><dd><tt>:param start: str, (Required) range start<br>
|
||||
:param end: str (Required) range end<br>
|
||||
<br>
|
||||
:return Range</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="Prepare-row_record"><strong>row_record</strong></a>(vector_data)<font color="#909090"><font face="helvetica, arial"> from <a href="builtins.html#type">builtins.type</a></font></font></dt><dd><tt>Record inserted<br>
|
||||
<br>
|
||||
:param vector_data: float binary str, (Required) a binary str</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="Prepare-table_schema"><strong>table_schema</strong></a>(table_name, dimension, index_type=<IndexType.INVALIDE: 0>, store_raw_vector=False)<font color="#909090"><font face="helvetica, arial"> from <a href="builtins.html#type">builtins.type</a></font></font></dt><dd><tt>:param table_name: str, (Required) name of table<br>
|
||||
:param index_type: IndexType, (Required) index type, default = IndexType.INVALID<br>
|
||||
:param dimension: int64, (Optional) dimension of the table<br>
|
||||
:param store_raw_vector: bool, (Optional) default = False<br>
|
||||
<br>
|
||||
:return: TableSchema</tt></dd></dl>
|
||||
|
||||
<hr>
|
||||
Data descriptors defined here:<br>
|
||||
<dl><dt><strong>__dict__</strong></dt>
|
||||
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
|
||||
</dl>
|
||||
<dl><dt><strong>__weakref__</strong></dt>
|
||||
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
||||
</dl>
|
||||
</td></tr></table></td></tr></table><p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#55aa55">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"><big><strong>Data</strong></big></font></td></tr>
|
||||
|
||||
<tr><td bgcolor="#55aa55"><tt> </tt></td><td> </td>
|
||||
<td width="100%"><strong>LOGGER</strong> = <Logger Client (WARNING)><br>
|
||||
<strong>__NAME__</strong> = 'Thrift_Client'<br>
|
||||
<strong>__VERSION__</strong> = '0.0.1'</td></tr></table>
|
||||
</body></html>
|
|
@ -0,0 +1,349 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><title>Python: module Exceptions</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
</head><body bgcolor="#f0f0f8">
|
||||
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
|
||||
<tr bgcolor="#7799ee">
|
||||
<td valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>Exceptions</strong></big></big></font></td
|
||||
><td align=right valign=bottom
|
||||
><font color="#ffffff" face="helvetica, arial"><a href="../..">index</a><br><a href="file:/home/yangxuan/vecwise_engine/python/sdk/client/Exceptions.py">/home/yangxuan/vecwise_engine/python/sdk/client/Exceptions.py</a></font></td></tr></table>
|
||||
<p></p>
|
||||
<p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#ee77aa">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
|
||||
|
||||
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
|
||||
<td width="100%"><dl>
|
||||
<dt><font face="helvetica, arial"><a href="builtins.html#ValueError">builtins.ValueError</a>(<a href="builtins.html#Exception">builtins.Exception</a>)
|
||||
</font></dt><dd>
|
||||
<dl>
|
||||
<dt><font face="helvetica, arial"><a href="client.Exceptions.html#ConnectError">ConnectError</a>
|
||||
</font></dt><dd>
|
||||
<dl>
|
||||
<dt><font face="helvetica, arial"><a href="client.Exceptions.html#NotConnectError">NotConnectError</a>
|
||||
</font></dt><dt><font face="helvetica, arial"><a href="client.Exceptions.html#RepeatingConnectError">RepeatingConnectError</a>
|
||||
</font></dt></dl>
|
||||
</dd>
|
||||
<dt><font face="helvetica, arial"><a href="client.Exceptions.html#DisconnectNotConnectedClientError">DisconnectNotConnectedClientError</a>
|
||||
</font></dt><dt><font face="helvetica, arial"><a href="client.Exceptions.html#ParamError">ParamError</a>
|
||||
</font></dt></dl>
|
||||
</dd>
|
||||
</dl>
|
||||
<p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#ffc8d8">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#000000" face="helvetica, arial"><a name="ConnectError">class <strong>ConnectError</strong></a>(<a href="builtins.html#ValueError">builtins.ValueError</a>)</font></td></tr>
|
||||
|
||||
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
||||
<td colspan=2><tt>Inappropriate argument value (of correct type).<br> </tt></td></tr>
|
||||
<tr><td> </td>
|
||||
<td width="100%"><dl><dt>Method resolution order:</dt>
|
||||
<dd><a href="client.Exceptions.html#ConnectError">ConnectError</a></dd>
|
||||
<dd><a href="builtins.html#ValueError">builtins.ValueError</a></dd>
|
||||
<dd><a href="builtins.html#Exception">builtins.Exception</a></dd>
|
||||
<dd><a href="builtins.html#BaseException">builtins.BaseException</a></dd>
|
||||
<dd><a href="builtins.html#object">builtins.object</a></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
Data descriptors defined here:<br>
|
||||
<dl><dt><strong>__weakref__</strong></dt>
|
||||
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
Methods inherited from <a href="builtins.html#ValueError">builtins.ValueError</a>:<br>
|
||||
<dl><dt><a name="ConnectError-__init__"><strong>__init__</strong></a>(self, /, *args, **kwargs)</dt><dd><tt>Initialize self. See help(type(self)) for accurate signature.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="ConnectError-__new__"><strong>__new__</strong></a>(*args, **kwargs)<font color="#909090"><font face="helvetica, arial"> from <a href="builtins.html#type">builtins.type</a></font></font></dt><dd><tt>Create and return a new object. See help(type) for accurate signature.</tt></dd></dl>
|
||||
|
||||
<hr>
|
||||
Methods inherited from <a href="builtins.html#BaseException">builtins.BaseException</a>:<br>
|
||||
<dl><dt><a name="ConnectError-__delattr__"><strong>__delattr__</strong></a>(self, name, /)</dt><dd><tt>Implement delattr(self, name).</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="ConnectError-__getattribute__"><strong>__getattribute__</strong></a>(self, name, /)</dt><dd><tt>Return getattr(self, name).</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="ConnectError-__reduce__"><strong>__reduce__</strong></a>(...)</dt><dd><tt>helper for pickle</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="ConnectError-__repr__"><strong>__repr__</strong></a>(self, /)</dt><dd><tt>Return repr(self).</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="ConnectError-__setattr__"><strong>__setattr__</strong></a>(self, name, value, /)</dt><dd><tt>Implement setattr(self, name, value).</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="ConnectError-__setstate__"><strong>__setstate__</strong></a>(...)</dt></dl>
|
||||
|
||||
<dl><dt><a name="ConnectError-__str__"><strong>__str__</strong></a>(self, /)</dt><dd><tt>Return str(self).</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="ConnectError-with_traceback"><strong>with_traceback</strong></a>(...)</dt><dd><tt>Exception.<a href="#ConnectError-with_traceback">with_traceback</a>(tb) --<br>
|
||||
set self.<strong>__traceback__</strong> to tb and return self.</tt></dd></dl>
|
||||
|
||||
<hr>
|
||||
Data descriptors inherited from <a href="builtins.html#BaseException">builtins.BaseException</a>:<br>
|
||||
<dl><dt><strong>__cause__</strong></dt>
|
||||
<dd><tt>exception cause</tt></dd>
|
||||
</dl>
|
||||
<dl><dt><strong>__context__</strong></dt>
|
||||
<dd><tt>exception context</tt></dd>
|
||||
</dl>
|
||||
<dl><dt><strong>__dict__</strong></dt>
|
||||
</dl>
|
||||
<dl><dt><strong>__suppress_context__</strong></dt>
|
||||
</dl>
|
||||
<dl><dt><strong>__traceback__</strong></dt>
|
||||
</dl>
|
||||
<dl><dt><strong>args</strong></dt>
|
||||
</dl>
|
||||
</td></tr></table> <p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#ffc8d8">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#000000" face="helvetica, arial"><a name="DisconnectNotConnectedClientError">class <strong>DisconnectNotConnectedClientError</strong></a>(<a href="builtins.html#ValueError">builtins.ValueError</a>)</font></td></tr>
|
||||
|
||||
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
||||
<td colspan=2><tt>Inappropriate argument value (of correct type).<br> </tt></td></tr>
|
||||
<tr><td> </td>
|
||||
<td width="100%"><dl><dt>Method resolution order:</dt>
|
||||
<dd><a href="client.Exceptions.html#DisconnectNotConnectedClientError">DisconnectNotConnectedClientError</a></dd>
|
||||
<dd><a href="builtins.html#ValueError">builtins.ValueError</a></dd>
|
||||
<dd><a href="builtins.html#Exception">builtins.Exception</a></dd>
|
||||
<dd><a href="builtins.html#BaseException">builtins.BaseException</a></dd>
|
||||
<dd><a href="builtins.html#object">builtins.object</a></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
Data descriptors defined here:<br>
|
||||
<dl><dt><strong>__weakref__</strong></dt>
|
||||
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
Methods inherited from <a href="builtins.html#ValueError">builtins.ValueError</a>:<br>
|
||||
<dl><dt><a name="DisconnectNotConnectedClientError-__init__"><strong>__init__</strong></a>(self, /, *args, **kwargs)</dt><dd><tt>Initialize self. See help(type(self)) for accurate signature.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="DisconnectNotConnectedClientError-__new__"><strong>__new__</strong></a>(*args, **kwargs)<font color="#909090"><font face="helvetica, arial"> from <a href="builtins.html#type">builtins.type</a></font></font></dt><dd><tt>Create and return a new object. See help(type) for accurate signature.</tt></dd></dl>
|
||||
|
||||
<hr>
|
||||
Methods inherited from <a href="builtins.html#BaseException">builtins.BaseException</a>:<br>
|
||||
<dl><dt><a name="DisconnectNotConnectedClientError-__delattr__"><strong>__delattr__</strong></a>(self, name, /)</dt><dd><tt>Implement delattr(self, name).</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="DisconnectNotConnectedClientError-__getattribute__"><strong>__getattribute__</strong></a>(self, name, /)</dt><dd><tt>Return getattr(self, name).</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="DisconnectNotConnectedClientError-__reduce__"><strong>__reduce__</strong></a>(...)</dt><dd><tt>helper for pickle</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="DisconnectNotConnectedClientError-__repr__"><strong>__repr__</strong></a>(self, /)</dt><dd><tt>Return repr(self).</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="DisconnectNotConnectedClientError-__setattr__"><strong>__setattr__</strong></a>(self, name, value, /)</dt><dd><tt>Implement setattr(self, name, value).</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="DisconnectNotConnectedClientError-__setstate__"><strong>__setstate__</strong></a>(...)</dt></dl>
|
||||
|
||||
<dl><dt><a name="DisconnectNotConnectedClientError-__str__"><strong>__str__</strong></a>(self, /)</dt><dd><tt>Return str(self).</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="DisconnectNotConnectedClientError-with_traceback"><strong>with_traceback</strong></a>(...)</dt><dd><tt>Exception.<a href="#DisconnectNotConnectedClientError-with_traceback">with_traceback</a>(tb) --<br>
|
||||
set self.<strong>__traceback__</strong> to tb and return self.</tt></dd></dl>
|
||||
|
||||
<hr>
|
||||
Data descriptors inherited from <a href="builtins.html#BaseException">builtins.BaseException</a>:<br>
|
||||
<dl><dt><strong>__cause__</strong></dt>
|
||||
<dd><tt>exception cause</tt></dd>
|
||||
</dl>
|
||||
<dl><dt><strong>__context__</strong></dt>
|
||||
<dd><tt>exception context</tt></dd>
|
||||
</dl>
|
||||
<dl><dt><strong>__dict__</strong></dt>
|
||||
</dl>
|
||||
<dl><dt><strong>__suppress_context__</strong></dt>
|
||||
</dl>
|
||||
<dl><dt><strong>__traceback__</strong></dt>
|
||||
</dl>
|
||||
<dl><dt><strong>args</strong></dt>
|
||||
</dl>
|
||||
</td></tr></table> <p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#ffc8d8">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#000000" face="helvetica, arial"><a name="NotConnectError">class <strong>NotConnectError</strong></a>(<a href="client.Exceptions.html#ConnectError">ConnectError</a>)</font></td></tr>
|
||||
|
||||
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
||||
<td colspan=2><tt>Inappropriate argument value (of correct type).<br> </tt></td></tr>
|
||||
<tr><td> </td>
|
||||
<td width="100%"><dl><dt>Method resolution order:</dt>
|
||||
<dd><a href="client.Exceptions.html#NotConnectError">NotConnectError</a></dd>
|
||||
<dd><a href="client.Exceptions.html#ConnectError">ConnectError</a></dd>
|
||||
<dd><a href="builtins.html#ValueError">builtins.ValueError</a></dd>
|
||||
<dd><a href="builtins.html#Exception">builtins.Exception</a></dd>
|
||||
<dd><a href="builtins.html#BaseException">builtins.BaseException</a></dd>
|
||||
<dd><a href="builtins.html#object">builtins.object</a></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
Data descriptors inherited from <a href="client.Exceptions.html#ConnectError">ConnectError</a>:<br>
|
||||
<dl><dt><strong>__weakref__</strong></dt>
|
||||
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
Methods inherited from <a href="builtins.html#ValueError">builtins.ValueError</a>:<br>
|
||||
<dl><dt><a name="NotConnectError-__init__"><strong>__init__</strong></a>(self, /, *args, **kwargs)</dt><dd><tt>Initialize self. See help(type(self)) for accurate signature.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="NotConnectError-__new__"><strong>__new__</strong></a>(*args, **kwargs)<font color="#909090"><font face="helvetica, arial"> from <a href="builtins.html#type">builtins.type</a></font></font></dt><dd><tt>Create and return a new object. See help(type) for accurate signature.</tt></dd></dl>
|
||||
|
||||
<hr>
|
||||
Methods inherited from <a href="builtins.html#BaseException">builtins.BaseException</a>:<br>
|
||||
<dl><dt><a name="NotConnectError-__delattr__"><strong>__delattr__</strong></a>(self, name, /)</dt><dd><tt>Implement delattr(self, name).</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="NotConnectError-__getattribute__"><strong>__getattribute__</strong></a>(self, name, /)</dt><dd><tt>Return getattr(self, name).</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="NotConnectError-__reduce__"><strong>__reduce__</strong></a>(...)</dt><dd><tt>helper for pickle</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="NotConnectError-__repr__"><strong>__repr__</strong></a>(self, /)</dt><dd><tt>Return repr(self).</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="NotConnectError-__setattr__"><strong>__setattr__</strong></a>(self, name, value, /)</dt><dd><tt>Implement setattr(self, name, value).</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="NotConnectError-__setstate__"><strong>__setstate__</strong></a>(...)</dt></dl>
|
||||
|
||||
<dl><dt><a name="NotConnectError-__str__"><strong>__str__</strong></a>(self, /)</dt><dd><tt>Return str(self).</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="NotConnectError-with_traceback"><strong>with_traceback</strong></a>(...)</dt><dd><tt>Exception.<a href="#NotConnectError-with_traceback">with_traceback</a>(tb) --<br>
|
||||
set self.<strong>__traceback__</strong> to tb and return self.</tt></dd></dl>
|
||||
|
||||
<hr>
|
||||
Data descriptors inherited from <a href="builtins.html#BaseException">builtins.BaseException</a>:<br>
|
||||
<dl><dt><strong>__cause__</strong></dt>
|
||||
<dd><tt>exception cause</tt></dd>
|
||||
</dl>
|
||||
<dl><dt><strong>__context__</strong></dt>
|
||||
<dd><tt>exception context</tt></dd>
|
||||
</dl>
|
||||
<dl><dt><strong>__dict__</strong></dt>
|
||||
</dl>
|
||||
<dl><dt><strong>__suppress_context__</strong></dt>
|
||||
</dl>
|
||||
<dl><dt><strong>__traceback__</strong></dt>
|
||||
</dl>
|
||||
<dl><dt><strong>args</strong></dt>
|
||||
</dl>
|
||||
</td></tr></table> <p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#ffc8d8">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#000000" face="helvetica, arial"><a name="ParamError">class <strong>ParamError</strong></a>(<a href="builtins.html#ValueError">builtins.ValueError</a>)</font></td></tr>
|
||||
|
||||
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
||||
<td colspan=2><tt>Inappropriate argument value (of correct type).<br> </tt></td></tr>
|
||||
<tr><td> </td>
|
||||
<td width="100%"><dl><dt>Method resolution order:</dt>
|
||||
<dd><a href="client.Exceptions.html#ParamError">ParamError</a></dd>
|
||||
<dd><a href="builtins.html#ValueError">builtins.ValueError</a></dd>
|
||||
<dd><a href="builtins.html#Exception">builtins.Exception</a></dd>
|
||||
<dd><a href="builtins.html#BaseException">builtins.BaseException</a></dd>
|
||||
<dd><a href="builtins.html#object">builtins.object</a></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
Data descriptors defined here:<br>
|
||||
<dl><dt><strong>__weakref__</strong></dt>
|
||||
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
Methods inherited from <a href="builtins.html#ValueError">builtins.ValueError</a>:<br>
|
||||
<dl><dt><a name="ParamError-__init__"><strong>__init__</strong></a>(self, /, *args, **kwargs)</dt><dd><tt>Initialize self. See help(type(self)) for accurate signature.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="ParamError-__new__"><strong>__new__</strong></a>(*args, **kwargs)<font color="#909090"><font face="helvetica, arial"> from <a href="builtins.html#type">builtins.type</a></font></font></dt><dd><tt>Create and return a new object. See help(type) for accurate signature.</tt></dd></dl>
|
||||
|
||||
<hr>
|
||||
Methods inherited from <a href="builtins.html#BaseException">builtins.BaseException</a>:<br>
|
||||
<dl><dt><a name="ParamError-__delattr__"><strong>__delattr__</strong></a>(self, name, /)</dt><dd><tt>Implement delattr(self, name).</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="ParamError-__getattribute__"><strong>__getattribute__</strong></a>(self, name, /)</dt><dd><tt>Return getattr(self, name).</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="ParamError-__reduce__"><strong>__reduce__</strong></a>(...)</dt><dd><tt>helper for pickle</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="ParamError-__repr__"><strong>__repr__</strong></a>(self, /)</dt><dd><tt>Return repr(self).</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="ParamError-__setattr__"><strong>__setattr__</strong></a>(self, name, value, /)</dt><dd><tt>Implement setattr(self, name, value).</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="ParamError-__setstate__"><strong>__setstate__</strong></a>(...)</dt></dl>
|
||||
|
||||
<dl><dt><a name="ParamError-__str__"><strong>__str__</strong></a>(self, /)</dt><dd><tt>Return str(self).</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="ParamError-with_traceback"><strong>with_traceback</strong></a>(...)</dt><dd><tt>Exception.<a href="#ParamError-with_traceback">with_traceback</a>(tb) --<br>
|
||||
set self.<strong>__traceback__</strong> to tb and return self.</tt></dd></dl>
|
||||
|
||||
<hr>
|
||||
Data descriptors inherited from <a href="builtins.html#BaseException">builtins.BaseException</a>:<br>
|
||||
<dl><dt><strong>__cause__</strong></dt>
|
||||
<dd><tt>exception cause</tt></dd>
|
||||
</dl>
|
||||
<dl><dt><strong>__context__</strong></dt>
|
||||
<dd><tt>exception context</tt></dd>
|
||||
</dl>
|
||||
<dl><dt><strong>__dict__</strong></dt>
|
||||
</dl>
|
||||
<dl><dt><strong>__suppress_context__</strong></dt>
|
||||
</dl>
|
||||
<dl><dt><strong>__traceback__</strong></dt>
|
||||
</dl>
|
||||
<dl><dt><strong>args</strong></dt>
|
||||
</dl>
|
||||
</td></tr></table> <p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#ffc8d8">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#000000" face="helvetica, arial"><a name="RepeatingConnectError">class <strong>RepeatingConnectError</strong></a>(<a href="client.Exceptions.html#ConnectError">ConnectError</a>)</font></td></tr>
|
||||
|
||||
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
||||
<td colspan=2><tt>Inappropriate argument value (of correct type).<br> </tt></td></tr>
|
||||
<tr><td> </td>
|
||||
<td width="100%"><dl><dt>Method resolution order:</dt>
|
||||
<dd><a href="client.Exceptions.html#RepeatingConnectError">RepeatingConnectError</a></dd>
|
||||
<dd><a href="client.Exceptions.html#ConnectError">ConnectError</a></dd>
|
||||
<dd><a href="builtins.html#ValueError">builtins.ValueError</a></dd>
|
||||
<dd><a href="builtins.html#Exception">builtins.Exception</a></dd>
|
||||
<dd><a href="builtins.html#BaseException">builtins.BaseException</a></dd>
|
||||
<dd><a href="builtins.html#object">builtins.object</a></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
Data descriptors inherited from <a href="client.Exceptions.html#ConnectError">ConnectError</a>:<br>
|
||||
<dl><dt><strong>__weakref__</strong></dt>
|
||||
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
Methods inherited from <a href="builtins.html#ValueError">builtins.ValueError</a>:<br>
|
||||
<dl><dt><a name="RepeatingConnectError-__init__"><strong>__init__</strong></a>(self, /, *args, **kwargs)</dt><dd><tt>Initialize self. See help(type(self)) for accurate signature.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="RepeatingConnectError-__new__"><strong>__new__</strong></a>(*args, **kwargs)<font color="#909090"><font face="helvetica, arial"> from <a href="builtins.html#type">builtins.type</a></font></font></dt><dd><tt>Create and return a new object. See help(type) for accurate signature.</tt></dd></dl>
|
||||
|
||||
<hr>
|
||||
Methods inherited from <a href="builtins.html#BaseException">builtins.BaseException</a>:<br>
|
||||
<dl><dt><a name="RepeatingConnectError-__delattr__"><strong>__delattr__</strong></a>(self, name, /)</dt><dd><tt>Implement delattr(self, name).</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="RepeatingConnectError-__getattribute__"><strong>__getattribute__</strong></a>(self, name, /)</dt><dd><tt>Return getattr(self, name).</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="RepeatingConnectError-__reduce__"><strong>__reduce__</strong></a>(...)</dt><dd><tt>helper for pickle</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="RepeatingConnectError-__repr__"><strong>__repr__</strong></a>(self, /)</dt><dd><tt>Return repr(self).</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="RepeatingConnectError-__setattr__"><strong>__setattr__</strong></a>(self, name, value, /)</dt><dd><tt>Implement setattr(self, name, value).</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="RepeatingConnectError-__setstate__"><strong>__setstate__</strong></a>(...)</dt></dl>
|
||||
|
||||
<dl><dt><a name="RepeatingConnectError-__str__"><strong>__str__</strong></a>(self, /)</dt><dd><tt>Return str(self).</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="RepeatingConnectError-with_traceback"><strong>with_traceback</strong></a>(...)</dt><dd><tt>Exception.<a href="#RepeatingConnectError-with_traceback">with_traceback</a>(tb) --<br>
|
||||
set self.<strong>__traceback__</strong> to tb and return self.</tt></dd></dl>
|
||||
|
||||
<hr>
|
||||
Data descriptors inherited from <a href="builtins.html#BaseException">builtins.BaseException</a>:<br>
|
||||
<dl><dt><strong>__cause__</strong></dt>
|
||||
<dd><tt>exception cause</tt></dd>
|
||||
</dl>
|
||||
<dl><dt><strong>__context__</strong></dt>
|
||||
<dd><tt>exception context</tt></dd>
|
||||
</dl>
|
||||
<dl><dt><strong>__dict__</strong></dt>
|
||||
</dl>
|
||||
<dl><dt><strong>__suppress_context__</strong></dt>
|
||||
</dl>
|
||||
<dl><dt><strong>__traceback__</strong></dt>
|
||||
</dl>
|
||||
<dl><dt><strong>args</strong></dt>
|
||||
</dl>
|
||||
</td></tr></table></td></tr></table>
|
||||
</body></html>
|
|
@ -0,0 +1,74 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><title>Python: module Status</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
</head><body bgcolor="#f0f0f8">
|
||||
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
|
||||
<tr bgcolor="#7799ee">
|
||||
<td valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>Status</strong></big></big></font></td
|
||||
><td align=right valign=bottom
|
||||
><font color="#ffffff" face="helvetica, arial"><a href="../..">index</a><br><a href="file:/home/yangxuan/vecwise_engine/python/sdk/client/Status.py">/home/yangxuan/vecwise_engine/python/sdk/client/Status.py</a></font></td></tr></table>
|
||||
<p></p>
|
||||
<p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#ee77aa">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"><big><strong>Classes</strong></big></font></td></tr>
|
||||
|
||||
<tr><td bgcolor="#ee77aa"><tt> </tt></td><td> </td>
|
||||
<td width="100%"><dl>
|
||||
<dt><font face="helvetica, arial"><a href="builtins.html#object">builtins.object</a>
|
||||
</font></dt><dd>
|
||||
<dl>
|
||||
<dt><font face="helvetica, arial"><a href="client.Status.html#Status">Status</a>
|
||||
</font></dt></dl>
|
||||
</dd>
|
||||
</dl>
|
||||
<p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#ffc8d8">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#000000" face="helvetica, arial"><a name="Status">class <strong>Status</strong></a>(<a href="builtins.html#object">builtins.object</a>)</font></td></tr>
|
||||
|
||||
<tr bgcolor="#ffc8d8"><td rowspan=2><tt> </tt></td>
|
||||
<td colspan=2><tt>:attribute code : int (optional) default as ok<br>
|
||||
:attribute message : str (optional) current status message<br> </tt></td></tr>
|
||||
<tr><td> </td>
|
||||
<td width="100%">Methods defined here:<br>
|
||||
<dl><dt><a name="Status-__eq__"><strong>__eq__</strong></a>(self, other)</dt><dd><tt>Make <a href="#Status">Status</a> comparable with self by code</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="Status-__init__"><strong>__init__</strong></a>(self, code=0, message=None)</dt><dd><tt>Initialize self. See help(type(self)) for accurate signature.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="Status-__ne__"><strong>__ne__</strong></a>(self, other)</dt><dd><tt>Return self!=value.</tt></dd></dl>
|
||||
|
||||
<dl><dt><a name="Status-__repr__"><strong>__repr__</strong></a>(self)</dt><dd><tt>Return repr(self).</tt></dd></dl>
|
||||
|
||||
<hr>
|
||||
Data descriptors defined here:<br>
|
||||
<dl><dt><strong>__dict__</strong></dt>
|
||||
<dd><tt>dictionary for instance variables (if defined)</tt></dd>
|
||||
</dl>
|
||||
<dl><dt><strong>__weakref__</strong></dt>
|
||||
<dd><tt>list of weak references to the object (if defined)</tt></dd>
|
||||
</dl>
|
||||
<hr>
|
||||
Data and other attributes defined here:<br>
|
||||
<dl><dt><strong>CONNECT_FAILED</strong> = 1</dl>
|
||||
|
||||
<dl><dt><strong>ILLEGAL_ARGUMENT</strong> = 4</dl>
|
||||
|
||||
<dl><dt><strong>ILLEGAL_DIMENSION</strong> = 6</dl>
|
||||
|
||||
<dl><dt><strong>ILLEGAL_RANGE</strong> = 5</dl>
|
||||
|
||||
<dl><dt><strong>PERMISSION_DENIED</strong> = 2</dl>
|
||||
|
||||
<dl><dt><strong>SUCCESS</strong> = 0</dl>
|
||||
|
||||
<dl><dt><strong>TABLE_NOT_EXISTS</strong> = 3</dl>
|
||||
|
||||
<dl><dt><strong>__hash__</strong> = None</dl>
|
||||
|
||||
</td></tr></table></td></tr></table>
|
||||
</body></html>
|
|
@ -0,0 +1,25 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html><head><title>Python: package client</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||||
</head><body bgcolor="#f0f0f8">
|
||||
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="heading">
|
||||
<tr bgcolor="#7799ee">
|
||||
<td valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"> <br><big><big><strong>client</strong></big></big></font></td
|
||||
><td align=right valign=bottom
|
||||
><font color="#ffffff" face="helvetica, arial"><a href="../..">index</a><br><a href="file:/home/yangxuan/vecwise_engine/python/sdk/client/__init__.py">/home/yangxuan/vecwise_engine/python/sdk/client/__init__.py</a></font></td></tr></table>
|
||||
<p><tt>client module</tt></p>
|
||||
<p>
|
||||
<table width="100%" cellspacing=0 cellpadding=2 border=0 summary="section">
|
||||
<tr bgcolor="#aa55cc">
|
||||
<td colspan=3 valign=bottom> <br>
|
||||
<font color="#ffffff" face="helvetica, arial"><big><strong>Package Contents</strong></big></font></td></tr>
|
||||
|
||||
<tr><td bgcolor="#aa55cc"><tt> </tt></td><td> </td>
|
||||
<td width="100%"><table width="100%" summary="list"><tr><td width="25%" valign=top><a href="client.Abstract.html">Abstract</a><br>
|
||||
</td><td width="25%" valign=top><a href="client.Client.html">Client</a><br>
|
||||
</td><td width="25%" valign=top><a href="client.Exceptions.html">Exceptions</a><br>
|
||||
</td><td width="25%" valign=top><a href="client.Status.html">Status</a><br>
|
||||
</td></tr></table></td></tr></table>
|
||||
</body></html>
|
|
@ -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))
|
||||
|
||||
|
||||
|
|
|
@ -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()
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1 @@
|
|||
__all__ = ['ttypes', 'constants', 'MilvusService.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 *
|
|
@ -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
|
|
@ -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')
|
||||
|
|
Loading…
Reference in New Issue