Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Serving
提交
d7fd7c8d
S
Serving
项目概览
PaddlePaddle
/
Serving
大约 1 年 前同步成功
通知
186
Star
833
Fork
253
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
105
列表
看板
标记
里程碑
合并请求
10
Wiki
2
Wiki
分析
仓库
DevOps
项目成员
Pages
S
Serving
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
105
Issue
105
列表
看板
标记
里程碑
合并请求
10
合并请求
10
Pages
分析
分析
仓库分析
DevOps
Wiki
2
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
d7fd7c8d
编写于
5月 27, 2019
作者:
W
wangjiawei04
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix icode RULE085
Change-Id: Ibea30897533f648436b855cd7aa804ca2a009fd0
上级
96ee1283
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
39 addition
and
39 deletion
+39
-39
demo-client/src/echo_kvdb.cpp
demo-client/src/echo_kvdb.cpp
+2
-2
demo-serving/op/kvdb_echo_op.cpp
demo-serving/op/kvdb_echo_op.cpp
+4
-4
kvdb/src/gtest_db_func.cpp
kvdb/src/gtest_db_func.cpp
+3
-3
kvdb/src/gtest_db_thread.cpp
kvdb/src/gtest_db_thread.cpp
+5
-5
kvdb/src/gtest_kvdb.cpp
kvdb/src/gtest_kvdb.cpp
+8
-8
kvdb/src/mock_param_dict_impl.cpp
kvdb/src/mock_param_dict_impl.cpp
+12
-12
kvdb/src/paddle_rocksdb.cpp
kvdb/src/paddle_rocksdb.cpp
+2
-2
kvdb/src/param_dict_mgr_impl.cpp
kvdb/src/param_dict_mgr_impl.cpp
+1
-1
kvdb/src/test_rocksdb.cpp
kvdb/src/test_rocksdb.cpp
+2
-2
未找到文件。
demo-client/src/echo_kvdb.cpp
浏览文件 @
d7fd7c8d
...
...
@@ -47,7 +47,7 @@ void print_res(const Request& req,
std
::
string
route_tag
,
uint64_t
elapse_ms
)
{
LOG
(
INFO
)
<<
"Receive Response size: "
<<
res
.
ress_size
();
for
(
size_t
i
=
0
;
i
<
res
.
ress_size
();
i
++
)
{
for
(
size_t
i
=
0
;
i
<
res
.
ress_size
();
i
++
)
{
KVDBRes
val
=
res
.
ress
(
i
);
LOG
(
INFO
)
<<
"Receive value from demo-server: "
<<
val
.
value
();
}
...
...
@@ -100,7 +100,7 @@ int main(int argc, char** argv) {
while
(
true
)
{
if
(
global_key
>
10000
)
if
(
global_key
>
10000
)
break
;
timeval
start
;
gettimeofday
(
&
start
,
NULL
);
...
...
demo-serving/op/kvdb_echo_op.cpp
浏览文件 @
d7fd7c8d
...
...
@@ -33,16 +33,16 @@ int KVDBEchoOp::debug() {
const
Request
*
req
=
dynamic_cast
<
const
Request
*>
(
get_request_message
());
Response
*
res
=
mutable_data
<
Response
>
();
LOG
(
INFO
)
<<
"Receive request in KVDB echo service: "
<<
req
->
ShortDebugString
();
for
(
size_t
i
=
0
;
i
<
req
->
reqs_size
();
i
++
)
{
for
(
size_t
i
=
0
;
i
<
req
->
reqs_size
();
i
++
)
{
auto
kvdbreq
=
req
->
reqs
(
i
);
std
::
string
op
=
kvdbreq
.
op
();
std
::
string
key
=
kvdbreq
.
key
();
std
::
string
val
=
kvdbreq
.
value
();
if
(
op
==
"SET"
)
{
if
(
op
==
"SET"
)
{
db
->
Put
(
key
,
val
);
KVDBRes
*
kvdb_value_res
=
res
->
mutable_ress
()
->
Add
();
kvdb_value_res
->
set_value
(
"OK"
);
}
else
if
(
op
==
"GET"
)
{
}
else
if
(
op
==
"GET"
)
{
std
::
string
getvalue
=
db
->
Get
(
key
);
KVDBRes
*
kvdb_value_res
=
res
->
mutable_ress
()
->
Add
();
kvdb_value_res
->
set_value
(
getvalue
);
...
...
@@ -52,7 +52,7 @@ int KVDBEchoOp::debug() {
}
void
KVDBEchoOp
::
DBInit
()
{
if
(
db
.
get
()
==
nullptr
)
{
if
(
db
.
get
()
==
nullptr
)
{
db
=
RocksDBWrapper
::
RocksDBWrapperFactory
(
"kvdb"
);
}
}
...
...
kvdb/src/gtest_db_func.cpp
浏览文件 @
d7fd7c8d
...
...
@@ -39,7 +39,7 @@ std::vector<std::string> StringSplit(std::string str, char split) {
std
::
vector
<
std
::
string
>
strs
;
std
::
istringstream
f
(
str
);
std
::
string
s
;
while
(
getline
(
f
,
s
,
split
))
{
while
(
getline
(
f
,
s
,
split
))
{
strs
.
push_back
(
s
);
}
return
strs
;
...
...
@@ -52,13 +52,13 @@ TEST_F(KVDBTest, AbstractKVDB_Func_Test) {
std
::
string
get_list
=
"getlist.txt"
;
std
::
ifstream
set_file
(
set_list
);
std
::
ifstream
get_file
(
get_list
);
for
(
std
::
string
line
;
getline
(
set_file
,
line
);
)
for
(
std
::
string
line
;
getline
(
set_file
,
line
);
)
{
std
::
vector
<
std
::
string
>
strs
=
StringSplit
(
line
,
' '
);
kvdb
->
Set
(
strs
[
0
],
strs
[
1
]);
}
for
(
std
::
string
line
;
getline
(
set_file
,
line
);
)
{
for
(
std
::
string
line
;
getline
(
set_file
,
line
);
)
{
std
::
vector
<
std
::
string
>
strs
=
StringSplit
(
line
,
' '
);
std
::
string
val
=
kvdb
->
Get
(
strs
[
0
]);
ASSERT_EQ
(
val
,
strs
[
1
]);
...
...
kvdb/src/gtest_db_thread.cpp
浏览文件 @
d7fd7c8d
...
...
@@ -36,29 +36,29 @@ char** my_argv;
void
db_thread_test
(
AbsKVDBPtr
kvdb
,
int
size
)
{
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
for
(
int
i
=
0
;
i
<
size
;
i
++
)
{
kvdb
->
Set
(
std
::
to_string
(
i
),
std
::
to_string
(
i
));
kvdb
->
Get
(
std
::
to_string
(
i
));
}
}
TEST_F
(
KVDBTest
,
AbstractKVDB_Thread_Test
)
{
if
(
my_argc
!=
3
)
{
if
(
my_argc
!=
3
)
{
std
::
cerr
<<
"illegal input! should be db_thread ${num_of_thread} ${num_of_ops_each_thread}"
<<
std
::
endl
;
return
;
}
int
num_of_thread
=
atoi
(
my_argv
[
1
]);
int
nums_of_ops_each_thread
=
atoi
(
my_argv
[
2
]);
std
::
vector
<
AbsKVDBPtr
>
kvdbptrs
;
for
(
int
i
=
0
;
i
<
num_of_thread
;
i
++
)
{
for
(
int
i
=
0
;
i
<
num_of_thread
;
i
++
)
{
kvdbptrs
.
push_back
(
std
::
make_shared
<
RocksKVDB
>
());
kvdbptrs
[
i
]
->
CreateDB
();
}
std
::
vector
<
std
::
thread
>
tarr
;
for
(
int
i
=
0
;
i
<
num_of_thread
;
i
++
)
{
for
(
int
i
=
0
;
i
<
num_of_thread
;
i
++
)
{
tarr
.
push_back
(
std
::
thread
(
db_thread_test
,
kvdbptrs
[
i
],
nums_of_ops_each_thread
));
}
for
(
int
i
=
0
;
i
<
num_of_thread
;
i
++
)
{
for
(
int
i
=
0
;
i
<
num_of_thread
;
i
++
)
{
tarr
[
i
].
join
();
}
return
;
...
...
kvdb/src/gtest_kvdb.cpp
浏览文件 @
d7fd7c8d
...
...
@@ -49,10 +49,10 @@ void UpdateTestIn(std::string);
TEST_F
(
KVDBTest
,
AbstractKVDB_Unit_Test
)
{
kvdb
->
CreateDB
();
kvdb
->
SetDBName
(
"test_kvdb"
);
for
(
int
i
=
0
;
i
<
100
;
i
++
)
{
for
(
int
i
=
0
;
i
<
100
;
i
++
)
{
kvdb
->
Set
(
std
::
to_string
(
i
),
std
::
to_string
(
i
*
2
));
}
for
(
int
i
=
0
;
i
<
100
;
i
++
)
{
for
(
int
i
=
0
;
i
<
100
;
i
++
)
{
std
::
string
val
=
kvdb
->
Get
(
std
::
to_string
(
i
));
ASSERT_EQ
(
val
,
std
::
to_string
(
i
*
2
));
}
...
...
@@ -101,15 +101,15 @@ TEST_F(KVDBTest, MockParamDict_Unit_Test) {
void
GenerateTestIn
(
std
::
string
filename
)
{
std
::
ifstream
in_file
(
filename
);
if
(
in_file
.
good
())
{
if
(
in_file
.
good
())
{
in_file
.
close
();
std
::
string
cmd
=
"rm -rf "
+
filename
;
system
(
cmd
.
c_str
());
}
std
::
ofstream
out_file
(
filename
);
for
(
size_t
i
=
0
;
i
<
100000
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
100000
;
i
++
)
{
out_file
<<
i
<<
" "
<<
i
<<
" "
;
for
(
size_t
j
=
0
;
j
<
3
;
j
++
)
{
for
(
size_t
j
=
0
;
j
<
3
;
j
++
)
{
out_file
<<
i
<<
" "
;
}
out_file
<<
std
::
endl
;
...
...
@@ -119,15 +119,15 @@ void GenerateTestIn(std::string filename) {
void
UpdateTestIn
(
std
::
string
filename
)
{
std
::
ifstream
in_file
(
filename
);
if
(
in_file
.
good
())
{
if
(
in_file
.
good
())
{
in_file
.
close
();
std
::
string
cmd
=
"rm -rf "
+
filename
;
system
(
cmd
.
c_str
());
}
std
::
ofstream
out_file
(
filename
);
for
(
size_t
i
=
0
;
i
<
10000
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
10000
;
i
++
)
{
out_file
<<
i
<<
" "
<<
i
<<
" "
;
for
(
size_t
j
=
0
;
j
<
3
;
j
++
)
{
for
(
size_t
j
=
0
;
j
<
3
;
j
++
)
{
out_file
<<
i
+
1
<<
" "
;
}
out_file
<<
std
::
endl
;
...
...
kvdb/src/mock_param_dict_impl.cpp
浏览文件 @
d7fd7c8d
...
...
@@ -35,8 +35,8 @@ std::string MockDictReader::GetMD5() {
char
buffer
[
max_buffer
];
cmd
.
append
(
" 2>&1"
);
stream
=
popen
(
cmd
.
c_str
(),
"r"
);
if
(
stream
)
{
if
(
fgets
(
buffer
,
max_buffer
,
stream
)
!=
NULL
)
{
if
(
stream
)
{
if
(
fgets
(
buffer
,
max_buffer
,
stream
)
!=
NULL
)
{
data
.
append
(
buffer
);
}
}
...
...
@@ -62,8 +62,8 @@ std::chrono::system_clock::time_point MockDictReader::GetTimeStamp() {
void
MockDictReader
::
Read
(
std
::
vector
<
std
::
string
>&
res
)
{
std
::
string
line
;
std
::
ifstream
infile
(
this
->
filename_
);
if
(
infile
.
is_open
())
{
while
(
getline
(
infile
,
line
))
{
if
(
infile
.
is_open
())
{
while
(
getline
(
infile
,
line
))
{
res
.
push_back
(
line
);
}
}
...
...
@@ -90,10 +90,10 @@ std::vector<float> MockParamDict::GetSparseValue(std::string feasign, std::strin
//TODO: the concatation of feasign and slot is TBD.
std
::
string
result
=
front_db
->
Get
(
feasign
+
slot
);
std
::
vector
<
float
>
value
;
if
(
result
==
"NOT_FOUND"
)
if
(
result
==
"NOT_FOUND"
)
return
value
;
uint8_t
*
raw_values_ptr
=
reinterpret_cast
<
uint8_t
*>
(
&
result
[
0
]);
for
(
size_t
i
=
0
;
i
<
result
.
size
();
i
+=
4
)
{
for
(
size_t
i
=
0
;
i
<
result
.
size
();
i
+=
4
)
{
float
temp
=
BytesToFloat
(
raw_values_ptr
+
i
);
value
.
push_back
(
temp
);
}
...
...
@@ -124,11 +124,11 @@ bool MockParamDict::InsertSparseValue(std::string feasign, std::string slot, con
std
::
string
key
=
feasign
+
slot
;
uint8_t
*
values_ptr
=
new
uint8_t
[
values
.
size
()
*
4
];
std
::
string
value
;
for
(
size_t
i
=
0
;
i
<
values
.
size
();
i
++
)
{
for
(
size_t
i
=
0
;
i
<
values
.
size
();
i
++
)
{
FloatToBytes
(
values
[
i
],
values_ptr
+
4
*
i
);
}
char
*
raw_values_ptr
=
reinterpret_cast
<
char
*>
(
values_ptr
);
for
(
size_t
i
=
0
;
i
<
values
.
size
()
*
4
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
values
.
size
()
*
4
;
i
++
)
{
value
.
push_back
(
raw_values_ptr
[
i
]);
}
back_db
->
Set
(
key
,
value
);
...
...
@@ -138,16 +138,16 @@ bool MockParamDict::InsertSparseValue(std::string feasign, std::string slot, con
void
MockParamDict
::
UpdateBaseModel
()
{
std
::
thread
t
([
&
]
()
{
for
(
AbsDictReaderPtr
dict_reader
:
this
->
dict_reader_lst_
)
{
if
(
dict_reader
->
CheckDiff
())
{
for
(
AbsDictReaderPtr
dict_reader
:
this
->
dict_reader_lst_
)
{
if
(
dict_reader
->
CheckDiff
())
{
std
::
vector
<
std
::
string
>
strs
;
dict_reader
->
Read
(
strs
);
for
(
const
std
::
string
&
str
:
strs
)
{
for
(
const
std
::
string
&
str
:
strs
)
{
std
::
vector
<
std
::
string
>
arr
;
std
::
istringstream
in
(
str
);
copy
(
std
::
istream_iterator
<
std
::
string
>
(
in
),
std
::
istream_iterator
<
std
::
string
>
(),
back_inserter
(
arr
));
std
::
vector
<
float
>
nums
;
for
(
size_t
i
=
2
;
i
<
arr
.
size
();
i
++
)
{
for
(
size_t
i
=
2
;
i
<
arr
.
size
();
i
++
)
{
nums
.
push_back
(
std
::
stof
(
arr
[
i
]));
}
this
->
InsertSparseValue
(
arr
[
0
],
arr
[
1
],
nums
);
...
...
kvdb/src/paddle_rocksdb.cpp
浏览文件 @
d7fd7c8d
...
...
@@ -28,7 +28,7 @@ std::string RocksDBWrapper::Get(std::string key) {
options
.
verify_checksums
=
true
;
std
::
string
result
;
rocksdb
::
Status
s
=
db_
->
Get
(
options
,
key
,
&
result
);
if
(
s
.
IsNotFound
())
{
if
(
s
.
IsNotFound
())
{
result
=
"NOT_FOUND"
;
}
return
result
;
...
...
@@ -37,7 +37,7 @@ std::string RocksDBWrapper::Get(std::string key) {
bool
RocksDBWrapper
::
Put
(
std
::
string
key
,
std
::
string
value
)
{
rocksdb
::
WriteOptions
options
;
rocksdb
::
Status
s
=
db_
->
Put
(
options
,
key
,
value
);
if
(
s
.
ok
())
{
if
(
s
.
ok
())
{
return
true
;
}
else
{
return
false
;
...
...
kvdb/src/param_dict_mgr_impl.cpp
浏览文件 @
d7fd7c8d
...
...
@@ -15,7 +15,7 @@
#include "kvdb/kvdb_impl.h"
void
ParamDictMgr
::
UpdateAll
()
{
for
(
auto
it
=
this
->
ParamDictMap
.
begin
();
it
!=
this
->
ParamDictMap
.
end
();
++
it
)
{
for
(
auto
it
=
this
->
ParamDictMap
.
begin
();
it
!=
this
->
ParamDictMap
.
end
();
++
it
)
{
it
->
second
->
UpdateBaseModel
();
}
...
...
kvdb/src/test_rocksdb.cpp
浏览文件 @
d7fd7c8d
...
...
@@ -26,10 +26,10 @@ void test_rockskvdb() {
void
test_rocksdbwrapper
()
{
std
::
shared_ptr
<
RocksDBWrapper
>
db
=
RocksDBWrapper
::
RocksDBWrapperFactory
(
"TEST"
);
for
(
size_t
i
=
0
;
i
<
1000
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
1000
;
i
++
)
{
db
->
Put
(
std
::
to_string
(
i
),
std
::
to_string
(
i
*
2
));
}
for
(
size_t
i
=
0
;
i
<
1000
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
1000
;
i
++
)
{
std
::
string
res
=
db
->
Get
(
std
::
to_string
(
i
));
std
::
cout
<<
res
<<
" "
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录