2019-09-17 02:51:48 +00:00
|
|
|
// Licensed to the Apache Software Foundation (ASF) under one
|
|
|
|
// or more contributor license agreements. See the NOTICE file
|
|
|
|
// distributed with this work for additional information
|
|
|
|
// regarding copyright ownership. The ASF licenses this file
|
|
|
|
// to you under the Apache License, Version 2.0 (the
|
|
|
|
// "License"); you may not use this file except in compliance
|
|
|
|
// with the License. You may obtain a copy of the License at
|
|
|
|
//
|
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
//
|
|
|
|
// Unless required by applicable law or agreed to in writing,
|
|
|
|
// software distributed under the License is distributed on an
|
|
|
|
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
// KIND, either express or implied. See the License for the
|
|
|
|
// specific language governing permissions and limitations
|
|
|
|
// under the License.
|
|
|
|
|
2019-10-08 07:44:03 +00:00
|
|
|
#include "db/Constants.h"
|
2019-11-05 05:35:24 +00:00
|
|
|
#include "db/Utils.h"
|
2019-08-08 07:36:00 +00:00
|
|
|
#include "db/meta/MetaConsts.h"
|
2019-11-05 05:35:24 +00:00
|
|
|
#include "db/meta/SqliteMetaImpl.h"
|
|
|
|
#include "db/utils.h"
|
2019-04-29 07:29:28 +00:00
|
|
|
|
2019-09-20 03:33:10 +00:00
|
|
|
#include <gtest/gtest.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <time.h>
|
2019-11-05 05:35:24 +00:00
|
|
|
#include <thread>
|
2019-09-20 03:33:10 +00:00
|
|
|
|
2019-06-27 10:03:52 +00:00
|
|
|
TEST_F(MetaTest, TABLE_TEST) {
|
|
|
|
auto table_id = "meta_test_table";
|
2019-04-29 07:29:28 +00:00
|
|
|
|
2019-10-10 08:03:29 +00:00
|
|
|
milvus::engine::meta::TableSchema table;
|
2019-06-27 10:03:52 +00:00
|
|
|
table.table_id_ = table_id;
|
|
|
|
auto status = impl_->CreateTable(table);
|
2019-04-29 07:29:28 +00:00
|
|
|
ASSERT_TRUE(status.ok());
|
|
|
|
|
2019-06-27 10:03:52 +00:00
|
|
|
auto gid = table.id_;
|
|
|
|
table.id_ = -1;
|
|
|
|
status = impl_->DescribeTable(table);
|
2019-04-29 07:29:28 +00:00
|
|
|
ASSERT_TRUE(status.ok());
|
2019-06-27 10:03:52 +00:00
|
|
|
ASSERT_EQ(table.id_, gid);
|
|
|
|
ASSERT_EQ(table.table_id_, table_id);
|
2019-04-29 07:29:28 +00:00
|
|
|
|
2019-06-27 10:03:52 +00:00
|
|
|
table.table_id_ = "not_found";
|
|
|
|
status = impl_->DescribeTable(table);
|
2019-04-29 07:29:28 +00:00
|
|
|
ASSERT_TRUE(!status.ok());
|
|
|
|
|
2019-06-27 10:03:52 +00:00
|
|
|
table.table_id_ = table_id;
|
|
|
|
status = impl_->CreateTable(table);
|
2019-10-10 08:03:29 +00:00
|
|
|
ASSERT_EQ(status.code(), milvus::DB_ALREADY_EXIST);
|
2019-06-30 06:20:56 +00:00
|
|
|
|
|
|
|
table.table_id_ = "";
|
|
|
|
status = impl_->CreateTable(table);
|
|
|
|
ASSERT_TRUE(status.ok());
|
2019-04-29 07:29:28 +00:00
|
|
|
}
|
2019-04-29 08:15:32 +00:00
|
|
|
|
2019-06-27 10:03:52 +00:00
|
|
|
TEST_F(MetaTest, TABLE_FILE_TEST) {
|
|
|
|
auto table_id = "meta_test_table";
|
2019-04-29 08:15:32 +00:00
|
|
|
|
2019-10-10 08:03:29 +00:00
|
|
|
milvus::engine::meta::TableSchema table;
|
2019-06-27 10:03:52 +00:00
|
|
|
table.table_id_ = table_id;
|
2019-06-30 06:20:56 +00:00
|
|
|
table.dimension_ = 256;
|
2019-06-27 10:03:52 +00:00
|
|
|
auto status = impl_->CreateTable(table);
|
2019-04-29 08:15:32 +00:00
|
|
|
|
2019-10-10 08:03:29 +00:00
|
|
|
milvus::engine::meta::TableFileSchema table_file;
|
2019-06-27 10:03:52 +00:00
|
|
|
table_file.table_id_ = table.table_id_;
|
2019-05-27 10:12:56 +00:00
|
|
|
status = impl_->CreateTableFile(table_file);
|
2019-04-29 08:15:32 +00:00
|
|
|
ASSERT_TRUE(status.ok());
|
2019-10-10 08:03:29 +00:00
|
|
|
ASSERT_EQ(table_file.file_type_, milvus::engine::meta::TableFileSchema::NEW);
|
2019-04-29 08:15:32 +00:00
|
|
|
|
2019-06-30 06:20:56 +00:00
|
|
|
uint64_t cnt = 0;
|
|
|
|
status = impl_->Count(table_id, cnt);
|
|
|
|
ASSERT_TRUE(status.ok());
|
|
|
|
ASSERT_EQ(cnt, 0UL);
|
|
|
|
|
2019-06-09 07:45:43 +00:00
|
|
|
auto file_id = table_file.file_id_;
|
2019-04-29 08:15:32 +00:00
|
|
|
|
2019-10-10 08:03:29 +00:00
|
|
|
auto new_file_type = milvus::engine::meta::TableFileSchema::INDEX;
|
2019-06-09 07:45:43 +00:00
|
|
|
table_file.file_type_ = new_file_type;
|
2019-04-29 08:15:32 +00:00
|
|
|
|
2019-05-27 10:38:55 +00:00
|
|
|
status = impl_->UpdateTableFile(table_file);
|
2019-04-29 08:15:32 +00:00
|
|
|
ASSERT_TRUE(status.ok());
|
2019-06-09 07:45:43 +00:00
|
|
|
ASSERT_EQ(table_file.file_type_, new_file_type);
|
2019-04-29 08:15:32 +00:00
|
|
|
|
2019-10-10 08:03:29 +00:00
|
|
|
milvus::engine::meta::DatesT dates;
|
|
|
|
dates.push_back(milvus::engine::utils::GetDate());
|
2019-11-07 08:46:31 +00:00
|
|
|
status = impl_->DropDataByDate(table_file.table_id_, dates);
|
2019-08-30 08:39:26 +00:00
|
|
|
ASSERT_TRUE(status.ok());
|
2019-05-19 13:50:24 +00:00
|
|
|
|
2019-05-20 03:33:26 +00:00
|
|
|
dates.clear();
|
2019-09-27 10:57:46 +00:00
|
|
|
for (auto i = 2; i < 10; ++i) {
|
2019-10-10 08:03:29 +00:00
|
|
|
dates.push_back(milvus::engine::utils::GetDateWithDelta(-1 * i));
|
2019-05-20 03:33:26 +00:00
|
|
|
}
|
2019-11-07 08:46:31 +00:00
|
|
|
status = impl_->DropDataByDate(table_file.table_id_, dates);
|
2019-05-20 03:33:26 +00:00
|
|
|
ASSERT_TRUE(status.ok());
|
|
|
|
|
2019-10-10 08:03:29 +00:00
|
|
|
table_file.date_ = milvus::engine::utils::GetDateWithDelta(-2);
|
2019-05-27 10:38:55 +00:00
|
|
|
status = impl_->UpdateTableFile(table_file);
|
2019-05-20 03:33:26 +00:00
|
|
|
ASSERT_TRUE(status.ok());
|
2019-10-10 08:03:29 +00:00
|
|
|
ASSERT_EQ(table_file.date_, milvus::engine::utils::GetDateWithDelta(-2));
|
|
|
|
ASSERT_FALSE(table_file.file_type_ == milvus::engine::meta::TableFileSchema::TO_DELETE);
|
2019-05-20 03:33:26 +00:00
|
|
|
|
|
|
|
dates.clear();
|
2019-06-09 07:45:43 +00:00
|
|
|
dates.push_back(table_file.date_);
|
2019-11-07 08:46:31 +00:00
|
|
|
status = impl_->DropDataByDate(table_file.table_id_, dates);
|
2019-05-20 03:33:26 +00:00
|
|
|
ASSERT_TRUE(status.ok());
|
2019-06-21 08:58:37 +00:00
|
|
|
|
|
|
|
std::vector<size_t> ids = {table_file.id_};
|
2019-10-10 08:03:29 +00:00
|
|
|
milvus::engine::meta::TableFilesSchema files;
|
2019-06-21 08:58:37 +00:00
|
|
|
status = impl_->GetTableFiles(table_file.table_id_, ids, files);
|
2019-05-20 03:33:26 +00:00
|
|
|
ASSERT_TRUE(status.ok());
|
2019-09-10 04:42:51 +00:00
|
|
|
ASSERT_EQ(files.size(), 0UL);
|
2019-04-29 08:15:32 +00:00
|
|
|
}
|
2019-04-29 10:09:24 +00:00
|
|
|
|
2019-05-24 07:35:29 +00:00
|
|
|
TEST_F(MetaTest, ARCHIVE_TEST_DAYS) {
|
|
|
|
srand(time(0));
|
2019-10-10 08:03:29 +00:00
|
|
|
milvus::engine::DBMetaOptions options;
|
2019-09-20 11:29:06 +00:00
|
|
|
options.path_ = "/tmp/milvus_test";
|
2019-09-27 10:57:46 +00:00
|
|
|
unsigned int seed = 1;
|
|
|
|
int days_num = rand_r(&seed) % 100;
|
2019-05-24 07:35:29 +00:00
|
|
|
std::stringstream ss;
|
|
|
|
ss << "days:" << days_num;
|
2019-10-10 08:03:29 +00:00
|
|
|
options.archive_conf_ = milvus::engine::ArchiveConf("delete", ss.str());
|
2019-05-24 07:35:29 +00:00
|
|
|
|
2019-10-10 08:03:29 +00:00
|
|
|
milvus::engine::meta::SqliteMetaImpl impl(options);
|
2019-06-27 10:03:52 +00:00
|
|
|
auto table_id = "meta_test_table";
|
2019-05-24 07:35:29 +00:00
|
|
|
|
2019-10-10 08:03:29 +00:00
|
|
|
milvus::engine::meta::TableSchema table;
|
2019-06-27 10:03:52 +00:00
|
|
|
table.table_id_ = table_id;
|
|
|
|
auto status = impl.CreateTable(table);
|
2019-05-24 07:35:29 +00:00
|
|
|
|
2019-10-10 08:03:29 +00:00
|
|
|
milvus::engine::meta::TableFilesSchema files;
|
|
|
|
milvus::engine::meta::TableFileSchema table_file;
|
2019-06-27 10:03:52 +00:00
|
|
|
table_file.table_id_ = table.table_id_;
|
2019-05-24 07:35:29 +00:00
|
|
|
|
|
|
|
auto cnt = 100;
|
2019-10-10 08:03:29 +00:00
|
|
|
int64_t ts = milvus::engine::utils::GetMicroSecTimeStamp();
|
2019-05-24 07:35:29 +00:00
|
|
|
std::vector<int> days;
|
2019-06-21 08:58:37 +00:00
|
|
|
std::vector<size_t> ids;
|
2019-09-27 10:57:46 +00:00
|
|
|
for (auto i = 0; i < cnt; ++i) {
|
2019-05-27 10:12:56 +00:00
|
|
|
status = impl.CreateTableFile(table_file);
|
2019-10-10 08:03:29 +00:00
|
|
|
table_file.file_type_ = milvus::engine::meta::TableFileSchema::NEW;
|
2019-09-27 10:57:46 +00:00
|
|
|
int day = rand_r(&seed) % (days_num * 2);
|
2019-12-03 02:49:00 +00:00
|
|
|
table_file.created_on_ = ts - day * milvus::engine::meta::DAY * milvus::engine::meta::US_PS - 10000;
|
2019-05-27 10:38:55 +00:00
|
|
|
status = impl.UpdateTableFile(table_file);
|
2019-05-27 10:12:56 +00:00
|
|
|
files.push_back(table_file);
|
2019-05-24 07:35:29 +00:00
|
|
|
days.push_back(day);
|
2019-06-21 08:58:37 +00:00
|
|
|
ids.push_back(table_file.id_);
|
2019-05-24 07:35:29 +00:00
|
|
|
}
|
|
|
|
|
2019-05-27 11:06:42 +00:00
|
|
|
impl.Archive();
|
2019-05-24 07:35:29 +00:00
|
|
|
int i = 0;
|
|
|
|
|
2019-10-10 08:03:29 +00:00
|
|
|
milvus::engine::meta::TableFilesSchema files_get;
|
2019-06-21 08:58:37 +00:00
|
|
|
status = impl.GetTableFiles(table_file.table_id_, ids, files_get);
|
|
|
|
ASSERT_TRUE(status.ok());
|
|
|
|
|
2019-11-05 05:35:24 +00:00
|
|
|
for (auto& file : files_get) {
|
2019-05-24 07:35:29 +00:00
|
|
|
if (days[i] < days_num) {
|
2019-10-10 08:03:29 +00:00
|
|
|
ASSERT_EQ(file.file_type_, milvus::engine::meta::TableFileSchema::NEW);
|
2019-05-24 07:35:29 +00:00
|
|
|
}
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
|
2019-05-27 11:22:58 +00:00
|
|
|
impl.DropAll();
|
2019-05-24 07:35:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
TEST_F(MetaTest, ARCHIVE_TEST_DISK) {
|
2019-10-10 08:03:29 +00:00
|
|
|
milvus::engine::DBMetaOptions options;
|
2019-09-20 11:29:06 +00:00
|
|
|
options.path_ = "/tmp/milvus_test";
|
2019-10-10 08:03:29 +00:00
|
|
|
options.archive_conf_ = milvus::engine::ArchiveConf("delete", "disk:11");
|
2019-05-24 02:56:15 +00:00
|
|
|
|
2019-10-10 08:03:29 +00:00
|
|
|
milvus::engine::meta::SqliteMetaImpl impl(options);
|
2019-05-27 09:30:17 +00:00
|
|
|
auto table_id = "meta_test_group";
|
2019-05-24 02:56:15 +00:00
|
|
|
|
2019-10-10 08:03:29 +00:00
|
|
|
milvus::engine::meta::TableSchema table;
|
2019-06-27 10:03:52 +00:00
|
|
|
table.table_id_ = table_id;
|
|
|
|
auto status = impl.CreateTable(table);
|
2019-05-24 02:56:15 +00:00
|
|
|
|
2019-10-10 08:03:29 +00:00
|
|
|
milvus::engine::meta::TableFilesSchema files;
|
|
|
|
milvus::engine::meta::TableFileSchema table_file;
|
2019-06-27 10:03:52 +00:00
|
|
|
table_file.table_id_ = table.table_id_;
|
2019-05-24 02:56:15 +00:00
|
|
|
|
|
|
|
auto cnt = 10;
|
|
|
|
auto each_size = 2UL;
|
2019-06-21 08:58:37 +00:00
|
|
|
std::vector<size_t> ids;
|
2019-09-27 10:57:46 +00:00
|
|
|
for (auto i = 0; i < cnt; ++i) {
|
2019-05-27 10:12:56 +00:00
|
|
|
status = impl.CreateTableFile(table_file);
|
2019-10-10 08:03:29 +00:00
|
|
|
table_file.file_type_ = milvus::engine::meta::TableFileSchema::NEW;
|
|
|
|
table_file.file_size_ = each_size * milvus::engine::G;
|
2019-05-27 10:38:55 +00:00
|
|
|
status = impl.UpdateTableFile(table_file);
|
2019-05-27 10:12:56 +00:00
|
|
|
files.push_back(table_file);
|
2019-06-21 08:58:37 +00:00
|
|
|
ids.push_back(table_file.id_);
|
2019-05-24 02:56:15 +00:00
|
|
|
}
|
|
|
|
|
2019-05-27 11:06:42 +00:00
|
|
|
impl.Archive();
|
2019-05-24 02:56:15 +00:00
|
|
|
int i = 0;
|
|
|
|
|
2019-10-10 08:03:29 +00:00
|
|
|
milvus::engine::meta::TableFilesSchema files_get;
|
2019-06-21 08:58:37 +00:00
|
|
|
status = impl.GetTableFiles(table_file.table_id_, ids, files_get);
|
|
|
|
ASSERT_TRUE(status.ok());
|
|
|
|
|
2019-11-05 05:35:24 +00:00
|
|
|
for (auto& file : files_get) {
|
2019-09-10 04:42:51 +00:00
|
|
|
if (i >= 5) {
|
2019-10-10 08:03:29 +00:00
|
|
|
ASSERT_EQ(file.file_type_, milvus::engine::meta::TableFileSchema::NEW);
|
2019-05-24 02:56:15 +00:00
|
|
|
}
|
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
2019-05-27 11:22:58 +00:00
|
|
|
impl.DropAll();
|
2019-05-24 02:56:15 +00:00
|
|
|
}
|
|
|
|
|
2019-05-27 10:12:56 +00:00
|
|
|
TEST_F(MetaTest, TABLE_FILES_TEST) {
|
2019-05-27 09:30:17 +00:00
|
|
|
auto table_id = "meta_test_group";
|
2019-04-29 10:09:24 +00:00
|
|
|
|
2019-10-10 08:03:29 +00:00
|
|
|
milvus::engine::meta::TableSchema table;
|
2019-06-27 10:03:52 +00:00
|
|
|
table.table_id_ = table_id;
|
|
|
|
auto status = impl_->CreateTable(table);
|
2019-04-29 10:09:24 +00:00
|
|
|
|
2019-09-09 04:42:40 +00:00
|
|
|
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;
|
2019-04-29 10:09:24 +00:00
|
|
|
|
2019-10-10 08:03:29 +00:00
|
|
|
milvus::engine::meta::TableFileSchema table_file;
|
2019-06-27 10:03:52 +00:00
|
|
|
table_file.table_id_ = table.table_id_;
|
2019-04-29 10:09:24 +00:00
|
|
|
|
2019-09-27 10:57:46 +00:00
|
|
|
for (auto i = 0; i < new_merge_files_cnt; ++i) {
|
2019-09-09 04:42:40 +00:00
|
|
|
status = impl_->CreateTableFile(table_file);
|
2019-10-10 08:03:29 +00:00
|
|
|
table_file.file_type_ = milvus::engine::meta::TableFileSchema::NEW_MERGE;
|
2019-09-09 04:42:40 +00:00
|
|
|
status = impl_->UpdateTableFile(table_file);
|
|
|
|
}
|
|
|
|
|
2019-09-27 10:57:46 +00:00
|
|
|
for (auto i = 0; i < new_index_files_cnt; ++i) {
|
2019-09-09 04:42:40 +00:00
|
|
|
status = impl_->CreateTableFile(table_file);
|
2019-10-10 08:03:29 +00:00
|
|
|
table_file.file_type_ = milvus::engine::meta::TableFileSchema::NEW_INDEX;
|
2019-09-09 04:42:40 +00:00
|
|
|
status = impl_->UpdateTableFile(table_file);
|
|
|
|
}
|
|
|
|
|
2019-09-27 10:57:46 +00:00
|
|
|
for (auto i = 0; i < backup_files_cnt; ++i) {
|
2019-09-09 04:42:40 +00:00
|
|
|
status = impl_->CreateTableFile(table_file);
|
2019-10-10 08:03:29 +00:00
|
|
|
table_file.file_type_ = milvus::engine::meta::TableFileSchema::BACKUP;
|
2019-09-09 04:42:40 +00:00
|
|
|
table_file.row_count_ = 1;
|
|
|
|
status = impl_->UpdateTableFile(table_file);
|
|
|
|
}
|
|
|
|
|
2019-09-27 10:57:46 +00:00
|
|
|
for (auto i = 0; i < new_files_cnt; ++i) {
|
2019-05-27 10:12:56 +00:00
|
|
|
status = impl_->CreateTableFile(table_file);
|
2019-10-10 08:03:29 +00:00
|
|
|
table_file.file_type_ = milvus::engine::meta::TableFileSchema::NEW;
|
2019-05-27 10:38:55 +00:00
|
|
|
status = impl_->UpdateTableFile(table_file);
|
2019-04-29 10:09:24 +00:00
|
|
|
}
|
|
|
|
|
2019-09-27 10:57:46 +00:00
|
|
|
for (auto i = 0; i < raw_files_cnt; ++i) {
|
2019-05-27 10:12:56 +00:00
|
|
|
status = impl_->CreateTableFile(table_file);
|
2019-10-10 08:03:29 +00:00
|
|
|
table_file.file_type_ = milvus::engine::meta::TableFileSchema::RAW;
|
2019-09-09 04:42:40 +00:00
|
|
|
table_file.row_count_ = 1;
|
2019-05-27 10:38:55 +00:00
|
|
|
status = impl_->UpdateTableFile(table_file);
|
2019-04-29 10:09:24 +00:00
|
|
|
}
|
|
|
|
|
2019-09-27 10:57:46 +00:00
|
|
|
for (auto i = 0; i < to_index_files_cnt; ++i) {
|
2019-05-27 10:12:56 +00:00
|
|
|
status = impl_->CreateTableFile(table_file);
|
2019-10-10 08:03:29 +00:00
|
|
|
table_file.file_type_ = milvus::engine::meta::TableFileSchema::TO_INDEX;
|
2019-09-09 04:42:40 +00:00
|
|
|
table_file.row_count_ = 1;
|
2019-05-27 10:38:55 +00:00
|
|
|
status = impl_->UpdateTableFile(table_file);
|
2019-04-29 10:09:24 +00:00
|
|
|
}
|
|
|
|
|
2019-09-27 10:57:46 +00:00
|
|
|
for (auto i = 0; i < index_files_cnt; ++i) {
|
2019-05-27 10:12:56 +00:00
|
|
|
status = impl_->CreateTableFile(table_file);
|
2019-10-10 08:03:29 +00:00
|
|
|
table_file.file_type_ = milvus::engine::meta::TableFileSchema::INDEX;
|
2019-09-09 04:42:40 +00:00
|
|
|
table_file.row_count_ = 1;
|
2019-05-27 10:38:55 +00:00
|
|
|
status = impl_->UpdateTableFile(table_file);
|
2019-04-29 10:09:24 +00:00
|
|
|
}
|
|
|
|
|
2019-09-09 04:42:40 +00:00
|
|
|
uint64_t total_row_count = 0;
|
|
|
|
status = impl_->Count(table_id, total_row_count);
|
|
|
|
ASSERT_TRUE(status.ok());
|
2019-09-27 10:57:46 +00:00
|
|
|
ASSERT_EQ(total_row_count, raw_files_cnt + to_index_files_cnt + index_files_cnt);
|
2019-04-29 10:09:24 +00:00
|
|
|
|
2019-10-10 08:03:29 +00:00
|
|
|
milvus::engine::meta::TableFilesSchema files;
|
2019-05-27 11:10:49 +00:00
|
|
|
status = impl_->FilesToIndex(files);
|
2019-04-29 10:09:24 +00:00
|
|
|
ASSERT_EQ(files.size(), to_index_files_cnt);
|
|
|
|
|
2019-10-10 08:03:29 +00:00
|
|
|
milvus::engine::meta::DatePartionedTableFilesSchema dated_files;
|
2019-06-27 10:03:52 +00:00
|
|
|
status = impl_->FilesToMerge(table.table_id_, dated_files);
|
2019-06-09 07:45:43 +00:00
|
|
|
ASSERT_EQ(dated_files[table_file.date_].size(), raw_files_cnt);
|
2019-04-29 10:09:24 +00:00
|
|
|
|
2019-05-27 11:10:49 +00:00
|
|
|
status = impl_->FilesToIndex(files);
|
2019-04-29 10:09:24 +00:00
|
|
|
ASSERT_EQ(files.size(), to_index_files_cnt);
|
|
|
|
|
2019-10-10 08:03:29 +00:00
|
|
|
milvus::engine::meta::DatesT dates = {table_file.date_};
|
2019-08-29 11:19:33 +00:00
|
|
|
std::vector<size_t> ids;
|
|
|
|
status = impl_->FilesToSearch(table_id, ids, dates, dated_files);
|
2019-11-05 05:35:24 +00:00
|
|
|
ASSERT_EQ(dated_files[table_file.date_].size(), to_index_files_cnt + raw_files_cnt + index_files_cnt);
|
2019-06-30 07:20:36 +00:00
|
|
|
|
2019-10-10 08:03:29 +00:00
|
|
|
status = impl_->FilesToSearch(table_id, ids, milvus::engine::meta::DatesT(), dated_files);
|
2019-11-05 05:35:24 +00:00
|
|
|
ASSERT_EQ(dated_files[table_file.date_].size(), to_index_files_cnt + raw_files_cnt + index_files_cnt);
|
2019-07-26 09:45:14 +00:00
|
|
|
|
2019-10-10 08:03:29 +00:00
|
|
|
status = impl_->FilesToSearch(table_id, ids, milvus::engine::meta::DatesT(), dated_files);
|
2019-11-05 05:35:24 +00:00
|
|
|
ASSERT_EQ(dated_files[table_file.date_].size(), to_index_files_cnt + raw_files_cnt + index_files_cnt);
|
2019-07-26 09:45:14 +00:00
|
|
|
|
|
|
|
ids.push_back(size_t(9999999999));
|
|
|
|
status = impl_->FilesToSearch(table_id, ids, dates, dated_files);
|
2019-09-27 10:57:46 +00:00
|
|
|
ASSERT_EQ(dated_files[table_file.date_].size(), 0);
|
2019-09-09 04:42:40 +00:00
|
|
|
|
|
|
|
std::vector<int> file_types;
|
2019-11-22 03:28:31 +00:00
|
|
|
milvus::engine::meta::TableFilesSchema table_files;
|
|
|
|
status = impl_->FilesByType(table.table_id_, file_types, table_files);
|
|
|
|
ASSERT_TRUE(table_files.empty());
|
2019-09-09 04:42:40 +00:00
|
|
|
ASSERT_FALSE(status.ok());
|
|
|
|
|
|
|
|
file_types = {
|
2019-11-05 05:35:24 +00:00
|
|
|
milvus::engine::meta::TableFileSchema::NEW, milvus::engine::meta::TableFileSchema::NEW_MERGE,
|
|
|
|
milvus::engine::meta::TableFileSchema::NEW_INDEX, milvus::engine::meta::TableFileSchema::TO_INDEX,
|
|
|
|
milvus::engine::meta::TableFileSchema::INDEX, milvus::engine::meta::TableFileSchema::RAW,
|
2019-10-10 08:03:29 +00:00
|
|
|
milvus::engine::meta::TableFileSchema::BACKUP,
|
2019-09-09 04:42:40 +00:00
|
|
|
};
|
2019-11-22 03:28:31 +00:00
|
|
|
status = impl_->FilesByType(table.table_id_, file_types, table_files);
|
2019-09-09 04:42:40 +00:00
|
|
|
ASSERT_TRUE(status.ok());
|
2019-11-05 05:35:24 +00:00
|
|
|
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;
|
2019-11-22 03:28:31 +00:00
|
|
|
ASSERT_EQ(table_files.size(), total_cnt);
|
2019-09-09 04:42:40 +00:00
|
|
|
|
|
|
|
status = impl_->DeleteTableFiles(table_id);
|
|
|
|
ASSERT_TRUE(status.ok());
|
|
|
|
|
2019-09-10 11:59:50 +00:00
|
|
|
status = impl_->CreateTableFile(table_file);
|
2019-10-10 08:03:29 +00:00
|
|
|
table_file.file_type_ = milvus::engine::meta::TableFileSchema::NEW;
|
2019-09-10 11:59:50 +00:00
|
|
|
status = impl_->UpdateTableFile(table_file);
|
2019-11-26 10:08:15 +00:00
|
|
|
status = impl_->CleanUpShadowFiles();
|
2019-09-10 11:59:50 +00:00
|
|
|
ASSERT_TRUE(status.ok());
|
|
|
|
|
2019-11-07 08:46:31 +00:00
|
|
|
status = impl_->DropTable(table_id);
|
2019-09-09 04:42:40 +00:00
|
|
|
ASSERT_TRUE(status.ok());
|
|
|
|
|
|
|
|
status = impl_->CleanUpFilesWithTTL(1UL);
|
|
|
|
ASSERT_TRUE(status.ok());
|
2019-04-29 10:09:24 +00:00
|
|
|
}
|
2019-09-09 04:42:40 +00:00
|
|
|
|
|
|
|
TEST_F(MetaTest, INDEX_TEST) {
|
|
|
|
auto table_id = "index_test";
|
|
|
|
|
2019-10-10 08:03:29 +00:00
|
|
|
milvus::engine::meta::TableSchema table;
|
2019-09-09 04:42:40 +00:00
|
|
|
table.table_id_ = table_id;
|
|
|
|
auto status = impl_->CreateTable(table);
|
|
|
|
|
2019-10-10 08:03:29 +00:00
|
|
|
milvus::engine::TableIndex index;
|
2019-09-09 04:42:40 +00:00
|
|
|
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());
|
|
|
|
|
2019-10-10 08:03:29 +00:00
|
|
|
milvus::engine::meta::TableSchema table_info;
|
2019-09-09 04:42:40 +00:00
|
|
|
table_info.table_id_ = table_id;
|
|
|
|
status = impl_->DescribeTable(table_info);
|
|
|
|
ASSERT_EQ(table_info.flag_, flag);
|
|
|
|
|
2019-10-10 08:03:29 +00:00
|
|
|
milvus::engine::TableIndex index_out;
|
2019-09-09 04:42:40 +00:00
|
|
|
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);
|
2019-12-05 12:08:15 +00:00
|
|
|
ASSERT_EQ(index_out.metric_type_, index.metric_type_);
|
2019-12-06 08:40:51 +00:00
|
|
|
ASSERT_NE(index_out.nlist_, index.nlist_);
|
2019-09-09 04:42:40 +00:00
|
|
|
ASSERT_NE(index_out.engine_type_, index.engine_type_);
|
|
|
|
|
|
|
|
status = impl_->UpdateTableFilesToIndex(table_id);
|
|
|
|
ASSERT_TRUE(status.ok());
|
2019-09-27 10:57:46 +00:00
|
|
|
}
|