提交 fcb56568 编写于 作者: G groot

refine c++sdk

Signed-off-by: Ngroot <yihua.mo@zilliz.com>
上级 ab8339ce
......@@ -415,21 +415,6 @@ ClientProxy::ServerStatus() const {
}
}
std::string
ClientProxy::DumpTaskTables() const {
if (channel_ == nullptr) {
return "not connected to server";
}
try {
std::string dummy;
Status status = client_ptr_->Cmd("tasktable", dummy);
return dummy;
} catch (std::exception& ex) {
return "connection lost";
}
}
Status
ClientProxy::DeleteByID(const std::string& table_name, const std::vector<int64_t>& id_array) {
try {
......
......@@ -84,9 +84,6 @@ class ClientProxy : public Connection {
std::string
ServerStatus() const override;
std::string
DumpTaskTables() const override;
Status
DeleteByID(const std::string& table_name, const std::vector<int64_t>& id_array) override;
......
......@@ -54,20 +54,19 @@ struct ConnectParam {
};
/**
* @brief Table Schema
* @brief Collection parameters
*/
struct TableSchema {
std::string table_name; ///< Table name
struct CollectionParam {
std::string collection_name; ///< Collection_name name
int64_t dimension = 0; ///< Vector dimension, must be a positive value
int64_t index_file_size = 1024; ///< Index file size, must be a positive value, unit: MB
MetricType metric_type = MetricType::L2; ///< Index metric type
};
/**
* @brief Record inserted
* @brief Entity inserted, currently each entity represent a vector
*/
struct RowRecord {
struct Entity {
std::vector<float> float_data; ///< Vector raw float data
std::vector<uint8_t> binary_data; ///< Vector raw binary data
};
......@@ -76,7 +75,7 @@ struct RowRecord {
* @brief TopK query result
*/
struct QueryResult {
std::vector<int64_t> ids; ///< Query ids result
std::vector<int64_t> ids; ///< Query entity ids result
std::vector<float> distances; ///< Query distances result
};
using TopKQueryResult = std::vector<QueryResult>; ///< Topk query result
......@@ -85,13 +84,14 @@ using TopKQueryResult = std::vector<QueryResult>; ///< Topk query result
* @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:
* FLAT/IVFLAT/SQ8: "{nlist: '16384'}"
* IVFPQ: "{nlist: '16384', nbits: "16"}"
* NSG: "{search_length: '100', out_degree:'40', pool_size:'66'}"
* HNSW "{M: '16', ef_construct:'500'}"
* FLAT/IVFLAT/SQ8: "{nlist: '16384'}" nlist range:[1, 999999]
* IVFPQ: "{nlist: '16384', m: "12"}" nlist range:[1, 999999] m is decided by dim and have a couple of results.
* NSG: "{search_length: '45', out_degree:'50', candidate_pool_size:'300', "knng":'100'}"
* search_length range:[10, 300] out_degree range:[5, 300] candidate_pool_size range:[50, 1000] knng range:[5, 300]
* HNSW "{M: '16', efConstruction:'500'}" M range:[5, 48] efConstruction range:[topk, 4096]
*/
struct IndexParam {
std::string table_name; ///< Table name for create index
std::string collection_name; ///< Collection name for create index
IndexType index_type; ///< Index type
std::string extra_params; ///< Extra parameters according to different index type, must be json format
};
......@@ -100,7 +100,7 @@ struct IndexParam {
* @brief partition parameters
*/
struct PartitionParam {
std::string table_name;
std::string collection_name;
std::string partition_tag;
};
......@@ -126,11 +126,11 @@ struct PartitionStat {
};
/**
* @brief table info
* @brief collection info
*/
struct TableInfo {
int64_t total_row_count; ///< Table total row count
std::vector<PartitionStat> partitions_stat; ///< Table's partitions statistics
struct CollectionInfo {
int64_t total_row_count; ///< Collection total entity count
std::vector<PartitionStat> partitions_stat; ///< Collection's partitions statistics
};
/**
......@@ -210,112 +210,132 @@ class Connection {
Disconnect() = 0;
/**
* @brief Create table method
* @brief Give the client version
*
* This method is used to create table.
* This method is used to give the client version.
*
* @param param, use to provide table information to be created.
* @return Client version.
*/
virtual std::string
ClientVersion() const = 0;
/**
* @brief Give the server version
*
* This method is used to give the server version.
*
* @return Indicate if table is created successfully
* @return Server version.
*/
virtual std::string
ServerVersion() const = 0;
/**
* @brief Create collection method
*
* This method is used to create collection.
*
* @param param, use to provide collection information to be created.
*
* @return Indicate if collection is created successfully
*/
virtual Status
CreateTable(const TableSchema& param) = 0;
CreateCollection(const CollectionParam& param) = 0;
/**
* @brief Test table existence method
* @brief Test collection existence method
*
* This method is used to create table.
* This method is used to test collection existence.
*
* @param table_name, target table's name.
* @param collection_name, target collection's name.
*
* @return Indicate if table is cexist
* @return Indicate if collection is cexist
*/
virtual bool
HasTable(const std::string& table_name) = 0;
HasCollection(const std::string& collection_name) = 0;
/**
* @brief Drop table method
* @brief Drop collection method
*
* This method is used to drop table(and its partitions).
* This method is used to drop collection(and its partitions).
*
* @param table_name, target table's name.
* @param collection_name, target collection's name.
*
* @return Indicate if table is drop successfully.
* @return Indicate if collection is drop successfully.
*/
virtual Status
DropTable(const std::string& table_name) = 0;
DropCollection(const std::string& collection_name) = 0;
/**
* @brief Create index method
*
* This method is used to create index for whole table(and its partitions).
* This method is used to create index for whole collection(and its partitions).
*
* @param IndexParam
* table_name, table name is going to be create index.
* index type,
* nlist,
* index file size
* @param index_param, use to provide index information to be created.
*
* @return Indicate if build index successfully.
* @return Indicate if create index successfully.
*/
virtual Status
CreateIndex(const IndexParam& index_param) = 0;
/**
* @brief Insert vector to table
* @brief Insert entity to table
*
* This method is used to insert vector array to table.
*
* @param table_name, target table's name.
* @param collection_name, target collection's name.
* @param partition_tag, target partition's tag, keep empty if no partition specified.
* @param record_array, vector array is inserted.
* @param entity_array, entity array is inserted, each entitu represent a vector.
* @param id_array,
* specify id for each vector,
* if this array is empty, milvus will generate unique id for each vector,
* specify id for each entity,
* if this array is empty, milvus will generate unique id for each entity,
* and return all ids by this parameter.
*
* @return Indicate if vector array are inserted successfully
* @return Indicate if entity array are inserted successfully
*/
virtual Status
Insert(const std::string& table_name, const std::string& partition_tag, const std::vector<RowRecord>& record_array,
Insert(const std::string& collection_name,
const std::string& partition_tag,
const std::vector<Entity>& entity_array,
std::vector<int64_t>& id_array) = 0;
/**
* @brief Get vector data by id
* @brief Get entity data by id
*
* This method is used to get vector data by id from a table.
* Return the first found vector if there are vectors with duplicated id
* 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
*
* @param table_name, target table's name.
* @param vector_id, target vector id.
* @param vector_data, returned vector data.
* @param collection_name, target collection's name.
* @param entity_id, target entity id.
* @param entity_data, returned entity data.
*
* @return Indicate if the operation is succeed.
*/
virtual Status
GetVectorByID(const std::string& table_name, int64_t vector_id, RowRecord& vector_data) = 0;
GetEntityByID(const std::string& collection_name, int64_t entity_id, Entity& entity_data) = 0;
/**
* @brief Get vector ids from a segment
* @brief Get entity ids from a segment
*
* This method is used to get vector ids from a segment
* Return all vector(not deleted) ids
* This method is used to get entity ids from a segment
* Return all entity(not deleted) ids
*
* @param table_name, target table's name.
* @param collection_name, target collection's name.
* @param segment_name, target segment name.
* @param id_array, returned vector id array.
* @param id_array, returned entity id array.
*
* @return Indicate if the operation is succeed.
*/
virtual Status
GetIDsInSegment(const std::string& table_name, const std::string& segment_name, std::vector<int64_t>& id_array) = 0;
GetIDsInSegment(const std::string& collection_name,
const std::string& segment_name,
std::vector<int64_t>& id_array) = 0;
/**
* @brief Search vector
* @brief Search entities in a collection
*
* This method is used to query vector in table.
* This method is used to query entity in collection.
*
* @param table_name, target table's name.
* @param collection_name, target collection's name.
* @param partition_tag_array, target partitions, keep empty if no partition specified.
* @param query_record_array, vectors to be queried.
* @param topk, how many similarity vectors will be returned.
......@@ -331,79 +351,59 @@ class Connection {
*/
virtual Status
Search(const std::string& table_name, const PartitionTagList& partition_tag_array,
const std::vector<RowRecord>& query_record_array, int64_t topk,
const std::vector<Entity>& query_record_array, int64_t topk,
const std::string& extra_params, TopKQueryResult& topk_query_result) = 0;
/**
* @brief Show table description
* @brief Show collection description
*
* This method is used to show table information.
* This method is used to show collection information.
*
* @param table_name, target table's name.
* @param table_schema, table_schema is given when operation is successful.
* @param collection_name, target collection's name.
* @param collection_schema, collection_schema is given when operation is successful.
*
* @return Indicate if this operation is successful.
*/
virtual Status
DescribeTable(const std::string& table_name, TableSchema& table_schema) = 0;
DescribeCollection(const std::string& collection_name, TableSchema& collection_schema) = 0;
/**
* @brief Get table row count
* @brief Get collection row count
*
* This method is used to get table row count.
* This method is used to get collection row count.
*
* @param table_name, target table's name.
* @param row_count, table total row count(including partitions).
* @param collection_name, target collection's name.
* @param entity_count, collection total entity count(including partitions).
*
* @return Indicate if this operation is successful.
*/
virtual Status
CountTable(const std::string& table_name, int64_t& row_count) = 0;
CountCollection(const std::string& collection_name, int64_t& entity_count) = 0;
/**
* @brief Show all tables in database
* @brief Show all collections in database
*
* This method is used to list all tables.
* This method is used to list all collections.
*
* @param table_array, all tables in database.
* @param collection_array, all collections in database.
*
* @return Indicate if this operation is successful.
*/
virtual Status
ShowTables(std::vector<std::string>& table_array) = 0;
ShowCollections(std::vector<std::string>& collection_array) = 0;
/**
* @brief Show table information
* @brief Show collections information
*
* This method is used to get detail information of a table.
* This method is used to get detail information of a collections.
*
* @param table_name, target table's name.
* @param table_info, target table's information
* @param collections_name, target collections's name.
* @param collections_info, target collections's information
*
* @return Indicate if this operation is successful.
*/
virtual Status
ShowTableInfo(const std::string& table_name, TableInfo& table_info) = 0;
/**
* @brief Give the client version
*
* This method is used to give the client version.
*
* @return Client version.
*/
virtual std::string
ClientVersion() const = 0;
/**
* @brief Give the server version
*
* This method is used to give the server version.
*
* @return Server version.
*/
virtual std::string
ServerVersion() const = 0;
ShowCollectionInfo(const std::string& collections_name, TableInfo& collections_info) = 0;
/**
* @brief Give the server status
......@@ -415,16 +415,6 @@ class Connection {
virtual std::string
ServerStatus() const = 0;
/**
* @brief dump server tasks information
*
* This method is internal used.
*
* @return Task information in tasktables.
*/
virtual std::string
DumpTaskTables() const = 0;
/**
* [deprecated]
* @brief delete tables by vector id
......
......@@ -130,11 +130,6 @@ ConnectionImpl::ServerStatus() const {
return client_proxy_->ServerStatus();
}
std::string
ConnectionImpl::DumpTaskTables() const {
return client_proxy_->DumpTaskTables();
}
Status
ConnectionImpl::DeleteByID(const std::string& table_name, const std::vector<int64_t>& id_array) {
return client_proxy_->DeleteByID(table_name, id_array);
......
......@@ -86,9 +86,6 @@ class ConnectionImpl : public Connection {
std::string
ServerStatus() const override;
std::string
DumpTaskTables() const override;
Status
DeleteByID(const std::string& table_name, const std::vector<int64_t>& id_array) override;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册