feat(db): add db factories

Former-commit-id: df8ec1140cc82755e14a739cbb22fb035b3c7d18
This commit is contained in:
Xu Peng 2019-04-29 14:06:40 +08:00
parent 3dfdfef07a
commit c1d40bfb3d
2 changed files with 66 additions and 0 deletions

39
cpp/src/db/Factories.cpp Normal file
View File

@ -0,0 +1,39 @@
////////////////////////////////////////////////////////////////////////////////
// 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;
}
} // namespace engine
} // namespace vecwise
} // namespace zilliz

27
cpp/src/db/Factories.h Normal file
View File

@ -0,0 +1,27 @@
////////////////////////////////////////////////////////////////////////////////
// Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
// Unauthorized copying of this file, via any medium is strictly prohibited.
// Proprietary and confidential.
////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <string>
#include "db/DB.h"
namespace zilliz {
namespace vecwise {
namespace engine {
struct DBMetaOptionsFactory {
static DBMetaOptions Build(const std::string& path = "");
};
struct OptionsFactory {
static Options Build();
};
} // namespace engine
} // namespace vecwise
} // namespace zilliz