|
@ -13,9 +13,6 @@ class MilvusClient(PyOperator): |
|
|
""" |
|
|
""" |
|
|
|
|
|
|
|
|
def __init__(self, host: str, port: int, collection_name: str): |
|
|
def __init__(self, host: str, port: int, collection_name: str): |
|
|
""" |
|
|
|
|
|
Get an existing collection. |
|
|
|
|
|
""" |
|
|
|
|
|
self._host = host |
|
|
self._host = host |
|
|
self._port = port |
|
|
self._port = port |
|
|
self._collection_name = collection_name |
|
|
self._collection_name = collection_name |
|
@ -23,7 +20,7 @@ class MilvusClient(PyOperator): |
|
|
connections.connect(alias=self._connect_name, host=self._host, port=self._port) |
|
|
connections.connect(alias=self._connect_name, host=self._host, port=self._port) |
|
|
self._collection = Collection(self._collection_name, using=self._connect_name) |
|
|
self._collection = Collection(self._collection_name, using=self._connect_name) |
|
|
|
|
|
|
|
|
def __call__(self, *data): |
|
|
|
|
|
|
|
|
def __call__(self, *row): |
|
|
""" |
|
|
""" |
|
|
Insert data to Milvus. |
|
|
Insert data to Milvus. |
|
|
|
|
|
|
|
@ -35,10 +32,7 @@ class MilvusClient(PyOperator): |
|
|
A MutationResult object contains `insert_count` represents how many and a `primary_keys` of primary keys. |
|
|
A MutationResult object contains `insert_count` represents how many and a `primary_keys` of primary keys. |
|
|
|
|
|
|
|
|
""" |
|
|
""" |
|
|
vectors = [] |
|
|
|
|
|
for v in data: |
|
|
|
|
|
vectors.append(v if isinstance(v, list) else [v]) |
|
|
|
|
|
mr = self._collection.insert(vectors) |
|
|
|
|
|
|
|
|
mr = self._collection.insert(row) |
|
|
if mr.err_count > 0: |
|
|
if mr.err_count > 0: |
|
|
raise RuntimeError("Insert to milvus failed") |
|
|
raise RuntimeError("Insert to milvus failed") |
|
|
return None |
|
|
return None |
|
|