提交 b96459cc 编写于 作者: X Xu Peng

refactor(db): add MetaConsts


Former-commit-id: 5db9dfba91c61274a8334e8daba1488fe5bead3e
上级 767e63bd
......@@ -12,9 +12,11 @@
#include <fstream>
#include <sqlite_orm.h>
#include <easylogging++.h>
#include "DBMetaImpl.h"
#include "IDGenerator.h"
#include "Utils.h"
#include "MetaConsts.h"
namespace zilliz {
namespace vecwise {
......@@ -44,16 +46,9 @@ inline auto StoragePrototype(const std::string& path) {
}
using ConnectorT = decltype(StoragePrototype("/tmp/dummy.sqlite3"));
using ConnectorT = decltype(StoragePrototype(""));
static std::unique_ptr<ConnectorT> ConnectorPtr;
long GetFileSize(const std::string& filename)
{
struct stat stat_buf;
int rc = stat(filename.c_str(), &stat_buf);
return rc == 0 ? stat_buf.st_size : -1;
}
std::string DBMetaImpl::GetGroupPath(const std::string& group_id) {
return _options.path + "/" + group_id;
}
......@@ -457,7 +452,7 @@ Status DBMetaImpl::archive_files() {
auto& criteria = kv.first;
auto& limit = kv.second;
if (criteria == "days") {
long usecs = 3600*24*limit*1000000UL;
long usecs = limit * D_SEC * US_PS;
long now = utils::GetMicroSecTimeStamp();
try
{
......@@ -475,7 +470,6 @@ Status DBMetaImpl::archive_files() {
}
}
if (criteria == "disk") {
size_t G = 1024*1024*1024UL;
long sum = 0;
size(sum);
......@@ -595,7 +589,7 @@ Status DBMetaImpl::cleanup_ttl_files(uint16_t seconds) {
&GroupFileSchema::rows,
&GroupFileSchema::date),
where(c(&GroupFileSchema::file_type) == (int)GroupFileSchema::TO_DELETE and
c(&GroupFileSchema::updated_time) > now - 1000000*seconds));
c(&GroupFileSchema::updated_time) > now - seconds*US_PS));
GroupFilesSchema updated;
......
/*******************************************************************************
* Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
* Unauthorized copying of this file, via any medium is strictly prohibited.
* Proprietary and confidential.
******************************************************************************/
#pragma once
namespace zilliz {
namespace vecwise {
namespace engine {
namespace meta {
const size_t K = 1024UL;
const size_t M = K*K;
const size_t G = K*M;
const size_t T = K*G;
const size_t S_PS = 1UL;
const size_t MS_PS = 1000*S_PS;
const size_t US_PS = 1000*MS_PS;
const size_t NS_PS = 1000*US_PS;
const size_t SECOND = 1UL;
const size_t M_SEC = 60*SECOND;
const size_t H_SEC = 60*M_SEC;
const size_t D_SEC = 24*H_SEC;
const size_t W_SEC = 7*D_SEC;
} // namespace meta
} // namespace engine
} // namespace vecwise
} // namespace zilliz
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册