mirror of
https://gitee.com/milvus-io/milvus.git
synced 2026-01-07 19:31:51 +08:00
* update mishards to 0.7.0 Signed-off-by: Yhz <yinghao.zou@zilliz.com> * update mishards to 0.7.0 Signed-off-by: Yhz <yinghao.zou@zilliz.com> * fix search bug and example pass Signed-off-by: Yhz <yinghao.zou@zilliz.com> * add new api Signed-off-by: Yhz <yinghao.zou@zilliz.com> * add segment stat Signed-off-by: Yhz <yinghao.zou@zilliz.com> * fix table info issue Signed-off-by: yhz <413554850@qq.com> * fix mishards api issue Signed-off-by: yhz <413554850@qq.com> * update mishards Signed-off-by: Yhz <yinghao.zou@zilliz.com> * update all_in_one docker images Signed-off-by: Yhz <yinghao.zou@zilliz.com> * fix delete_by_id param parser & remove some comments Signed-off-by: Yhz <yinghao.zou@zilliz.com> * update yaml config file Signed-off-by: Yhz <yinghao.zou@zilliz.com> * update all_in_one config Signed-off-by: Yhz <yinghao.zou@zilliz.com> * remove delete_by_range comments Signed-off-by: Yhz <yinghao.zou@zilliz.com> * update cmd api Signed-off-by: Yhz <yinghao.zou@zilliz.com> * add warning when search Signed-off-by: Yhz <yinghao.zou@zilliz.com> * update service_handler Signed-off-by: Yhz <yinghao.zou@zilliz.com> * update shrads requiremtns Signed-off-by: Yhz <yinghao.zou@zilliz.com> * [skip ci] remove surplus log info Signed-off-by: Yhz <yinghao.zou@zilliz.com>
130 lines
3.3 KiB
Python
130 lines
3.3 KiB
Python
import ujson
|
|
from milvus import Status
|
|
from functools import wraps
|
|
|
|
|
|
def error_status(func):
|
|
@wraps(func)
|
|
def inner(*args, **kwargs):
|
|
try:
|
|
results = func(*args, **kwargs)
|
|
except Exception as e:
|
|
return Status(code=Status.UNEXPECTED_ERROR, message=str(e)), None
|
|
|
|
return Status(code=0, message="Success"), results
|
|
|
|
return inner
|
|
|
|
|
|
class GrpcArgsParser(object):
|
|
|
|
@classmethod
|
|
@error_status
|
|
def parse_proto_TableSchema(cls, param):
|
|
_table_schema = {
|
|
'collection_name': param.table_name,
|
|
'dimension': param.dimension,
|
|
'index_file_size': param.index_file_size,
|
|
'metric_type': param.metric_type
|
|
}
|
|
|
|
return param.status, _table_schema
|
|
|
|
@classmethod
|
|
@error_status
|
|
def parse_proto_TableName(cls, param):
|
|
return param.table_name
|
|
|
|
@classmethod
|
|
@error_status
|
|
def parse_proto_FlushParam(cls, param):
|
|
return list(param.table_name_array)
|
|
|
|
@classmethod
|
|
@error_status
|
|
def parse_proto_Index(cls, param):
|
|
_index = {
|
|
'index_type': param.index_type,
|
|
'params': param.extra_params[0].value
|
|
}
|
|
|
|
return _index
|
|
|
|
@classmethod
|
|
@error_status
|
|
def parse_proto_IndexParam(cls, param):
|
|
_table_name = param.table_name
|
|
_index_type = param.index_type
|
|
_index_param = {}
|
|
|
|
for params in param.extra_params:
|
|
if params.key == 'params':
|
|
_index_param = ujson.loads(str(params.value))
|
|
|
|
return _table_name, _index_type, _index_param
|
|
|
|
@classmethod
|
|
@error_status
|
|
def parse_proto_Command(cls, param):
|
|
_cmd = param.cmd
|
|
|
|
return _cmd
|
|
|
|
@classmethod
|
|
@error_status
|
|
def parse_proto_RowRecord(cls, param):
|
|
return list(param.vector_data)
|
|
|
|
@classmethod
|
|
def parse_proto_PartitionParam(cls, param):
|
|
_table_name = param.table_name
|
|
_tag = param.tag
|
|
|
|
return _table_name, _tag
|
|
|
|
@classmethod
|
|
@error_status
|
|
def parse_proto_SearchParam(cls, param):
|
|
_table_name = param.table_name
|
|
_topk = param.topk
|
|
|
|
if len(param.extra_params) == 0:
|
|
raise Exception("Search param loss")
|
|
_params = ujson.loads(str(param.extra_params[0].value))
|
|
|
|
_query_record_array = []
|
|
if param.query_record_array:
|
|
for record in param.query_record_array:
|
|
if record.float_data:
|
|
_query_record_array.append(list(record.float_data))
|
|
else:
|
|
_query_record_array.append(bytes(record.binary_data))
|
|
else:
|
|
raise Exception("Search argument parse error: record array is empty")
|
|
|
|
return _table_name, _query_record_array, _topk, _params
|
|
|
|
@classmethod
|
|
@error_status
|
|
def parse_proto_DeleteByIDParam(cls, param):
|
|
_table_name = param.table_name
|
|
_id_array = list(param.id_array)
|
|
|
|
return _table_name, _id_array
|
|
|
|
@classmethod
|
|
@error_status
|
|
def parse_proto_VectorIdentity(cls, param):
|
|
_table_name = param.table_name
|
|
_id = param.id
|
|
|
|
return _table_name, _id
|
|
|
|
@classmethod
|
|
@error_status
|
|
def parse_proto_GetVectorIDsParam(cls, param):
|
|
_table__name = param.table_name
|
|
_segment_name = param.segment_name
|
|
|
|
return _table__name, _segment_name
|