mirror of https://github.com/milvus-io/milvus.git
parent
2d9fb6b959
commit
82fe888083
|
@ -9,7 +9,7 @@ server_config:
|
|||
log_config:
|
||||
global:
|
||||
format: "%datetime | %level | %logger | %msg"
|
||||
filename: "/tmp/logs/vecwise/vecwise_engine-%datetime{%h:%m}-global.log"
|
||||
filename: "/tmp/vecwise/logs/vecwise_engine-%datetime{%h:%m}-global.log"
|
||||
enabled: true
|
||||
to_file: true
|
||||
to_standard_output: true
|
||||
|
@ -17,22 +17,22 @@ log_config:
|
|||
performance_tracking: false
|
||||
max_log_file_size: 2097152 # throw log files away after 2mb
|
||||
debug:
|
||||
filename: "/tmp/logs/vecwise/vecwise_engine-%datetime{%h:%m}-debug.log"
|
||||
filename: "/tmp/vecwise/logs/vecwise_engine-%datetime{%h:%m}-debug.log"
|
||||
enabled: true
|
||||
warning:
|
||||
filename: "/tmp/logs/vecwise/vecwise_engine-%datetime{%h:%m}-warning.log"
|
||||
filename: "/tmp/vecwise/logs/vecwise_engine-%datetime{%h:%m}-warning.log"
|
||||
trace:
|
||||
filename: "/tmp/logs/vecwise/vecwise_engine-%datetime{%h:%m}-trace.log"
|
||||
filename: "/tmp/vecwise/logs/vecwise_engine-%datetime{%h:%m}-trace.log"
|
||||
verbose:
|
||||
format: "%datetime{%d/%m/%y} | %level-%vlevel | %msg"
|
||||
to_file: false
|
||||
to_standard_output: true
|
||||
error:
|
||||
enabled: false
|
||||
filename: "/tmp/logs/vecwise/vecwise_engine-%datetime{%h:%m}-error.log"
|
||||
filename: "/tmp/vecwise/logs/vecwise_engine-%datetime{%h:%m}-error.log"
|
||||
fatal:
|
||||
enabled: false
|
||||
filename: "/tmp/logs/vecwise/vecwise_engine-%datetime{%h:%m}-fatal.log"
|
||||
filename: "/tmp/vecwise/logs/vecwise_engine-%datetime{%h:%m}-fatal.log"
|
||||
|
||||
cache_config:
|
||||
cache_capacity: 16 # unit: GB
|
|
@ -1,6 +1,6 @@
|
|||
* GLOBAL:
|
||||
FORMAT = "%datetime | %level | %logger | %msg"
|
||||
FILENAME = "/tmp/logs/vecwise/vecwise_engine-%datetime{%H:%m}-global.log"
|
||||
FILENAME = "/tmp/vecwise/logs/vecwise_engine-%datetime{%H:%m}-global.log"
|
||||
ENABLED = true
|
||||
TO_FILE = true
|
||||
TO_STANDARD_OUTPUT = true
|
||||
|
@ -8,12 +8,12 @@
|
|||
PERFORMANCE_TRACKING = false
|
||||
MAX_LOG_FILE_SIZE = 2097152 ## Throw log files away after 2MB
|
||||
* DEBUG:
|
||||
FILENAME = "/tmp/logs/vecwise/vecwise_engine-%datetime{%H:%m}-debug.log"
|
||||
FILENAME = "/tmp/vecwise/logs/vecwise_engine-%datetime{%H:%m}-debug.log"
|
||||
ENABLED = true
|
||||
* WARNING:
|
||||
FILENAME = "/tmp/logs/vecwise/vecwise_engine-%datetime{%H:%m}-warning.log"
|
||||
FILENAME = "/tmp/vecwise/logs/vecwise_engine-%datetime{%H:%m}-warning.log"
|
||||
* TRACE:
|
||||
FILENAME = "/tmp/logs/vecwise/vecwise_engine-%datetime{%H:%m}-trace.log"
|
||||
FILENAME = "/tmp/vecwise/logs/vecwise_engine-%datetime{%H:%m}-trace.log"
|
||||
* VERBOSE:
|
||||
FORMAT = "%datetime{%d/%M/%y} | %level-%vlevel | %msg"
|
||||
TO_FILE = false
|
||||
|
@ -21,7 +21,7 @@
|
|||
## Error logs
|
||||
* ERROR:
|
||||
ENABLED = false
|
||||
FILENAME = "/tmp/logs/vecwise/vecwise_engine-%datetime{%H:%m}-error.log"
|
||||
FILENAME = "/tmp/vecwise/logs/vecwise_engine-%datetime{%H:%m}-error.log"
|
||||
* FATAL:
|
||||
ENABLED = false
|
||||
FILENAME = "/tmp/logs/vecwise/vecwise_engine-%datetime{%H:%m}-fatal.log"
|
||||
FILENAME = "/tmp/vecwise/logs/vecwise_engine-%datetime{%H:%m}-fatal.log"
|
|
@ -88,35 +88,37 @@ ServerError CommonUtil::CreateDirectory(const std::string &path) {
|
|||
return SERVER_SUCCESS;
|
||||
}
|
||||
|
||||
void RemoveDirectory(const std::string &path) {
|
||||
DIR *pDir = NULL;
|
||||
struct dirent *dmsg;
|
||||
char szFileName[256];
|
||||
char szFolderName[256];
|
||||
namespace {
|
||||
void RemoveDirectory(const std::string &path) {
|
||||
DIR *pDir = NULL;
|
||||
struct dirent *dmsg;
|
||||
char szFileName[256];
|
||||
char szFolderName[256];
|
||||
|
||||
strcpy(szFolderName, path.c_str());
|
||||
strcat(szFolderName, "/%s");
|
||||
if ((pDir = opendir(path.c_str())) != NULL) {
|
||||
while ((dmsg = readdir(pDir)) != NULL) {
|
||||
if (strcmp(dmsg->d_name, ".") != 0
|
||||
&& strcmp(dmsg->d_name, "..") != 0) {
|
||||
sprintf(szFileName, szFolderName, dmsg->d_name);
|
||||
std::string tmp = szFileName;
|
||||
if (tmp.find(".") == std::string::npos) {
|
||||
RemoveDirectory(szFileName);
|
||||
strcpy(szFolderName, path.c_str());
|
||||
strcat(szFolderName, "/%s");
|
||||
if ((pDir = opendir(path.c_str())) != NULL) {
|
||||
while ((dmsg = readdir(pDir)) != NULL) {
|
||||
if (strcmp(dmsg->d_name, ".") != 0
|
||||
&& strcmp(dmsg->d_name, "..") != 0) {
|
||||
sprintf(szFileName, szFolderName, dmsg->d_name);
|
||||
std::string tmp = szFileName;
|
||||
if (tmp.find(".") == std::string::npos) {
|
||||
RemoveDirectory(szFileName);
|
||||
}
|
||||
remove(szFileName);
|
||||
}
|
||||
remove(szFileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pDir != NULL) {
|
||||
closedir(pDir);
|
||||
if (pDir != NULL) {
|
||||
closedir(pDir);
|
||||
}
|
||||
remove(path.c_str());
|
||||
}
|
||||
remove(path.c_str());
|
||||
}
|
||||
|
||||
ServerError DeleteDirectory(const std::string &path) {
|
||||
ServerError CommonUtil::DeleteDirectory(const std::string &path) {
|
||||
struct stat directoryStat;
|
||||
int statOK = stat(path.c_str(), &directoryStat);
|
||||
if (statOK != 0)
|
||||
|
@ -126,7 +128,7 @@ ServerError DeleteDirectory(const std::string &path) {
|
|||
return SERVER_SUCCESS;
|
||||
}
|
||||
|
||||
bool IsFileExist(const std::string &path) {
|
||||
bool CommonUtil::IsFileExist(const std::string &path) {
|
||||
return (access(path.c_str(), F_OK) == 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ TEST(DBTest, DB_TEST) {
|
|||
|
||||
engine::Options opt;
|
||||
opt.meta.backend_uri = "http://127.0.0.1";
|
||||
opt.meta.path = "/tmp/db_test";
|
||||
opt.meta.path = "/tmp/vecwise_test/db_test";
|
||||
|
||||
engine::DB* db = nullptr;
|
||||
engine::DB::Open(opt, &db);
|
||||
|
|
|
@ -14,6 +14,7 @@ set(require_files
|
|||
../../src/server/VecIdMapper.cpp
|
||||
../../src/server/ServerConfig.cpp
|
||||
../../src/utils/CommonUtil.cpp
|
||||
../../src/utils/TimeRecorder.cpp
|
||||
)
|
||||
|
||||
add_executable(server_test
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// 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/CommonUtil.h"
|
||||
#include "utils/Error.h"
|
||||
|
||||
using namespace zilliz::vecwise;
|
||||
|
||||
|
||||
TEST(CommonTest, COMMON_TEST) {
|
||||
std::string path1 = "/tmp/vecwise_test/common_test_12345/";
|
||||
std::string path2 = path1 + "abcdef";
|
||||
server::ServerError err = server::CommonUtil::CreateDirectory(path2);
|
||||
ASSERT_EQ(err, server::SERVER_SUCCESS);
|
||||
|
||||
ASSERT_TRUE(server::CommonUtil::IsDirectoryExit(path2));
|
||||
|
||||
err = server::CommonUtil::DeleteDirectory(path1);
|
||||
ASSERT_EQ(err, server::SERVER_SUCCESS);
|
||||
|
||||
ASSERT_FALSE(server::CommonUtil::IsDirectoryExit(path1));
|
||||
}
|
|
@ -6,13 +6,16 @@
|
|||
#include <gtest/gtest.h>
|
||||
#include "server/ServerConfig.h"
|
||||
#include "server/VecIdMapper.h"
|
||||
#include "utils/TimeRecorder.h"
|
||||
#include "utils/CommonUtil.h"
|
||||
|
||||
using namespace zilliz::vecwise;
|
||||
|
||||
|
||||
TEST(IdMapperTest, IDMAPPER_TEST) {
|
||||
std::string db_path = "/tmp/vecwise_test";
|
||||
server::ConfigNode& server_config = server::ServerConfig::GetInstance().GetConfig("server_config");
|
||||
server_config.SetValue("db_path", "/tmp/vecwise_test");
|
||||
server_config.SetValue("db_path", db_path);
|
||||
|
||||
server::IVecIdMapper* mapper = server::IVecIdMapper::GetInstance();
|
||||
|
||||
|
@ -40,5 +43,32 @@ TEST(IdMapperTest, IDMAPPER_TEST) {
|
|||
|
||||
err = mapper->Get(900, str_id);
|
||||
ASSERT_NE(err, server::SERVER_SUCCESS);
|
||||
|
||||
|
||||
//performance?
|
||||
nid.clear();
|
||||
sid.clear();
|
||||
const int64_t count = 1000000;
|
||||
for(int64_t i = 0; i < count; i++) {
|
||||
nid.push_back(i+100000);
|
||||
sid.push_back("val_" + std::to_string(i));
|
||||
}
|
||||
|
||||
{
|
||||
std::string str_info = "Insert " + std::to_string(count) + " k/v into mapper";
|
||||
server::TimeRecorder rc(str_info);
|
||||
err = mapper->Put(nid, sid);
|
||||
ASSERT_EQ(err, server::SERVER_SUCCESS);
|
||||
rc.Record("done!");
|
||||
}
|
||||
|
||||
{
|
||||
std::string str_info = "Get " + std::to_string(count) + " k/v from mapper";
|
||||
server::TimeRecorder rc(str_info);
|
||||
std::vector<std::string> res;
|
||||
err = mapper->Get(nid, res);
|
||||
ASSERT_EQ(res.size(), nid.size());
|
||||
rc.Record("done!");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue