Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
milvus
提交
27d07164
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,发现更多精彩内容 >>
提交
27d07164
编写于
9月 10, 2019
作者:
G
groot
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add unitest case
Former-commit-id: 56cb9b2e7e7c4d283928995e11e12ddc6efe5563
上级
497354ec
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
109 addition
and
10 deletion
+109
-10
cpp/src/db/Utils.cpp
cpp/src/db/Utils.cpp
+1
-1
cpp/src/db/meta/MySQLMetaImpl.cpp
cpp/src/db/meta/MySQLMetaImpl.cpp
+16
-5
cpp/src/db/meta/SqliteMetaImpl.cpp
cpp/src/db/meta/SqliteMetaImpl.cpp
+18
-4
cpp/unittest/db/db_tests.cpp
cpp/unittest/db/db_tests.cpp
+73
-0
cpp/unittest/server/util_test.cpp
cpp/unittest/server/util_test.cpp
+1
-0
未找到文件。
cpp/src/db/Utils.cpp
浏览文件 @
27d07164
...
...
@@ -135,7 +135,7 @@ Status GetTableFilePath(const DBMetaOptions& options, meta::TableFileSchema& tab
}
}
std
::
string
msg
=
"Table file doesn't exist: "
+
table_file
.
file_id_
;
std
::
string
msg
=
"Table file doesn't exist: "
+
file_path
;
ENGINE_LOG_ERROR
<<
msg
;
return
Status
(
DB_ERROR
,
msg
);
}
...
...
cpp/src/db/meta/MySQLMetaImpl.cpp
浏览文件 @
27d07164
...
...
@@ -814,7 +814,6 @@ Status MySQLMetaImpl::CreateTableFile(TableFileSchema &file_schema) {
file_schema
.
engine_type_
=
table_schema
.
engine_type_
;
file_schema
.
nlist_
=
table_schema
.
nlist_
;
file_schema
.
metric_type_
=
table_schema
.
metric_type_
;
utils
::
GetTableFilePath
(
options_
,
file_schema
);
std
::
string
id
=
"NULL"
;
//auto-increment
std
::
string
table_id
=
file_schema
.
table_id_
;
...
...
@@ -924,7 +923,10 @@ Status MySQLMetaImpl::FilesToIndex(TableFilesSchema &files) {
table_file
.
nlist_
=
groups
[
table_file
.
table_id_
].
nlist_
;
table_file
.
metric_type_
=
groups
[
table_file
.
table_id_
].
metric_type_
;
utils
::
GetTableFilePath
(
options_
,
table_file
);
auto
status
=
utils
::
GetTableFilePath
(
options_
,
table_file
);
if
(
!
status
.
ok
())
{
return
status
;
}
files
.
push_back
(
table_file
);
}
...
...
@@ -1027,7 +1029,10 @@ Status MySQLMetaImpl::FilesToSearch(const std::string &table_id,
table_file
.
dimension_
=
table_schema
.
dimension_
;
utils
::
GetTableFilePath
(
options_
,
table_file
);
auto
status
=
utils
::
GetTableFilePath
(
options_
,
table_file
);
if
(
!
status
.
ok
())
{
return
status
;
}
auto
dateItr
=
files
.
find
(
table_file
.
date_
);
if
(
dateItr
==
files
.
end
())
{
...
...
@@ -1113,7 +1118,10 @@ Status MySQLMetaImpl::FilesToMerge(const std::string &table_id,
table_file
.
dimension_
=
table_schema
.
dimension_
;
utils
::
GetTableFilePath
(
options_
,
table_file
);
auto
status
=
utils
::
GetTableFilePath
(
options_
,
table_file
);
if
(
!
status
.
ok
())
{
return
status
;
}
auto
dateItr
=
files
.
find
(
table_file
.
date_
);
if
(
dateItr
==
files
.
end
())
{
...
...
@@ -1203,7 +1211,10 @@ Status MySQLMetaImpl::GetTableFiles(const std::string &table_id,
file_schema
.
dimension_
=
table_schema
.
dimension_
;
utils
::
GetTableFilePath
(
options_
,
file_schema
);
auto
status
=
utils
::
GetTableFilePath
(
options_
,
file_schema
);
if
(
!
status
.
ok
())
{
return
status
;
}
table_files
.
emplace_back
(
file_schema
);
}
...
...
cpp/src/db/meta/SqliteMetaImpl.cpp
浏览文件 @
27d07164
...
...
@@ -614,7 +614,10 @@ Status SqliteMetaImpl::FilesToIndex(TableFilesSchema &files) {
table_file
.
engine_type_
=
std
::
get
<
7
>
(
file
);
table_file
.
created_on_
=
std
::
get
<
8
>
(
file
);
utils
::
GetTableFilePath
(
options_
,
table_file
);
auto
status
=
utils
::
GetTableFilePath
(
options_
,
table_file
);
if
(
!
status
.
ok
())
{
return
status
;
}
auto
groupItr
=
groups
.
find
(
table_file
.
table_id_
);
if
(
groupItr
==
groups
.
end
())
{
TableSchema
table_schema
;
...
...
@@ -707,7 +710,11 @@ Status SqliteMetaImpl::FilesToSearch(const std::string &table_id,
table_file
.
nlist_
=
table_schema
.
nlist_
;
table_file
.
metric_type_
=
table_schema
.
metric_type_
;
utils
::
GetTableFilePath
(
options_
,
table_file
);
auto
status
=
utils
::
GetTableFilePath
(
options_
,
table_file
);
if
(
!
status
.
ok
())
{
return
status
;
}
auto
dateItr
=
files
.
find
(
table_file
.
date_
);
if
(
dateItr
==
files
.
end
())
{
files
[
table_file
.
date_
]
=
TableFilesSchema
();
...
...
@@ -773,7 +780,11 @@ Status SqliteMetaImpl::FilesToMerge(const std::string &table_id,
table_file
.
nlist_
=
table_schema
.
nlist_
;
table_file
.
metric_type_
=
table_schema
.
metric_type_
;
utils
::
GetTableFilePath
(
options_
,
table_file
);
auto
status
=
utils
::
GetTableFilePath
(
options_
,
table_file
);
if
(
!
status
.
ok
())
{
return
status
;
}
auto
dateItr
=
files
.
find
(
table_file
.
date_
);
if
(
dateItr
==
files
.
end
())
{
files
[
table_file
.
date_
]
=
TableFilesSchema
();
...
...
@@ -827,7 +838,10 @@ Status SqliteMetaImpl::GetTableFiles(const std::string& table_id,
file_schema
.
nlist_
=
table_schema
.
nlist_
;
file_schema
.
metric_type_
=
table_schema
.
metric_type_
;
utils
::
GetTableFilePath
(
options_
,
file_schema
);
auto
status
=
utils
::
GetTableFilePath
(
options_
,
file_schema
);
if
(
!
status
.
ok
())
{
return
status
;
}
table_files
.
emplace_back
(
file_schema
);
}
...
...
cpp/unittest/db/db_tests.cpp
浏览文件 @
27d07164
...
...
@@ -315,6 +315,79 @@ TEST_F(DBTest, PRELOADTABLE_TEST) {
}
TEST_F
(
DBTest
,
SHUTDOWN_TEST
)
{
db_
->
Stop
();
engine
::
meta
::
TableSchema
table_info
=
BuildTableSchema
();
engine
::
Status
stat
=
db_
->
CreateTable
(
table_info
);
ASSERT_FALSE
(
stat
.
ok
());
stat
=
db_
->
DescribeTable
(
table_info
);
ASSERT_FALSE
(
stat
.
ok
());
bool
has_table
=
false
;
stat
=
db_
->
HasTable
(
table_info
.
table_id_
,
has_table
);
ASSERT_FALSE
(
stat
.
ok
());
engine
::
IDNumbers
ids
;
stat
=
db_
->
InsertVectors
(
table_info
.
table_id_
,
0
,
nullptr
,
ids
);
ASSERT_FALSE
(
stat
.
ok
());
stat
=
db_
->
PreloadTable
(
table_info
.
table_id_
);
ASSERT_FALSE
(
stat
.
ok
());
uint64_t
row_count
=
0
;
stat
=
db_
->
GetTableRowCount
(
table_info
.
table_id_
,
row_count
);
ASSERT_FALSE
(
stat
.
ok
());
engine
::
TableIndex
index
;
stat
=
db_
->
CreateIndex
(
table_info
.
table_id_
,
index
);
ASSERT_FALSE
(
stat
.
ok
());
stat
=
db_
->
DescribeIndex
(
table_info
.
table_id_
,
index
);
ASSERT_FALSE
(
stat
.
ok
());
engine
::
meta
::
DatesT
dates
;
engine
::
QueryResults
results
;
stat
=
db_
->
Query
(
table_info
.
table_id_
,
1
,
1
,
1
,
nullptr
,
dates
,
results
);
ASSERT_FALSE
(
stat
.
ok
());
std
::
vector
<
std
::
string
>
file_ids
;
stat
=
db_
->
Query
(
table_info
.
table_id_
,
file_ids
,
1
,
1
,
1
,
nullptr
,
dates
,
results
);
ASSERT_FALSE
(
stat
.
ok
());
stat
=
db_
->
DeleteTable
(
table_info
.
table_id_
,
dates
);
ASSERT_FALSE
(
stat
.
ok
());
}
TEST_F
(
DBTest
,
INDEX_TEST
)
{
engine
::
meta
::
TableSchema
table_info
=
BuildTableSchema
();
engine
::
Status
stat
=
db_
->
CreateTable
(
table_info
);
int64_t
nb
=
VECTOR_COUNT
;
std
::
vector
<
float
>
xb
;
BuildVectors
(
nb
,
xb
);
engine
::
IDNumbers
vector_ids
;
db_
->
InsertVectors
(
TABLE_NAME
,
nb
,
xb
.
data
(),
vector_ids
);
ASSERT_EQ
(
vector_ids
.
size
(),
nb
);
engine
::
TableIndex
index
;
index
.
engine_type_
=
(
int
)
engine
::
EngineType
::
FAISS_IVFSQ8
;
index
.
metric_type_
=
(
int
)
engine
::
MetricType
::
IP
;
stat
=
db_
->
CreateIndex
(
table_info
.
table_id_
,
index
);
ASSERT_TRUE
(
stat
.
ok
());
engine
::
TableIndex
index_out
;
stat
=
db_
->
DescribeIndex
(
table_info
.
table_id_
,
index
);
ASSERT_TRUE
(
stat
.
ok
());
ASSERT_EQ
(
index
.
engine_type_
,
index_out
.
engine_type_
);
ASSERT_EQ
(
index
.
nlist_
,
index_out
.
nlist_
);
ASSERT_EQ
(
index
.
metric_type_
,
index_out
.
metric_type_
);
stat
=
db_
->
DropIndex
(
table_info
.
table_id_
);
ASSERT_TRUE
(
stat
.
ok
());
}
TEST_F
(
DBTest2
,
ARHIVE_DISK_CHECK
)
{
engine
::
meta
::
TableSchema
table_info
=
BuildTableSchema
();
...
...
cpp/unittest/server/util_test.cpp
浏览文件 @
27d07164
...
...
@@ -5,6 +5,7 @@
////////////////////////////////////////////////////////////////////////////////
#include <gtest/gtest.h>
#include <thread>
#include <easylogging++.h>
#include "utils/CommonUtil.h"
#include "utils/Error.h"
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录