def DescribeCollection(self, request, context): _status, _collection_name = Parser.parse_proto_CollectionName(request) if not _status.OK(): return milvus_pb2.CollectionSchema(status=status_pb2.Status( error_code=_status.code, reason=_status.message), ) metadata = {'resp_class': milvus_pb2.CollectionSchema} logger.info('DescribeCollection {}'.format(_collection_name)) _status, _collection = self._describe_collection(metadata=metadata, collection_name=_collection_name) if _status.OK(): return milvus_pb2.CollectionSchema( collection_name=_collection_name, index_file_size=_collection.index_file_size, dimension=_collection.dimension, metric_type=_collection.metric_type, status=status_pb2.Status(error_code=_status.code, reason=_status.message), ) return milvus_pb2.CollectionSchema( collection_name=_collection_name, status=status_pb2.Status(error_code=_status.code, reason=_status.message), )
def DescribeIndex(self, request, context): _status, _collection_name = Parser.parse_proto_CollectionName(request) if not _status.OK(): return milvus_pb2.IndexParam(status=status_pb2.Status( error_code=_status.code, reason=_status.message)) metadata = {'resp_class': milvus_pb2.IndexParam} logger.info('DescribeIndex {}'.format(_collection_name)) _status, _index_param = self._describe_index(collection_name=_collection_name, metadata=metadata) if not _index_param: return milvus_pb2.IndexParam(status=status_pb2.Status( error_code=_status.code, reason=_status.message)) _index_type = _index_param._index_type grpc_index = milvus_pb2.IndexParam(status=status_pb2.Status( error_code=_status.code, reason=_status.message), collection_name=_collection_name, index_type=_index_type) grpc_index.extra_params.add(key='params', value=ujson.dumps(_index_param._params)) return grpc_index
def ShowCollectionInfo(self, request, context): _status, _collection_name = Parser.parse_proto_CollectionName(request) if not _status.OK(): return milvus_pb2.CollectionInfo(status=status_pb2.Status( error_code=_status.code, reason=_status.message), ) metadata = {'resp_class': milvus_pb2.CollectionInfo} logger.info('ShowCollectionInfo {}'.format(_collection_name)) _status, _info = self._collection_info( metadata=metadata, collection_name=_collection_name) if _status.OK(): _collection_info = milvus_pb2.CollectionInfo( status=status_pb2.Status(error_code=_status.code, reason=_status.message), total_row_count=_info.count) for par_stat in _info.partitions_stat: _par = milvus_pb2.PartitionStat(tag=par_stat.tag, total_row_count=par_stat.count) for seg_stat in par_stat.segments_stat: _par.segments_stat.add( segment_name=seg_stat.segment_name, row_count=seg_stat.count, index_name=seg_stat.index_name, data_size=seg_stat.data_size, ) _collection_info.partitions_stat.append(_par) return _collection_info return milvus_pb2.CollectionInfo(status=status_pb2.Status( error_code=_status.code, reason=_status.message), )
def Compact(self, request, context): _status, _collection_name = Parser.parse_proto_CollectionName(request) if not _status.OK(): return status_pb2.Status(error_code=_status.code, reason=_status.message) logger.info('Compact {}'.format(_collection_name)) _status = self._compact(_collection_name) return status_pb2.Status(error_code=_status.code, reason=_status.message)
def ShowPartitions(self, request, context): _status, _collection_name = Parser.parse_proto_CollectionName(request) if not _status.OK(): return milvus_pb2.PartitionList(status=status_pb2.Status( error_code=_status.code, reason=_status.message), partition_array=[]) logger.info('ShowPartitions {}'.format(_collection_name)) _status, partition_array = self.router.connection().show_partitions(_collection_name) return milvus_pb2.PartitionList(status=status_pb2.Status( error_code=_status.code, reason=_status.message), partition_tag_array=[param.tag for param in partition_array])
def HasCollection(self, request, context): _status, _collection_name = Parser.parse_proto_CollectionName(request) if not _status.OK(): return milvus_pb2.BoolReply(status=status_pb2.Status( error_code=_status.code, reason=_status.message), bool_reply=False) logger.info('HasCollection {}'.format(_collection_name)) _status, _bool = self._has_collection(_collection_name, metadata={'resp_class': milvus_pb2.BoolReply}) return milvus_pb2.BoolReply(status=status_pb2.Status( error_code=_status.code, reason=_status.message), bool_reply=_bool)
def CountCollection(self, request, context): _status, _collection_name = Parser.parse_proto_CollectionName(request) if not _status.OK(): status = status_pb2.Status(error_code=_status.code, reason=_status.message) return milvus_pb2.CollectionRowCount(status=status) logger.info('CountCollection {}'.format(_collection_name)) metadata = {'resp_class': milvus_pb2.CollectionRowCount} _status, _count = self._count_collection(_collection_name, metadata=metadata) return milvus_pb2.CollectionRowCount( status=status_pb2.Status(error_code=_status.code, reason=_status.message), collection_row_count=_count if isinstance(_count, int) else -1)
def ShowCollectionInfo(self, request, context): _status, _collection_name = Parser.parse_proto_CollectionName(request) if not _status.OK(): return milvus_pb2.CollectionInfo(status=status_pb2.Status( error_code=_status.code, reason=_status.message), ) metadata = {'resp_class': milvus_pb2.CollectionInfo} _status, _info = self._collection_info( metadata=metadata, collection_name=_collection_name) _info_str = ujson.dumps(_info) if _status.OK(): return milvus_pb2.CollectionInfo(status=status_pb2.Status( error_code=_status.code, reason=_status.message), json_info=_info_str) return milvus_pb2.CollectionInfo(status=status_pb2.Status( error_code=_status.code, reason=_status.message), )