Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
milvus
提交
ded5dbf9
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,发现更多精彩内容 >>
提交
ded5dbf9
编写于
9月 09, 2019
作者:
S
starlord
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add testcase for meta
Former-commit-id: 3e4df983fd97bfd8cae1571393e217ff8fc200e6
上级
4be7f73a
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
239 addition
and
37 deletion
+239
-37
cpp/src/db/DBImpl.cpp
cpp/src/db/DBImpl.cpp
+1
-1
cpp/src/db/meta/Meta.h
cpp/src/db/meta/Meta.h
+1
-1
cpp/src/db/meta/MySQLMetaImpl.cpp
cpp/src/db/meta/MySQLMetaImpl.cpp
+15
-20
cpp/src/db/meta/MySQLMetaImpl.h
cpp/src/db/meta/MySQLMetaImpl.h
+1
-1
cpp/src/db/meta/SqliteMetaImpl.cpp
cpp/src/db/meta/SqliteMetaImpl.cpp
+1
-1
cpp/src/db/meta/SqliteMetaImpl.h
cpp/src/db/meta/SqliteMetaImpl.h
+1
-1
cpp/src/server/grpc_impl/GrpcRequestTask.cpp
cpp/src/server/grpc_impl/GrpcRequestTask.cpp
+11
-1
cpp/unittest/db/meta_tests.cpp
cpp/unittest/db/meta_tests.cpp
+105
-5
cpp/unittest/db/mysql_meta_test.cpp
cpp/unittest/db/mysql_meta_test.cpp
+103
-6
未找到文件。
cpp/src/db/DBImpl.cpp
浏览文件 @
ded5dbf9
...
...
@@ -257,7 +257,7 @@ Status DBImpl::CreateIndex(const std::string& table_id, const TableIndex& index)
if
(
!
utils
::
IsSameIndex
(
old_index
,
new_index
))
{
DropIndex
(
table_id
);
status
=
meta_ptr_
->
UpdateTableIndex
Param
(
table_id
,
new_index
);
status
=
meta_ptr_
->
UpdateTableIndex
(
table_id
,
new_index
);
if
(
!
status
.
ok
())
{
ENGINE_LOG_ERROR
<<
"Failed to update table index info for table: "
<<
table_id
;
return
status
;
...
...
cpp/src/db/meta/Meta.h
浏览文件 @
ded5dbf9
...
...
@@ -32,7 +32,7 @@ class Meta {
virtual
Status
AllTables
(
std
::
vector
<
TableSchema
>
&
table_schema_array
)
=
0
;
virtual
Status
UpdateTableIndex
Param
(
const
std
::
string
&
table_id
,
const
TableIndex
&
index
)
=
0
;
virtual
Status
UpdateTableIndex
(
const
std
::
string
&
table_id
,
const
TableIndex
&
index
)
=
0
;
virtual
Status
UpdateTableFlag
(
const
std
::
string
&
table_id
,
int64_t
flag
)
=
0
;
...
...
cpp/src/db/meta/MySQLMetaImpl.cpp
浏览文件 @
ded5dbf9
...
...
@@ -419,7 +419,7 @@ Status MySQLMetaImpl::FilesByType(const std::string &table_id,
return
Status
::
OK
();
}
Status
MySQLMetaImpl
::
UpdateTableIndex
Param
(
const
std
::
string
&
table_id
,
const
TableIndex
&
index
)
{
Status
MySQLMetaImpl
::
UpdateTableIndex
(
const
std
::
string
&
table_id
,
const
TableIndex
&
index
)
{
try
{
server
::
MetricCollector
metric
;
...
...
@@ -436,7 +436,7 @@ Status MySQLMetaImpl::UpdateTableIndexParam(const std::string &table_id, const T
"WHERE table_id = "
<<
quote
<<
table_id
<<
" AND "
<<
"state <> "
<<
std
::
to_string
(
TableSchema
::
TO_DELETE
)
<<
";"
;
ENGINE_LOG_DEBUG
<<
"MySQLMetaImpl::UpdateTableIndex
Param
: "
<<
updateTableIndexParamQuery
.
str
();
ENGINE_LOG_DEBUG
<<
"MySQLMetaImpl::UpdateTableIndex: "
<<
updateTableIndexParamQuery
.
str
();
StoreQueryResult
res
=
updateTableIndexParamQuery
.
store
();
...
...
@@ -453,12 +453,12 @@ Status MySQLMetaImpl::UpdateTableIndexParam(const std::string &table_id, const T
"state = "
<<
state
<<
", "
<<
"dimension = "
<<
dimension
<<
", "
<<
"created_on = "
<<
created_on
<<
", "
<<
"engine_type
_
= "
<<
index
.
engine_type_
<<
", "
<<
"engine_type = "
<<
index
.
engine_type_
<<
", "
<<
"nlist = "
<<
index
.
nlist_
<<
", "
<<
"metric_type = "
<<
index
.
metric_type_
<<
" "
<<
"WHERE id = "
<<
quote
<<
table_id
<<
";"
;
"WHERE
table_
id = "
<<
quote
<<
table_id
<<
";"
;
ENGINE_LOG_DEBUG
<<
"MySQLMetaImpl::UpdateTableIndex
Param
: "
<<
updateTableIndexParamQuery
.
str
();
ENGINE_LOG_DEBUG
<<
"MySQLMetaImpl::UpdateTableIndex: "
<<
updateTableIndexParamQuery
.
str
();
if
(
!
updateTableIndexParamQuery
.
exec
())
{
...
...
@@ -497,7 +497,7 @@ Status MySQLMetaImpl::UpdateTableFlag(const std::string &table_id, int64_t flag)
Query
updateTableFlagQuery
=
connectionPtr
->
query
();
updateTableFlagQuery
<<
"UPDATE Tables "
<<
"SET flag = "
<<
flag
<<
" "
<<
"WHERE id = "
<<
quote
<<
table_id
<<
";"
;
"WHERE
table_
id = "
<<
quote
<<
table_id
<<
";"
;
ENGINE_LOG_DEBUG
<<
"MySQLMetaImpl::UpdateTableFlag: "
<<
updateTableFlagQuery
.
str
();
...
...
@@ -608,7 +608,7 @@ Status MySQLMetaImpl::DropTableIndex(const std::string &table_id) {
//set table index type to raw
dropTableIndexQuery
<<
"UPDATE Tables "
<<
"SET engine_type = "
<<
std
::
to_string
(
DEFAULT_ENGINE_TYPE
)
<<
","
<<
"nlist = "
<<
std
::
to_string
(
DEFAULT_NLIST
)
<<
" "
<<
"nlist = "
<<
std
::
to_string
(
DEFAULT_NLIST
)
<<
"
,
"
<<
"metric_type = "
<<
std
::
to_string
(
DEFAULT_METRIC_TYPE
)
<<
" "
<<
"WHERE table_id = "
<<
quote
<<
table_id
<<
";"
;
...
...
@@ -725,7 +725,8 @@ Status MySQLMetaImpl::DescribeTable(TableSchema &table_schema) {
}
Query
describeTableQuery
=
connectionPtr
->
query
();
describeTableQuery
<<
"SELECT id, state, dimension, engine_type, nlist, index_file_size, metric_type "
<<
describeTableQuery
<<
"SELECT id, state, dimension, created_on, "
<<
"flag, index_file_size, engine_type, nlist, metric_type "
<<
"FROM Tables "
<<
"WHERE table_id = "
<<
quote
<<
table_schema
.
table_id_
<<
" "
<<
"AND state <> "
<<
std
::
to_string
(
TableSchema
::
TO_DELETE
)
<<
";"
;
...
...
@@ -744,6 +745,10 @@ Status MySQLMetaImpl::DescribeTable(TableSchema &table_schema) {
table_schema
.
dimension_
=
resRow
[
"dimension"
];
table_schema
.
created_on_
=
resRow
[
"created_on"
];
table_schema
.
flag_
=
resRow
[
"flag"
];
table_schema
.
index_file_size_
=
resRow
[
"index_file_size"
];
table_schema
.
engine_type_
=
resRow
[
"engine_type"
];
...
...
@@ -1927,7 +1932,7 @@ Status MySQLMetaImpl::Count(const std::string &table_id, uint64_t &result) {
Query
countQuery
=
connectionPtr
->
query
();
countQuery
<<
"SELECT
size
"
<<
countQuery
<<
"SELECT
row_count
"
<<
"FROM TableFiles "
<<
"WHERE table_id = "
<<
quote
<<
table_id
<<
" AND "
<<
"(file_type = "
<<
std
::
to_string
(
TableFileSchema
::
RAW
)
<<
" OR "
<<
...
...
@@ -1941,20 +1946,10 @@ Status MySQLMetaImpl::Count(const std::string &table_id, uint64_t &result) {
result
=
0
;
for
(
auto
&
resRow
:
res
)
{
size_t
size
=
resRow
[
"
size
"
];
size_t
size
=
resRow
[
"
row_count
"
];
result
+=
size
;
}
if
(
table_schema
.
dimension_
<=
0
)
{
std
::
stringstream
errorMsg
;
errorMsg
<<
"MySQLMetaImpl::Count: "
<<
"table dimension = "
<<
std
::
to_string
(
table_schema
.
dimension_
)
<<
", table_id = "
<<
table_id
;
ENGINE_LOG_ERROR
<<
errorMsg
.
str
();
return
Status
(
DB_ERROR
,
errorMsg
.
str
());
}
result
/=
table_schema
.
dimension_
;
result
/=
sizeof
(
float
);
}
catch
(
const
BadQuery
&
e
)
{
// Handle any query errors
return
HandleException
(
"GENERAL ERROR WHEN RETRIEVING COUNT"
,
e
.
what
());
...
...
cpp/src/db/meta/MySQLMetaImpl.h
浏览文件 @
ded5dbf9
...
...
@@ -51,7 +51,7 @@ class MySQLMetaImpl : public Meta {
const
std
::
vector
<
int
>
&
file_types
,
std
::
vector
<
std
::
string
>
&
file_ids
)
override
;
Status
UpdateTableIndex
Param
(
const
std
::
string
&
table_id
,
const
TableIndex
&
index
)
override
;
Status
UpdateTableIndex
(
const
std
::
string
&
table_id
,
const
TableIndex
&
index
)
override
;
Status
UpdateTableFlag
(
const
std
::
string
&
table_id
,
int64_t
flag
);
...
...
cpp/src/db/meta/SqliteMetaImpl.cpp
浏览文件 @
ded5dbf9
...
...
@@ -339,7 +339,7 @@ Status SqliteMetaImpl::FilesByType(const std::string& table_id,
return
Status
::
OK
();
}
Status
SqliteMetaImpl
::
UpdateTableIndex
Param
(
const
std
::
string
&
table_id
,
const
TableIndex
&
index
)
{
Status
SqliteMetaImpl
::
UpdateTableIndex
(
const
std
::
string
&
table_id
,
const
TableIndex
&
index
)
{
try
{
server
::
MetricCollector
metric
;
...
...
cpp/src/db/meta/SqliteMetaImpl.h
浏览文件 @
ded5dbf9
...
...
@@ -46,7 +46,7 @@ class SqliteMetaImpl : public Meta {
const
std
::
vector
<
int
>
&
file_types
,
std
::
vector
<
std
::
string
>
&
file_ids
)
override
;
Status
UpdateTableIndex
Param
(
const
std
::
string
&
table_id
,
const
TableIndex
&
index
)
override
;
Status
UpdateTableIndex
(
const
std
::
string
&
table_id
,
const
TableIndex
&
index
)
override
;
Status
UpdateTableFlag
(
const
std
::
string
&
table_id
,
int64_t
flag
)
override
;
...
...
cpp/src/server/grpc_impl/GrpcRequestTask.cpp
浏览文件 @
ded5dbf9
...
...
@@ -953,8 +953,18 @@ DropIndexTask::OnExecute() {
return
SetError
(
res
,
"Invalid table name: "
+
table_name_
);
}
bool
has_table
=
false
;
auto
stat
=
DBWrapper
::
DB
()
->
HasTable
(
table_name_
,
has_table
);
if
(
!
stat
.
ok
())
{
return
SetError
(
DB_META_TRANSACTION_FAILED
,
stat
.
ToString
());
}
if
(
!
has_table
)
{
return
SetError
(
SERVER_TABLE_NOT_EXIST
,
"Table "
+
table_name_
+
" not exists"
);
}
//step 2: check table existence
auto
stat
=
DBWrapper
::
DB
()
->
DropIndex
(
table_name_
);
stat
=
DBWrapper
::
DB
()
->
DropIndex
(
table_name_
);
if
(
!
stat
.
ok
())
{
return
SetError
(
DB_META_TRANSACTION_FAILED
,
stat
.
ToString
());
}
...
...
cpp/unittest/db/meta_tests.cpp
浏览文件 @
ded5dbf9
...
...
@@ -213,14 +213,36 @@ TEST_F(MetaTest, TABLE_FILES_TEST) {
table
.
table_id_
=
table_id
;
auto
status
=
impl_
->
CreateTable
(
table
);
int
new_files_cnt
=
4
;
int
raw_files_cnt
=
5
;
int
to_index_files_cnt
=
6
;
int
index_files_cnt
=
7
;
uint64_t
new_merge_files_cnt
=
1
;
uint64_t
new_index_files_cnt
=
2
;
uint64_t
backup_files_cnt
=
3
;
uint64_t
new_files_cnt
=
4
;
uint64_t
raw_files_cnt
=
5
;
uint64_t
to_index_files_cnt
=
6
;
uint64_t
index_files_cnt
=
7
;
meta
::
TableFileSchema
table_file
;
table_file
.
table_id_
=
table
.
table_id_
;
for
(
auto
i
=
0
;
i
<
new_merge_files_cnt
;
++
i
)
{
status
=
impl_
->
CreateTableFile
(
table_file
);
table_file
.
file_type_
=
meta
::
TableFileSchema
::
NEW_MERGE
;
status
=
impl_
->
UpdateTableFile
(
table_file
);
}
for
(
auto
i
=
0
;
i
<
new_index_files_cnt
;
++
i
)
{
status
=
impl_
->
CreateTableFile
(
table_file
);
table_file
.
file_type_
=
meta
::
TableFileSchema
::
NEW_INDEX
;
status
=
impl_
->
UpdateTableFile
(
table_file
);
}
for
(
auto
i
=
0
;
i
<
backup_files_cnt
;
++
i
)
{
status
=
impl_
->
CreateTableFile
(
table_file
);
table_file
.
file_type_
=
meta
::
TableFileSchema
::
BACKUP
;
table_file
.
row_count_
=
1
;
status
=
impl_
->
UpdateTableFile
(
table_file
);
}
for
(
auto
i
=
0
;
i
<
new_files_cnt
;
++
i
)
{
status
=
impl_
->
CreateTableFile
(
table_file
);
table_file
.
file_type_
=
meta
::
TableFileSchema
::
NEW
;
...
...
@@ -230,23 +252,30 @@ TEST_F(MetaTest, TABLE_FILES_TEST) {
for
(
auto
i
=
0
;
i
<
raw_files_cnt
;
++
i
)
{
status
=
impl_
->
CreateTableFile
(
table_file
);
table_file
.
file_type_
=
meta
::
TableFileSchema
::
RAW
;
table_file
.
row_count_
=
1
;
status
=
impl_
->
UpdateTableFile
(
table_file
);
}
for
(
auto
i
=
0
;
i
<
to_index_files_cnt
;
++
i
)
{
status
=
impl_
->
CreateTableFile
(
table_file
);
table_file
.
file_type_
=
meta
::
TableFileSchema
::
TO_INDEX
;
table_file
.
row_count_
=
1
;
status
=
impl_
->
UpdateTableFile
(
table_file
);
}
for
(
auto
i
=
0
;
i
<
index_files_cnt
;
++
i
)
{
status
=
impl_
->
CreateTableFile
(
table_file
);
table_file
.
file_type_
=
meta
::
TableFileSchema
::
INDEX
;
table_file
.
row_count_
=
1
;
status
=
impl_
->
UpdateTableFile
(
table_file
);
}
meta
::
TableFilesSchema
files
;
uint64_t
total_row_count
=
0
;
status
=
impl_
->
Count
(
table_id
,
total_row_count
);
ASSERT_TRUE
(
status
.
ok
());
ASSERT_EQ
(
total_row_count
,
raw_files_cnt
+
to_index_files_cnt
+
index_files_cnt
);
meta
::
TableFilesSchema
files
;
status
=
impl_
->
FilesToIndex
(
files
);
ASSERT_TRUE
(
status
.
ok
());
ASSERT_EQ
(
files
.
size
(),
to_index_files_cnt
);
...
...
@@ -281,4 +310,75 @@ TEST_F(MetaTest, TABLE_FILES_TEST) {
status
=
impl_
->
FilesToSearch
(
table_id
,
ids
,
dates
,
dated_files
);
ASSERT_TRUE
(
status
.
ok
());
ASSERT_EQ
(
dated_files
[
table_file
.
date_
].
size
(),
0
);
std
::
vector
<
int
>
file_types
;
std
::
vector
<
std
::
string
>
file_ids
;
status
=
impl_
->
FilesByType
(
table
.
table_id_
,
file_types
,
file_ids
);
ASSERT_TRUE
(
file_ids
.
empty
());
ASSERT_FALSE
(
status
.
ok
());
file_types
=
{
meta
::
TableFileSchema
::
NEW
,
meta
::
TableFileSchema
::
NEW_MERGE
,
meta
::
TableFileSchema
::
NEW_INDEX
,
meta
::
TableFileSchema
::
TO_INDEX
,
meta
::
TableFileSchema
::
INDEX
,
meta
::
TableFileSchema
::
RAW
,
meta
::
TableFileSchema
::
BACKUP
,
};
status
=
impl_
->
FilesByType
(
table
.
table_id_
,
file_types
,
file_ids
);
ASSERT_TRUE
(
status
.
ok
());
uint64_t
total_cnt
=
new_index_files_cnt
+
new_merge_files_cnt
+
backup_files_cnt
+
new_files_cnt
+
raw_files_cnt
+
to_index_files_cnt
+
index_files_cnt
;
ASSERT_EQ
(
file_ids
.
size
(),
total_cnt
);
status
=
impl_
->
DeleteTableFiles
(
table_id
);
ASSERT_TRUE
(
status
.
ok
());
status
=
impl_
->
DeleteTable
(
table_id
);
ASSERT_TRUE
(
status
.
ok
());
status
=
impl_
->
CleanUpFilesWithTTL
(
1UL
);
ASSERT_TRUE
(
status
.
ok
());
}
TEST_F
(
MetaTest
,
INDEX_TEST
)
{
auto
table_id
=
"index_test"
;
meta
::
TableSchema
table
;
table
.
table_id_
=
table_id
;
auto
status
=
impl_
->
CreateTable
(
table
);
TableIndex
index
;
index
.
metric_type_
=
2
;
index
.
nlist_
=
1234
;
index
.
engine_type_
=
3
;
status
=
impl_
->
UpdateTableIndex
(
table_id
,
index
);
ASSERT_TRUE
(
status
.
ok
());
int64_t
flag
=
65536
;
status
=
impl_
->
UpdateTableFlag
(
table_id
,
flag
);
ASSERT_TRUE
(
status
.
ok
());
engine
::
meta
::
TableSchema
table_info
;
table_info
.
table_id_
=
table_id
;
status
=
impl_
->
DescribeTable
(
table_info
);
ASSERT_EQ
(
table_info
.
flag_
,
flag
);
TableIndex
index_out
;
status
=
impl_
->
DescribeTableIndex
(
table_id
,
index_out
);
ASSERT_EQ
(
index_out
.
metric_type_
,
index
.
metric_type_
);
ASSERT_EQ
(
index_out
.
nlist_
,
index
.
nlist_
);
ASSERT_EQ
(
index_out
.
engine_type_
,
index
.
engine_type_
);
status
=
impl_
->
DropTableIndex
(
table_id
);
ASSERT_TRUE
(
status
.
ok
());
status
=
impl_
->
DescribeTableIndex
(
table_id
,
index_out
);
ASSERT_NE
(
index_out
.
metric_type_
,
index
.
metric_type_
);
ASSERT_NE
(
index_out
.
nlist_
,
index
.
nlist_
);
ASSERT_NE
(
index_out
.
engine_type_
,
index
.
engine_type_
);
status
=
impl_
->
UpdateTableFilesToIndex
(
table_id
);
ASSERT_TRUE
(
status
.
ok
());
}
\ No newline at end of file
cpp/unittest/db/mysql_meta_test.cpp
浏览文件 @
ded5dbf9
...
...
@@ -238,14 +238,36 @@ TEST_F(MySqlMetaTest, TABLE_FILES_TEST) {
table
.
table_id_
=
table_id
;
auto
status
=
impl_
->
CreateTable
(
table
);
int
new_files_cnt
=
4
;
int
raw_files_cnt
=
5
;
int
to_index_files_cnt
=
6
;
int
index_files_cnt
=
7
;
uint64_t
new_merge_files_cnt
=
1
;
uint64_t
new_index_files_cnt
=
2
;
uint64_t
backup_files_cnt
=
3
;
uint64_t
new_files_cnt
=
4
;
uint64_t
raw_files_cnt
=
5
;
uint64_t
to_index_files_cnt
=
6
;
uint64_t
index_files_cnt
=
7
;
meta
::
TableFileSchema
table_file
;
table_file
.
table_id_
=
table
.
table_id_
;
for
(
auto
i
=
0
;
i
<
new_merge_files_cnt
;
++
i
)
{
status
=
impl_
->
CreateTableFile
(
table_file
);
table_file
.
file_type_
=
meta
::
TableFileSchema
::
NEW_MERGE
;
status
=
impl_
->
UpdateTableFile
(
table_file
);
}
for
(
auto
i
=
0
;
i
<
new_index_files_cnt
;
++
i
)
{
status
=
impl_
->
CreateTableFile
(
table_file
);
table_file
.
file_type_
=
meta
::
TableFileSchema
::
NEW_INDEX
;
status
=
impl_
->
UpdateTableFile
(
table_file
);
}
for
(
auto
i
=
0
;
i
<
backup_files_cnt
;
++
i
)
{
status
=
impl_
->
CreateTableFile
(
table_file
);
table_file
.
file_type_
=
meta
::
TableFileSchema
::
BACKUP
;
table_file
.
row_count_
=
1
;
status
=
impl_
->
UpdateTableFile
(
table_file
);
}
for
(
auto
i
=
0
;
i
<
new_files_cnt
;
++
i
)
{
status
=
impl_
->
CreateTableFile
(
table_file
);
table_file
.
file_type_
=
meta
::
TableFileSchema
::
NEW
;
...
...
@@ -255,23 +277,30 @@ TEST_F(MySqlMetaTest, TABLE_FILES_TEST) {
for
(
auto
i
=
0
;
i
<
raw_files_cnt
;
++
i
)
{
status
=
impl_
->
CreateTableFile
(
table_file
);
table_file
.
file_type_
=
meta
::
TableFileSchema
::
RAW
;
table_file
.
row_count_
=
1
;
status
=
impl_
->
UpdateTableFile
(
table_file
);
}
for
(
auto
i
=
0
;
i
<
to_index_files_cnt
;
++
i
)
{
status
=
impl_
->
CreateTableFile
(
table_file
);
table_file
.
file_type_
=
meta
::
TableFileSchema
::
TO_INDEX
;
table_file
.
row_count_
=
1
;
status
=
impl_
->
UpdateTableFile
(
table_file
);
}
for
(
auto
i
=
0
;
i
<
index_files_cnt
;
++
i
)
{
status
=
impl_
->
CreateTableFile
(
table_file
);
table_file
.
file_type_
=
meta
::
TableFileSchema
::
INDEX
;
table_file
.
row_count_
=
1
;
status
=
impl_
->
UpdateTableFile
(
table_file
);
}
meta
::
TableFilesSchema
files
;
uint64_t
total_row_count
=
0
;
status
=
impl_
->
Count
(
table_id
,
total_row_count
);
ASSERT_TRUE
(
status
.
ok
());
ASSERT_EQ
(
total_row_count
,
raw_files_cnt
+
to_index_files_cnt
+
index_files_cnt
);
meta
::
TableFilesSchema
files
;
status
=
impl_
->
FilesToIndex
(
files
);
ASSERT_TRUE
(
status
.
ok
());
ASSERT_EQ
(
files
.
size
(),
to_index_files_cnt
);
...
...
@@ -307,6 +336,74 @@ TEST_F(MySqlMetaTest, TABLE_FILES_TEST) {
ASSERT_TRUE
(
status
.
ok
());
ASSERT_EQ
(
dated_files
[
table_file
.
date_
].
size
(),
0
);
status
=
impl_
->
DropAll
();
std
::
vector
<
int
>
file_types
;
std
::
vector
<
std
::
string
>
file_ids
;
status
=
impl_
->
FilesByType
(
table
.
table_id_
,
file_types
,
file_ids
);
ASSERT_TRUE
(
file_ids
.
empty
());
ASSERT_FALSE
(
status
.
ok
());
file_types
=
{
meta
::
TableFileSchema
::
NEW
,
meta
::
TableFileSchema
::
NEW_MERGE
,
meta
::
TableFileSchema
::
NEW_INDEX
,
meta
::
TableFileSchema
::
TO_INDEX
,
meta
::
TableFileSchema
::
INDEX
,
meta
::
TableFileSchema
::
RAW
,
meta
::
TableFileSchema
::
BACKUP
,
};
status
=
impl_
->
FilesByType
(
table
.
table_id_
,
file_types
,
file_ids
);
ASSERT_TRUE
(
status
.
ok
());
uint64_t
total_cnt
=
new_index_files_cnt
+
new_merge_files_cnt
+
backup_files_cnt
+
new_files_cnt
+
raw_files_cnt
+
to_index_files_cnt
+
index_files_cnt
;
ASSERT_EQ
(
file_ids
.
size
(),
total_cnt
);
status
=
impl_
->
DeleteTableFiles
(
table_id
);
ASSERT_TRUE
(
status
.
ok
());
status
=
impl_
->
DeleteTable
(
table_id
);
ASSERT_TRUE
(
status
.
ok
());
status
=
impl_
->
CleanUpFilesWithTTL
(
1UL
);
ASSERT_TRUE
(
status
.
ok
());
}
TEST_F
(
MySqlMetaTest
,
INDEX_TEST
)
{
auto
table_id
=
"index_test"
;
meta
::
TableSchema
table
;
table
.
table_id_
=
table_id
;
auto
status
=
impl_
->
CreateTable
(
table
);
TableIndex
index
;
index
.
metric_type_
=
2
;
index
.
nlist_
=
1234
;
index
.
engine_type_
=
3
;
status
=
impl_
->
UpdateTableIndex
(
table_id
,
index
);
ASSERT_TRUE
(
status
.
ok
());
int64_t
flag
=
65536
;
status
=
impl_
->
UpdateTableFlag
(
table_id
,
flag
);
ASSERT_TRUE
(
status
.
ok
());
engine
::
meta
::
TableSchema
table_info
;
table_info
.
table_id_
=
table_id
;
status
=
impl_
->
DescribeTable
(
table_info
);
ASSERT_EQ
(
table_info
.
flag_
,
flag
);
TableIndex
index_out
;
status
=
impl_
->
DescribeTableIndex
(
table_id
,
index_out
);
ASSERT_EQ
(
index_out
.
metric_type_
,
index
.
metric_type_
);
ASSERT_EQ
(
index_out
.
nlist_
,
index
.
nlist_
);
ASSERT_EQ
(
index_out
.
engine_type_
,
index
.
engine_type_
);
status
=
impl_
->
DropTableIndex
(
table_id
);
ASSERT_TRUE
(
status
.
ok
());
status
=
impl_
->
DescribeTableIndex
(
table_id
,
index_out
);
ASSERT_NE
(
index_out
.
metric_type_
,
index
.
metric_type_
);
ASSERT_NE
(
index_out
.
nlist_
,
index
.
nlist_
);
ASSERT_NE
(
index_out
.
engine_type_
,
index
.
engine_type_
);
status
=
impl_
->
UpdateTableFilesToIndex
(
table_id
);
ASSERT_TRUE
(
status
.
ok
());
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录