2020-02-17 15:40:58 +00:00
|
|
|
// Copyright (C) 2019-2020 Zilliz. All rights reserved.
|
2019-09-17 02:51:48 +00:00
|
|
|
//
|
2020-02-17 15:40:58 +00:00
|
|
|
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance
|
|
|
|
// with the License. You may obtain a copy of the License at
|
2019-09-17 02:51:48 +00:00
|
|
|
//
|
2020-02-17 15:40:58 +00:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing, software distributed under the License
|
|
|
|
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
|
|
|
|
// or implied. See the License for the specific language governing permissions and limitations under the License.
|
2019-09-17 02:51:48 +00:00
|
|
|
|
2019-05-26 07:59:05 +00:00
|
|
|
#pragma once
|
|
|
|
|
2019-09-28 02:28:51 +00:00
|
|
|
#include <memory>
|
2019-05-26 07:59:05 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2020-02-29 08:11:31 +00:00
|
|
|
#include "Status.h"
|
|
|
|
|
2019-06-14 09:29:29 +00:00
|
|
|
/** \brief Milvus SDK namespace
|
2019-05-26 07:59:05 +00:00
|
|
|
*/
|
2019-06-14 09:29:29 +00:00
|
|
|
namespace milvus {
|
2019-05-26 07:59:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Index Type
|
|
|
|
*/
|
|
|
|
enum class IndexType {
|
2019-11-13 06:34:07 +00:00
|
|
|
INVALID = 0,
|
|
|
|
FLAT = 1,
|
|
|
|
IVFFLAT = 2,
|
|
|
|
IVFSQ8 = 3,
|
2019-12-10 08:47:35 +00:00
|
|
|
RNSG = 4,
|
2019-11-13 06:34:07 +00:00
|
|
|
IVFSQ8H = 5,
|
2019-11-23 07:37:36 +00:00
|
|
|
IVFPQ = 6,
|
|
|
|
SPTAGKDT = 7,
|
|
|
|
SPTAGBKT = 8,
|
2020-02-14 04:04:09 +00:00
|
|
|
HNSW = 11,
|
2019-05-26 07:59:05 +00:00
|
|
|
};
|
|
|
|
|
2019-09-05 09:32:03 +00:00
|
|
|
enum class MetricType {
|
2020-02-29 08:11:31 +00:00
|
|
|
L2 = 1, // Euclidean Distance
|
|
|
|
IP = 2, // Cosine Similarity
|
|
|
|
HAMMING = 3, // Hamming Distance
|
|
|
|
JACCARD = 4, // Jaccard Distance
|
|
|
|
TANIMOTO = 5, // Tanimoto Distance
|
2019-09-05 09:32:03 +00:00
|
|
|
};
|
|
|
|
|
2019-05-26 07:59:05 +00:00
|
|
|
/**
|
|
|
|
* @brief Connect API parameter
|
|
|
|
*/
|
|
|
|
struct ConnectParam {
|
2019-09-28 02:28:51 +00:00
|
|
|
std::string ip_address; ///< Server IP address
|
|
|
|
std::string port; ///< Server PORT
|
2019-05-26 07:59:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2020-03-08 04:13:06 +00:00
|
|
|
* @brief Collection parameters
|
2019-05-26 07:59:05 +00:00
|
|
|
*/
|
2020-03-08 04:13:06 +00:00
|
|
|
struct CollectionParam {
|
|
|
|
std::string collection_name; ///< Collection_name name
|
2019-09-28 02:28:51 +00:00
|
|
|
int64_t dimension = 0; ///< Vector dimension, must be a positive value
|
2020-03-07 07:23:34 +00:00
|
|
|
int64_t index_file_size = 1024; ///< Index file size, must be a positive value, unit: MB
|
2019-09-28 02:28:51 +00:00
|
|
|
MetricType metric_type = MetricType::L2; ///< Index metric type
|
2019-05-26 07:59:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2020-03-08 04:13:06 +00:00
|
|
|
* @brief Entity inserted, currently each entity represent a vector
|
2019-05-26 07:59:05 +00:00
|
|
|
*/
|
2020-03-08 04:13:06 +00:00
|
|
|
struct Entity {
|
2020-02-29 08:11:31 +00:00
|
|
|
std::vector<float> float_data; ///< Vector raw float data
|
2020-01-14 11:22:27 +00:00
|
|
|
std::vector<uint8_t> binary_data; ///< Vector raw binary data
|
2019-05-26 07:59:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief TopK query result
|
|
|
|
*/
|
2019-11-20 09:54:45 +00:00
|
|
|
struct QueryResult {
|
2020-03-08 04:13:06 +00:00
|
|
|
std::vector<int64_t> ids; ///< Query entity ids result
|
2019-11-28 11:08:15 +00:00
|
|
|
std::vector<float> distances; ///< Query distances result
|
2019-05-26 07:59:05 +00:00
|
|
|
};
|
2019-11-28 10:48:34 +00:00
|
|
|
using TopKQueryResult = std::vector<QueryResult>; ///< Topk query result
|
2019-05-26 07:59:05 +00:00
|
|
|
|
2019-08-13 07:37:16 +00:00
|
|
|
/**
|
2020-03-07 07:23:34 +00:00
|
|
|
* @brief Index parameters
|
|
|
|
* Note: extra_params is extra parameters list, it must be json format
|
|
|
|
* For different index type, parameter list is different accordingly, for example:
|
2020-03-10 04:25:38 +00:00
|
|
|
* FLAT/IVFLAT/SQ8: {nlist: 16384}
|
2020-03-08 06:27:16 +00:00
|
|
|
* ///< nlist range:[1, 999999]
|
2020-03-10 04:25:38 +00:00
|
|
|
* IVFPQ: {nlist: 16384, m: 12}
|
2020-03-08 06:27:16 +00:00
|
|
|
* ///< nlist range:[1, 999999]
|
|
|
|
* ///< m is decided by dim and have a couple of results.
|
2020-03-10 04:25:38 +00:00
|
|
|
* NSG: {search_length: 45, out_degree:50, candidate_pool_size:300, knng:100}
|
2020-03-08 06:27:16 +00:00
|
|
|
* ///< search_length range:[10, 300]
|
|
|
|
* ///< out_degree range:[5, 300]
|
|
|
|
* ///< candidate_pool_size range:[50, 1000]
|
|
|
|
* ///< knng range:[5, 300]
|
2020-03-10 04:25:38 +00:00
|
|
|
* HNSW {M: 16, efConstruction:300}
|
2020-03-08 06:27:16 +00:00
|
|
|
* ///< M range:[5, 48]
|
2020-03-10 04:25:38 +00:00
|
|
|
* ///< efConstruction range:[100, 500]
|
2019-08-13 07:37:16 +00:00
|
|
|
*/
|
|
|
|
struct IndexParam {
|
2020-03-08 04:13:06 +00:00
|
|
|
std::string collection_name; ///< Collection name for create index
|
2020-03-07 07:23:34 +00:00
|
|
|
IndexType index_type; ///< Index type
|
|
|
|
std::string extra_params; ///< Extra parameters according to different index type, must be json format
|
2019-08-13 07:37:16 +00:00
|
|
|
};
|
2019-06-09 07:45:43 +00:00
|
|
|
|
2019-11-07 08:46:31 +00:00
|
|
|
/**
|
|
|
|
* @brief partition parameters
|
|
|
|
*/
|
|
|
|
struct PartitionParam {
|
2020-03-08 04:13:06 +00:00
|
|
|
std::string collection_name;
|
2019-11-07 08:46:31 +00:00
|
|
|
std::string partition_tag;
|
|
|
|
};
|
|
|
|
|
2020-02-29 08:11:31 +00:00
|
|
|
using PartitionTagList = std::vector<std::string>;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief segment statistics
|
|
|
|
*/
|
|
|
|
struct SegmentStat {
|
|
|
|
std::string segment_name; ///< Segment name
|
|
|
|
int64_t row_count; ///< Segment row count
|
|
|
|
std::string index_name; ///< Segment index name
|
|
|
|
int64_t data_size; ///< Segment data size
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief partition statistics
|
|
|
|
*/
|
|
|
|
struct PartitionStat {
|
|
|
|
std::string tag; ///< Partition tag
|
|
|
|
int64_t row_count; ///< Partition row count
|
|
|
|
std::vector<SegmentStat> segments_stat; ///< Partition's segments statistics
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2020-03-08 04:13:06 +00:00
|
|
|
* @brief collection info
|
2020-02-29 08:11:31 +00:00
|
|
|
*/
|
2020-03-08 04:13:06 +00:00
|
|
|
struct CollectionInfo {
|
|
|
|
int64_t total_row_count; ///< Collection total entity count
|
|
|
|
std::vector<PartitionStat> partitions_stat; ///< Collection's partitions statistics
|
2020-02-29 08:11:31 +00:00
|
|
|
};
|
2019-11-07 08:46:31 +00:00
|
|
|
|
2019-05-26 07:59:05 +00:00
|
|
|
/**
|
|
|
|
* @brief SDK main class
|
|
|
|
*/
|
|
|
|
class Connection {
|
2019-07-24 11:29:18 +00:00
|
|
|
public:
|
2019-05-26 07:59:05 +00:00
|
|
|
/**
|
2020-03-08 06:27:16 +00:00
|
|
|
* @brief Create connection
|
2019-05-26 07:59:05 +00:00
|
|
|
*
|
|
|
|
* Create a connection instance and return it's shared pointer
|
|
|
|
*
|
2020-03-08 06:27:16 +00:00
|
|
|
* @return connection instance pointer
|
2019-05-26 07:59:05 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
static std::shared_ptr<Connection>
|
|
|
|
Create();
|
|
|
|
|
|
|
|
/**
|
2020-03-08 06:27:16 +00:00
|
|
|
* @brief Destroy connection
|
2019-05-26 07:59:05 +00:00
|
|
|
*
|
|
|
|
* Destroy the connection instance
|
|
|
|
*
|
|
|
|
* @param connection, the shared pointer to the instance to be destroyed
|
|
|
|
*
|
|
|
|
* @return if destroy is successful
|
|
|
|
*/
|
|
|
|
|
|
|
|
static Status
|
2019-09-28 02:28:51 +00:00
|
|
|
Destroy(std::shared_ptr<Connection>& connection_ptr);
|
2019-05-26 07:59:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Connect
|
|
|
|
*
|
2019-11-28 11:38:22 +00:00
|
|
|
* This method is used to connect server.
|
|
|
|
* Connect function should be called before any operations.
|
2019-05-26 07:59:05 +00:00
|
|
|
*
|
|
|
|
* @param param, use to provide server information
|
|
|
|
*
|
|
|
|
* @return Indicate if connect is successful
|
|
|
|
*/
|
|
|
|
|
2019-08-08 07:02:27 +00:00
|
|
|
virtual Status
|
2020-03-08 06:27:16 +00:00
|
|
|
Connect(const ConnectParam& connect_param) = 0;
|
2019-05-26 07:59:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Connect
|
|
|
|
*
|
2019-11-28 11:38:22 +00:00
|
|
|
* This method is used to connect server.
|
|
|
|
* Connect function should be called before any operations.
|
2019-05-26 07:59:05 +00:00
|
|
|
*
|
2019-11-28 11:38:22 +00:00
|
|
|
* @param uri, use to provide server uri, example: milvus://ipaddress:port
|
2019-05-26 07:59:05 +00:00
|
|
|
*
|
|
|
|
* @return Indicate if connect is successful
|
|
|
|
*/
|
2019-08-08 07:02:27 +00:00
|
|
|
virtual Status
|
2019-09-28 02:28:51 +00:00
|
|
|
Connect(const std::string& uri) = 0;
|
2019-05-26 07:59:05 +00:00
|
|
|
|
|
|
|
/**
|
2020-03-08 06:27:16 +00:00
|
|
|
* @brief Connected
|
2019-05-26 07:59:05 +00:00
|
|
|
*
|
2019-11-28 11:38:22 +00:00
|
|
|
* This method is used to test whether server is connected.
|
2019-05-26 07:59:05 +00:00
|
|
|
*
|
|
|
|
* @return Indicate if connection status
|
|
|
|
*/
|
2019-08-08 07:02:27 +00:00
|
|
|
virtual Status
|
|
|
|
Connected() const = 0;
|
2019-05-26 07:59:05 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Disconnect
|
|
|
|
*
|
2019-11-28 11:38:22 +00:00
|
|
|
* This method is used to disconnect server.
|
2019-05-26 07:59:05 +00:00
|
|
|
*
|
|
|
|
* @return Indicate if disconnect is successful
|
|
|
|
*/
|
2019-08-08 07:02:27 +00:00
|
|
|
virtual Status
|
|
|
|
Disconnect() = 0;
|
2019-05-26 07:59:05 +00:00
|
|
|
|
|
|
|
/**
|
2020-03-08 06:27:16 +00:00
|
|
|
* @brief Get the client version
|
2020-03-08 04:13:06 +00:00
|
|
|
*
|
|
|
|
* This method is used to give the client version.
|
|
|
|
*
|
|
|
|
* @return Client version.
|
|
|
|
*/
|
|
|
|
virtual std::string
|
|
|
|
ClientVersion() const = 0;
|
|
|
|
|
|
|
|
/**
|
2020-03-08 06:27:16 +00:00
|
|
|
* @brief Get the server version
|
2020-03-08 04:13:06 +00:00
|
|
|
*
|
|
|
|
* This method is used to give the server version.
|
|
|
|
*
|
|
|
|
* @return Server version.
|
|
|
|
*/
|
|
|
|
virtual std::string
|
|
|
|
ServerVersion() const = 0;
|
|
|
|
|
2020-03-08 06:27:16 +00:00
|
|
|
/**
|
|
|
|
* @brief Get the server status
|
|
|
|
*
|
|
|
|
* This method is used to give the server status.
|
|
|
|
*
|
|
|
|
* @return Server status.
|
|
|
|
*/
|
|
|
|
virtual std::string
|
|
|
|
ServerStatus() const = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get config method
|
|
|
|
*
|
|
|
|
* This method is used to set config.
|
|
|
|
*
|
|
|
|
* @param node_name, config node name.
|
|
|
|
* @param value, config value.
|
|
|
|
*
|
|
|
|
* @return Indicate if this operation is successful.
|
|
|
|
*/
|
|
|
|
virtual Status
|
|
|
|
GetConfig(const std::string& node_name, std::string& value) const = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Set config method
|
|
|
|
*
|
|
|
|
* This method is used to set config.
|
|
|
|
*
|
|
|
|
* @param node_name, config node name.
|
|
|
|
* @param value, config value.
|
|
|
|
*
|
|
|
|
* @return Indicate if this operation is successful.
|
|
|
|
*/
|
|
|
|
virtual Status
|
|
|
|
SetConfig(const std::string& node_name, const std::string& value) const = 0;
|
|
|
|
|
2020-03-08 04:13:06 +00:00
|
|
|
/**
|
|
|
|
* @brief Create collection method
|
2019-05-26 07:59:05 +00:00
|
|
|
*
|
2020-03-08 04:13:06 +00:00
|
|
|
* This method is used to create collection.
|
2019-05-26 07:59:05 +00:00
|
|
|
*
|
2020-03-08 04:13:06 +00:00
|
|
|
* @param param, use to provide collection information to be created.
|
2019-05-26 07:59:05 +00:00
|
|
|
*
|
2020-03-08 04:13:06 +00:00
|
|
|
* @return Indicate if collection is created successfully
|
2019-05-26 07:59:05 +00:00
|
|
|
*/
|
2019-08-08 07:02:27 +00:00
|
|
|
virtual Status
|
2020-03-08 04:13:06 +00:00
|
|
|
CreateCollection(const CollectionParam& param) = 0;
|
2019-05-26 07:59:05 +00:00
|
|
|
|
2019-06-27 07:51:25 +00:00
|
|
|
/**
|
2020-03-08 04:13:06 +00:00
|
|
|
* @brief Test collection existence method
|
2019-06-27 07:51:25 +00:00
|
|
|
*
|
2020-03-08 04:13:06 +00:00
|
|
|
* This method is used to test collection existence.
|
2019-06-27 07:51:25 +00:00
|
|
|
*
|
2020-03-08 04:13:06 +00:00
|
|
|
* @param collection_name, target collection's name.
|
2019-06-27 07:51:25 +00:00
|
|
|
*
|
2020-03-08 04:13:06 +00:00
|
|
|
* @return Indicate if collection is cexist
|
2019-06-27 07:51:25 +00:00
|
|
|
*/
|
2019-08-08 07:02:27 +00:00
|
|
|
virtual bool
|
2020-03-08 04:13:06 +00:00
|
|
|
HasCollection(const std::string& collection_name) = 0;
|
2019-06-27 07:51:25 +00:00
|
|
|
|
2019-05-26 07:59:05 +00:00
|
|
|
/**
|
2020-03-08 04:13:06 +00:00
|
|
|
* @brief Drop collection method
|
2019-05-26 07:59:05 +00:00
|
|
|
*
|
2020-03-08 04:13:06 +00:00
|
|
|
* This method is used to drop collection(and its partitions).
|
2019-05-26 07:59:05 +00:00
|
|
|
*
|
2020-03-08 04:13:06 +00:00
|
|
|
* @param collection_name, target collection's name.
|
2019-05-26 07:59:05 +00:00
|
|
|
*
|
2020-03-08 04:13:06 +00:00
|
|
|
* @return Indicate if collection is drop successfully.
|
2019-05-26 07:59:05 +00:00
|
|
|
*/
|
2019-08-08 07:02:27 +00:00
|
|
|
virtual Status
|
2020-03-08 04:13:06 +00:00
|
|
|
DropCollection(const std::string& collection_name) = 0;
|
2019-07-24 11:29:18 +00:00
|
|
|
|
2019-07-12 04:19:32 +00:00
|
|
|
/**
|
2019-08-13 07:37:16 +00:00
|
|
|
* @brief Create index method
|
2019-07-12 04:19:32 +00:00
|
|
|
*
|
2020-03-08 04:13:06 +00:00
|
|
|
* This method is used to create index for whole collection(and its partitions).
|
2019-07-12 04:19:32 +00:00
|
|
|
*
|
2020-03-08 04:13:06 +00:00
|
|
|
* @param index_param, use to provide index information to be created.
|
2019-07-12 04:19:32 +00:00
|
|
|
*
|
2020-03-08 04:13:06 +00:00
|
|
|
* @return Indicate if create index successfully.
|
2019-07-12 04:19:32 +00:00
|
|
|
*/
|
2019-08-08 07:02:27 +00:00
|
|
|
virtual Status
|
2019-09-28 02:28:51 +00:00
|
|
|
CreateIndex(const IndexParam& index_param) = 0;
|
2019-07-12 04:19:32 +00:00
|
|
|
|
2019-05-26 07:59:05 +00:00
|
|
|
/**
|
2020-03-08 06:27:16 +00:00
|
|
|
* @brief Insert entity to collection
|
2019-05-26 07:59:05 +00:00
|
|
|
*
|
2020-03-08 06:27:16 +00:00
|
|
|
* This method is used to insert vector array to collection.
|
2019-05-26 07:59:05 +00:00
|
|
|
*
|
2020-03-08 04:13:06 +00:00
|
|
|
* @param collection_name, target collection's name.
|
2020-03-07 07:23:34 +00:00
|
|
|
* @param partition_tag, target partition's tag, keep empty if no partition specified.
|
2020-03-08 04:13:06 +00:00
|
|
|
* @param entity_array, entity array is inserted, each entitu represent a vector.
|
2019-11-28 11:38:22 +00:00
|
|
|
* @param id_array,
|
2020-03-08 04:13:06 +00:00
|
|
|
* specify id for each entity,
|
|
|
|
* if this array is empty, milvus will generate unique id for each entity,
|
2019-11-28 11:38:22 +00:00
|
|
|
* and return all ids by this parameter.
|
2019-05-26 07:59:05 +00:00
|
|
|
*
|
2020-03-08 04:13:06 +00:00
|
|
|
* @return Indicate if entity array are inserted successfully
|
2019-05-26 07:59:05 +00:00
|
|
|
*/
|
2019-08-08 07:02:27 +00:00
|
|
|
virtual Status
|
2020-03-08 04:13:06 +00:00
|
|
|
Insert(const std::string& collection_name,
|
|
|
|
const std::string& partition_tag,
|
|
|
|
const std::vector<Entity>& entity_array,
|
2019-09-28 02:28:51 +00:00
|
|
|
std::vector<int64_t>& id_array) = 0;
|
2019-05-26 07:59:05 +00:00
|
|
|
|
2020-02-29 08:11:31 +00:00
|
|
|
/**
|
2020-03-08 04:13:06 +00:00
|
|
|
* @brief Get entity data by id
|
2020-02-29 08:11:31 +00:00
|
|
|
*
|
2020-03-08 04:13:06 +00:00
|
|
|
* This method is used to get entity data by id from a collection.
|
|
|
|
* Return the first found entity if there are entities with duplicated id
|
2020-02-29 08:11:31 +00:00
|
|
|
*
|
2020-03-08 04:13:06 +00:00
|
|
|
* @param collection_name, target collection's name.
|
|
|
|
* @param entity_id, target entity id.
|
|
|
|
* @param entity_data, returned entity data.
|
2020-02-29 08:11:31 +00:00
|
|
|
*
|
|
|
|
* @return Indicate if the operation is succeed.
|
|
|
|
*/
|
|
|
|
virtual Status
|
2020-03-08 04:13:06 +00:00
|
|
|
GetEntityByID(const std::string& collection_name, int64_t entity_id, Entity& entity_data) = 0;
|
2020-02-29 08:11:31 +00:00
|
|
|
|
|
|
|
/**
|
2020-03-08 04:13:06 +00:00
|
|
|
* @brief Get entity ids from a segment
|
2020-02-29 08:11:31 +00:00
|
|
|
*
|
2020-03-08 04:13:06 +00:00
|
|
|
* This method is used to get entity ids from a segment
|
|
|
|
* Return all entity(not deleted) ids
|
2020-02-29 08:11:31 +00:00
|
|
|
*
|
2020-03-08 04:13:06 +00:00
|
|
|
* @param collection_name, target collection's name.
|
2020-02-29 08:11:31 +00:00
|
|
|
* @param segment_name, target segment name.
|
2020-03-08 04:13:06 +00:00
|
|
|
* @param id_array, returned entity id array.
|
2020-02-29 08:11:31 +00:00
|
|
|
*
|
|
|
|
* @return Indicate if the operation is succeed.
|
|
|
|
*/
|
|
|
|
virtual Status
|
2020-03-08 04:13:06 +00:00
|
|
|
GetIDsInSegment(const std::string& collection_name,
|
|
|
|
const std::string& segment_name,
|
|
|
|
std::vector<int64_t>& id_array) = 0;
|
2020-02-29 08:11:31 +00:00
|
|
|
|
2019-05-26 07:59:05 +00:00
|
|
|
/**
|
2020-03-08 04:13:06 +00:00
|
|
|
* @brief Search entities in a collection
|
2019-05-26 07:59:05 +00:00
|
|
|
*
|
2020-03-08 04:13:06 +00:00
|
|
|
* This method is used to query entity in collection.
|
2019-05-26 07:59:05 +00:00
|
|
|
*
|
2020-03-08 04:13:06 +00:00
|
|
|
* @param collection_name, target collection's name.
|
2020-03-07 07:23:34 +00:00
|
|
|
* @param partition_tag_array, target partitions, keep empty if no partition specified.
|
2020-03-08 06:27:16 +00:00
|
|
|
* @param query_entity_array, vectors to be queried.
|
|
|
|
* @param topk, how many similarity entities will be returned.
|
2020-03-07 07:23:34 +00:00
|
|
|
* @param extra_params, extra search parameters according to different index type, must be json format.
|
|
|
|
* Note: extra_params is extra parameters list, it must be json format, for example:
|
|
|
|
* For different index type, parameter list is different accordingly
|
2020-03-10 04:25:38 +00:00
|
|
|
* FLAT/IVFLAT/SQ8/IVFPQ: {nprobe: 32}
|
2020-03-08 06:27:16 +00:00
|
|
|
* ///< nprobe range:[1,999999]
|
2020-03-10 04:25:38 +00:00
|
|
|
* NSG: {search_length:100}
|
2020-03-08 06:27:16 +00:00
|
|
|
* ///< search_length range:[10, 300]
|
2020-03-10 04:25:38 +00:00
|
|
|
* HNSW {ef: 64}
|
|
|
|
* ///< ef range:[topk, 4096]
|
2020-03-07 07:23:34 +00:00
|
|
|
* @param topk_query_result, result array.
|
2019-05-26 07:59:05 +00:00
|
|
|
*
|
|
|
|
* @return Indicate if query is successful.
|
|
|
|
*/
|
2019-08-08 07:02:27 +00:00
|
|
|
virtual Status
|
2020-03-08 06:27:16 +00:00
|
|
|
Search(const std::string& collection_name, const PartitionTagList& partition_tag_array,
|
|
|
|
const std::vector<Entity>& entity_array, int64_t topk,
|
2020-03-07 07:23:34 +00:00
|
|
|
const std::string& extra_params, TopKQueryResult& topk_query_result) = 0;
|
2019-05-26 07:59:05 +00:00
|
|
|
|
|
|
|
/**
|
2020-03-08 04:13:06 +00:00
|
|
|
* @brief Show collection description
|
2019-05-26 07:59:05 +00:00
|
|
|
*
|
2020-03-08 04:13:06 +00:00
|
|
|
* This method is used to show collection information.
|
2019-05-26 07:59:05 +00:00
|
|
|
*
|
2020-03-08 04:13:06 +00:00
|
|
|
* @param collection_name, target collection's name.
|
2020-03-08 06:27:16 +00:00
|
|
|
* @param collection_param, collection_param is given when operation is successful.
|
2019-05-26 07:59:05 +00:00
|
|
|
*
|
|
|
|
* @return Indicate if this operation is successful.
|
|
|
|
*/
|
2019-08-08 07:02:27 +00:00
|
|
|
virtual Status
|
2020-03-08 06:27:16 +00:00
|
|
|
DescribeCollection(const std::string& collection_name, CollectionParam& collection_param) = 0;
|
2019-05-26 07:59:05 +00:00
|
|
|
|
2019-06-09 07:45:43 +00:00
|
|
|
/**
|
2020-03-08 06:27:16 +00:00
|
|
|
* @brief Get collection entity count
|
2019-06-09 07:45:43 +00:00
|
|
|
*
|
2020-03-08 06:27:16 +00:00
|
|
|
* This method is used to get collection entity count.
|
2019-06-09 07:45:43 +00:00
|
|
|
*
|
2020-03-08 04:13:06 +00:00
|
|
|
* @param collection_name, target collection's name.
|
|
|
|
* @param entity_count, collection total entity count(including partitions).
|
2019-06-09 07:45:43 +00:00
|
|
|
*
|
|
|
|
* @return Indicate if this operation is successful.
|
|
|
|
*/
|
2019-08-08 07:02:27 +00:00
|
|
|
virtual Status
|
2020-03-08 04:13:06 +00:00
|
|
|
CountCollection(const std::string& collection_name, int64_t& entity_count) = 0;
|
2019-06-09 07:45:43 +00:00
|
|
|
|
2019-05-26 07:59:05 +00:00
|
|
|
/**
|
2020-03-08 04:13:06 +00:00
|
|
|
* @brief Show all collections in database
|
2019-05-26 07:59:05 +00:00
|
|
|
*
|
2020-03-08 04:13:06 +00:00
|
|
|
* This method is used to list all collections.
|
2019-05-26 07:59:05 +00:00
|
|
|
*
|
2020-03-08 04:13:06 +00:00
|
|
|
* @param collection_array, all collections in database.
|
2019-05-26 07:59:05 +00:00
|
|
|
*
|
|
|
|
* @return Indicate if this operation is successful.
|
|
|
|
*/
|
2019-08-08 07:02:27 +00:00
|
|
|
virtual Status
|
2020-03-08 04:13:06 +00:00
|
|
|
ShowCollections(std::vector<std::string>& collection_array) = 0;
|
2019-05-26 07:59:05 +00:00
|
|
|
|
2020-02-29 08:11:31 +00:00
|
|
|
/**
|
2020-03-08 06:27:16 +00:00
|
|
|
* @brief Show collection information
|
2020-02-29 08:11:31 +00:00
|
|
|
*
|
2020-03-08 06:27:16 +00:00
|
|
|
* This method is used to get detail information of a collection.
|
2020-02-29 08:11:31 +00:00
|
|
|
*
|
2020-03-08 06:27:16 +00:00
|
|
|
* @param collection_name, target collection's name.
|
|
|
|
* @param collection_info, target collection's information
|
2020-02-29 08:11:31 +00:00
|
|
|
*
|
|
|
|
* @return Indicate if this operation is successful.
|
|
|
|
*/
|
|
|
|
virtual Status
|
2020-03-08 06:27:16 +00:00
|
|
|
ShowCollectionInfo(const std::string& collection_name, CollectionInfo& collection_info) = 0;
|
2019-08-13 07:37:16 +00:00
|
|
|
|
|
|
|
/**
|
2020-03-08 06:27:16 +00:00
|
|
|
* @brief Delete entity by id
|
2019-08-13 07:37:16 +00:00
|
|
|
*
|
2020-03-08 06:27:16 +00:00
|
|
|
* This method is used to delete entity by id.
|
2019-08-13 07:37:16 +00:00
|
|
|
*
|
2020-03-08 06:27:16 +00:00
|
|
|
* @param collection_name, target collection's name.
|
|
|
|
* @param id_array, entity id array to be deleted.
|
2019-08-13 07:37:16 +00:00
|
|
|
*
|
|
|
|
* @return Indicate if this operation is successful.
|
|
|
|
*/
|
|
|
|
virtual Status
|
2020-03-08 06:27:16 +00:00
|
|
|
DeleteByID(const std::string& collection_name, const std::vector<int64_t>& id_array) = 0;
|
2019-08-13 07:37:16 +00:00
|
|
|
|
|
|
|
/**
|
2020-03-08 06:27:16 +00:00
|
|
|
* @brief Preload collection
|
2019-08-13 07:37:16 +00:00
|
|
|
*
|
2020-03-08 06:27:16 +00:00
|
|
|
* This method is used to preload collection data into memory
|
2019-08-13 07:37:16 +00:00
|
|
|
*
|
2020-03-08 06:27:16 +00:00
|
|
|
* @param collection_name, target collection's name.
|
2019-08-13 07:37:16 +00:00
|
|
|
*
|
|
|
|
* @return Indicate if this operation is successful.
|
|
|
|
*/
|
|
|
|
virtual Status
|
2020-03-08 06:27:16 +00:00
|
|
|
PreloadCollection(const std::string& collection_name) const = 0;
|
2019-08-13 07:37:16 +00:00
|
|
|
|
|
|
|
/**
|
2020-03-08 06:27:16 +00:00
|
|
|
* @brief Describe index
|
2019-08-13 07:37:16 +00:00
|
|
|
*
|
|
|
|
* This method is used to describe index
|
|
|
|
*
|
2020-03-08 06:27:16 +00:00
|
|
|
* @param collection_name, target collection's name.
|
2019-11-07 08:46:31 +00:00
|
|
|
* @param index_param, returned index information.
|
2019-08-13 07:37:16 +00:00
|
|
|
*
|
2019-11-07 08:46:31 +00:00
|
|
|
* @return Indicate if this operation is successful.
|
2019-08-13 07:37:16 +00:00
|
|
|
*/
|
2019-08-21 08:53:31 +00:00
|
|
|
virtual Status
|
2020-03-08 06:27:16 +00:00
|
|
|
DescribeIndex(const std::string& collection_name, IndexParam& index_param) const = 0;
|
2019-08-13 07:37:16 +00:00
|
|
|
|
|
|
|
/**
|
2020-03-08 06:27:16 +00:00
|
|
|
* @brief Drop index
|
2019-08-13 07:37:16 +00:00
|
|
|
*
|
2020-03-08 06:27:16 +00:00
|
|
|
* This method is used to drop index of collection(and its partitions)
|
2019-08-13 07:37:16 +00:00
|
|
|
*
|
2020-03-08 06:27:16 +00:00
|
|
|
* @param collection_name, target collection's name.
|
2019-08-13 07:37:16 +00:00
|
|
|
*
|
|
|
|
* @return Indicate if this operation is successful.
|
|
|
|
*/
|
|
|
|
virtual Status
|
2020-03-08 06:27:16 +00:00
|
|
|
DropIndex(const std::string& collection_name) const = 0;
|
2019-11-07 08:46:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Create partition method
|
|
|
|
*
|
2020-03-08 06:27:16 +00:00
|
|
|
* This method is used to create collection's partition
|
2019-11-07 08:46:31 +00:00
|
|
|
*
|
2020-03-08 06:27:16 +00:00
|
|
|
* @param partition_param, use to provide partition information to be created.
|
2019-11-07 08:46:31 +00:00
|
|
|
*
|
|
|
|
* @return Indicate if partition is created successfully
|
|
|
|
*/
|
|
|
|
virtual Status
|
2020-03-08 06:27:16 +00:00
|
|
|
CreatePartition(const PartitionParam& partition_param) = 0;
|
2019-11-07 08:46:31 +00:00
|
|
|
|
|
|
|
/**
|
2020-03-08 06:27:16 +00:00
|
|
|
* @brief Show all partitions method
|
2019-11-07 08:46:31 +00:00
|
|
|
*
|
2020-03-08 06:27:16 +00:00
|
|
|
* This method is used to show all partitions(return their tags)
|
2019-11-07 08:46:31 +00:00
|
|
|
*
|
2020-03-08 06:27:16 +00:00
|
|
|
* @param collection_name, target collection's name.
|
|
|
|
* @param partition_tag_array, partition tag array of the collection.
|
2019-11-07 08:46:31 +00:00
|
|
|
*
|
|
|
|
* @return Indicate if this operation is successful
|
|
|
|
*/
|
|
|
|
virtual Status
|
2020-03-08 06:27:16 +00:00
|
|
|
ShowPartitions(const std::string& collection_name, PartitionTagList& partition_tag_array) const = 0;
|
2019-11-07 08:46:31 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Delete partition method
|
|
|
|
*
|
2020-03-08 06:27:16 +00:00
|
|
|
* This method is used to delete collection's partition.
|
2019-11-07 08:46:31 +00:00
|
|
|
*
|
2020-03-08 06:27:16 +00:00
|
|
|
* @param partition_param, target partition to be deleted.
|
2019-11-07 08:46:31 +00:00
|
|
|
*
|
|
|
|
* @return Indicate if partition is delete successfully.
|
|
|
|
*/
|
|
|
|
virtual Status
|
2020-03-08 06:27:16 +00:00
|
|
|
DropPartition(const PartitionParam& partition_param) = 0;
|
2019-12-31 02:47:52 +00:00
|
|
|
|
|
|
|
/**
|
2020-03-08 06:27:16 +00:00
|
|
|
* @brief Flush collection buffer into storage
|
2019-12-31 02:47:52 +00:00
|
|
|
*
|
2020-03-08 06:27:16 +00:00
|
|
|
* This method is used to flush collection buffer into storage
|
2019-12-31 02:47:52 +00:00
|
|
|
*
|
2020-03-08 06:27:16 +00:00
|
|
|
* @param collection_name, target collection's name.
|
2020-02-29 08:11:31 +00:00
|
|
|
*
|
|
|
|
* @return Indicate if this operation is successful.
|
|
|
|
*/
|
|
|
|
virtual Status
|
2020-03-08 06:27:16 +00:00
|
|
|
FlushCollection(const std::string& collection_name) = 0;
|
2020-02-29 08:11:31 +00:00
|
|
|
|
|
|
|
/**
|
2020-03-08 06:27:16 +00:00
|
|
|
* @brief Flush all buffer into storage
|
2020-02-29 08:11:31 +00:00
|
|
|
*
|
2020-03-08 06:27:16 +00:00
|
|
|
* This method is used to all collection buffer into storage
|
2020-02-29 08:11:31 +00:00
|
|
|
*
|
|
|
|
* @return Indicate if this operation is successful.
|
|
|
|
*/
|
|
|
|
virtual Status
|
|
|
|
Flush() = 0;
|
|
|
|
|
|
|
|
/**
|
2020-03-08 06:27:16 +00:00
|
|
|
* @brief Compact collection, permanently remove deleted vectors
|
2020-02-29 08:11:31 +00:00
|
|
|
*
|
2020-03-08 06:27:16 +00:00
|
|
|
* This method is used to compact collection
|
2020-02-29 08:11:31 +00:00
|
|
|
*
|
2020-03-08 06:27:16 +00:00
|
|
|
* @param collection_name, target collection's name.
|
2020-02-29 08:11:31 +00:00
|
|
|
*
|
|
|
|
* @return Indicate if this operation is successful.
|
|
|
|
*/
|
|
|
|
virtual Status
|
2020-03-08 06:27:16 +00:00
|
|
|
CompactCollection(const std::string& collection_name) = 0;
|
2019-05-26 07:59:05 +00:00
|
|
|
};
|
|
|
|
|
2019-09-28 02:28:51 +00:00
|
|
|
} // namespace milvus
|