mirror of https://github.com/milvus-io/milvus.git
Merge branch 'jinhai' of 192.168.1.105:jinhai/vecwise_engine into jinhai
Former-commit-id: 69eee8018a8a7d7478181c11fef7ef4206ee0784pull/191/head
commit
fe5909a597
|
@ -0,0 +1,44 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
|
||||
// Unauthorized copying of this file, via any medium is strictly prohibited.
|
||||
// Proprietary and confidential.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include <stdlib.h>
|
||||
#include <time.h>
|
||||
#include <sstream>
|
||||
|
||||
#include "Factories.h"
|
||||
|
||||
|
||||
namespace zilliz {
|
||||
namespace vecwise {
|
||||
namespace engine {
|
||||
|
||||
DBMetaOptions DBMetaOptionsFactory::Build(const std::string& path) {
|
||||
auto p = path;
|
||||
if(p == "") {
|
||||
srand(time(nullptr));
|
||||
std::stringstream ss;
|
||||
ss << "/tmp/" << rand();
|
||||
p = ss.str();
|
||||
}
|
||||
DBMetaOptions meta;
|
||||
meta.path = p;
|
||||
return meta;
|
||||
}
|
||||
|
||||
Options OptionsFactory::Build() {
|
||||
auto meta = DBMetaOptionsFactory::Build();
|
||||
Options options;
|
||||
options.meta = meta;
|
||||
return options;
|
||||
}
|
||||
|
||||
std::shared_ptr<meta::DBMetaImpl> DBMetaImplFactory::Build() {
|
||||
DBMetaOptions options = DBMetaOptionsFactory::Build();
|
||||
return std::shared_ptr<meta::DBMetaImpl>(new meta::DBMetaImpl(options));
|
||||
}
|
||||
|
||||
} // namespace engine
|
||||
} // namespace vecwise
|
||||
} // namespace zilliz
|
|
@ -0,0 +1,32 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
|
||||
// Unauthorized copying of this file, via any medium is strictly prohibited.
|
||||
// Proprietary and confidential.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include "db/DB.h"
|
||||
#include "DBMetaImpl.h"
|
||||
|
||||
namespace zilliz {
|
||||
namespace vecwise {
|
||||
namespace engine {
|
||||
|
||||
struct DBMetaOptionsFactory {
|
||||
static DBMetaOptions Build(const std::string& path = "");
|
||||
};
|
||||
|
||||
struct OptionsFactory {
|
||||
static Options Build();
|
||||
};
|
||||
|
||||
struct DBMetaImplFactory {
|
||||
static std::shared_ptr<meta::DBMetaImpl> Build();
|
||||
};
|
||||
|
||||
} // namespace engine
|
||||
} // namespace vecwise
|
||||
} // namespace zilliz
|
|
@ -26,7 +26,9 @@ set(db_test_src
|
|||
${db_srcs}
|
||||
${wrapper_src}
|
||||
${require_files}
|
||||
db_tests.cpp)
|
||||
utils.cpp
|
||||
db_tests.cpp
|
||||
meta_tests.cpp)
|
||||
|
||||
cuda_add_executable(db_test ${db_test_src})
|
||||
|
||||
|
|
|
@ -6,48 +6,12 @@
|
|||
#include <gtest/gtest.h>
|
||||
#include <thread>
|
||||
#include <easylogging++.h>
|
||||
#include <chrono>
|
||||
|
||||
#include "utils.h"
|
||||
#include "db/DB.h"
|
||||
|
||||
using namespace zilliz::vecwise;
|
||||
|
||||
#define TIMING
|
||||
|
||||
#ifdef TIMING
|
||||
#define INIT_TIMER auto start = std::chrono::high_resolution_clock::now();
|
||||
#define START_TIMER start = std::chrono::high_resolution_clock::now();
|
||||
#define STOP_TIMER(name) LOG(DEBUG) << "RUNTIME of " << name << ": " << \
|
||||
std::chrono::duration_cast<std::chrono::milliseconds>( \
|
||||
std::chrono::high_resolution_clock::now()-start \
|
||||
).count() << " ms ";
|
||||
#else
|
||||
#define INIT_TIMER
|
||||
#define START_TIMER
|
||||
#define STOP_TIMER(name)
|
||||
#endif
|
||||
|
||||
class DBTest : public ::testing::Test {
|
||||
protected:
|
||||
virtual void SetUp() {
|
||||
el::Configurations defaultConf;
|
||||
defaultConf.setToDefault();
|
||||
defaultConf.set(el::Level::Debug,
|
||||
el::ConfigurationType::Format, "[%thread-%datetime-%level]: %msg (%fbase:%line)");
|
||||
el::Loggers::reconfigureLogger("default", defaultConf);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
namespace {
|
||||
void ASSERT_STATS(engine::Status& stat) {
|
||||
ASSERT_TRUE(stat.ok());
|
||||
if(!stat.ok()) {
|
||||
std::cout << stat.ToString() << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(DBTest, DB_TEST) {
|
||||
|
||||
static const std::string group_name = "test_group";
|
||||
|
@ -101,7 +65,7 @@ TEST_F(DBTest, DB_TEST) {
|
|||
std::stringstream ss;
|
||||
long count = 0;
|
||||
|
||||
for (auto j=0; j<8; ++j) {
|
||||
for (auto j=0; j<15; ++j) {
|
||||
ss.str("");
|
||||
db->count(group_name, count);
|
||||
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
|
||||
// Unauthorized copying of this file, via any medium is strictly prohibited.
|
||||
// Proprietary and confidential.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
#include <gtest/gtest.h>
|
||||
#include <thread>
|
||||
#include <easylogging++.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "db/DBMetaImpl.h"
|
||||
#include "db/Factories.h"
|
||||
|
||||
using namespace zilliz::vecwise::engine;
|
||||
|
||||
TEST_F(MetaTest, GROUP_TEST) {
|
||||
auto group_id = "meta_test_group";
|
||||
|
||||
meta::GroupSchema group;
|
||||
group.group_id = group_id;
|
||||
auto status = impl_->add_group(group);
|
||||
ASSERT_TRUE(status.ok());
|
||||
|
||||
auto gid = group.id;
|
||||
group.id = -1;
|
||||
status = impl_->get_group(group);
|
||||
ASSERT_TRUE(status.ok());
|
||||
ASSERT_EQ(group.id, gid);
|
||||
ASSERT_EQ(group.group_id, group_id);
|
||||
|
||||
group.group_id = "not_found";
|
||||
status = impl_->get_group(group);
|
||||
ASSERT_TRUE(!status.ok());
|
||||
|
||||
group.group_id = group_id;
|
||||
status = impl_->add_group(group);
|
||||
ASSERT_TRUE(!status.ok());
|
||||
}
|
|
@ -0,0 +1,37 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
|
||||
// Unauthorized copying of this file, via any medium is strictly prohibited.
|
||||
// Proprietary and confidential.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <iostream>
|
||||
#include <easylogging++.h>
|
||||
|
||||
#include "utils.h"
|
||||
#include "db/Factories.h"
|
||||
|
||||
using namespace zilliz::vecwise;
|
||||
|
||||
void ASSERT_STATS(engine::Status& stat) {
|
||||
ASSERT_TRUE(stat.ok());
|
||||
if(!stat.ok()) {
|
||||
std::cout << stat.ToString() << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void DBTest::SetUp() {
|
||||
el::Configurations defaultConf;
|
||||
defaultConf.setToDefault();
|
||||
defaultConf.set(el::Level::Debug,
|
||||
el::ConfigurationType::Format, "[%thread-%datetime-%level]: %msg (%fbase:%line)");
|
||||
el::Loggers::reconfigureLogger("default", defaultConf);
|
||||
}
|
||||
|
||||
void MetaTest::SetUp() {
|
||||
DBTest::SetUp();
|
||||
impl_ = engine::DBMetaImplFactory::Build();
|
||||
}
|
||||
|
||||
void MetaTest::TearDown() {
|
||||
impl_->drop_all();
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
|
||||
// Unauthorized copying of this file, via any medium is strictly prohibited.
|
||||
// Proprietary and confidential.
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <chrono>
|
||||
|
||||
#include "db/DB.h"
|
||||
#include "db/DBMetaImpl.h"
|
||||
|
||||
|
||||
#define TIMING
|
||||
|
||||
#ifdef TIMING
|
||||
#define INIT_TIMER auto start = std::chrono::high_resolution_clock::now();
|
||||
#define START_TIMER start = std::chrono::high_resolution_clock::now();
|
||||
#define STOP_TIMER(name) LOG(DEBUG) << "RUNTIME of " << name << ": " << \
|
||||
std::chrono::duration_cast<std::chrono::milliseconds>( \
|
||||
std::chrono::high_resolution_clock::now()-start \
|
||||
).count() << " ms ";
|
||||
#else
|
||||
#define INIT_TIMER
|
||||
#define START_TIMER
|
||||
#define STOP_TIMER(name)
|
||||
#endif
|
||||
|
||||
|
||||
void ASSERT_STATS(zilliz::vecwise::engine::Status& stat);
|
||||
|
||||
|
||||
class DBTest : public ::testing::Test {
|
||||
protected:
|
||||
virtual void SetUp() override;
|
||||
};
|
||||
|
||||
|
||||
class MetaTest : public DBTest {
|
||||
protected:
|
||||
std::shared_ptr<zilliz::vecwise::engine::meta::DBMetaImpl> impl_;
|
||||
|
||||
virtual void SetUp() override;
|
||||
virtual void TearDown() override;
|
||||
};
|
Loading…
Reference in New Issue