Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
milvus
提交
9203bdf8
milvus
项目概览
BaiXuePrincess
/
milvus
与 Fork 源项目一致
从无法访问的项目Fork
通知
7
Star
4
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
milvus
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9203bdf8
编写于
3月 08, 2020
作者:
G
groot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rename c++sdk
Signed-off-by:
N
groot
<
yihua.mo@zilliz.com
>
上级
fcb56568
变更
11
展开全部
隐藏空白更改
内联
并排
Showing
11 changed file
with
688 addition
and
667 deletion
+688
-667
sdk/examples/binary_vector/src/ClientTest.cpp
sdk/examples/binary_vector/src/ClientTest.cpp
+54
-53
sdk/examples/partition/src/ClientTest.cpp
sdk/examples/partition/src/ClientTest.cpp
+74
-79
sdk/examples/simple/src/ClientTest.cpp
sdk/examples/simple/src/ClientTest.cpp
+104
-95
sdk/examples/simple/src/ClientTest.h
sdk/examples/simple/src/ClientTest.h
+12
-12
sdk/examples/utils/Utils.cpp
sdk/examples/utils/Utils.cpp
+42
-37
sdk/examples/utils/Utils.h
sdk/examples/utils/Utils.h
+9
-9
sdk/grpc/ClientProxy.cpp
sdk/grpc/ClientProxy.cpp
+147
-148
sdk/grpc/ClientProxy.h
sdk/grpc/ClientProxy.h
+38
-36
sdk/include/MilvusApi.h
sdk/include/MilvusApi.h
+110
-102
sdk/interface/ConnectionImpl.cpp
sdk/interface/ConnectionImpl.cpp
+59
-59
sdk/interface/ConnectionImpl.h
sdk/interface/ConnectionImpl.h
+39
-37
未找到文件。
sdk/examples/binary_vector/src/ClientTest.cpp
浏览文件 @
9203bdf8
...
...
@@ -22,52 +22,53 @@
namespace
{
const
char
*
TABLE_NAME
=
milvus_sdk
::
Utils
::
GenTable
Name
().
c_str
();
const
char
*
COLLECTION_NAME
=
milvus_sdk
::
Utils
::
GenCollection
Name
().
c_str
();
constexpr
int64_t
TABLE
_DIMENSION
=
512
;
constexpr
int64_t
TABLE
_INDEX_FILE_SIZE
=
128
;
constexpr
milvus
::
MetricType
TABLE
_METRIC_TYPE
=
milvus
::
MetricType
::
TANIMOTO
;
constexpr
int64_t
BATCH_
ROW
_COUNT
=
100000
;
constexpr
int64_t
COLLECTION
_DIMENSION
=
512
;
constexpr
int64_t
COLLECTION
_INDEX_FILE_SIZE
=
128
;
constexpr
milvus
::
MetricType
COLLECTION
_METRIC_TYPE
=
milvus
::
MetricType
::
TANIMOTO
;
constexpr
int64_t
BATCH_
ENTITY
_COUNT
=
100000
;
constexpr
int64_t
NQ
=
5
;
constexpr
int64_t
TOP_K
=
10
;
constexpr
int64_t
NPROBE
=
32
;
constexpr
int64_t
SEARCH_TARGET
=
5000
;
// change this value, result is different, ensure less than BATCH_
ROW
_COUNT
constexpr
int64_t
ADD_
VECTOR
_LOOP
=
20
;
constexpr
int64_t
SEARCH_TARGET
=
5000
;
// change this value, result is different, ensure less than BATCH_
ENTITY
_COUNT
constexpr
int64_t
ADD_
ENTITY
_LOOP
=
20
;
constexpr
milvus
::
IndexType
INDEX_TYPE
=
milvus
::
IndexType
::
IVFFLAT
;
milvus
::
TableSchema
BuildTableSchema
()
{
milvus
::
TableSchema
tb_schema
=
{
TABLE_NAME
,
TABLE_DIMENSION
,
TABLE_INDEX_FILE_SIZE
,
TABLE_METRIC_TYPE
};
return
tb_schema
;
milvus
::
CollectionParam
BuildCollectionParam
()
{
milvus
::
CollectionParam
collection_param
=
{
COLLECTION_NAME
,
COLLECTION_DIMENSION
,
COLLECTION_INDEX_FILE_SIZE
,
COLLECTION_METRIC_TYPE
};
return
collection_param
;
}
milvus
::
IndexParam
BuildIndexParam
()
{
JSON
json_params
=
{{
"nlist"
,
1024
}};
milvus
::
IndexParam
index_param
=
{
TABLE
_NAME
,
INDEX_TYPE
,
json_params
.
dump
()};
milvus
::
IndexParam
index_param
=
{
COLLECTION
_NAME
,
INDEX_TYPE
,
json_params
.
dump
()};
return
index_param
;
}
void
BuildBinaryVectors
(
int64_t
from
,
int64_t
to
,
std
::
vector
<
milvus
::
RowRecord
>&
vector_record
_array
,
std
::
vector
<
int64_t
>&
record
_ids
,
int64_t
dimension
)
{
BuildBinaryVectors
(
int64_t
from
,
int64_t
to
,
std
::
vector
<
milvus
::
Entity
>&
entity
_array
,
std
::
vector
<
int64_t
>&
entity
_ids
,
int64_t
dimension
)
{
if
(
to
<=
from
)
{
return
;
}
vector_record
_array
.
clear
();
record
_ids
.
clear
();
entity
_array
.
clear
();
entity
_ids
.
clear
();
int64_t
dim_byte
=
dimension
/
8
;
for
(
int64_t
k
=
from
;
k
<
to
;
k
++
)
{
milvus
::
RowRecord
record
;
record
.
binary_data
.
resize
(
dim_byte
);
milvus
::
Entity
entity
;
entity
.
binary_data
.
resize
(
dim_byte
);
for
(
int64_t
i
=
0
;
i
<
dim_byte
;
i
++
)
{
record
.
binary_data
[
i
]
=
(
uint8_t
)
lrand48
();
entity
.
binary_data
[
i
]
=
(
uint8_t
)
lrand48
();
}
vector_record_array
.
emplace_back
(
record
);
record
_ids
.
push_back
(
k
);
entity_array
.
emplace_back
(
entity
);
entity
_ids
.
push_back
(
k
);
}
}
...
...
@@ -84,54 +85,54 @@ ClientTest::Test(const std::string& address, const std::string& port) {
std
::
cout
<<
"Connect function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
}
{
// create
table
milvus
::
TableSchema
tb_schema
=
BuildTableSchema
();
stat
=
conn
->
Create
Table
(
tb_schema
);
std
::
cout
<<
"Create
Table
function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
milvus_sdk
::
Utils
::
Print
TableSchema
(
tb_schema
);
{
// create
collection
milvus
::
CollectionParam
collection_param
=
BuildCollectionParam
();
stat
=
conn
->
Create
Collection
(
collection_param
);
std
::
cout
<<
"Create
Collection
function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
milvus_sdk
::
Utils
::
Print
CollectionParam
(
collection_param
);
bool
has_
table
=
conn
->
HasTable
(
tb_schema
.
table
_name
);
if
(
has_
table
)
{
std
::
cout
<<
"
Table
is created"
<<
std
::
endl
;
bool
has_
collection
=
conn
->
HasCollection
(
collection_param
.
collection
_name
);
if
(
has_
collection
)
{
std
::
cout
<<
"
Collection
is created"
<<
std
::
endl
;
}
}
std
::
vector
<
std
::
pair
<
int64_t
,
milvus
::
RowRecord
>>
search_record
_array
;
std
::
vector
<
std
::
pair
<
int64_t
,
milvus
::
Entity
>>
search_entity
_array
;
{
// insert vectors
for
(
int
i
=
0
;
i
<
ADD_
VECTOR
_LOOP
;
i
++
)
{
std
::
vector
<
milvus
::
RowRecord
>
record
_array
;
std
::
vector
<
int64_t
>
record
_ids
;
int64_t
begin_index
=
i
*
BATCH_
ROW
_COUNT
;
for
(
int
i
=
0
;
i
<
ADD_
ENTITY
_LOOP
;
i
++
)
{
std
::
vector
<
milvus
::
Entity
>
entity
_array
;
std
::
vector
<
int64_t
>
entity
_ids
;
int64_t
begin_index
=
i
*
BATCH_
ENTITY
_COUNT
;
{
// generate vectors
milvus_sdk
::
TimeRecorder
rc
(
"Build
vector
s No."
+
std
::
to_string
(
i
));
milvus_sdk
::
TimeRecorder
rc
(
"Build
entitie
s No."
+
std
::
to_string
(
i
));
BuildBinaryVectors
(
begin_index
,
begin_index
+
BATCH_
ROW
_COUNT
,
record
_array
,
record
_ids
,
TABLE
_DIMENSION
);
begin_index
+
BATCH_
ENTITY
_COUNT
,
entity
_array
,
entity
_ids
,
COLLECTION
_DIMENSION
);
}
if
(
search_
record
_array
.
size
()
<
NQ
)
{
search_
record_array
.
push_back
(
std
::
make_pair
(
record_ids
[
SEARCH_TARGET
],
record
_array
[
SEARCH_TARGET
]));
if
(
search_
entity
_array
.
size
()
<
NQ
)
{
search_
entity_array
.
push_back
(
std
::
make_pair
(
entity_ids
[
SEARCH_TARGET
],
entity
_array
[
SEARCH_TARGET
]));
}
std
::
string
title
=
"Insert "
+
std
::
to_string
(
record_array
.
size
())
+
" vector
s No."
+
std
::
to_string
(
i
);
std
::
string
title
=
"Insert "
+
std
::
to_string
(
entity_array
.
size
())
+
" entitie
s No."
+
std
::
to_string
(
i
);
milvus_sdk
::
TimeRecorder
rc
(
title
);
stat
=
conn
->
Insert
(
TABLE_NAME
,
""
,
record_array
,
record
_ids
);
std
::
cout
<<
"Insert
Vector
function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
std
::
cout
<<
"Returned id array count: "
<<
record
_ids
.
size
()
<<
std
::
endl
;
stat
=
conn
->
Insert
(
COLLECTION_NAME
,
""
,
entity_array
,
entity
_ids
);
std
::
cout
<<
"Insert function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
std
::
cout
<<
"Returned id array count: "
<<
entity
_ids
.
size
()
<<
std
::
endl
;
}
}
{
// flush buffer
stat
=
conn
->
Flush
Table
(
TABLE
_NAME
);
std
::
cout
<<
"Flush
Table
function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
stat
=
conn
->
Flush
Collection
(
COLLECTION
_NAME
);
std
::
cout
<<
"Flush
Collection
function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
}
{
// search vectors
std
::
vector
<
std
::
string
>
partition_tags
;
milvus
::
TopKQueryResult
topk_query_result
;
milvus_sdk
::
Utils
::
DoSearch
(
conn
,
TABLE_NAME
,
partition_tags
,
TOP_K
,
NPROBE
,
search_record
_array
,
milvus_sdk
::
Utils
::
DoSearch
(
conn
,
COLLECTION_NAME
,
partition_tags
,
TOP_K
,
NPROBE
,
search_entity
_array
,
topk_query_result
);
}
...
...
@@ -144,7 +145,7 @@ ClientTest::Test(const std::string& address, const std::string& port) {
std
::
cout
<<
"CreateIndex function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
milvus
::
IndexParam
index2
;
stat
=
conn
->
DescribeIndex
(
TABLE
_NAME
,
index2
);
stat
=
conn
->
DescribeIndex
(
COLLECTION
_NAME
,
index2
);
std
::
cout
<<
"DescribeIndex function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
milvus_sdk
::
Utils
::
PrintIndexParam
(
index2
);
}
...
...
@@ -152,13 +153,13 @@ ClientTest::Test(const std::string& address, const std::string& port) {
{
// search vectors
std
::
vector
<
std
::
string
>
partition_tags
;
milvus
::
TopKQueryResult
topk_query_result
;
milvus_sdk
::
Utils
::
DoSearch
(
conn
,
TABLE_NAME
,
partition_tags
,
TOP_K
,
NPROBE
,
search_record
_array
,
milvus_sdk
::
Utils
::
DoSearch
(
conn
,
COLLECTION_NAME
,
partition_tags
,
TOP_K
,
NPROBE
,
search_entity
_array
,
topk_query_result
);
}
{
// drop
table
stat
=
conn
->
Drop
Table
(
TABLE
_NAME
);
std
::
cout
<<
"Drop
Table
function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
{
// drop
collection
stat
=
conn
->
Drop
Collection
(
COLLECTION
_NAME
);
std
::
cout
<<
"Drop
Collection
function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
}
milvus
::
Connection
::
Destroy
(
conn
);
...
...
sdk/examples/partition/src/ClientTest.cpp
浏览文件 @
9203bdf8
...
...
@@ -22,12 +22,12 @@
namespace
{
const
char
*
TABLE_NAME
=
milvus_sdk
::
Utils
::
GenTable
Name
().
c_str
();
const
char
*
COLLECTION_NAME
=
milvus_sdk
::
Utils
::
GenCollection
Name
().
c_str
();
constexpr
int64_t
TABLE
_DIMENSION
=
512
;
constexpr
int64_t
TABLE
_INDEX_FILE_SIZE
=
1024
;
constexpr
milvus
::
MetricType
TABLE
_METRIC_TYPE
=
milvus
::
MetricType
::
L2
;
constexpr
int64_t
BATCH_
ROW
_COUNT
=
10000
;
constexpr
int64_t
COLLECTION
_DIMENSION
=
512
;
constexpr
int64_t
COLLECTION
_INDEX_FILE_SIZE
=
1024
;
constexpr
milvus
::
MetricType
COLLECTION
_METRIC_TYPE
=
milvus
::
MetricType
::
L2
;
constexpr
int64_t
BATCH_
ENTITY
_COUNT
=
10000
;
constexpr
int64_t
NQ
=
5
;
constexpr
int64_t
TOP_K
=
10
;
constexpr
int64_t
NPROBE
=
32
;
...
...
@@ -36,27 +36,45 @@ constexpr milvus::IndexType INDEX_TYPE = milvus::IndexType::IVFSQ8;
constexpr
int32_t
PARTITION_COUNT
=
5
;
constexpr
int32_t
TARGET_PARTITION
=
3
;
milvus
::
TableSchema
BuildTableSchema
()
{
milvus
::
TableSchema
tb_schema
=
{
TABLE_NAME
,
TABLE_DIMENSION
,
TABLE_INDEX_FILE_SIZE
,
TABLE_METRIC_TYPE
};
return
tb_schema
;
milvus
::
CollectionParam
BuildCollectionParam
()
{
milvus
::
CollectionParam
collection_param
=
{
COLLECTION_NAME
,
COLLECTION_DIMENSION
,
COLLECTION_INDEX_FILE_SIZE
,
COLLECTION_METRIC_TYPE
};
return
collection_param
;
}
milvus
::
PartitionParam
BuildPartitionParam
(
int32_t
index
)
{
std
::
string
tag
=
std
::
to_string
(
index
);
std
::
string
partition_name
=
std
::
string
(
TABLE
_NAME
)
+
"_"
+
tag
;
milvus
::
PartitionParam
partition_param
=
{
TABLE
_NAME
,
tag
};
std
::
string
partition_name
=
std
::
string
(
COLLECTION
_NAME
)
+
"_"
+
tag
;
milvus
::
PartitionParam
partition_param
=
{
COLLECTION
_NAME
,
tag
};
return
partition_param
;
}
milvus
::
IndexParam
BuildIndexParam
()
{
JSON
json_params
=
{{
"nlist"
,
16384
}};
milvus
::
IndexParam
index_param
=
{
TABLE
_NAME
,
INDEX_TYPE
,
json_params
.
dump
()};
milvus
::
IndexParam
index_param
=
{
COLLECTION
_NAME
,
INDEX_TYPE
,
json_params
.
dump
()};
return
index_param
;
}
void
CountCollection
(
std
::
shared_ptr
<
milvus
::
Connection
>&
conn
)
{
int64_t
entity_count
=
0
;
auto
stat
=
conn
->
CountCollection
(
COLLECTION_NAME
,
entity_count
);
std
::
cout
<<
COLLECTION_NAME
<<
"("
<<
entity_count
<<
" entities)"
<<
std
::
endl
;
}
void
ShowCollectionInfo
(
std
::
shared_ptr
<
milvus
::
Connection
>&
conn
)
{
CountCollection
(
conn
);
milvus
::
CollectionInfo
collection_info
;
auto
stat
=
conn
->
ShowCollectionInfo
(
COLLECTION_NAME
,
collection_info
);
milvus_sdk
::
Utils
::
PrintCollectionInfo
(
collection_info
);
std
::
cout
<<
"ShowCollectionInfo function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
}
}
// namespace
void
...
...
@@ -70,11 +88,11 @@ ClientTest::Test(const std::string& address, const std::string& port) {
std
::
cout
<<
"Connect function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
}
{
// create
table
milvus
::
TableSchema
tb_schema
=
BuildTableSchema
();
stat
=
conn
->
Create
Table
(
tb_schema
);
std
::
cout
<<
"Create
Table
function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
milvus_sdk
::
Utils
::
Print
TableSchema
(
tb_schema
);
{
// create
collection
milvus
::
CollectionParam
tb_schema
=
BuildCollectionParam
();
stat
=
conn
->
Create
Collection
(
tb_schema
);
std
::
cout
<<
"Create
Collection
function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
milvus_sdk
::
Utils
::
Print
CollectionParam
(
tb_schema
);
}
{
// create partition
...
...
@@ -87,7 +105,7 @@ ClientTest::Test(const std::string& address, const std::string& port) {
// show partitions
milvus
::
PartitionTagList
partition_array
;
stat
=
conn
->
ShowPartitions
(
TABLE
_NAME
,
partition_array
);
stat
=
conn
->
ShowPartitions
(
COLLECTION
_NAME
,
partition_array
);
std
::
cout
<<
partition_array
.
size
()
<<
" partitions created:"
<<
std
::
endl
;
for
(
auto
&
partition_tag
:
partition_array
)
{
...
...
@@ -96,64 +114,56 @@ ClientTest::Test(const std::string& address, const std::string& port) {
}
{
// insert vectors
milvus_sdk
::
TimeRecorder
rc
(
"All
vector
s"
);
milvus_sdk
::
TimeRecorder
rc
(
"All
entitie
s"
);
for
(
int
i
=
0
;
i
<
PARTITION_COUNT
*
5
;
i
++
)
{
std
::
vector
<
milvus
::
RowRecord
>
record
_array
;
std
::
vector
<
int64_t
>
record
_ids
;
int64_t
begin_index
=
i
*
BATCH_
ROW
_COUNT
;
std
::
vector
<
milvus
::
Entity
>
entity
_array
;
std
::
vector
<
int64_t
>
entity
_ids
;
int64_t
begin_index
=
i
*
BATCH_
ENTITY
_COUNT
;
{
// generate vectors
milvus_sdk
::
TimeRecorder
rc
(
"Build vectors No."
+
std
::
to_string
(
i
));
milvus_sdk
::
Utils
::
BuildVectors
(
begin_index
,
begin_index
+
BATCH_ROW_COUNT
,
record_array
,
record_ids
,
TABLE_DIMENSION
);
milvus_sdk
::
TimeRecorder
rc
(
"Build entities No."
+
std
::
to_string
(
i
));
milvus_sdk
::
Utils
::
BuildEntities
(
begin_index
,
begin_index
+
BATCH_ENTITY_COUNT
,
entity_array
,
entity_ids
,
COLLECTION_DIMENSION
);
}
std
::
string
title
=
"Insert "
+
std
::
to_string
(
record_array
.
size
())
+
" vector
s No."
+
std
::
to_string
(
i
);
std
::
string
title
=
"Insert "
+
std
::
to_string
(
entity_array
.
size
())
+
" entitie
s No."
+
std
::
to_string
(
i
);
milvus_sdk
::
TimeRecorder
rc
(
title
);
stat
=
conn
->
Insert
(
TABLE_NAME
,
std
::
to_string
(
i
%
PARTITION_COUNT
),
record_array
,
record
_ids
);
stat
=
conn
->
Insert
(
COLLECTION_NAME
,
std
::
to_string
(
i
%
PARTITION_COUNT
),
entity_array
,
entity
_ids
);
}
}
{
// flush buffer
stat
=
conn
->
Flush
Table
(
TABLE
_NAME
);
std
::
cout
<<
"Flush
Table
function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
stat
=
conn
->
Flush
Collection
(
COLLECTION
_NAME
);
std
::
cout
<<
"Flush
Collection
function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
}
{
// table row count
int64_t
row_count
=
0
;
stat
=
conn
->
CountTable
(
TABLE_NAME
,
row_count
);
std
::
cout
<<
TABLE_NAME
<<
"("
<<
row_count
<<
" rows)"
<<
std
::
endl
;
}
ShowCollectionInfo
(
conn
);
{
// get table information
milvus
::
TableInfo
table_info
;
stat
=
conn
->
ShowTableInfo
(
TABLE_NAME
,
table_info
);
milvus_sdk
::
Utils
::
PrintTableInfo
(
table_info
);
std
::
cout
<<
"ShowTableInfo function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
}
std
::
vector
<
std
::
pair
<
int64_t
,
milvus
::
RowRecord
>>
search_record_array
;
std
::
vector
<
std
::
pair
<
int64_t
,
milvus
::
Entity
>>
search_entity_array
;
{
// build search vectors
std
::
vector
<
milvus
::
RowRecord
>
record
_array
;
std
::
vector
<
int64_t
>
record
_ids
;
int64_t
index
=
TARGET_PARTITION
*
BATCH_
ROW
_COUNT
+
SEARCH_TARGET
;
milvus_sdk
::
Utils
::
Build
Vectors
(
index
,
index
+
1
,
record_array
,
record_ids
,
TABLE
_DIMENSION
);
search_
record_array
.
push_back
(
std
::
make_pair
(
record_ids
[
0
],
record
_array
[
0
]));
std
::
vector
<
milvus
::
Entity
>
entity
_array
;
std
::
vector
<
int64_t
>
entity
_ids
;
int64_t
index
=
TARGET_PARTITION
*
BATCH_
ENTITY
_COUNT
+
SEARCH_TARGET
;
milvus_sdk
::
Utils
::
Build
Entities
(
index
,
index
+
1
,
entity_array
,
entity_ids
,
COLLECTION
_DIMENSION
);
search_
entity_array
.
push_back
(
std
::
make_pair
(
entity_ids
[
0
],
entity
_array
[
0
]));
}
{
// search vectors
std
::
cout
<<
"Search in correct partition"
<<
std
::
endl
;
std
::
vector
<
std
::
string
>
partition_tags
=
{
std
::
to_string
(
TARGET_PARTITION
)};
milvus
::
TopKQueryResult
topk_query_result
;
milvus_sdk
::
Utils
::
DoSearch
(
conn
,
TABLE_NAME
,
partition_tags
,
TOP_K
,
NPROBE
,
search_record
_array
,
milvus_sdk
::
Utils
::
DoSearch
(
conn
,
COLLECTION_NAME
,
partition_tags
,
TOP_K
,
NPROBE
,
search_entity
_array
,
topk_query_result
);
std
::
cout
<<
"Search in wrong partition"
<<
std
::
endl
;
partition_tags
=
{
"0"
};
milvus_sdk
::
Utils
::
DoSearch
(
conn
,
TABLE_NAME
,
partition_tags
,
TOP_K
,
NPROBE
,
search_record
_array
,
milvus_sdk
::
Utils
::
DoSearch
(
conn
,
COLLECTION_NAME
,
partition_tags
,
TOP_K
,
NPROBE
,
search_entity
_array
,
topk_query_result
);
std
::
cout
<<
"Search by regex matched partition tag"
<<
std
::
endl
;
partition_tags
=
{
"
\\
d"
};
milvus_sdk
::
Utils
::
DoSearch
(
conn
,
TABLE_NAME
,
partition_tags
,
TOP_K
,
NPROBE
,
search_record
_array
,
milvus_sdk
::
Utils
::
DoSearch
(
conn
,
COLLECTION_NAME
,
partition_tags
,
TOP_K
,
NPROBE
,
search_entity
_array
,
topk_query_result
);
}
...
...
@@ -166,57 +176,42 @@ ClientTest::Test(const std::string& address, const std::string& port) {
std
::
cout
<<
"CreateIndex function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
milvus
::
IndexParam
index2
;
stat
=
conn
->
DescribeIndex
(
TABLE
_NAME
,
index2
);
stat
=
conn
->
DescribeIndex
(
COLLECTION
_NAME
,
index2
);
std
::
cout
<<
"DescribeIndex function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
milvus_sdk
::
Utils
::
PrintIndexParam
(
index2
);
}
{
// table row count
int64_t
row_count
=
0
;
stat
=
conn
->
CountTable
(
TABLE_NAME
,
row_count
);
std
::
cout
<<
TABLE_NAME
<<
"("
<<
row_count
<<
" rows)"
<<
std
::
endl
;
}
{
// get table information
milvus
::
TableInfo
table_info
;
stat
=
conn
->
ShowTableInfo
(
TABLE_NAME
,
table_info
);
milvus_sdk
::
Utils
::
PrintTableInfo
(
table_info
);
std
::
cout
<<
"ShowTableInfo function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
}
ShowCollectionInfo
(
conn
);
{
// drop partition
milvus
::
PartitionParam
param1
=
{
TABLE
_NAME
,
std
::
to_string
(
TARGET_PARTITION
)};
milvus
::
PartitionParam
param1
=
{
COLLECTION
_NAME
,
std
::
to_string
(
TARGET_PARTITION
)};
milvus_sdk
::
Utils
::
PrintPartitionParam
(
param1
);
stat
=
conn
->
DropPartition
(
param1
);
std
::
cout
<<
"DropPartition function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
}
{
// table row count
int64_t
row_count
=
0
;
stat
=
conn
->
CountTable
(
TABLE_NAME
,
row_count
);
std
::
cout
<<
TABLE_NAME
<<
"("
<<
row_count
<<
" rows)"
<<
std
::
endl
;
}
CountCollection
(
conn
);
{
// search vectors
std
::
cout
<<
"Search in whole
table
"
<<
std
::
endl
;
{
// search vectors
, will get search error since we delete a partition
std
::
cout
<<
"Search in whole
collection after delete one partition
"
<<
std
::
endl
;
std
::
vector
<
std
::
string
>
partition_tags
;
milvus
::
TopKQueryResult
topk_query_result
;
milvus_sdk
::
Utils
::
DoSearch
(
conn
,
TABLE_NAME
,
partition_tags
,
TOP_K
,
NPROBE
,
search_record
_array
,
milvus_sdk
::
Utils
::
DoSearch
(
conn
,
COLLECTION_NAME
,
partition_tags
,
TOP_K
,
NPROBE
,
search_entity
_array
,
topk_query_result
);
}
{
// drop index
stat
=
conn
->
DropIndex
(
TABLE
_NAME
);
stat
=
conn
->
DropIndex
(
COLLECTION
_NAME
);
std
::
cout
<<
"DropIndex function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
int64_t
row
_count
=
0
;
stat
=
conn
->
Count
Table
(
TABLE_NAME
,
row
_count
);
std
::
cout
<<
TABLE_NAME
<<
"("
<<
row_count
<<
" row
s)"
<<
std
::
endl
;
int64_t
entity
_count
=
0
;
stat
=
conn
->
Count
Collection
(
COLLECTION_NAME
,
entity
_count
);
std
::
cout
<<
COLLECTION_NAME
<<
"("
<<
entity_count
<<
" entitie
s)"
<<
std
::
endl
;
}
{
// drop
table
stat
=
conn
->
Drop
Table
(
TABLE
_NAME
);
std
::
cout
<<
"Drop
Table
function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
{
// drop
collection
stat
=
conn
->
Drop
Collection
(
COLLECTION
_NAME
);
std
::
cout
<<
"Drop
Collection
function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
}
milvus
::
Connection
::
Destroy
(
conn
);
...
...
sdk/examples/simple/src/ClientTest.cpp
浏览文件 @
9203bdf8
...
...
@@ -19,20 +19,19 @@
#include <utility>
#include <vector>
namespace
{
const
char
*
TABLE_NAME
=
milvus_sdk
::
Utils
::
GenTable
Name
().
c_str
();
const
char
*
COLLECTION_NAME
=
milvus_sdk
::
Utils
::
GenCollection
Name
().
c_str
();
constexpr
int64_t
TABLE
_DIMENSION
=
512
;
constexpr
int64_t
TABLE
_INDEX_FILE_SIZE
=
1024
;
constexpr
milvus
::
MetricType
TABLE
_METRIC_TYPE
=
milvus
::
MetricType
::
L2
;
constexpr
int64_t
BATCH_
ROW
_COUNT
=
100000
;
constexpr
int64_t
COLLECTION
_DIMENSION
=
512
;
constexpr
int64_t
COLLECTION
_INDEX_FILE_SIZE
=
1024
;
constexpr
milvus
::
MetricType
COLLECTION
_METRIC_TYPE
=
milvus
::
MetricType
::
L2
;
constexpr
int64_t
BATCH_
ENTITY
_COUNT
=
100000
;
constexpr
int64_t
NQ
=
5
;
constexpr
int64_t
TOP_K
=
10
;
constexpr
int64_t
NPROBE
=
32
;
constexpr
int64_t
SEARCH_TARGET
=
5000
;
// change this value, result is different
constexpr
int64_t
ADD_
VECTOR
_LOOP
=
5
;
constexpr
int64_t
ADD_
ENTITY
_LOOP
=
5
;
constexpr
milvus
::
IndexType
INDEX_TYPE
=
milvus
::
IndexType
::
IVFSQ8
;
constexpr
int32_t
NLIST
=
16384
;
...
...
@@ -63,191 +62,201 @@ ClientTest::ShowSdkVersion() {
}
void
ClientTest
::
Show
Tables
(
std
::
vector
<
std
::
string
>&
tables
)
{
milvus
::
Status
stat
=
conn_
->
Show
Tables
(
tables
);
std
::
cout
<<
"Show
Table
s function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
std
::
cout
<<
"All
table
s: "
<<
std
::
endl
;
for
(
auto
&
table
:
tables
)
{
int64_t
row
_count
=
0
;
stat
=
conn_
->
Count
Table
(
table
,
row
_count
);
std
::
cout
<<
"
\t
"
<<
table
<<
"("
<<
row_count
<<
" row
s)"
<<
std
::
endl
;
ClientTest
::
Show
Collections
(
std
::
vector
<
std
::
string
>&
collection_array
)
{
milvus
::
Status
stat
=
conn_
->
Show
Collections
(
collection_array
);
std
::
cout
<<
"Show
Collection
s function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
std
::
cout
<<
"All
collection
s: "
<<
std
::
endl
;
for
(
auto
&
collection
:
collection_array
)
{
int64_t
entity
_count
=
0
;
stat
=
conn_
->
Count
Collection
(
collection
,
entity
_count
);
std
::
cout
<<
"
\t
"
<<
collection
<<
"("
<<
entity_count
<<
" entitie
s)"
<<
std
::
endl
;
}
}
void
ClientTest
::
Create
Table
(
const
std
::
string
&
table
_name
,
int64_t
dim
,
milvus
::
MetricType
type
)
{
milvus
::
TableSchema
tb_schema
=
{
table_name
,
dim
,
TABLE
_INDEX_FILE_SIZE
,
type
};
milvus
::
Status
stat
=
conn_
->
Create
Table
(
tb_schema
);
std
::
cout
<<
"Create
Table
function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
milvus_sdk
::
Utils
::
Print
TableSchema
(
tb_schema
);
ClientTest
::
Create
Collection
(
const
std
::
string
&
collection
_name
,
int64_t
dim
,
milvus
::
MetricType
type
)
{
milvus
::
CollectionParam
collection_param
=
{
collection_name
,
dim
,
COLLECTION
_INDEX_FILE_SIZE
,
type
};
milvus
::
Status
stat
=
conn_
->
Create
Collection
(
collection_param
);
std
::
cout
<<
"Create
Collection
function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
milvus_sdk
::
Utils
::
Print
CollectionParam
(
collection_param
);
bool
has_table
=
conn_
->
Has
Table
(
tb_schema
.
table
_name
);
bool
has_table
=
conn_
->
Has
Collection
(
collection_param
.
collection
_name
);
if
(
has_table
)
{
std
::
cout
<<
"
Table
is created"
<<
std
::
endl
;
std
::
cout
<<
"
Collection
is created"
<<
std
::
endl
;
}
}
void
ClientTest
::
Describe
Table
(
const
std
::
string
&
table
_name
)
{
milvus
::
TableSchema
tb_schema
;
milvus
::
Status
stat
=
conn_
->
Describe
Table
(
table_name
,
tb_schema
);
std
::
cout
<<
"Describe
Table
function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
milvus_sdk
::
Utils
::
Print
TableSchema
(
tb_schema
);
ClientTest
::
Describe
Collection
(
const
std
::
string
&
collection
_name
)
{
milvus
::
CollectionParam
collection_param
;
milvus
::
Status
stat
=
conn_
->
Describe
Collection
(
collection_name
,
collection_param
);
std
::
cout
<<
"Describe
Collection
function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
milvus_sdk
::
Utils
::
Print
CollectionParam
(
collection_param
);
}
void
ClientTest
::
Insert
Vectors
(
const
std
::
string
&
table
_name
,
int64_t
dim
)
{
for
(
int
i
=
0
;
i
<
ADD_
VECTOR
_LOOP
;
i
++
)
{
std
::
vector
<
milvus
::
RowRecord
>
record
_array
;
ClientTest
::
Insert
Entities
(
const
std
::
string
&
collection
_name
,
int64_t
dim
)
{
for
(
int
i
=
0
;
i
<
ADD_
ENTITY
_LOOP
;
i
++
)
{
std
::
vector
<
milvus
::
Entity
>
entity
_array
;
std
::
vector
<
int64_t
>
record_ids
;
int64_t
begin_index
=
i
*
BATCH_
ROW
_COUNT
;
int64_t
begin_index
=
i
*
BATCH_
ENTITY
_COUNT
;
{
// generate vectors
milvus_sdk
::
TimeRecorder
rc
(
"Build vectors No."
+
std
::
to_string
(
i
));
milvus_sdk
::
Utils
::
BuildVectors
(
begin_index
,
begin_index
+
BATCH_ROW_COUNT
,
record_array
,
record_ids
,
dim
);
milvus_sdk
::
TimeRecorder
rc
(
"Build entities No."
+
std
::
to_string
(
i
));
milvus_sdk
::
Utils
::
BuildEntities
(
begin_index
,
begin_index
+
BATCH_ENTITY_COUNT
,
entity_array
,
record_ids
,
dim
);
}
std
::
string
title
=
"Insert "
+
std
::
to_string
(
record_array
.
size
())
+
" vector
s No."
+
std
::
to_string
(
i
);
std
::
string
title
=
"Insert "
+
std
::
to_string
(
entity_array
.
size
())
+
" entitie
s No."
+
std
::
to_string
(
i
);
milvus_sdk
::
TimeRecorder
rc
(
title
);
milvus
::
Status
stat
=
conn_
->
Insert
(
table_name
,
""
,
record
_array
,
record_ids
);
std
::
cout
<<
"Insert
Vector
function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
milvus
::
Status
stat
=
conn_
->
Insert
(
collection_name
,
""
,
entity
_array
,
record_ids
);
std
::
cout
<<
"Insert
Entities
function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
std
::
cout
<<
"Returned id array count: "
<<
record_ids
.
size
()
<<
std
::
endl
;
}
}
void
ClientTest
::
BuildSearch
Vector
s
(
int64_t
nq
,
int64_t
dim
)
{
search_
record
_array_
.
clear
();
ClientTest
::
BuildSearch
Entitie
s
(
int64_t
nq
,
int64_t
dim
)
{
search_
entity
_array_
.
clear
();
search_id_array_
.
clear
();
for
(
int64_t
i
=
0
;
i
<
nq
;
i
++
)
{
std
::
vector
<
milvus
::
RowRecord
>
record
_array
;
std
::
vector
<
milvus
::
Entity
>
entity
_array
;
std
::
vector
<
int64_t
>
record_ids
;
int64_t
index
=
i
*
BATCH_
ROW
_COUNT
+
SEARCH_TARGET
;
milvus_sdk
::
Utils
::
Build
Vectors
(
index
,
index
+
1
,
record
_array
,
record_ids
,
dim
);
search_
record_array_
.
push_back
(
std
::
make_pair
(
record_ids
[
0
],
record
_array
[
0
]));
int64_t
index
=
i
*
BATCH_
ENTITY
_COUNT
+
SEARCH_TARGET
;
milvus_sdk
::
Utils
::
Build
Entities
(
index
,
index
+
1
,
entity
_array
,
record_ids
,
dim
);
search_
entity_array_
.
push_back
(
std
::
make_pair
(
record_ids
[
0
],
entity
_array
[
0
]));
search_id_array_
.
push_back
(
record_ids
[
0
]);
}
}
void
ClientTest
::
Flush
(
const
std
::
string
&
table
_name
)
{
ClientTest
::
Flush
(
const
std
::
string
&
collection
_name
)
{
milvus_sdk
::
TimeRecorder
rc
(
"Flush"
);
milvus
::
Status
stat
=
conn_
->
Flush
Table
(
table
_name
);
std
::
cout
<<
"Flush
Table
function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
milvus
::
Status
stat
=
conn_
->
Flush
Collection
(
collection
_name
);
std
::
cout
<<
"Flush
Collection
function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
}
void
ClientTest
::
Show
TableInfo
(
const
std
::
string
&
table
_name
)
{
milvus
::
TableInfo
table
_info
;
milvus
::
Status
stat
=
conn_
->
Show
TableInfo
(
table_name
,
table
_info
);
milvus_sdk
::
Utils
::
Print
TableInfo
(
table
_info
);
std
::
cout
<<
"Show
Table
Info function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
ClientTest
::
Show
CollectionInfo
(
const
std
::
string
&
collection
_name
)
{
milvus
::
CollectionInfo
collection
_info
;
milvus
::
Status
stat
=
conn_
->
Show
CollectionInfo
(
collection_name
,
collection
_info
);
milvus_sdk
::
Utils
::
Print
CollectionInfo
(
collection
_info
);
std
::
cout
<<
"Show
Collection
Info function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
}
void
ClientTest
::
Get
VectorById
(
const
std
::
string
&
table
_name
,
int64_t
id
)
{
milvus
::
RowRecord
vector_data
;
milvus
::
Status
stat
=
conn_
->
Get
VectorByID
(
table_name
,
id
,
vector_data
);
std
::
cout
<<
"The
vector "
<<
id
<<
" has "
<<
vector_data
.
float_data
.
size
()
<<
" float elements"
<<
std
::
endl
;
std
::
cout
<<
"Get
VectorByID
function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
ClientTest
::
Get
EntityById
(
const
std
::
string
&
collection
_name
,
int64_t
id
)
{
milvus
::
Entity
entity
;
milvus
::
Status
stat
=
conn_
->
Get
EntityByID
(
collection_name
,
id
,
entity
);
std
::
cout
<<
"The
entity "
<<
id
<<
" has "
<<
entity
.
float_data
.
size
()
<<
" float elements"
<<
std
::
endl
;
std
::
cout
<<
"Get
EntityById
function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
}
void
ClientTest
::
Search
Vectors
(
const
std
::
string
&
table
_name
,
int64_t
topk
,
int64_t
nprobe
)
{
ClientTest
::
Search
Entities
(
const
std
::
string
&
collection
_name
,
int64_t
topk
,
int64_t
nprobe
)
{
std
::
vector
<
std
::
string
>
partition_tags
;
milvus
::
TopKQueryResult
topk_query_result
;
milvus_sdk
::
Utils
::
DoSearch
(
conn_
,
table_name
,
partition_tags
,
topk
,
nprobe
,
search_record
_array_
,
milvus_sdk
::
Utils
::
DoSearch
(
conn_
,
collection_name
,
partition_tags
,
topk
,
nprobe
,
search_entity
_array_
,
topk_query_result
);
}
void
ClientTest
::
CreateIndex
(
const
std
::
string
&
table
_name
,
milvus
::
IndexType
type
,
int64_t
nlist
)
{
ClientTest
::
CreateIndex
(
const
std
::
string
&
collection
_name
,
milvus
::
IndexType
type
,
int64_t
nlist
)
{
milvus_sdk
::
TimeRecorder
rc
(
"Create index"
);
std
::
cout
<<
"Wait until create all index done"
<<
std
::
endl
;
JSON
json_params
=
{{
"nlist"
,
nlist
}};
milvus
::
IndexParam
index1
=
{
table
_name
,
type
,
json_params
.
dump
()};
milvus
::
IndexParam
index1
=
{
collection
_name
,
type
,
json_params
.
dump
()};
milvus_sdk
::
Utils
::
PrintIndexParam
(
index1
);
milvus
::
Status
stat
=
conn_
->
CreateIndex
(
index1
);
std
::
cout
<<
"CreateIndex function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
milvus
::
IndexParam
index2
;
stat
=
conn_
->
DescribeIndex
(
table
_name
,
index2
);
stat
=
conn_
->
DescribeIndex
(
collection
_name
,
index2
);
std
::
cout
<<
"DescribeIndex function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
milvus_sdk
::
Utils
::
PrintIndexParam
(
index2
);
}
void
ClientTest
::
Preload
Table
(
const
std
::
string
&
table
_name
)
{
milvus
::
Status
stat
=
conn_
->
Preload
Table
(
table
_name
);
std
::
cout
<<
"Preload
Table
function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
ClientTest
::
Preload
Collection
(
const
std
::
string
&
collection
_name
)
{
milvus
::
Status
stat
=
conn_
->
Preload
Collection
(
collection
_name
);
std
::
cout
<<
"Preload
Collection
function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
}
void
ClientTest
::
DeleteByIds
(
const
std
::
string
&
table_name
,
const
std
::
vector
<
int64_t
>&
id_array
)
{
milvus
::
Status
stat
=
conn_
->
DeleteByID
(
table_name
,
id_array
);
ClientTest
::
DeleteByIds
(
const
std
::
string
&
collection_name
,
const
std
::
vector
<
int64_t
>&
id_array
)
{
std
::
cout
<<
"Delete entity: "
;
for
(
auto
id
:
id_array
)
{
std
::
cout
<<
"
\t
"
<<
id
;
}
std
::
cout
<<
std
::
endl
;
milvus
::
Status
stat
=
conn_
->
DeleteByID
(
collection_name
,
id_array
);
std
::
cout
<<
"DeleteByID function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
{
milvus_sdk
::
TimeRecorder
rc
(
"Flush"
);
stat
=
conn_
->
Flush
Table
(
table
_name
);
std
::
cout
<<
"Flush
Table
function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
stat
=
conn_
->
Flush
Collection
(
collection
_name
);
std
::
cout
<<
"Flush
Collection
function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
}
{
// compact table
milvus_sdk
::
TimeRecorder
rc1
(
"Compact"
);
stat
=
conn_
->
Compact
Table
(
table
_name
);
std
::
cout
<<
"Compact
Table
function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
stat
=
conn_
->
Compact
Collection
(
collection
_name
);
std
::
cout
<<
"Compact
Collection
function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
}
}
void
ClientTest
::
DropIndex
(
const
std
::
string
&
table
_name
)
{
milvus
::
Status
stat
=
conn_
->
DropIndex
(
table
_name
);
ClientTest
::
DropIndex
(
const
std
::
string
&
collection
_name
)
{
milvus
::
Status
stat
=
conn_
->
DropIndex
(
collection
_name
);
std
::
cout
<<
"DropIndex function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
int64_t
row_count
=
0
;
stat
=
conn_
->
Count
Table
(
table
_name
,
row_count
);
std
::
cout
<<
table
_name
<<
"("
<<
row_count
<<
" rows)"
<<
std
::
endl
;
stat
=
conn_
->
Count
Collection
(
collection
_name
,
row_count
);
std
::
cout
<<
collection
_name
<<
"("
<<
row_count
<<
" rows)"
<<
std
::
endl
;
}
void
ClientTest
::
Drop
Table
(
const
std
::
string
&
table
_name
)
{
milvus
::
Status
stat
=
conn_
->
Drop
Table
(
table
_name
);
std
::
cout
<<
"Drop
Table
function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
ClientTest
::
Drop
Collection
(
const
std
::
string
&
collection
_name
)
{
milvus
::
Status
stat
=
conn_
->
Drop
Collection
(
collection
_name
);
std
::
cout
<<
"Drop
Collection
function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
}
void
ClientTest
::
Test
()
{
std
::
string
table_name
=
TABLE
_NAME
;
int64_t
dim
=
TABLE
_DIMENSION
;
milvus
::
MetricType
metric_type
=
TABLE
_METRIC_TYPE
;
std
::
string
collection_name
=
COLLECTION
_NAME
;
int64_t
dim
=
COLLECTION
_DIMENSION
;
milvus
::
MetricType
metric_type
=
COLLECTION
_METRIC_TYPE
;
ShowServerVersion
();
ShowSdkVersion
();
std
::
vector
<
std
::
string
>
table_array
;
Show
Table
s
(
table_array
);
Show
Collection
s
(
table_array
);
Create
Table
(
table
_name
,
dim
,
metric_type
);
Describe
Table
(
table
_name
);
Create
Collection
(
collection
_name
,
dim
,
metric_type
);
Describe
Collection
(
collection
_name
);
Insert
Vectors
(
table
_name
,
dim
);
BuildSearch
Vector
s
(
NQ
,
dim
);
Flush
(
table
_name
);
Show
TableInfo
(
table
_name
);
Insert
Entities
(
collection
_name
,
dim
);
BuildSearch
Entitie
s
(
NQ
,
dim
);
Flush
(
collection
_name
);
Show
CollectionInfo
(
collection
_name
);
Get
VectorById
(
table
_name
,
search_id_array_
[
0
]);
Search
Vectors
(
table
_name
,
TOP_K
,
NPROBE
);
Get
EntityById
(
collection
_name
,
search_id_array_
[
0
]);
Search
Entities
(
collection
_name
,
TOP_K
,
NPROBE
);
CreateIndex
(
table
_name
,
INDEX_TYPE
,
NLIST
);
Show
TableInfo
(
table
_name
);
CreateIndex
(
collection
_name
,
INDEX_TYPE
,
NLIST
);
Show
CollectionInfo
(
collection
_name
);
Preload
Table
(
table
_name
);
Preload
Collection
(
collection
_name
);
std
::
vector
<
int64_t
>
delete_ids
=
{
search_id_array_
[
0
],
search_id_array_
[
1
]};
DeleteByIds
(
table
_name
,
delete_ids
);
Search
Vectors
(
table_name
,
TOP_K
,
NPROBE
);
DeleteByIds
(
collection
_name
,
delete_ids
);
Search
Entities
(
collection_name
,
TOP_K
,
NPROBE
);
// this line get two search error since we delete two entities
DropIndex
(
table
_name
);
Drop
Table
(
table
_name
);
DropIndex
(
collection
_name
);
Drop
Collection
(
collection
_name
);
}
sdk/examples/simple/src/ClientTest.h
浏览文件 @
9203bdf8
...
...
@@ -34,49 +34,49 @@ class ClientTest {
ShowSdkVersion
();
void
Show
Table
s
(
std
::
vector
<
std
::
string
>&
);
Show
Collection
s
(
std
::
vector
<
std
::
string
>&
);
void
Create
Table
(
const
std
::
string
&
,
int64_t
,
milvus
::
MetricType
);
Create
Collection
(
const
std
::
string
&
,
int64_t
,
milvus
::
MetricType
);
void
Describe
Table
(
const
std
::
string
&
);
Describe
Collection
(
const
std
::
string
&
);
void
Insert
Vector
s
(
const
std
::
string
&
,
int64_t
);
Insert
Entitie
s
(
const
std
::
string
&
,
int64_t
);
void
BuildSearch
Vector
s
(
int64_t
,
int64_t
);
BuildSearch
Entitie
s
(
int64_t
,
int64_t
);
void
Flush
(
const
std
::
string
&
);
void
Show
Table
Info
(
const
std
::
string
&
);
Show
Collection
Info
(
const
std
::
string
&
);
void
Get
Vector
ById
(
const
std
::
string
&
,
int64_t
);
Get
Entity
ById
(
const
std
::
string
&
,
int64_t
);
void
Search
Vector
s
(
const
std
::
string
&
,
int64_t
,
int64_t
);
Search
Entitie
s
(
const
std
::
string
&
,
int64_t
,
int64_t
);
void
CreateIndex
(
const
std
::
string
&
,
milvus
::
IndexType
,
int64_t
);
void
Preload
Table
(
const
std
::
string
&
);
Preload
Collection
(
const
std
::
string
&
);
void
DeleteByIds
(
const
std
::
string
&
,
const
std
::
vector
<
int64_t
>&
);
DeleteByIds
(
const
std
::
string
&
,
const
std
::
vector
<
int64_t
>&
id_array
);
void
DropIndex
(
const
std
::
string
&
);
void
Drop
Table
(
const
std
::
string
&
);
Drop
Collection
(
const
std
::
string
&
);
private:
std
::
shared_ptr
<
milvus
::
Connection
>
conn_
;
std
::
vector
<
std
::
pair
<
int64_t
,
milvus
::
RowRecord
>>
search_record
_array_
;
std
::
vector
<
std
::
pair
<
int64_t
,
milvus
::
Entity
>>
search_entity
_array_
;
std
::
vector
<
int64_t
>
search_id_array_
;
};
sdk/examples/utils/Utils.cpp
浏览文件 @
9203bdf8
...
...
@@ -64,8 +64,8 @@ Utils::Sleep(int seconds) {
}
const
std
::
string
&
Utils
::
Gen
Table
Name
()
{
static
std
::
string
s_id
(
"
tbl
_"
+
CurrentTime
());
Utils
::
Gen
Collection
Name
()
{
static
std
::
string
s_id
(
"
C
_"
+
CurrentTime
());
return
s_id
;
}
...
...
@@ -97,19 +97,19 @@ Utils::IndexTypeName(const milvus::IndexType& index_type) {
}
void
Utils
::
Print
TableSchema
(
const
milvus
::
TableSchema
&
tb_schema
)
{
Utils
::
Print
CollectionParam
(
const
milvus
::
CollectionParam
&
collection_param
)
{
BLOCK_SPLITER
std
::
cout
<<
"
Table name: "
<<
tb_schema
.
table
_name
<<
std
::
endl
;
std
::
cout
<<
"
Table dimension: "
<<
tb_schema
.
dimension
<<
std
::
endl
;
std
::
cout
<<
"
Table index file size: "
<<
tb_schema
.
index_file_size
<<
std
::
endl
;
std
::
cout
<<
"
Table metric type: "
<<
MetricTypeName
(
tb_schema
.
metric_type
)
<<
std
::
endl
;
std
::
cout
<<
"
Collection name: "
<<
collection_param
.
collection
_name
<<
std
::
endl
;
std
::
cout
<<
"
Collection dimension: "
<<
collection_param
.
dimension
<<
std
::
endl
;
std
::
cout
<<
"
Collection index file size: "
<<
collection_param
.
index_file_size
<<
std
::
endl
;
std
::
cout
<<
"
Collection metric type: "
<<
MetricTypeName
(
collection_param
.
metric_type
)
<<
std
::
endl
;
BLOCK_SPLITER
}
void
Utils
::
PrintPartitionParam
(
const
milvus
::
PartitionParam
&
partition_param
)
{
BLOCK_SPLITER
std
::
cout
<<
"
Table name: "
<<
partition_param
.
table
_name
<<
std
::
endl
;
std
::
cout
<<
"
Collection name: "
<<
partition_param
.
collection
_name
<<
std
::
endl
;
std
::
cout
<<
"Partition tag: "
<<
partition_param
.
partition_tag
<<
std
::
endl
;
BLOCK_SPLITER
}
...
...
@@ -117,40 +117,40 @@ Utils::PrintPartitionParam(const milvus::PartitionParam& partition_param) {
void
Utils
::
PrintIndexParam
(
const
milvus
::
IndexParam
&
index_param
)
{
BLOCK_SPLITER
std
::
cout
<<
"Index
table name: "
<<
index_param
.
table
_name
<<
std
::
endl
;
std
::
cout
<<
"Index
collection name: "
<<
index_param
.
collection
_name
<<
std
::
endl
;
std
::
cout
<<
"Index type: "
<<
IndexTypeName
(
index_param
.
index_type
)
<<
std
::
endl
;
std
::
cout
<<
"Index extra_params: "
<<
index_param
.
extra_params
<<
std
::
endl
;
BLOCK_SPLITER
}
void
Utils
::
Build
Vectors
(
int64_t
from
,
int64_t
to
,
std
::
vector
<
milvus
::
RowRecord
>&
vector_record
_array
,
std
::
vector
<
int64_t
>&
record
_ids
,
int64_t
dimension
)
{
Utils
::
Build
Entities
(
int64_t
from
,
int64_t
to
,
std
::
vector
<
milvus
::
Entity
>&
entity
_array
,
std
::
vector
<
int64_t
>&
entity
_ids
,
int64_t
dimension
)
{
if
(
to
<=
from
)
{
return
;
}
vector_record
_array
.
clear
();
record
_ids
.
clear
();
entity
_array
.
clear
();
entity
_ids
.
clear
();
for
(
int64_t
k
=
from
;
k
<
to
;
k
++
)
{
milvus
::
RowRecord
record
;
record
.
float_data
.
resize
(
dimension
);
milvus
::
Entity
entity
;
entity
.
float_data
.
resize
(
dimension
);
for
(
int64_t
i
=
0
;
i
<
dimension
;
i
++
)
{
record
.
float_data
[
i
]
=
(
float
)(
k
%
(
i
+
1
));
entity
.
float_data
[
i
]
=
(
float
)(
k
%
(
i
+
1
));
}
vector_record_array
.
emplace_back
(
record
);
record
_ids
.
push_back
(
k
);
entity_array
.
emplace_back
(
entity
);
entity
_ids
.
push_back
(
k
);
}
}
void
Utils
::
PrintSearchResult
(
const
std
::
vector
<
std
::
pair
<
int64_t
,
milvus
::
RowRecord
>>&
search_record
_array
,
Utils
::
PrintSearchResult
(
const
std
::
vector
<
std
::
pair
<
int64_t
,
milvus
::
Entity
>>&
entity
_array
,
const
milvus
::
TopKQueryResult
&
topk_query_result
)
{
BLOCK_SPLITER
std
::
cout
<<
"Returned result count: "
<<
topk_query_result
.
size
()
<<
std
::
endl
;
if
(
topk_query_result
.
size
()
!=
search_record
_array
.
size
())
{
if
(
topk_query_result
.
size
()
!=
entity
_array
.
size
())
{
std
::
cout
<<
"ERROR: Returned result count not equal nq"
<<
std
::
endl
;
return
;
}
...
...
@@ -158,8 +158,8 @@ Utils::PrintSearchResult(const std::vector<std::pair<int64_t, milvus::RowRecord>
for
(
size_t
i
=
0
;
i
<
topk_query_result
.
size
();
i
++
)
{
const
milvus
::
QueryResult
&
one_result
=
topk_query_result
[
i
];
size_t
topk
=
one_result
.
ids
.
size
();
auto
search_id
=
search_record
_array
[
i
].
first
;
std
::
cout
<<
"No."
<<
i
<<
"
vector
"
<<
search_id
<<
" top "
<<
topk
<<
" search result:"
<<
std
::
endl
;
auto
search_id
=
entity
_array
[
i
].
first
;
std
::
cout
<<
"No."
<<
i
<<
"
entity
"
<<
search_id
<<
" top "
<<
topk
<<
" search result:"
<<
std
::
endl
;
for
(
size_t
j
=
0
;
j
<
topk
;
j
++
)
{
std
::
cout
<<
"
\t
"
<<
one_result
.
ids
[
j
]
<<
"
\t
"
<<
one_result
.
distances
[
j
]
<<
std
::
endl
;
}
...
...
@@ -168,13 +168,13 @@ Utils::PrintSearchResult(const std::vector<std::pair<int64_t, milvus::RowRecord>
}
void
Utils
::
CheckSearchResult
(
const
std
::
vector
<
std
::
pair
<
int64_t
,
milvus
::
RowRecord
>>&
search_record
_array
,
Utils
::
CheckSearchResult
(
const
std
::
vector
<
std
::
pair
<
int64_t
,
milvus
::
Entity
>>&
entity
_array
,
const
milvus
::
TopKQueryResult
&
topk_query_result
)
{
BLOCK_SPLITER
size_t
nq
=
topk_query_result
.
size
();
for
(
size_t
i
=
0
;
i
<
nq
;
i
++
)
{
const
milvus
::
QueryResult
&
one_result
=
topk_query_result
[
i
];
auto
search_id
=
search_record
_array
[
i
].
first
;
auto
search_id
=
entity
_array
[
i
].
first
;
uint64_t
match_index
=
one_result
.
ids
.
size
();
for
(
uint64_t
index
=
0
;
index
<
one_result
.
ids
.
size
();
index
++
)
{
...
...
@@ -195,15 +195,15 @@ Utils::CheckSearchResult(const std::vector<std::pair<int64_t, milvus::RowRecord>
}
void
Utils
::
DoSearch
(
std
::
shared_ptr
<
milvus
::
Connection
>
conn
,
const
std
::
string
&
table
_name
,
Utils
::
DoSearch
(
std
::
shared_ptr
<
milvus
::
Connection
>
conn
,
const
std
::
string
&
collection
_name
,
const
std
::
vector
<
std
::
string
>&
partition_tags
,
int64_t
top_k
,
int64_t
nprobe
,
const
std
::
vector
<
std
::
pair
<
int64_t
,
milvus
::
RowRecord
>>&
search_record
_array
,
const
std
::
vector
<
std
::
pair
<
int64_t
,
milvus
::
Entity
>>&
entity
_array
,
milvus
::
TopKQueryResult
&
topk_query_result
)
{
topk_query_result
.
clear
();
std
::
vector
<
milvus
::
RowRecord
>
record
_array
;
for
(
auto
&
pair
:
search_record
_array
)
{
record
_array
.
push_back
(
pair
.
second
);
std
::
vector
<
milvus
::
Entity
>
temp_entity
_array
;
for
(
auto
&
pair
:
entity
_array
)
{
temp_entity
_array
.
push_back
(
pair
.
second
);
}
{
...
...
@@ -211,28 +211,33 @@ Utils::DoSearch(std::shared_ptr<milvus::Connection> conn, const std::string& tab
JSON
json_params
=
{{
"nprobe"
,
nprobe
}};
milvus_sdk
::
TimeRecorder
rc
(
"search"
);
milvus
::
Status
stat
=
conn
->
Search
(
table_name
,
partition_tags
,
record_array
,
top_k
,
json_params
.
dump
(),
topk_query_result
);
std
::
cout
<<
"SearchVector function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
conn
->
Search
(
collection_name
,
partition_tags
,
temp_entity_array
,
top_k
,
json_params
.
dump
(),
topk_query_result
);
std
::
cout
<<
"Search function call status: "
<<
stat
.
message
()
<<
std
::
endl
;
BLOCK_SPLITER
}
PrintSearchResult
(
search_record
_array
,
topk_query_result
);
CheckSearchResult
(
search_record
_array
,
topk_query_result
);
PrintSearchResult
(
entity
_array
,
topk_query_result
);
CheckSearchResult
(
entity
_array
,
topk_query_result
);
}
void
PrintPartitionStat
(
const
milvus
::
PartitionStat
&
partition_stat
)
{
std
::
cout
<<
"
\t
Partition "
<<
partition_stat
.
tag
<<
"
row
count: "
<<
partition_stat
.
row_count
<<
std
::
endl
;
std
::
cout
<<
"
\t
Partition "
<<
partition_stat
.
tag
<<
"
entity
count: "
<<
partition_stat
.
row_count
<<
std
::
endl
;
for
(
auto
&
seg_stat
:
partition_stat
.
segments_stat
)
{
std
::
cout
<<
"
\t\t
segment "
<<
seg_stat
.
segment_name
<<
"
row
count: "
<<
seg_stat
.
row_count
std
::
cout
<<
"
\t\t
segment "
<<
seg_stat
.
segment_name
<<
"
entity
count: "
<<
seg_stat
.
row_count
<<
" index: "
<<
seg_stat
.
index_name
<<
" data size: "
<<
seg_stat
.
data_size
<<
std
::
endl
;
}
}
void
Utils
::
Print
TableInfo
(
const
milvus
::
Table
Info
&
info
)
{
Utils
::
Print
CollectionInfo
(
const
milvus
::
Collection
Info
&
info
)
{
BLOCK_SPLITER
std
::
cout
<<
"
Table "
<<
" total row
count: "
<<
info
.
total_row_count
<<
std
::
endl
;
std
::
cout
<<
"
Collection "
<<
" total entity
count: "
<<
info
.
total_row_count
<<
std
::
endl
;
for
(
const
milvus
::
PartitionStat
&
partition_stat
:
info
.
partitions_stat
)
{
PrintPartitionStat
(
partition_stat
);
}
...
...
sdk/examples/utils/Utils.h
浏览文件 @
9203bdf8
...
...
@@ -32,7 +32,7 @@ class Utils {
CurrentTmDate
(
int64_t
offset_day
=
0
);
static
const
std
::
string
&
Gen
Table
Name
();
Gen
Collection
Name
();
static
void
Sleep
(
int
seconds
);
...
...
@@ -44,7 +44,7 @@ class Utils {
IndexTypeName
(
const
milvus
::
IndexType
&
index_type
);
static
void
Print
TableSchema
(
const
milvus
::
TableSchema
&
tb_schema
);
Print
CollectionParam
(
const
milvus
::
CollectionParam
&
collection_param
);
static
void
PrintPartitionParam
(
const
milvus
::
PartitionParam
&
partition_param
);
...
...
@@ -53,25 +53,25 @@ class Utils {
PrintIndexParam
(
const
milvus
::
IndexParam
&
index_param
);
static
void
Build
Vectors
(
int64_t
from
,
int64_t
to
,
std
::
vector
<
milvus
::
RowRecord
>&
vector_record
_array
,
std
::
vector
<
int64_t
>&
record
_ids
,
int64_t
dimension
);
Build
Entities
(
int64_t
from
,
int64_t
to
,
std
::
vector
<
milvus
::
Entity
>&
entity
_array
,
std
::
vector
<
int64_t
>&
entity
_ids
,
int64_t
dimension
);
static
void
PrintSearchResult
(
const
std
::
vector
<
std
::
pair
<
int64_t
,
milvus
::
RowRecord
>>&
search_record
_array
,
PrintSearchResult
(
const
std
::
vector
<
std
::
pair
<
int64_t
,
milvus
::
Entity
>>&
entity
_array
,
const
milvus
::
TopKQueryResult
&
topk_query_result
);
static
void
CheckSearchResult
(
const
std
::
vector
<
std
::
pair
<
int64_t
,
milvus
::
RowRecord
>>&
search_record
_array
,
CheckSearchResult
(
const
std
::
vector
<
std
::
pair
<
int64_t
,
milvus
::
Entity
>>&
entity
_array
,
const
milvus
::
TopKQueryResult
&
topk_query_result
);
static
void
DoSearch
(
std
::
shared_ptr
<
milvus
::
Connection
>
conn
,
const
std
::
string
&
table
_name
,
DoSearch
(
std
::
shared_ptr
<
milvus
::
Connection
>
conn
,
const
std
::
string
&
collection
_name
,
const
std
::
vector
<
std
::
string
>&
partition_tags
,
int64_t
top_k
,
int64_t
nprobe
,
const
std
::
vector
<
std
::
pair
<
int64_t
,
milvus
::
RowRecord
>>&
search_record
_array
,
const
std
::
vector
<
std
::
pair
<
int64_t
,
milvus
::
Entity
>>&
entity
_array
,
milvus
::
TopKQueryResult
&
topk_query_result
);
static
void
Print
TableInfo
(
const
milvus
::
TableInfo
&
info
);
Print
CollectionInfo
(
const
milvus
::
CollectionInfo
&
collection_
info
);
};
}
// namespace milvus_sdk
sdk/grpc/ClientProxy.cpp
浏览文件 @
9203bdf8
此差异已折叠。
点击以展开。
sdk/grpc/ClientProxy.h
浏览文件 @
9203bdf8
...
...
@@ -24,7 +24,7 @@ class ClientProxy : public Connection {
public:
// Implementations of the Connection interface
Status
Connect
(
const
ConnectParam
&
param
)
override
;
Connect
(
const
ConnectParam
&
connect_
param
)
override
;
Status
Connect
(
const
std
::
string
&
uri
)
override
;
...
...
@@ -35,90 +35,92 @@ class ClientProxy : public Connection {
Status
Disconnect
()
override
;
std
::
string
ClientVersion
()
const
override
;
std
::
string
ServerVersion
()
const
override
;
std
::
string
ServerStatus
()
const
override
;
Status
GetConfig
(
const
std
::
string
&
node_name
,
std
::
string
&
value
)
const
override
;
Status
SetConfig
(
const
std
::
string
&
node_name
,
const
std
::
string
&
value
)
const
override
;
Status
Create
Table
(
const
TableSchema
&
param
)
override
;
Create
Collection
(
const
CollectionParam
&
param
)
override
;
bool
Has
Table
(
const
std
::
string
&
table
_name
)
override
;
Has
Collection
(
const
std
::
string
&
collection
_name
)
override
;
Status
Drop
Table
(
const
std
::
string
&
table
_name
)
override
;
Drop
Collection
(
const
std
::
string
&
collection
_name
)
override
;
Status
CreateIndex
(
const
IndexParam
&
index_param
)
override
;
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
)
override
;
Status
Get
VectorByID
(
const
std
::
string
&
table_name
,
int64_t
vector_id
,
RowRecord
&
vector
_data
)
override
;
Get
EntityByID
(
const
std
::
string
&
collection_name
,
int64_t
entity_id
,
Entity
&
entity
_data
)
override
;
Status
GetIDsInSegment
(
const
std
::
string
&
table
_name
,
const
std
::
string
&
segment_name
,
GetIDsInSegment
(
const
std
::
string
&
collection
_name
,
const
std
::
string
&
segment_name
,
std
::
vector
<
int64_t
>&
id_array
)
override
;
Status
Search
(
const
std
::
string
&
table
_name
,
const
std
::
vector
<
std
::
string
>&
partition_tag_array
,
const
std
::
vector
<
RowRecord
>&
query_record_array
,
int64_t
topk
,
const
std
::
string
&
extra_params
,
TopKQueryResult
&
topk_query_result
)
override
;
Search
(
const
std
::
string
&
collection
_name
,
const
std
::
vector
<
std
::
string
>&
partition_tag_array
,
const
std
::
vector
<
Entity
>&
entity_array
,
int64_t
topk
,
const
std
::
string
&
extra_params
,
TopKQueryResult
&
topk_query_result
)
override
;
Status
Describe
Table
(
const
std
::
string
&
table_name
,
TableSchema
&
table
_schema
)
override
;
Describe
Collection
(
const
std
::
string
&
collection_name
,
CollectionParam
&
collection
_schema
)
override
;
Status
Count
Table
(
const
std
::
string
&
table_name
,
int64_t
&
row
_count
)
override
;
Count
Collection
(
const
std
::
string
&
collection_name
,
int64_t
&
entity
_count
)
override
;
Status
Show
Tables
(
std
::
vector
<
std
::
string
>&
table
_array
)
override
;
Show
Collections
(
std
::
vector
<
std
::
string
>&
collection
_array
)
override
;
Status
ShowTableInfo
(
const
std
::
string
&
table_name
,
TableInfo
&
table_info
)
override
;
std
::
string
ClientVersion
()
const
override
;
std
::
string
ServerVersion
()
const
override
;
std
::
string
ServerStatus
()
const
override
;
ShowCollectionInfo
(
const
std
::
string
&
collection_name
,
CollectionInfo
&
collection_info
)
override
;
Status
DeleteByID
(
const
std
::
string
&
table
_name
,
const
std
::
vector
<
int64_t
>&
id_array
)
override
;
DeleteByID
(
const
std
::
string
&
collection
_name
,
const
std
::
vector
<
int64_t
>&
id_array
)
override
;
Status
Preload
Table
(
const
std
::
string
&
table
_name
)
const
override
;
Preload
Collection
(
const
std
::
string
&
collection
_name
)
const
override
;
Status
DescribeIndex
(
const
std
::
string
&
table
_name
,
IndexParam
&
index_param
)
const
override
;
DescribeIndex
(
const
std
::
string
&
collection
_name
,
IndexParam
&
index_param
)
const
override
;
Status
DropIndex
(
const
std
::
string
&
table
_name
)
const
override
;
DropIndex
(
const
std
::
string
&
collection
_name
)
const
override
;
Status
CreatePartition
(
const
PartitionParam
&
partition_param
)
override
;
Status
ShowPartitions
(
const
std
::
string
&
table
_name
,
PartitionTagList
&
partition_tag_array
)
const
override
;
ShowPartitions
(
const
std
::
string
&
collection
_name
,
PartitionTagList
&
partition_tag_array
)
const
override
;
Status
DropPartition
(
const
PartitionParam
&
partition_param
)
override
;
Status
GetConfig
(
const
std
::
string
&
node_name
,
std
::
string
&
value
)
const
override
;
Status
SetConfig
(
const
std
::
string
&
node_name
,
const
std
::
string
&
value
)
const
override
;
Status
FlushTable
(
const
std
::
string
&
table_name
)
override
;
FlushCollection
(
const
std
::
string
&
collection_name
)
override
;
Status
Flush
()
override
;
Status
Compact
Table
(
const
std
::
string
&
table
_name
)
override
;
Compact
Collection
(
const
std
::
string
&
collection
_name
)
override
;
private:
std
::
shared_ptr
<::
grpc
::
Channel
>
channel_
;
...
...
sdk/include/MilvusApi.h
浏览文件 @
9203bdf8
...
...
@@ -84,11 +84,19 @@ 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'}" nlist range:[1, 999999]
* IVFPQ: "{nlist: '16384', m: "12"}" nlist range:[1, 999999] m is decided by dim and have a couple of results.
* 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]
* ///< 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
collection_name
;
///< Collection name for create index
...
...
@@ -139,18 +147,18 @@ struct CollectionInfo {
class
Connection
{
public:
/**
* @brief Create
C
onnection
* @brief Create
c
onnection
*
* Create a connection instance and return it's shared pointer
*
* @return
C
onnection instance pointer
* @return
c
onnection instance pointer
*/
static
std
::
shared_ptr
<
Connection
>
Create
();
/**
* @brief Destroy
C
onnection
* @brief Destroy
c
onnection
*
* Destroy the connection instance
*
...
...
@@ -174,7 +182,7 @@ class Connection {
*/
virtual
Status
Connect
(
const
ConnectParam
&
param
)
=
0
;
Connect
(
const
ConnectParam
&
connect_
param
)
=
0
;
/**
* @brief Connect
...
...
@@ -190,7 +198,7 @@ class Connection {
Connect
(
const
std
::
string
&
uri
)
=
0
;
/**
* @brief
c
onnected
* @brief
C
onnected
*
* This method is used to test whether server is connected.
*
...
...
@@ -210,7 +218,7 @@ class Connection {
Disconnect
()
=
0
;
/**
* @brief G
ive
the client version
* @brief G
et
the client version
*
* This method is used to give the client version.
*
...
...
@@ -220,7 +228,7 @@ class Connection {
ClientVersion
()
const
=
0
;
/**
* @brief G
ive
the server version
* @brief G
et
the server version
*
* This method is used to give the server version.
*
...
...
@@ -229,6 +237,42 @@ class Connection {
virtual
std
::
string
ServerVersion
()
const
=
0
;
/**
* @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
;
/**
* @brief Create collection method
*
...
...
@@ -278,9 +322,9 @@ class Connection {
CreateIndex
(
const
IndexParam
&
index_param
)
=
0
;
/**
* @brief Insert entity to
table
* @brief Insert entity to
collection
*
* This method is used to insert vector array to
table
.
* This method is used to insert vector array to
collection
.
*
* @param collection_name, target collection's name.
* @param partition_tag, target partition's tag, keep empty if no partition specified.
...
...
@@ -337,21 +381,24 @@ class Connection {
*
* @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
vector
s will be returned.
* @param query_
entity
_array, vectors to be queried.
* @param topk, how many similarity
entitie
s will be returned.
* @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
* FLAT/IVFLAT/SQ8/IVFPQ: "{nprobe: '32'}"
* ///< nprobe range:[1,999999]
* NSG: "{search_length:'100'}
* ///< search_length range:[10, 300]
* HNSW "{ef: '64'}
* ///< ef range:[k, 4096]
* @param topk_query_result, result array.
*
* @return Indicate if query is successful.
*/
virtual
Status
Search
(
const
std
::
string
&
table
_name
,
const
PartitionTagList
&
partition_tag_array
,
const
std
::
vector
<
Entity
>&
query_record
_array
,
int64_t
topk
,
Search
(
const
std
::
string
&
collection
_name
,
const
PartitionTagList
&
partition_tag_array
,
const
std
::
vector
<
Entity
>&
entity
_array
,
int64_t
topk
,
const
std
::
string
&
extra_params
,
TopKQueryResult
&
topk_query_result
)
=
0
;
/**
...
...
@@ -360,17 +407,17 @@ class Connection {
* This method is used to show collection information.
*
* @param collection_name, target collection's name.
* @param collection_
schema, collection_schema
is given when operation is successful.
* @param collection_
param, collection_param
is given when operation is successful.
*
* @return Indicate if this operation is successful.
*/
virtual
Status
DescribeCollection
(
const
std
::
string
&
collection_name
,
TableSchema
&
collection_schema
)
=
0
;
DescribeCollection
(
const
std
::
string
&
collection_name
,
CollectionParam
&
collection_param
)
=
0
;
/**
* @brief Get collection
row
count
* @brief Get collection
entity
count
*
* This method is used to get collection
row
count.
* This method is used to get collection
entity
count.
*
* @param collection_name, target collection's name.
* @param entity_count, collection total entity count(including partitions).
...
...
@@ -393,160 +440,121 @@ class Connection {
ShowCollections
(
std
::
vector
<
std
::
string
>&
collection_array
)
=
0
;
/**
* @brief Show collection
s
information
* @brief Show collection information
*
* This method is used to get detail information of a collection
s
.
* This method is used to get detail information of a collection.
*
* @param collection
s_name, target collections
's name.
* @param collection
s_info, target collections
's information
* @param collection
_name, target collection
's name.
* @param collection
_info, target collection
's information
*
* @return Indicate if this operation is successful.
*/
virtual
Status
ShowCollectionInfo
(
const
std
::
string
&
collections_name
,
TableInfo
&
collections_info
)
=
0
;
/**
* @brief Give the server status
*
* This method is used to give the server status.
*
* @return Server status.
*/
virtual
std
::
string
ServerStatus
()
const
=
0
;
ShowCollectionInfo
(
const
std
::
string
&
collection_name
,
CollectionInfo
&
collection_info
)
=
0
;
/**
* [deprecated]
* @brief delete tables by vector id
* @brief Delete entity by id
*
* This method is used to delete
table data by date range
.
* This method is used to delete
entity by id
.
*
* @param
table_name, target table
's name.
* @param id_array,
vector ids to
deleted.
* @param
collection_name, target collection
's name.
* @param id_array,
entity id array to be
deleted.
*
* @return Indicate if this operation is successful.
*/
virtual
Status
DeleteByID
(
const
std
::
string
&
table
_name
,
const
std
::
vector
<
int64_t
>&
id_array
)
=
0
;
DeleteByID
(
const
std
::
string
&
collection
_name
,
const
std
::
vector
<
int64_t
>&
id_array
)
=
0
;
/**
* @brief
preload table
* @brief
Preload collection
*
* This method is used to preload
table
* This method is used to preload
collection data into memory
*
* @param
table_name
* @param
collection_name, target collection's name.
*
* @return Indicate if this operation is successful.
*/
virtual
Status
Preload
Table
(
const
std
::
string
&
table
_name
)
const
=
0
;
Preload
Collection
(
const
std
::
string
&
collection
_name
)
const
=
0
;
/**
* @brief
d
escribe index
* @brief
D
escribe index
*
* This method is used to describe index
*
* @param
table_name, target table
's name.
* @param
collection_name, target collection
's name.
* @param index_param, returned index information.
*
* @return Indicate if this operation is successful.
*/
virtual
Status
DescribeIndex
(
const
std
::
string
&
table
_name
,
IndexParam
&
index_param
)
const
=
0
;
DescribeIndex
(
const
std
::
string
&
collection
_name
,
IndexParam
&
index_param
)
const
=
0
;
/**
* @brief
d
rop index
* @brief
D
rop index
*
* This method is used to drop index of
table
(and its partitions)
* This method is used to drop index of
collection
(and its partitions)
*
* @param
table_name, target table
's name.
* @param
collection_name, target collection
's name.
*
* @return Indicate if this operation is successful.
*/
virtual
Status
DropIndex
(
const
std
::
string
&
table
_name
)
const
=
0
;
DropIndex
(
const
std
::
string
&
collection
_name
)
const
=
0
;
/**
* @brief Create partition method
*
* This method is used to create
table
partition
* This method is used to create
collection's
partition
*
* @param param, use to provide partition information to be created.
* @param par
tition_par
am, use to provide partition information to be created.
*
* @return Indicate if partition is created successfully
*/
virtual
Status
CreatePartition
(
const
PartitionParam
&
param
)
=
0
;
CreatePartition
(
const
PartitionParam
&
par
tition_par
am
)
=
0
;
/**
* @brief
Test table existence
method
* @brief
Show all partitions
method
*
* This method is used to
create table
* This method is used to
show all partitions(return their tags)
*
* @param
table_name, table name is going to be tested
.
* @param partition_tag_array, partition tag array of the
table
.
* @param
collection_name, target collection's name
.
* @param partition_tag_array, partition tag array of the
collection
.
*
* @return Indicate if this operation is successful
*/
virtual
Status
ShowPartitions
(
const
std
::
string
&
table
_name
,
PartitionTagList
&
partition_tag_array
)
const
=
0
;
ShowPartitions
(
const
std
::
string
&
collection
_name
,
PartitionTagList
&
partition_tag_array
)
const
=
0
;
/**
* @brief Delete partition method
*
* This method is used to delete
table
partition.
* This method is used to delete
collection's
partition.
*
* @param param, target partition to be deleted.
* NOTE: if param.table_name is empty, you must specify param.partition_name,
* else you can specify param.table_name and param.tag and let the param.partition_name be empty
* @param partition_param, target partition to be deleted.
*
* @return Indicate if partition is delete successfully.
*/
virtual
Status
DropPartition
(
const
PartitionParam
&
param
)
=
0
;
DropPartition
(
const
PartitionParam
&
par
tition_par
am
)
=
0
;
/**
* @brief
Get config method
* @brief
Flush collection buffer into storage
*
* This method is used to set config.
*
* @param node_name, config node name.
* @param value, config value.
* This method is used to flush collection buffer into storage
*
* @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
;
/**
* @brief flush table buffer into storage
*
* This method is used to flush table buffer into storage
*
* @param table_name, target table's name.
* @param collection_name, target collection's name.
*
* @return Indicate if this operation is successful.
*/
virtual
Status
Flush
Table
(
const
std
::
string
&
table
_name
)
=
0
;
Flush
Collection
(
const
std
::
string
&
collection
_name
)
=
0
;
/**
* @brief
f
lush all buffer into storage
* @brief
F
lush all buffer into storage
*
* This method is used to all
table
buffer into storage
* This method is used to all
collection
buffer into storage
*
* @return Indicate if this operation is successful.
*/
...
...
@@ -554,16 +562,16 @@ class Connection {
Flush
()
=
0
;
/**
* @brief
compact table,
remove deleted vectors
* @brief
Compact collection, permanently
remove deleted vectors
*
* This method is used to compact
table
* This method is used to compact
collection
*
* @param
table_name, target table
's name.
* @param
collection_name, target collection
's name.
*
* @return Indicate if this operation is successful.
*/
virtual
Status
Compact
Table
(
const
std
::
string
&
table
_name
)
=
0
;
Compact
Collection
(
const
std
::
string
&
collection
_name
)
=
0
;
};
}
// namespace milvus
sdk/interface/ConnectionImpl.cpp
浏览文件 @
9203bdf8
...
...
@@ -56,128 +56,128 @@ ConnectionImpl::ClientVersion() const {
return
client_proxy_
->
ClientVersion
();
}
Status
ConnectionImpl
::
CreateTable
(
const
TableSchema
&
param
)
{
return
client_proxy_
->
CreateTable
(
param
);
std
::
string
ConnectionImpl
::
ServerVersion
()
const
{
return
client_proxy_
->
ServerVersion
(
);
}
bool
ConnectionImpl
::
HasTable
(
const
std
::
string
&
table_name
)
{
return
client_proxy_
->
HasTable
(
table_name
);
std
::
string
ConnectionImpl
::
ServerStatus
()
const
{
return
client_proxy_
->
ServerStatus
(
);
}
Status
ConnectionImpl
::
DropTable
(
const
std
::
string
&
table_name
)
{
return
client_proxy_
->
DropTable
(
table_nam
e
);
ConnectionImpl
::
GetConfig
(
const
std
::
string
&
node_name
,
std
::
string
&
value
)
const
{
return
client_proxy_
->
GetConfig
(
node_name
,
valu
e
);
}
Status
ConnectionImpl
::
CreateIndex
(
const
IndexParam
&
index_param
)
{
return
client_proxy_
->
CreateIndex
(
index_param
);
ConnectionImpl
::
SetConfig
(
const
std
::
string
&
node_name
,
const
std
::
string
&
value
)
const
{
return
client_proxy_
->
SetConfig
(
node_name
,
value
);
}
Status
ConnectionImpl
::
Insert
(
const
std
::
string
&
table_name
,
const
std
::
string
&
partition_tag
,
const
std
::
vector
<
RowRecord
>&
record_array
,
std
::
vector
<
int64_t
>&
id_array
)
{
return
client_proxy_
->
Insert
(
table_name
,
partition_tag
,
record_array
,
id_array
);
ConnectionImpl
::
CreateCollection
(
const
CollectionParam
&
param
)
{
return
client_proxy_
->
CreateCollection
(
param
);
}
Status
ConnectionImpl
::
GetVectorByID
(
const
std
::
string
&
table_name
,
int64_t
vector_id
,
RowRecord
&
vector_data
)
{
return
client_proxy_
->
GetVectorByID
(
table_name
,
vector_id
,
vector_data
);
bool
ConnectionImpl
::
HasCollection
(
const
std
::
string
&
collection_name
)
{
return
client_proxy_
->
HasCollection
(
collection_name
);
}
Status
ConnectionImpl
::
GetIDsInSegment
(
const
std
::
string
&
table_name
,
const
std
::
string
&
segment_name
,
std
::
vector
<
int64_t
>&
id_array
)
{
return
client_proxy_
->
GetIDsInSegment
(
table_name
,
segment_name
,
id_array
);
ConnectionImpl
::
DropCollection
(
const
std
::
string
&
collection_name
)
{
return
client_proxy_
->
DropCollection
(
collection_name
);
}
Status
ConnectionImpl
::
Search
(
const
std
::
string
&
table_name
,
const
std
::
vector
<
std
::
string
>&
partition_tags
,
const
std
::
vector
<
RowRecord
>&
query_record_array
,
int64_t
topk
,
const
std
::
string
&
extra_params
,
TopKQueryResult
&
topk_query_result
)
{
return
client_proxy_
->
Search
(
table_name
,
partition_tags
,
query_record_array
,
topk
,
extra_params
,
topk_query_result
);
ConnectionImpl
::
CreateIndex
(
const
IndexParam
&
index_param
)
{
return
client_proxy_
->
CreateIndex
(
index_param
);
}
Status
ConnectionImpl
::
DescribeTable
(
const
std
::
string
&
table_name
,
TableSchema
&
table_schema
)
{
return
client_proxy_
->
DescribeTable
(
table_name
,
table_schema
);
ConnectionImpl
::
Insert
(
const
std
::
string
&
collection_name
,
const
std
::
string
&
partition_tag
,
const
std
::
vector
<
Entity
>&
entity_array
,
std
::
vector
<
int64_t
>&
id_array
)
{
return
client_proxy_
->
Insert
(
collection_name
,
partition_tag
,
entity_array
,
id_array
);
}
Status
ConnectionImpl
::
CountTable
(
const
std
::
string
&
table_name
,
int64_t
&
row_count
)
{
return
client_proxy_
->
CountTable
(
table_name
,
row_count
);
ConnectionImpl
::
GetEntityByID
(
const
std
::
string
&
collection_name
,
int64_t
entity_id
,
Entity
&
entity_data
)
{
return
client_proxy_
->
GetEntityByID
(
collection_name
,
entity_id
,
entity_data
);
}
Status
ConnectionImpl
::
ShowTables
(
std
::
vector
<
std
::
string
>&
table_array
)
{
return
client_proxy_
->
ShowTables
(
table_array
);
ConnectionImpl
::
GetIDsInSegment
(
const
std
::
string
&
collection_name
,
const
std
::
string
&
segment_name
,
std
::
vector
<
int64_t
>&
id_array
)
{
return
client_proxy_
->
GetIDsInSegment
(
collection_name
,
segment_name
,
id_array
);
}
Status
ConnectionImpl
::
ShowTableInfo
(
const
std
::
string
&
table_name
,
TableInfo
&
table_info
)
{
return
client_proxy_
->
ShowTableInfo
(
table_name
,
table_info
);
ConnectionImpl
::
Search
(
const
std
::
string
&
collection_name
,
const
std
::
vector
<
std
::
string
>&
partition_tags
,
const
std
::
vector
<
Entity
>&
entity_array
,
int64_t
topk
,
const
std
::
string
&
extra_params
,
TopKQueryResult
&
topk_query_result
)
{
return
client_proxy_
->
Search
(
collection_name
,
partition_tags
,
entity_array
,
topk
,
extra_params
,
topk_query_result
);
}
std
::
string
ConnectionImpl
::
ServerVersion
()
const
{
return
client_proxy_
->
ServerVersion
(
);
Status
ConnectionImpl
::
DescribeCollection
(
const
std
::
string
&
collection_name
,
CollectionParam
&
collection_schema
)
{
return
client_proxy_
->
DescribeCollection
(
collection_name
,
collection_schema
);
}
std
::
string
ConnectionImpl
::
ServerStatus
()
const
{
return
client_proxy_
->
ServerStatus
(
);
Status
ConnectionImpl
::
CountCollection
(
const
std
::
string
&
collection_name
,
int64_t
&
row_count
)
{
return
client_proxy_
->
CountCollection
(
collection_name
,
row_count
);
}
Status
ConnectionImpl
::
DeleteByID
(
const
std
::
string
&
table_name
,
const
std
::
vector
<
int64_t
>&
id
_array
)
{
return
client_proxy_
->
DeleteByID
(
table_name
,
id
_array
);
ConnectionImpl
::
ShowCollections
(
std
::
vector
<
std
::
string
>&
collection
_array
)
{
return
client_proxy_
->
ShowCollections
(
collection
_array
);
}
Status
ConnectionImpl
::
PreloadTable
(
const
std
::
string
&
table_name
)
const
{
return
client_proxy_
->
PreloadTable
(
table_name
);
ConnectionImpl
::
ShowCollectionInfo
(
const
std
::
string
&
collection_name
,
CollectionInfo
&
collection_info
)
{
return
client_proxy_
->
ShowCollectionInfo
(
collection_name
,
collection_info
);
}
Status
ConnectionImpl
::
De
scribeIndex
(
const
std
::
string
&
table_name
,
IndexParam
&
index_param
)
const
{
return
client_proxy_
->
De
scribeIndex
(
table_name
,
index_param
);
ConnectionImpl
::
De
leteByID
(
const
std
::
string
&
collection_name
,
const
std
::
vector
<
int64_t
>&
id_array
)
{
return
client_proxy_
->
De
leteByID
(
collection_name
,
id_array
);
}
Status
ConnectionImpl
::
DropIndex
(
const
std
::
string
&
table
_name
)
const
{
return
client_proxy_
->
DropIndex
(
table
_name
);
ConnectionImpl
::
PreloadCollection
(
const
std
::
string
&
collection
_name
)
const
{
return
client_proxy_
->
PreloadCollection
(
collection
_name
);
}
Status
ConnectionImpl
::
CreatePartition
(
const
PartitionParam
&
param
)
{
return
client_proxy_
->
CreatePartition
(
param
);
ConnectionImpl
::
DescribeIndex
(
const
std
::
string
&
collection_name
,
IndexParam
&
index_param
)
const
{
return
client_proxy_
->
DescribeIndex
(
collection_name
,
index_
param
);
}
Status
ConnectionImpl
::
ShowPartitions
(
const
std
::
string
&
table_name
,
PartitionTagList
&
partition_array
)
const
{
return
client_proxy_
->
ShowPartitions
(
table_name
,
partition_array
);
ConnectionImpl
::
DropIndex
(
const
std
::
string
&
collection_name
)
const
{
return
client_proxy_
->
DropIndex
(
collection_name
);
}
Status
ConnectionImpl
::
DropPartition
(
const
PartitionParam
&
param
)
{
return
client_proxy_
->
DropPartition
(
param
);
ConnectionImpl
::
CreatePartition
(
const
PartitionParam
&
partition_
param
)
{
return
client_proxy_
->
CreatePartition
(
partition_
param
);
}
Status
ConnectionImpl
::
GetConfig
(
const
std
::
string
&
node_name
,
std
::
string
&
value
)
const
{
return
client_proxy_
->
GetConfig
(
node_name
,
value
);
ConnectionImpl
::
ShowPartitions
(
const
std
::
string
&
collection_name
,
PartitionTagList
&
partition_array
)
const
{
return
client_proxy_
->
ShowPartitions
(
collection_name
,
partition_array
);
}
Status
ConnectionImpl
::
SetConfig
(
const
std
::
string
&
node_name
,
const
std
::
string
&
value
)
const
{
return
client_proxy_
->
SetConfig
(
node_name
,
value
);
ConnectionImpl
::
DropPartition
(
const
PartitionParam
&
partition_param
)
{
return
client_proxy_
->
DropPartition
(
partition_param
);
}
Status
ConnectionImpl
::
Flush
Table
(
const
std
::
string
&
Status
)
{
return
client_proxy_
->
Flush
Table
(
Status
);
ConnectionImpl
::
Flush
Collection
(
const
std
::
string
&
Status
)
{
return
client_proxy_
->
Flush
Collection
(
Status
);
}
Status
...
...
@@ -186,8 +186,8 @@ ConnectionImpl::Flush() {
}
Status
ConnectionImpl
::
Compact
Table
(
const
std
::
string
&
table
_name
)
{
return
client_proxy_
->
Compact
Table
(
table
_name
);
ConnectionImpl
::
Compact
Collection
(
const
std
::
string
&
collection
_name
)
{
return
client_proxy_
->
Compact
Collection
(
collection
_name
);
}
}
// namespace milvus
sdk/interface/ConnectionImpl.h
浏览文件 @
9203bdf8
...
...
@@ -26,7 +26,7 @@ class ConnectionImpl : public Connection {
// Implementations of the Connection interface
Status
Connect
(
const
ConnectParam
&
param
)
override
;
Connect
(
const
ConnectParam
&
connect_
param
)
override
;
Status
Connect
(
const
std
::
string
&
uri
)
override
;
...
...
@@ -37,90 +37,92 @@ class ConnectionImpl : public Connection {
Status
Disconnect
()
override
;
std
::
string
ClientVersion
()
const
override
;
std
::
string
ServerVersion
()
const
override
;
std
::
string
ServerStatus
()
const
override
;
Status
GetConfig
(
const
std
::
string
&
node_name
,
std
::
string
&
value
)
const
override
;
Status
SetConfig
(
const
std
::
string
&
node_name
,
const
std
::
string
&
value
)
const
override
;
Status
Create
Table
(
const
TableSchema
&
param
)
override
;
Create
Collection
(
const
CollectionParam
&
param
)
override
;
bool
Has
Table
(
const
std
::
string
&
table
_name
)
override
;
Has
Collection
(
const
std
::
string
&
collection
_name
)
override
;
Status
Drop
Table
(
const
std
::
string
&
table
_name
)
override
;
Drop
Collection
(
const
std
::
string
&
collection
_name
)
override
;
Status
CreateIndex
(
const
IndexParam
&
index_param
)
override
;
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
)
override
;
Status
Get
VectorByID
(
const
std
::
string
&
table_name
,
int64_t
vector_id
,
RowRecord
&
vector
_data
)
override
;
Get
EntityByID
(
const
std
::
string
&
collection_name
,
int64_t
entity_id
,
Entity
&
entity
_data
)
override
;
Status
GetIDsInSegment
(
const
std
::
string
&
table
_name
,
const
std
::
string
&
segment_name
,
GetIDsInSegment
(
const
std
::
string
&
collection
_name
,
const
std
::
string
&
segment_name
,
std
::
vector
<
int64_t
>&
id_array
)
override
;
Status
Search
(
const
std
::
string
&
table
_name
,
const
std
::
vector
<
std
::
string
>&
partition_tag_array
,
const
std
::
vector
<
RowRecord
>&
query_record
_array
,
int64_t
topk
,
Search
(
const
std
::
string
&
collection
_name
,
const
std
::
vector
<
std
::
string
>&
partition_tag_array
,
const
std
::
vector
<
Entity
>&
entity
_array
,
int64_t
topk
,
const
std
::
string
&
extra_params
,
TopKQueryResult
&
topk_query_result
)
override
;
Status
Describe
Table
(
const
std
::
string
&
table_name
,
TableSchema
&
table
_schema
)
override
;
Describe
Collection
(
const
std
::
string
&
collection_name
,
CollectionParam
&
collection
_schema
)
override
;
Status
Count
Table
(
const
std
::
string
&
table_name
,
int64_t
&
row
_count
)
override
;
Count
Collection
(
const
std
::
string
&
collection_name
,
int64_t
&
entity
_count
)
override
;
Status
Show
Tables
(
std
::
vector
<
std
::
string
>&
table
_array
)
override
;
Show
Collections
(
std
::
vector
<
std
::
string
>&
collection
_array
)
override
;
Status
ShowTableInfo
(
const
std
::
string
&
table_name
,
TableInfo
&
table_info
)
override
;
std
::
string
ClientVersion
()
const
override
;
std
::
string
ServerVersion
()
const
override
;
std
::
string
ServerStatus
()
const
override
;
Status
DeleteByID
(
const
std
::
string
&
table_name
,
const
std
::
vector
<
int64_t
>&
id_array
)
override
;
ShowCollectionInfo
(
const
std
::
string
&
collection_name
,
CollectionInfo
&
collection_info
)
override
;
Status
PreloadTable
(
const
std
::
string
&
table_name
)
const
override
;
DeleteByID
(
const
std
::
string
&
collection_name
,
const
std
::
vector
<
int64_t
>&
id_array
)
override
;
Status
DescribeIndex
(
const
std
::
string
&
table_name
,
IndexParam
&
index_param
)
const
override
;
PreloadCollection
(
const
std
::
string
&
collection_name
)
const
override
;
Status
D
ropIndex
(
const
std
::
string
&
table_name
)
const
override
;
D
escribeIndex
(
const
std
::
string
&
collection_name
,
IndexParam
&
index_param
)
const
override
;
Status
CreatePartition
(
const
PartitionParam
&
param
)
override
;
DropIndex
(
const
std
::
string
&
collection_name
)
const
override
;
Status
ShowPartitions
(
const
std
::
string
&
table_name
,
PartitionTagList
&
partition_tag_array
)
const
override
;
CreatePartition
(
const
PartitionParam
&
partition_param
)
override
;
Status
DropPartition
(
const
PartitionParam
&
param
)
override
;
ShowPartitions
(
const
std
::
string
&
collection_name
,
PartitionTagList
&
partition_tag_array
)
const
override
;
Status
GetConfig
(
const
std
::
string
&
node_name
,
std
::
string
&
value
)
const
override
;
Status
SetConfig
(
const
std
::
string
&
node_name
,
const
std
::
string
&
value
)
const
override
;
DropPartition
(
const
PartitionParam
&
partition_param
)
override
;
Status
Flush
Table
(
const
std
::
string
&
table
_name
)
override
;
Flush
Collection
(
const
std
::
string
&
collection
_name
)
override
;
Status
Flush
()
override
;
Status
Compact
Table
(
const
std
::
string
&
table
_name
)
override
;
Compact
Collection
(
const
std
::
string
&
collection
_name
)
override
;
private:
std
::
shared_ptr
<
ClientProxy
>
client_proxy_
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录