MS-327 clean code

Former-commit-id: 46b960c0a67766c4d67b36826ec88b47ae470206
This commit is contained in:
starlord 2019-08-08 15:36:00 +08:00
parent 1d04dba7bb
commit 39499d2f77
62 changed files with 223 additions and 273 deletions

View File

@ -9,8 +9,10 @@ aux_source_directory(cache cache_files)
aux_source_directory(config config_files)
aux_source_directory(server server_files)
aux_source_directory(utils utils_files)
aux_source_directory(db db_files)
#aux_source_directory(wrapper wrapper_files)
aux_source_directory(db db_main_files)
aux_source_directory(db/engine db_engine_files)
aux_source_directory(db/insert db_insert_files)
aux_source_directory(db/meta db_meta_files)
aux_source_directory(metrics metrics_files)
aux_source_directory(wrapper/knowhere knowhere_files)
@ -33,12 +35,14 @@ set(service_files
server/ThreadPoolServer.h
)
set(engine_files
set(db_files
${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
${cache_files}
${db_files}
${db_main_files}
${db_engine_files}
${db_insert_files}
${db_meta_files}
${db_scheduler_files}
${wrapper_files}
${metrics_files}
${knowhere_files}
)
@ -126,7 +130,7 @@ if (NOT ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64")
endif ()
cuda_add_library(milvus_engine STATIC ${engine_files})
cuda_add_library(milvus_engine STATIC ${db_files})
target_link_libraries(milvus_engine ${engine_libs} ${third_party_libs})
add_library(metrics STATIC ${metrics_files})

View File

@ -5,7 +5,6 @@
******************************************************************************/
#include "DBImpl.h"
#include "DBMetaImpl.h"
#include "Factories.h"
namespace zilliz {

View File

@ -6,7 +6,7 @@
#pragma once
#include "Options.h"
#include "Meta.h"
#include "meta/Meta.h"
#include "Status.h"
#include "Types.h"

View File

@ -4,16 +4,16 @@
* Proprietary and confidential.
******************************************************************************/
#include "DBImpl.h"
#include "DBMetaImpl.h"
#include "src/db/meta/SqliteMetaImpl.h"
#include "Log.h"
#include "EngineFactory.h"
#include "engine/EngineFactory.h"
#include "Factories.h"
#include "metrics/Metrics.h"
#include "scheduler/TaskScheduler.h"
#include "scheduler/context/DeleteContext.h"
#include "utils/TimeRecorder.h"
#include "MetaConsts.h"
#include "meta/MetaConsts.h"
#include <assert.h>
#include <chrono>

View File

@ -8,7 +8,7 @@
#include "DB.h"
#include "Types.h"
#include "utils/ThreadPool.h"
#include "MemManagerAbstract.h"
#include "src/db/insert/MemManager.h"
#include <mutex>
#include <condition_variable>

View File

@ -6,7 +6,7 @@
#include "Factories.h"
#include "DBImpl.h"
#include "NewMemManager.h"
#include "src/db/insert/MemManagerImpl.h"
#include "Exception.h"
#include <stdlib.h>
@ -46,9 +46,9 @@ Options OptionsFactory::Build() {
return options;
}
std::shared_ptr<meta::DBMetaImpl> DBMetaImplFactory::Build() {
std::shared_ptr<meta::SqliteMetaImpl> DBMetaImplFactory::Build() {
DBMetaOptions options = DBMetaOptionsFactory::Build();
return std::shared_ptr<meta::DBMetaImpl>(new meta::DBMetaImpl(options));
return std::shared_ptr<meta::SqliteMetaImpl>(new meta::SqliteMetaImpl(options));
}
std::shared_ptr<meta::Meta> DBMetaImplFactory::Build(const DBMetaOptions& metaOptions,
@ -79,7 +79,7 @@ std::shared_ptr<meta::Meta> DBMetaImplFactory::Build(const DBMetaOptions& metaOp
return std::make_shared<meta::MySQLMetaImpl>(metaOptions, mode);
} else if (dialect.find("sqlite") != std::string::npos) {
ENGINE_LOG_INFO << "Using SQLite";
return std::make_shared<meta::DBMetaImpl>(metaOptions);
return std::make_shared<meta::SqliteMetaImpl>(metaOptions);
} else {
ENGINE_LOG_ERROR << "Invalid dialect in URI: dialect = " << dialect;
throw InvalidArgumentException("URI dialect is not mysql / sqlite");
@ -102,7 +102,7 @@ DB* DBFactory::Build(const Options& options) {
MemManagerAbstractPtr MemManagerFactory::Build(const std::shared_ptr<meta::Meta>& meta,
const Options& options) {
return std::make_shared<NewMemManager>(meta, options);
return std::make_shared<MemManagerImpl>(meta, options);
}
} // namespace engine

View File

@ -6,11 +6,10 @@
#pragma once
#include "DB.h"
#include "DBMetaImpl.h"
#include "MySQLMetaImpl.h"
#include "src/db/meta/SqliteMetaImpl.h"
#include "meta/MySQLMetaImpl.h"
#include "Options.h"
#include "ExecutionEngine.h"
#include "MemManagerAbstract.h"
#include "src/db/insert/MemManager.h"
#include <string>
#include <memory>
@ -29,7 +28,7 @@ struct OptionsFactory {
};
struct DBMetaImplFactory {
static std::shared_ptr<meta::DBMetaImpl> Build();
static std::shared_ptr<meta::SqliteMetaImpl> Build();
static std::shared_ptr<meta::Meta> Build(const DBMetaOptions &metaOptions, const int &mode);
};

View File

@ -9,7 +9,7 @@
#include <boost/algorithm/string.hpp>
#include "Options.h"
#include "DBMetaImpl.h"
#include "db/meta/SqliteMetaImpl.h"
#include "Exception.h"
namespace zilliz {

View File

@ -6,7 +6,7 @@
#pragma once
#include "Options.h"
#include "MetaTypes.h"
#include "db/meta/MetaTypes.h"
#include <string>

View File

@ -6,7 +6,7 @@
#include "EngineFactory.h"
//#include "FaissExecutionEngine.h"
#include "ExecutionEngineImpl.h"
#include "Log.h"
#include "db/Log.h"
namespace zilliz {
namespace milvus {

View File

@ -5,7 +5,7 @@
******************************************************************************/
#pragma once
#include "Status.h"
#include "db/Status.h"
#include "ExecutionEngine.h"
namespace zilliz {

View File

@ -5,7 +5,7 @@
******************************************************************************/
#pragma once
#include "Status.h"
#include "db/Status.h"
#include <vector>
#include <memory>

View File

@ -5,9 +5,9 @@
******************************************************************************/
#include <stdexcept>
#include <src/server/ServerConfig.h>
#include <src/metrics/Metrics.h>
#include "Log.h"
#include "src/server/ServerConfig.h"
#include "src/metrics/Metrics.h"
#include "db/Log.h"
#include "utils/CommonUtil.h"
#include "src/cache/CpuCacheMgr.h"
@ -15,7 +15,7 @@
#include "wrapper/knowhere/vec_index.h"
#include "wrapper/knowhere/vec_impl.h"
#include "knowhere/common/exception.h"
#include "Exception.h"
#include "db/Exception.h"
namespace zilliz {

View File

@ -7,7 +7,7 @@ namespace zilliz {
namespace milvus {
namespace engine {
class MemManagerAbstract {
class MemManager {
public:
virtual Status InsertVectors(const std::string &table_id,
@ -25,7 +25,7 @@ class MemManagerAbstract {
}; // MemManagerAbstract
using MemManagerAbstractPtr = std::shared_ptr<MemManagerAbstract>;
using MemManagerAbstractPtr = std::shared_ptr<MemManager>;
} // namespace engine
} // namespace milvus

View File

@ -1,7 +1,7 @@
#include "NewMemManager.h"
#include "MemManagerImpl.h"
#include "VectorSource.h"
#include "Log.h"
#include "Constants.h"
#include "db/Log.h"
#include "db/Constants.h"
#include <thread>
@ -10,7 +10,7 @@ namespace zilliz {
namespace milvus {
namespace engine {
NewMemManager::MemTablePtr NewMemManager::GetMemByTable(const std::string &table_id) {
MemManagerImpl::MemTablePtr MemManagerImpl::GetMemByTable(const std::string &table_id) {
auto memIt = mem_id_map_.find(table_id);
if (memIt != mem_id_map_.end()) {
return memIt->second;
@ -20,7 +20,7 @@ NewMemManager::MemTablePtr NewMemManager::GetMemByTable(const std::string &table
return mem_id_map_[table_id];
}
Status NewMemManager::InsertVectors(const std::string &table_id_,
Status MemManagerImpl::InsertVectors(const std::string &table_id_,
size_t n_,
const float *vectors_,
IDNumbers &vector_ids_) {
@ -34,7 +34,7 @@ Status NewMemManager::InsertVectors(const std::string &table_id_,
return InsertVectorsNoLock(table_id_, n_, vectors_, vector_ids_);
}
Status NewMemManager::InsertVectorsNoLock(const std::string &table_id,
Status MemManagerImpl::InsertVectorsNoLock(const std::string &table_id,
size_t n,
const float *vectors,
IDNumbers &vector_ids) {
@ -49,7 +49,7 @@ Status NewMemManager::InsertVectorsNoLock(const std::string &table_id,
return status;
}
Status NewMemManager::ToImmutable() {
Status MemManagerImpl::ToImmutable() {
std::unique_lock<std::mutex> lock(mutex_);
MemIdMap temp_map;
for (auto &kv: mem_id_map_) {
@ -65,7 +65,7 @@ Status NewMemManager::ToImmutable() {
return Status::OK();
}
Status NewMemManager::Serialize(std::set<std::string> &table_ids) {
Status MemManagerImpl::Serialize(std::set<std::string> &table_ids) {
ToImmutable();
std::unique_lock<std::mutex> lock(serialization_mtx_);
table_ids.clear();
@ -77,7 +77,7 @@ Status NewMemManager::Serialize(std::set<std::string> &table_ids) {
return Status::OK();
}
Status NewMemManager::EraseMemVector(const std::string &table_id) {
Status MemManagerImpl::EraseMemVector(const std::string &table_id) {
{//erase MemVector from rapid-insert cache
std::unique_lock<std::mutex> lock(mutex_);
mem_id_map_.erase(table_id);
@ -97,7 +97,7 @@ Status NewMemManager::EraseMemVector(const std::string &table_id) {
return Status::OK();
}
size_t NewMemManager::GetCurrentMutableMem() {
size_t MemManagerImpl::GetCurrentMutableMem() {
size_t total_mem = 0;
for (auto &kv : mem_id_map_) {
auto memTable = kv.second;
@ -106,7 +106,7 @@ size_t NewMemManager::GetCurrentMutableMem() {
return total_mem;
}
size_t NewMemManager::GetCurrentImmutableMem() {
size_t MemManagerImpl::GetCurrentImmutableMem() {
size_t total_mem = 0;
for (auto &mem_table : immu_mem_list_) {
total_mem += mem_table->GetCurrentMem();
@ -114,7 +114,7 @@ size_t NewMemManager::GetCurrentImmutableMem() {
return total_mem;
}
size_t NewMemManager::GetCurrentMem() {
size_t MemManagerImpl::GetCurrentMem() {
return GetCurrentMutableMem() + GetCurrentImmutableMem();
}

View File

@ -1,9 +1,9 @@
#pragma once
#include "Meta.h"
#include "db/meta/Meta.h"
#include "MemTable.h"
#include "Status.h"
#include "MemManagerAbstract.h"
#include "db/Status.h"
#include "MemManager.h"
#include <map>
#include <string>
@ -16,13 +16,13 @@ namespace zilliz {
namespace milvus {
namespace engine {
class NewMemManager : public MemManagerAbstract {
class MemManagerImpl : public MemManager {
public:
using MetaPtr = meta::Meta::Ptr;
using Ptr = std::shared_ptr<NewMemManager>;
using Ptr = std::shared_ptr<MemManagerImpl>;
using MemTablePtr = typename MemTable::Ptr;
NewMemManager(const std::shared_ptr<meta::Meta> &meta, const Options &options)
MemManagerImpl(const std::shared_ptr<meta::Meta> &meta, const Options &options)
: meta_(meta), options_(options) {}
Status InsertVectors(const std::string &table_id,

View File

@ -1,5 +1,5 @@
#include "MemTable.h"
#include "Log.h"
#include "db/Log.h"
namespace zilliz {

View File

@ -1,6 +1,6 @@
#pragma once
#include "Status.h"
#include "db/Status.h"
#include "MemTableFile.h"
#include "VectorSource.h"

View File

@ -1,7 +1,7 @@
#include "MemTableFile.h"
#include "Constants.h"
#include "Log.h"
#include "EngineFactory.h"
#include "db/Constants.h"
#include "db/Log.h"
#include "db/engine/EngineFactory.h"
#include "metrics/Metrics.h"
#include <cmath>

View File

@ -1,9 +1,9 @@
#pragma once
#include "Status.h"
#include "Meta.h"
#include "db/Status.h"
#include "db/meta/Meta.h"
#include "VectorSource.h"
#include "ExecutionEngine.h"
#include "db/engine/ExecutionEngine.h"
namespace zilliz {

View File

@ -1,7 +1,7 @@
#include "VectorSource.h"
#include "ExecutionEngine.h"
#include "EngineFactory.h"
#include "Log.h"
#include "db/engine/ExecutionEngine.h"
#include "db/engine/EngineFactory.h"
#include "db/Log.h"
#include "metrics/Metrics.h"

View File

@ -1,9 +1,9 @@
#pragma once
#include "Status.h"
#include "Meta.h"
#include "IDGenerator.h"
#include "ExecutionEngine.h"
#include "db/Status.h"
#include "db/meta/Meta.h"
#include "db/IDGenerator.h"
#include "db/engine/ExecutionEngine.h"
namespace zilliz {

View File

@ -6,8 +6,8 @@
#pragma once
#include "MetaTypes.h"
#include "Options.h"
#include "Status.h"
#include "db/Options.h"
#include "db/Status.h"
#include <cstddef>
#include <ctime>

View File

@ -5,7 +5,7 @@
******************************************************************************/
#pragma once
#include "ExecutionEngine.h"
#include "db/engine/ExecutionEngine.h"
#include <vector>
#include <map>

View File

@ -4,7 +4,7 @@
#include <unistd.h>
#include <atomic>
#include "Log.h"
#include "db/Log.h"
namespace zilliz {
namespace milvus {

View File

@ -4,11 +4,11 @@
* Proprietary and confidential.
******************************************************************************/
#include "MySQLMetaImpl.h"
#include "IDGenerator.h"
#include "Utils.h"
#include "Log.h"
#include "db/IDGenerator.h"
#include "db/Utils.h"
#include "db/Log.h"
#include "MetaConsts.h"
#include "Factories.h"
#include "db/Factories.h"
#include "metrics/Metrics.h"
#include <unistd.h>

View File

@ -6,7 +6,7 @@
#pragma once
#include "Meta.h"
#include "Options.h"
#include "db/Options.h"
#include "MySQLConnectionPool.h"
#include "mysql++/mysql++.h"

View File

@ -3,12 +3,12 @@
* Unauthorized copying of this file, via any medium is strictly prohibited.
* Proprietary and confidential.
******************************************************************************/
#include "DBMetaImpl.h"
#include "IDGenerator.h"
#include "Utils.h"
#include "Log.h"
#include "SqliteMetaImpl.h"
#include "db/IDGenerator.h"
#include "db/Utils.h"
#include "db/Log.h"
#include "MetaConsts.h"
#include "Factories.h"
#include "db/Factories.h"
#include "metrics/Metrics.h"
#include <unistd.h>
@ -83,7 +83,7 @@ using ConnectorT = decltype(StoragePrototype(""));
static std::unique_ptr<ConnectorT> ConnectorPtr;
using ConditionT = decltype(c(&TableFileSchema::id_) == 1UL);
Status DBMetaImpl::NextTableId(std::string &table_id) {
Status SqliteMetaImpl::NextTableId(std::string &table_id) {
std::stringstream ss;
SimpleIDGenerator g;
ss << g.GetNextIDNumber();
@ -91,7 +91,7 @@ Status DBMetaImpl::NextTableId(std::string &table_id) {
return Status::OK();
}
Status DBMetaImpl::NextFileId(std::string &file_id) {
Status SqliteMetaImpl::NextFileId(std::string &file_id) {
std::stringstream ss;
SimpleIDGenerator g;
ss << g.GetNextIDNumber();
@ -99,12 +99,12 @@ Status DBMetaImpl::NextFileId(std::string &file_id) {
return Status::OK();
}
DBMetaImpl::DBMetaImpl(const DBMetaOptions &options_)
SqliteMetaImpl::SqliteMetaImpl(const DBMetaOptions &options_)
: options_(options_) {
Initialize();
}
Status DBMetaImpl::Initialize() {
Status SqliteMetaImpl::Initialize() {
if (!boost::filesystem::is_directory(options_.path)) {
auto ret = boost::filesystem::create_directory(options_.path);
if (!ret) {
@ -125,7 +125,7 @@ Status DBMetaImpl::Initialize() {
}
// PXU TODO: Temp solution. Will fix later
Status DBMetaImpl::DropPartitionsByDates(const std::string &table_id,
Status SqliteMetaImpl::DropPartitionsByDates(const std::string &table_id,
const DatesT &dates) {
if (dates.size() == 0) {
return Status::OK();
@ -165,7 +165,7 @@ Status DBMetaImpl::DropPartitionsByDates(const std::string &table_id,
return Status::OK();
}
Status DBMetaImpl::CreateTable(TableSchema &table_schema) {
Status SqliteMetaImpl::CreateTable(TableSchema &table_schema) {
try {
MetricCollector metric;
@ -209,7 +209,7 @@ Status DBMetaImpl::CreateTable(TableSchema &table_schema) {
return Status::OK();
}
Status DBMetaImpl::DeleteTable(const std::string& table_id) {
Status SqliteMetaImpl::DeleteTable(const std::string& table_id) {
try {
MetricCollector metric;
@ -244,7 +244,7 @@ Status DBMetaImpl::DeleteTable(const std::string& table_id) {
return Status::OK();
}
Status DBMetaImpl::DeleteTableFiles(const std::string& table_id) {
Status SqliteMetaImpl::DeleteTableFiles(const std::string& table_id) {
try {
MetricCollector metric;
@ -269,7 +269,7 @@ Status DBMetaImpl::DeleteTableFiles(const std::string& table_id) {
return Status::OK();
}
Status DBMetaImpl::DescribeTable(TableSchema &table_schema) {
Status SqliteMetaImpl::DescribeTable(TableSchema &table_schema) {
try {
MetricCollector metric;
@ -299,7 +299,7 @@ Status DBMetaImpl::DescribeTable(TableSchema &table_schema) {
return Status::OK();
}
Status DBMetaImpl::HasNonIndexFiles(const std::string& table_id, bool& has) {
Status SqliteMetaImpl::HasNonIndexFiles(const std::string& table_id, bool& has) {
has = false;
try {
auto selected = ConnectorPtr->select(columns(&TableFileSchema::id_,
@ -353,7 +353,7 @@ Status DBMetaImpl::HasNonIndexFiles(const std::string& table_id, bool& has) {
return Status::OK();
}
Status DBMetaImpl::HasTable(const std::string &table_id, bool &has_or_not) {
Status SqliteMetaImpl::HasTable(const std::string &table_id, bool &has_or_not) {
has_or_not = false;
try {
@ -374,7 +374,7 @@ Status DBMetaImpl::HasTable(const std::string &table_id, bool &has_or_not) {
return Status::OK();
}
Status DBMetaImpl::AllTables(std::vector<TableSchema>& table_schema_array) {
Status SqliteMetaImpl::AllTables(std::vector<TableSchema>& table_schema_array) {
try {
MetricCollector metric;
@ -404,7 +404,7 @@ Status DBMetaImpl::AllTables(std::vector<TableSchema>& table_schema_array) {
return Status::OK();
}
Status DBMetaImpl::CreateTableFile(TableFileSchema &file_schema) {
Status SqliteMetaImpl::CreateTableFile(TableFileSchema &file_schema) {
if (file_schema.date_ == EmptyDate) {
file_schema.date_ = Meta::GetDate();
}
@ -440,7 +440,7 @@ Status DBMetaImpl::CreateTableFile(TableFileSchema &file_schema) {
return Status::OK();
}
Status DBMetaImpl::FilesToIndex(TableFilesSchema &files) {
Status SqliteMetaImpl::FilesToIndex(TableFilesSchema &files) {
files.clear();
try {
@ -490,7 +490,7 @@ Status DBMetaImpl::FilesToIndex(TableFilesSchema &files) {
return Status::OK();
}
Status DBMetaImpl::FilesToSearch(const std::string &table_id,
Status SqliteMetaImpl::FilesToSearch(const std::string &table_id,
const DatesT &partition,
DatePartionedTableFilesSchema &files) {
files.clear();
@ -589,7 +589,7 @@ Status DBMetaImpl::FilesToSearch(const std::string &table_id,
return Status::OK();
}
Status DBMetaImpl::FilesToSearch(const std::string &table_id,
Status SqliteMetaImpl::FilesToSearch(const std::string &table_id,
const std::vector<size_t> &ids,
const DatesT &partition,
DatePartionedTableFilesSchema &files) {
@ -662,7 +662,7 @@ Status DBMetaImpl::FilesToSearch(const std::string &table_id,
return Status::OK();
}
Status DBMetaImpl::FilesToMerge(const std::string &table_id,
Status SqliteMetaImpl::FilesToMerge(const std::string &table_id,
DatePartionedTableFilesSchema &files) {
files.clear();
@ -710,7 +710,7 @@ Status DBMetaImpl::FilesToMerge(const std::string &table_id,
return Status::OK();
}
Status DBMetaImpl::GetTableFiles(const std::string& table_id,
Status SqliteMetaImpl::GetTableFiles(const std::string& table_id,
const std::vector<size_t>& ids,
TableFilesSchema& table_files) {
try {
@ -754,7 +754,7 @@ Status DBMetaImpl::GetTableFiles(const std::string& table_id,
}
// PXU TODO: Support Swap
Status DBMetaImpl::Archive() {
Status SqliteMetaImpl::Archive() {
auto &criterias = options_.archive_conf.GetCriterias();
if (criterias.size() == 0) {
return Status::OK();
@ -794,7 +794,7 @@ Status DBMetaImpl::Archive() {
return Status::OK();
}
Status DBMetaImpl::Size(uint64_t &result) {
Status SqliteMetaImpl::Size(uint64_t &result) {
result = 0;
try {
auto files = ConnectorPtr->select(columns(&TableFileSchema::size_,
@ -821,7 +821,7 @@ Status DBMetaImpl::Size(uint64_t &result) {
return Status::OK();
}
Status DBMetaImpl::DiscardFiles(long to_discard_size) {
Status SqliteMetaImpl::DiscardFiles(long to_discard_size) {
if (to_discard_size <= 0) {
return Status::OK();
}
@ -883,7 +883,7 @@ Status DBMetaImpl::DiscardFiles(long to_discard_size) {
return DiscardFiles(to_discard_size);
}
Status DBMetaImpl::UpdateTableFile(TableFileSchema &file_schema) {
Status SqliteMetaImpl::UpdateTableFile(TableFileSchema &file_schema) {
file_schema.updated_time_ = utils::GetMicroSecTimeStamp();
try {
MetricCollector metric;
@ -910,7 +910,7 @@ Status DBMetaImpl::UpdateTableFile(TableFileSchema &file_schema) {
return Status::OK();
}
Status DBMetaImpl::UpdateTableFilesToIndex(const std::string& table_id) {
Status SqliteMetaImpl::UpdateTableFilesToIndex(const std::string& table_id) {
try {
MetricCollector metric;
@ -932,7 +932,7 @@ Status DBMetaImpl::UpdateTableFilesToIndex(const std::string& table_id) {
return Status::OK();
}
Status DBMetaImpl::UpdateTableFiles(TableFilesSchema &files) {
Status SqliteMetaImpl::UpdateTableFiles(TableFilesSchema &files) {
try {
MetricCollector metric;
@ -977,7 +977,7 @@ Status DBMetaImpl::UpdateTableFiles(TableFilesSchema &files) {
return Status::OK();
}
Status DBMetaImpl::CleanUpFilesWithTTL(uint16_t seconds) {
Status SqliteMetaImpl::CleanUpFilesWithTTL(uint16_t seconds) {
auto now = utils::GetMicroSecTimeStamp();
try {
MetricCollector metric;
@ -1052,7 +1052,7 @@ Status DBMetaImpl::CleanUpFilesWithTTL(uint16_t seconds) {
return Status::OK();
}
Status DBMetaImpl::CleanUp() {
Status SqliteMetaImpl::CleanUp() {
try {
MetricCollector metric;
@ -1086,7 +1086,7 @@ Status DBMetaImpl::CleanUp() {
return Status::OK();
}
Status DBMetaImpl::Count(const std::string &table_id, uint64_t &result) {
Status SqliteMetaImpl::Count(const std::string &table_id, uint64_t &result) {
try {
MetricCollector metric;
@ -1120,14 +1120,14 @@ Status DBMetaImpl::Count(const std::string &table_id, uint64_t &result) {
return Status::OK();
}
Status DBMetaImpl::DropAll() {
Status SqliteMetaImpl::DropAll() {
if (boost::filesystem::is_directory(options_.path)) {
boost::filesystem::remove_all(options_.path);
}
return Status::OK();
}
DBMetaImpl::~DBMetaImpl() {
SqliteMetaImpl::~SqliteMetaImpl() {
CleanUp();
}

View File

@ -6,7 +6,7 @@
#pragma once
#include "Meta.h"
#include "Options.h"
#include "db/Options.h"
#include <mutex>
@ -17,9 +17,9 @@ namespace meta {
auto StoragePrototype(const std::string &path);
class DBMetaImpl : public Meta {
class SqliteMetaImpl : public Meta {
public:
explicit DBMetaImpl(const DBMetaOptions &options_);
explicit SqliteMetaImpl(const DBMetaOptions &options_);
Status
CreateTable(TableSchema &table_schema) override;
@ -91,7 +91,7 @@ class DBMetaImpl : public Meta {
Status Count(const std::string &table_id, uint64_t &result) override;
~DBMetaImpl() override;
~SqliteMetaImpl() override;
private:
Status NextFileId(std::string &file_id);

View File

@ -8,7 +8,7 @@
#include "TaskDispatchQueue.h"
#include "utils/Log.h"
#include "utils/TimeRecorder.h"
#include "db/EngineFactory.h"
#include "db/engine/EngineFactory.h"
namespace zilliz {
namespace milvus {

View File

@ -6,7 +6,7 @@
#pragma once
#include "IScheduleContext.h"
#include "db/Meta.h"
#include "db/meta/Meta.h"
namespace zilliz {
namespace milvus {

View File

@ -6,7 +6,7 @@
#pragma once
#include "IScheduleContext.h"
#include "db/MetaTypes.h"
#include "db/meta/MetaTypes.h"
#include <unordered_map>
#include <vector>

View File

@ -7,7 +7,7 @@
#include "IndexLoadTask.h"
#include "SearchTask.h"
#include "db/Log.h"
#include "db/EngineFactory.h"
#include "db/engine/EngineFactory.h"
#include "utils/TimeRecorder.h"
#include "metrics/Metrics.h"

View File

@ -7,7 +7,7 @@
#include "IScheduleTask.h"
#include "db/scheduler/context/SearchContext.h"
#include "db/ExecutionEngine.h"
#include "db/engine/ExecutionEngine.h"
namespace zilliz {
namespace milvus {

View File

@ -6,7 +6,6 @@
#pragma once
#include "db/DB.h"
#include "db/Meta.h"
namespace zilliz {
namespace milvus {

View File

@ -1,4 +1,4 @@
#include "db/ExecutionEngine.h"
#include "db/engine/ExecutionEngine.h"
#include "ValidationUtil.h"
#include "Log.h"

View File

@ -40,7 +40,6 @@ set(unittest_libs
add_subdirectory(server)
add_subdirectory(db)
add_subdirectory(index_wrapper)
add_subdirectory(knowhere)
add_subdirectory(metrics)
add_subdirectory(storage)
add_subdirectory(utils)
#add_subdirectory(storage)

View File

@ -3,10 +3,12 @@
# Unauthorized copying of this file, via any medium is strictly prohibited.
# Proprietary and confidential.
#-------------------------------------------------------------------------------
aux_source_directory(${MILVUS_ENGINE_SRC}/db db_srcs)
aux_source_directory(${MILVUS_ENGINE_SRC}/db db_main_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/db/engine db_engine_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/db/insert db_insert_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/db/meta db_meta_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/config config_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/cache cache_srcs)
#aux_source_directory(${MILVUS_ENGINE_SRC}/wrapper wrapper_src)
aux_source_directory(${MILVUS_ENGINE_SRC}/wrapper/knowhere knowhere_src)
aux_source_directory(./ test_srcs)
@ -32,14 +34,17 @@ include_directories(/usr/include/mysql)
set(db_test_src
${config_files}
${cache_srcs}
${db_srcs}
${db_main_files}
${db_engine_files}
${db_insert_files}
${db_meta_files}
${db_scheduler_srcs}
${wrapper_src}
${knowhere_src}
${util_files}
${require_files}
${test_srcs}
)
)
cuda_add_executable(db_test ${db_test_src})

View File

@ -6,7 +6,7 @@
#include "utils.h"
#include "db/DB.h"
#include "db/DBImpl.h"
#include "db/MetaConsts.h"
#include "db/meta/MetaConsts.h"
#include "db/Factories.h"
#include <gtest/gtest.h>

View File

@ -1,16 +1,16 @@
#include "gtest/gtest.h"
#include "db/VectorSource.h"
#include "db/MemTableFile.h"
#include "db/MemTable.h"
#include "db/insert/VectorSource.h"
#include "db/insert/MemTableFile.h"
#include "db/insert/MemTable.h"
#include "utils.h"
#include "db/Factories.h"
#include "db/Constants.h"
#include "db/EngineFactory.h"
#include "db/engine/EngineFactory.h"
#include "metrics/Metrics.h"
#include "db/MetaConsts.h"
#include "boost/filesystem.hpp"
#include "db/meta/MetaConsts.h"
#include <boost/filesystem.hpp>
#include <thread>
#include <fstream>
#include <iostream>
@ -47,7 +47,7 @@ void BuildVectors(int64_t n, std::vector<float> &vectors) {
TEST_F(NewMemManagerTest, VECTOR_SOURCE_TEST) {
std::shared_ptr<engine::meta::DBMetaImpl> impl_ = engine::DBMetaImplFactory::Build();
std::shared_ptr<engine::meta::SqliteMetaImpl> impl_ = engine::DBMetaImplFactory::Build();
engine::meta::TableSchema table_schema = BuildTableSchema();
auto status = impl_->CreateTable(table_schema);
@ -90,7 +90,7 @@ TEST_F(NewMemManagerTest, VECTOR_SOURCE_TEST) {
TEST_F(NewMemManagerTest, MEM_TABLE_FILE_TEST) {
std::shared_ptr<engine::meta::DBMetaImpl> impl_ = engine::DBMetaImplFactory::Build();
std::shared_ptr<engine::meta::SqliteMetaImpl> impl_ = engine::DBMetaImplFactory::Build();
auto options = engine::OptionsFactory::Build();
engine::meta::TableSchema table_schema = BuildTableSchema();
@ -134,7 +134,7 @@ TEST_F(NewMemManagerTest, MEM_TABLE_FILE_TEST) {
TEST_F(NewMemManagerTest, MEM_TABLE_TEST) {
std::shared_ptr<engine::meta::DBMetaImpl> impl_ = engine::DBMetaImplFactory::Build();
std::shared_ptr<engine::meta::SqliteMetaImpl> impl_ = engine::DBMetaImplFactory::Build();
auto options = engine::OptionsFactory::Build();
engine::meta::TableSchema table_schema = BuildTableSchema();

View File

@ -10,10 +10,10 @@
#include <time.h>
#include "utils.h"
#include "db/DBMetaImpl.h"
#include "db/meta/SqliteMetaImpl.h"
#include "db/Factories.h"
#include "db/Utils.h"
#include "db/MetaConsts.h"
#include "db/meta/MetaConsts.h"
using namespace zilliz::milvus::engine;
@ -113,7 +113,7 @@ TEST_F(MetaTest, ARCHIVE_TEST_DAYS) {
ss << "days:" << days_num;
options.archive_conf = ArchiveConf("delete", ss.str());
meta::DBMetaImpl impl(options);
meta::SqliteMetaImpl impl(options);
auto table_id = "meta_test_table";
meta::TableSchema table;
@ -163,7 +163,7 @@ TEST_F(MetaTest, ARCHIVE_TEST_DISK) {
options.path = "/tmp/milvus_test";
options.archive_conf = ArchiveConf("delete", "disk:11");
meta::DBMetaImpl impl(options);
meta::SqliteMetaImpl impl(options);
auto table_id = "meta_test_group";
meta::TableSchema table;

View File

@ -11,8 +11,8 @@
#include "db/Exception.h"
#include "db/Status.h"
#include "db/Options.h"
#include "db/DBMetaImpl.h"
#include "db/EngineFactory.h"
#include "db/meta/SqliteMetaImpl.h"
#include "db/engine/EngineFactory.h"
#include "db/Utils.h"
#include <vector>
@ -100,7 +100,7 @@ TEST(DBMiscTest, OPTIONS_TEST) {
TEST(DBMiscTest, META_TEST) {
engine::DBMetaOptions options;
options.path = "/tmp/milvus_test";
engine::meta::DBMetaImpl impl(options);
engine::meta::SqliteMetaImpl impl(options);
time_t tt;
time( &tt );

View File

@ -6,7 +6,7 @@
#include "utils.h"
#include "db/DB.h"
#include "db/DBImpl.h"
#include "db/MetaConsts.h"
#include "db/meta/MetaConsts.h"
#include "db/Factories.h"
#include <gtest/gtest.h>

View File

@ -10,10 +10,10 @@
#include <time.h>
#include "utils.h"
#include "db/MySQLMetaImpl.h"
#include "db/meta/MySQLMetaImpl.h"
#include "db/Factories.h"
#include "db/Utils.h"
#include "db/MetaConsts.h"
#include "db/meta/MetaConsts.h"
#include "mysql++/mysql++.h"

View File

@ -11,8 +11,8 @@
//#include <src/db/MySQLMetaImpl.h>
#include "db/DB.h"
#include "db/DBMetaImpl.h"
#include "db/MySQLMetaImpl.h"
#include "db/meta/SqliteMetaImpl.h"
#include "db/meta/MySQLMetaImpl.h"
#define TIMING
@ -71,7 +71,7 @@ class DBTest2 : public DBTest {
class MetaTest : public DBTest {
protected:
std::shared_ptr<zilliz::milvus::engine::meta::DBMetaImpl> impl_;
std::shared_ptr<zilliz::milvus::engine::meta::SqliteMetaImpl> impl_;
virtual void SetUp() override;
virtual void TearDown() override;

View File

@ -11,8 +11,10 @@
include_directories(../../src)
aux_source_directory(${MILVUS_ENGINE_SRC}/db db_srcs)
aux_source_directory(${MILVUS_ENGINE_SRC}/db db_main_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/db/engine db_engine_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/db/insert db_insert_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/db/meta db_meta_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/config config_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/cache cache_srcs)
aux_source_directory(${MILVUS_ENGINE_SRC}/wrapper wrapper_src)
@ -44,7 +46,10 @@ include_directories(/usr/include/mysql)
set(count_test_src
${config_files}
${cache_srcs}
${db_srcs}
${db_main_files}
${db_engine_files}
${db_insert_files}
${db_meta_files}
${db_scheduler_srcs}
${wrapper_src}
${knowhere_src}

View File

@ -17,7 +17,7 @@
#include "metrics/Metrics.h"
#include "utils.h"
#include "db/DB.h"
#include "db/DBMetaImpl.h"
#include "db/meta/SqliteMetaImpl.h"
#include "db/Factories.h"

View File

@ -11,8 +11,8 @@
//#include <src/db/MySQLMetaImpl.h>
#include "db/DB.h"
#include "db/DBMetaImpl.h"
#include "db/MySQLMetaImpl.h"
#include "db/meta/SqliteMetaImpl.h"
#include "db/meta/MySQLMetaImpl.h"
#define TIMING

View File

@ -3,15 +3,15 @@
# Unauthorized copying of this file, via any medium is strictly prohibited.
# Proprietary and confidential.
#-------------------------------------------------------------------------------
include_directories(../../src)
include_directories(${MILVUS_ENGINE_SRC}/)
include_directories(/usr/include)
include_directories(/usr/local/cuda/include)
link_directories(/usr/local/cuda/lib64)
aux_source_directory(../../src/config config_files)
aux_source_directory(../../src/cache cache_srcs)
aux_source_directory(../../src/wrapper wrapper_src)
aux_source_directory(${MILVUS_ENGINE_SRC}/config config_files)
aux_source_directory(${MILVUS_ENGINE_SRC}/cache cache_srcs)
aux_source_directory(${MILVUS_ENGINE_SRC}/wrapper wrapper_src)
aux_source_directory(./ test_srcs)
set(utils_srcs

View File

@ -1,20 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
// Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
// Unauthorized copying of this file, via any medium is strictly prohibited.
// Proprietary and confidential.
////////////////////////////////////////////////////////////////////////////////
#include <gtest/gtest.h>
#include "easylogging++.h"
class LogTest: public testing::Test {
protected:
void SetUp() override {
el::Configurations conf("../../../conf/log_config.conf");
el::Loggers::reconfigureAllLoggers(conf);
}
};
TEST_F(LogTest, TEST) {
EXPECT_FALSE(el::Loggers::hasFlag(el::LoggingFlag::NewLineForContainer));
EXPECT_FALSE(el::Loggers::hasFlag(el::LoggingFlag::LogDetailedCrashReason));
}

View File

@ -12,6 +12,8 @@
#include "utils/TimeRecorder.h"
#include "utils/BlockingQueue.h"
#include "utils/LogUtil.h"
#include "utils/ValidationUtil.h"
#include "db/engine/ExecutionEngine.h"
using namespace zilliz::milvus;
@ -148,6 +150,57 @@ TEST(UtilTest, LOG_TEST) {
int32_t res = server::InitLog(LOG_FILE_PATH);
ASSERT_EQ(res, 0);
EXPECT_FALSE(el::Loggers::hasFlag(el::LoggingFlag::NewLineForContainer));
EXPECT_FALSE(el::Loggers::hasFlag(el::LoggingFlag::LogDetailedCrashReason));
std::string fname = server::GetFileName(LOG_FILE_PATH);
ASSERT_EQ(fname, "log_config.conf");
}
TEST(UtilTest, VALIDATE_TABLENAME_TEST) {
std::string table_name = "Normal123_";
server:: ServerError res = server::ValidationUtil::ValidateTableName(table_name);
ASSERT_EQ(res, server::SERVER_SUCCESS);
table_name = "12sds";
res = server::ValidationUtil::ValidateTableName(table_name);
ASSERT_EQ(res, server::SERVER_INVALID_TABLE_NAME);
table_name = "";
res = server::ValidationUtil::ValidateTableName(table_name);
ASSERT_EQ(res, server::SERVER_INVALID_TABLE_NAME);
table_name = "_asdasd";
res = server::ValidationUtil::ValidateTableName(table_name);
ASSERT_EQ(res, server::SERVER_SUCCESS);
table_name = "!@#!@";
res = server::ValidationUtil::ValidateTableName(table_name);
ASSERT_EQ(res, server::SERVER_INVALID_TABLE_NAME);
table_name = "中文";
res = server::ValidationUtil::ValidateTableName(table_name);
ASSERT_EQ(res, server::SERVER_INVALID_TABLE_NAME);
table_name = std::string('a', 32768);
res = server::ValidationUtil::ValidateTableName(table_name);
ASSERT_EQ(res, server::SERVER_INVALID_TABLE_NAME);
}
TEST(UtilTest, VALIDATE_DIMENSIONTEST) {
ASSERT_EQ(server::ValidationUtil::ValidateTableDimension(-1), server::SERVER_INVALID_VECTOR_DIMENSION);
ASSERT_EQ(server::ValidationUtil::ValidateTableDimension(0), server::SERVER_INVALID_VECTOR_DIMENSION);
ASSERT_EQ(server::ValidationUtil::ValidateTableDimension(16385), server::SERVER_INVALID_VECTOR_DIMENSION);
ASSERT_EQ(server::ValidationUtil::ValidateTableDimension(16384), server::SERVER_SUCCESS);
ASSERT_EQ(server::ValidationUtil::ValidateTableDimension(1), server::SERVER_SUCCESS);
}
TEST(UtilTest, VALIDATE_INDEXTYPE_TEST) {
ASSERT_EQ(server::ValidationUtil::ValidateTableIndexType((int)engine::EngineType::INVALID), server::SERVER_INVALID_INDEX_TYPE);
for(int i = 1; i <= (int)engine::EngineType::MAX_VALUE; i++) {
ASSERT_EQ(server::ValidationUtil::ValidateTableIndexType(i), server::SERVER_SUCCESS);
}
ASSERT_EQ(server::ValidationUtil::ValidateTableIndexType((int)engine::EngineType::MAX_VALUE + 1), server::SERVER_INVALID_INDEX_TYPE);
}

View File

@ -1,30 +0,0 @@
#-------------------------------------------------------------------------------
# Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
# Unauthorized copying of this file, via any medium is strictly prohibited.
# Proprietary and confidential.
#-------------------------------------------------------------------------------
# Make sure that your call to link_directories takes place before your call to the relevant add_executable.
include_directories("${CUDA_TOOLKIT_ROOT_DIR}/include")
link_directories("${CUDA_TOOLKIT_ROOT_DIR}/lib64")
set(validation_util_src
${MILVUS_ENGINE_SRC}/utils/ValidationUtil.cpp
${MILVUS_ENGINE_SRC}/utils/ValidationUtil.h)
set(validation_util_test_src
${unittest_srcs}
${validation_util_src}
${require_files}
ValidationUtilTest.cpp
)
add_executable(valication_util_test
${validation_util_test_src}
${config_files})
target_link_libraries(valication_util_test
${unittest_libs}
boost_filesystem_static)
install(TARGETS valication_util_test DESTINATION bin)

View File

@ -1,63 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
// Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
// Unauthorized copying of this file, via any medium is strictly prohibited.
// Proprietary and confidential.
////////////////////////////////////////////////////////////////////////////////
#include <gtest/gtest.h>
#include "utils/ValidationUtil.h"
#include "utils/Error.h"
#include "db/ExecutionEngine.h"
#include <string>
using namespace zilliz::milvus;
using namespace zilliz::milvus::server;
TEST(ValidationUtilTest, TableNameTest) {
std::string table_name = "Normal123_";
ServerError res = ValidationUtil::ValidateTableName(table_name);
ASSERT_EQ(res, SERVER_SUCCESS);
table_name = "12sds";
res = ValidationUtil::ValidateTableName(table_name);
ASSERT_EQ(res, SERVER_INVALID_TABLE_NAME);
table_name = "";
res = ValidationUtil::ValidateTableName(table_name);
ASSERT_EQ(res, SERVER_INVALID_TABLE_NAME);
table_name = "_asdasd";
res = ValidationUtil::ValidateTableName(table_name);
ASSERT_EQ(res, SERVER_SUCCESS);
table_name = "!@#!@";
res = ValidationUtil::ValidateTableName(table_name);
ASSERT_EQ(res, SERVER_INVALID_TABLE_NAME);
table_name = "中文";
res = ValidationUtil::ValidateTableName(table_name);
ASSERT_EQ(res, SERVER_INVALID_TABLE_NAME);
table_name = std::string('a', 32768);
res = ValidationUtil::ValidateTableName(table_name);
ASSERT_EQ(res, SERVER_INVALID_TABLE_NAME);
}
TEST(ValidationUtilTest, TableDimensionTest) {
ASSERT_EQ(ValidationUtil::ValidateTableDimension(-1), SERVER_INVALID_VECTOR_DIMENSION);
ASSERT_EQ(ValidationUtil::ValidateTableDimension(0), SERVER_INVALID_VECTOR_DIMENSION);
ASSERT_EQ(ValidationUtil::ValidateTableDimension(16385), SERVER_INVALID_VECTOR_DIMENSION);
ASSERT_EQ(ValidationUtil::ValidateTableDimension(16384), SERVER_SUCCESS);
ASSERT_EQ(ValidationUtil::ValidateTableDimension(1), SERVER_SUCCESS);
}
TEST(ValidationUtilTest, TableIndexTypeTest) {
ASSERT_EQ(ValidationUtil::ValidateTableIndexType((int)engine::EngineType::INVALID), SERVER_INVALID_INDEX_TYPE);
for(int i = 1; i <= (int)engine::EngineType::MAX_VALUE; i++) {
ASSERT_EQ(ValidationUtil::ValidateTableIndexType(i), SERVER_SUCCESS);
}
ASSERT_EQ(ValidationUtil::ValidateTableIndexType((int)engine::EngineType::MAX_VALUE + 1), SERVER_INVALID_INDEX_TYPE);
}