Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
milvus
milvus
提交
7812eed0
M
milvus
项目概览
milvus
/
milvus
大约 1 年 前同步成功
通知
261
Star
22476
Fork
2472
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
milvus
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
7812eed0
编写于
9月 22, 2020
作者:
S
shengjh
提交者:
yefu.chen
9月 22, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add count row for proxy
Signed-off-by:
N
shengjh
<
1572099106@qq.com
>
上级
bd696486
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
53 addition
and
8 deletion
+53
-8
conf/config.yaml
conf/config.yaml
+1
-1
proxy/src/server/MetaWrapper.cpp
proxy/src/server/MetaWrapper.cpp
+15
-3
proxy/src/server/MetaWrapper.h
proxy/src/server/MetaWrapper.h
+3
-0
proxy/src/server/delivery/request/CountEntitiesReq.cpp
proxy/src/server/delivery/request/CountEntitiesReq.cpp
+2
-1
sdk/examples/simple/CountCollection.cpp
sdk/examples/simple/CountCollection.cpp
+29
-0
sdk/examples/simple/CreateCollection.cpp
sdk/examples/simple/CreateCollection.cpp
+1
-1
sdk/examples/simple/CreateIndex.cpp
sdk/examples/simple/CreateIndex.cpp
+1
-1
sdk/examples/simple/delete.cpp
sdk/examples/simple/delete.cpp
+1
-1
未找到文件。
conf/config.yaml
浏览文件 @
7812eed0
...
...
@@ -16,7 +16,7 @@ master:
etcd
:
address
:
localhost
port
:
2379
rootpath
:
by-dev
/
rootpath
:
by-dev
segthreshold
:
10000
timesync
:
...
...
proxy/src/server/MetaWrapper.cpp
浏览文件 @
7812eed0
...
...
@@ -3,6 +3,7 @@
#include "nlohmann/json.hpp"
#include <mutex>
#include <google/protobuf/text_format.h>
#include <boost/filesystem.hpp>
using
Collection
=
masterpb
::
Collection
;
using
Schema
=
milvus
::
grpc
::
Schema
;
...
...
@@ -23,6 +24,7 @@ void ParseSegmentInfo(const std::string &json_str, SegmentInfo &segment_info) {
segment_info
.
set_close_timestamp
(
json
[
"close_timestamp"
].
get
<
uint64_t
>
());
segment_info
.
set_collection_id
(
json
[
"collection_id"
].
get
<
uint64_t
>
());
segment_info
.
set_collection_name
(
json
[
"collection_name"
].
get
<
std
::
string
>
());
segment_info
.
set_rows
(
json
[
"rows"
].
get
<
std
::
int64_t
>
());
}
void
ParseCollectionSchema
(
const
std
::
string
&
json_str
,
Collection
&
collection
)
{
...
...
@@ -51,8 +53,8 @@ MetaWrapper &MetaWrapper::GetInstance() {
Status
MetaWrapper
::
Init
()
{
try
{
etcd_root_path_
=
config
.
etcd
.
rootpath
();
segment_path_
=
etcd_root_path_
+
"segment/"
;
collection_path_
=
etcd_root_path_
+
"collection/"
;
segment_path_
=
(
boost
::
filesystem
::
path
(
etcd_root_path_
)
/
"segment/"
).
string
()
;
collection_path_
=
(
boost
::
filesystem
::
path
(
etcd_root_path_
)
/
"collection/"
).
string
()
;
auto
master_addr
=
config
.
master
.
address
()
+
":"
+
std
::
to_string
(
config
.
master
.
port
());
master_client_
=
std
::
make_shared
<
milvus
::
master
::
GrpcClient
>
(
master_addr
);
...
...
@@ -65,7 +67,6 @@ Status MetaWrapper::Init() {
UpdateMeta
(
res
);
};
watcher_
=
std
::
make_shared
<
milvus
::
master
::
Watcher
>
(
etcd_addr
,
segment_path_
,
f
,
true
);
SyncMeta
();
}
catch
(
const
std
::
exception
&
e
)
{
...
...
@@ -162,5 +163,16 @@ Status MetaWrapper::SyncMeta() {
return
status
;
}
int64_t
MetaWrapper
::
CountCollection
(
const
std
::
string
&
collection_name
)
{
uint64_t
count
=
0
;
// TODO: index to speed up
for
(
const
auto
&
segment_info
:
segment_infos_
){
if
(
segment_info
.
second
.
collection_name
()
==
collection_name
){
count
+=
segment_info
.
second
.
rows
();
}
}
return
count
;
}
}
}
\ No newline at end of file
proxy/src/server/MetaWrapper.h
浏览文件 @
7812eed0
...
...
@@ -31,6 +31,9 @@ class MetaWrapper {
Status
SyncMeta
();
int64_t
CountCollection
(
const
std
::
string
&
collection_name
);
private:
bool
IsCollectionMetaKey
(
const
std
::
string
&
key
);
...
...
proxy/src/server/delivery/request/CountEntitiesReq.cpp
浏览文件 @
7812eed0
...
...
@@ -14,6 +14,7 @@
#include "server/ValidationUtil.h"
#include "utils/Log.h"
#include "utils/TimeRecorder.h"
#include "server/MetaWrapper.h"
#include <memory>
#include <unordered_map>
...
...
@@ -36,7 +37,7 @@ CountEntitiesReq::OnExecute() {
try
{
std
::
string
hdr
=
"CountEntitiesReq(collection="
+
collection_name_
+
")"
;
TimeRecorderAuto
rc
(
hdr
);
row_count_
=
MetaWrapper
::
GetInstance
().
CountCollection
(
collection_name_
);
rc
.
ElapseFromBegin
(
"done"
);
}
catch
(
std
::
exception
&
ex
)
{
...
...
sdk/examples/simple/CountCollection.cpp
0 → 100644
浏览文件 @
7812eed0
#include <Status.h>
#include <Field.h>
#include <MilvusApi.h>
#include <interface/ConnectionImpl.h>
#include "utils/Utils.h"
int
main
(
int
argc
,
char
**
argv
)
{
TestParameters
parameters
=
milvus_sdk
::
Utils
::
ParseTestParameters
(
argc
,
argv
);
if
(
!
parameters
.
is_valid
)
{
return
0
;
}
auto
client
=
milvus
::
ConnectionImpl
();
milvus
::
ConnectParam
connect_param
;
connect_param
.
ip_address
=
parameters
.
address_
.
empty
()
?
"127.0.0.1"
:
parameters
.
address_
;
connect_param
.
port
=
parameters
.
port_
.
empty
()
?
"19530"
:
parameters
.
port_
;
client
.
Connect
(
connect_param
);
milvus
::
Status
stat
;
const
std
::
string
collectin_name
=
"collection1"
;
int64_t
count
=
0
;
stat
=
client
.
CountEntities
(
collectin_name
,
count
);
if
(
!
stat
.
ok
()){
std
::
cerr
<<
"Error: "
<<
stat
.
message
()
<<
std
::
endl
;
}
std
::
cout
<<
"Collection "
<<
collectin_name
<<
" rows: "
<<
count
<<
std
::
endl
;
}
\ No newline at end of file
sdk/examples/simple/CreateCollection.cpp
浏览文件 @
7812eed0
...
...
@@ -18,7 +18,7 @@ int main(int argc , char**argv) {
client
.
Connect
(
connect_param
);
milvus
::
Status
stat
;
const
std
::
string
collectin_name
=
"collection
0
"
;
const
std
::
string
collectin_name
=
"collection
1
"
;
// Create
milvus
::
FieldPtr
field_ptr1
=
std
::
make_shared
<
milvus
::
Field
>
();
...
...
sdk/examples/simple/CreateIndex.cpp
浏览文件 @
7812eed0
...
...
@@ -2,7 +2,7 @@
#include "interface/ConnectionImpl.h"
#include "utils/Utils.h"
const
std
::
string
COLLECTION
=
"collection
_0
"
;
const
std
::
string
COLLECTION
=
"collection
1
"
;
int
main
(
int
argc
,
char
*
argv
[])
{
TestParameters
parameters
=
milvus_sdk
::
Utils
::
ParseTestParameters
(
argc
,
argv
);
...
...
sdk/examples/simple/delete.cpp
浏览文件 @
7812eed0
...
...
@@ -32,7 +32,7 @@ main(int argc, char *argv[]) {
delete_ids
.
push_back
(
1
);
delete_ids
.
push_back
(
2
);
delete_ids
.
push_back
(
3
);
client
.
DeleteEntityByID
(
"collection
0
"
,
delete_ids
);
client
.
DeleteEntityByID
(
"collection
1
"
,
delete_ids
);
return
0
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录