mirror of https://github.com/milvus-io/milvus.git
Merge remote-tracking branch 'main/branch-0.4.0' into branch-0.4.0
Former-commit-id: 3c80472df6cff1a661116f5a16f0ff405948a262pull/191/head
commit
f4d006ad1f
|
@ -6,10 +6,13 @@ container('milvus-build-env') {
|
|||
def knowhere_build_dir = "${env.WORKSPACE}/milvus_engine/cpp/thirdparty/knowhere/cmake_build"
|
||||
|
||||
checkout([$class: 'GitSCM', branches: [[name: "${SEMVER}"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'SubmoduleOption',disableSubmodules: false,parentCredentials: true,recursiveSubmodules: true,reference: '',trackingSubmodules: false]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: "${params.GIT_USER}", url: "git@192.168.1.105:megasearch/milvus.git", name: 'origin', refspec: "+refs/heads/${SEMVER}:refs/remotes/origin/${SEMVER}"]]])
|
||||
|
||||
/*
|
||||
dir ("cpp/thirdparty/knowhere") {
|
||||
checkout([$class: 'GitSCM', branches: [[name: "${SEMVER}"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'SubmoduleOption',disableSubmodules: false,parentCredentials: true,recursiveSubmodules: true,reference: '',trackingSubmodules: false]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: "${params.GIT_USER}", url: "git@192.168.1.105:megasearch/knowhere.git", name: 'origin', refspec: "+refs/heads/${SEMVER}:refs/remotes/origin/${SEMVER}"]]])
|
||||
sh "./build.sh -t ${params.BUILD_TYPE} -p ${knowhere_build_dir} -j"
|
||||
}
|
||||
*/
|
||||
|
||||
dir ("cpp") {
|
||||
sh "git config --global user.email \"test@zilliz.com\""
|
||||
|
|
|
@ -7,10 +7,12 @@ container('milvus-build-env') {
|
|||
|
||||
checkout([$class: 'GitSCM', branches: [[name: "${SEMVER}"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'SubmoduleOption',disableSubmodules: false,parentCredentials: true,recursiveSubmodules: true,reference: '',trackingSubmodules: false]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: "${params.GIT_USER}", url: "git@192.168.1.105:megasearch/milvus.git", name: 'origin', refspec: "+refs/heads/${SEMVER}:refs/remotes/origin/${SEMVER}"]]])
|
||||
|
||||
/*
|
||||
dir ("cpp/thirdparty/knowhere") {
|
||||
checkout([$class: 'GitSCM', branches: [[name: "${SEMVER}"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'SubmoduleOption',disableSubmodules: false,parentCredentials: true,recursiveSubmodules: true,reference: '',trackingSubmodules: false]], submoduleCfg: [], userRemoteConfigs: [[credentialsId: "${params.GIT_USER}", url: "git@192.168.1.105:megasearch/knowhere.git", name: 'origin', refspec: "+refs/heads/${SEMVER}:refs/remotes/origin/${SEMVER}"]]])
|
||||
sh "./build.sh -t ${params.BUILD_TYPE} -p ${knowhere_build_dir} -j"
|
||||
}
|
||||
*/
|
||||
|
||||
dir ("cpp") {
|
||||
sh "git config --global user.email \"test@zilliz.com\""
|
||||
|
|
|
@ -16,6 +16,7 @@ Please mark all change in change log and use the ticket from JIRA.
|
|||
- MS-331 - Crate Table : when table exists, error code is META_FAILED(code=15) rather than ILLEGAL TABLE NAME(code=9))
|
||||
- MS-430 - Search no result if index created with FLAT
|
||||
- MS-443 - Create index hang again
|
||||
- MS-436 - Delete vectors failed if index created with index_type: IVF_FLAT/IVF_SQ8
|
||||
|
||||
## Improvement
|
||||
- MS-327 - Clean code for milvus
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
BUILD_TYPE="Debug"
|
||||
BUILD_UNITTEST="OFF"
|
||||
LICENSE_CHECK="OFF"
|
||||
INSTALL_PREFIX=$(pwd)/milvus
|
||||
MAKE_CLEAN="OFF"
|
||||
BUILD_COVERAGE="OFF"
|
||||
|
@ -12,7 +11,7 @@ BUILD_FAISS_WITH_MKL="OFF"
|
|||
USE_JFROG_CACHE="OFF"
|
||||
KNOWHERE_BUILD_DIR="`pwd`/src/core/cmake_build"
|
||||
|
||||
while getopts "p:d:t:k:uhlrcgmj" arg
|
||||
while getopts "p:d:t:k:uhrcgmj" arg
|
||||
do
|
||||
case $arg in
|
||||
t)
|
||||
|
@ -28,9 +27,6 @@ do
|
|||
d)
|
||||
DB_PATH=$OPTARG
|
||||
;;
|
||||
l)
|
||||
LICENSE_CHECK="ON"
|
||||
;;
|
||||
r)
|
||||
if [[ -d cmake_build ]]; then
|
||||
rm ./cmake_build -r
|
||||
|
@ -60,7 +56,6 @@ parameter:
|
|||
-u: building unit test options(default: OFF)
|
||||
-p: install prefix(default: $(pwd)/milvus)
|
||||
-d: db path(default: /opt/milvus)
|
||||
-l: build license version(default: OFF)
|
||||
-r: remove previous build directory(default: OFF)
|
||||
-c: code coverage(default: OFF)
|
||||
-g: profiling(default: OFF)
|
||||
|
@ -94,7 +89,6 @@ if [[ ${MAKE_CLEAN} == "ON" ]]; then
|
|||
-DCMAKE_INSTALL_PREFIX=${INSTALL_PREFIX}
|
||||
-DCMAKE_BUILD_TYPE=${BUILD_TYPE} \
|
||||
-DCMAKE_CUDA_COMPILER=${CUDA_COMPILER} \
|
||||
-DCMAKE_LICENSE_CHECK=${LICENSE_CHECK} \
|
||||
-DBUILD_COVERAGE=${BUILD_COVERAGE} \
|
||||
-DMILVUS_DB_PATH=${DB_PATH} \
|
||||
-DMILVUS_ENABLE_PROFILING=${PROFILING} \
|
||||
|
|
|
@ -162,7 +162,7 @@ Status DBImpl::Query(const std::string &table_id, uint64_t k, uint64_t nq, uint6
|
|||
const float *vectors, QueryResults &results) {
|
||||
server::CollectQueryMetrics metrics(nq);
|
||||
|
||||
meta::DatesT dates = {meta::Meta::GetDate()};
|
||||
meta::DatesT dates = {utils::GetDate()};
|
||||
Status result = Query(table_id, k, nq, nprobe, vectors, dates, results);
|
||||
|
||||
return result;
|
||||
|
|
|
@ -156,6 +156,35 @@ bool UserDefinedId(int64_t flag) {
|
|||
return flag & meta::FLAG_MASK_USERID;
|
||||
}
|
||||
|
||||
meta::DateT GetDate(const std::time_t& t, int day_delta) {
|
||||
struct tm ltm;
|
||||
localtime_r(&t, <m);
|
||||
if (day_delta > 0) {
|
||||
do {
|
||||
++ltm.tm_mday;
|
||||
--day_delta;
|
||||
} while(day_delta > 0);
|
||||
mktime(<m);
|
||||
} else if (day_delta < 0) {
|
||||
do {
|
||||
--ltm.tm_mday;
|
||||
++day_delta;
|
||||
} while(day_delta < 0);
|
||||
mktime(<m);
|
||||
} else {
|
||||
ltm.tm_mday;
|
||||
}
|
||||
return ltm.tm_year*10000 + ltm.tm_mon*100 + ltm.tm_mday;
|
||||
}
|
||||
|
||||
meta::DateT GetDateWithDelta(int day_delta) {
|
||||
return GetDate(std::time(nullptr), day_delta);
|
||||
}
|
||||
|
||||
meta::DateT GetDate() {
|
||||
return GetDate(std::time(nullptr), 0);
|
||||
}
|
||||
|
||||
} // namespace utils
|
||||
} // namespace engine
|
||||
} // namespace milvus
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include "db/Types.h"
|
||||
|
||||
#include <string>
|
||||
#include <ctime>
|
||||
|
||||
namespace zilliz {
|
||||
namespace milvus {
|
||||
|
@ -29,6 +30,10 @@ bool IsSameIndex(const TableIndex& index1, const TableIndex& index2);
|
|||
|
||||
bool UserDefinedId(int64_t flag);
|
||||
|
||||
meta::DateT GetDate(const std::time_t &t, int day_delta = 0);
|
||||
meta::DateT GetDate();
|
||||
meta::DateT GetDateWithDelta(int day_delta);
|
||||
|
||||
} // namespace utils
|
||||
} // namespace engine
|
||||
} // namespace milvus
|
||||
|
|
|
@ -1,50 +0,0 @@
|
|||
/*******************************************************************************
|
||||
* Copyright 上海赜睿信息科技有限公司(Zilliz) - All Rights Reserved
|
||||
* Unauthorized copying of this file, via any medium is strictly prohibited.
|
||||
* Proprietary and confidential.
|
||||
******************************************************************************/
|
||||
#include "Meta.h"
|
||||
|
||||
#include <ctime>
|
||||
#include <stdio.h>
|
||||
|
||||
namespace zilliz {
|
||||
namespace milvus {
|
||||
namespace engine {
|
||||
namespace meta {
|
||||
|
||||
Meta::~Meta() = default;
|
||||
|
||||
DateT Meta::GetDate(const std::time_t& t, int day_delta) {
|
||||
struct tm ltm;
|
||||
localtime_r(&t, <m);
|
||||
if (day_delta > 0) {
|
||||
do {
|
||||
++ltm.tm_mday;
|
||||
--day_delta;
|
||||
} while(day_delta > 0);
|
||||
mktime(<m);
|
||||
} else if (day_delta < 0) {
|
||||
do {
|
||||
--ltm.tm_mday;
|
||||
++day_delta;
|
||||
} while(day_delta < 0);
|
||||
mktime(<m);
|
||||
} else {
|
||||
ltm.tm_mday;
|
||||
}
|
||||
return ltm.tm_year*10000 + ltm.tm_mon*100 + ltm.tm_mday;
|
||||
}
|
||||
|
||||
DateT Meta::GetDateWithDelta(int day_delta) {
|
||||
return GetDate(std::time(nullptr), day_delta);
|
||||
}
|
||||
|
||||
DateT Meta::GetDate() {
|
||||
return GetDate(std::time(nullptr), 0);
|
||||
}
|
||||
|
||||
} // namespace meta
|
||||
} // namespace engine
|
||||
} // namespace milvus
|
||||
} // namespace zilliz
|
|
@ -11,7 +11,6 @@
|
|||
#include "db/Types.h"
|
||||
|
||||
#include <cstddef>
|
||||
#include <ctime>
|
||||
#include <memory>
|
||||
|
||||
namespace zilliz {
|
||||
|
@ -19,105 +18,70 @@ namespace milvus {
|
|||
namespace engine {
|
||||
namespace meta {
|
||||
|
||||
|
||||
class Meta {
|
||||
public:
|
||||
using Ptr = std::shared_ptr<Meta>;
|
||||
|
||||
virtual
|
||||
~Meta() = 0;
|
||||
virtual ~Meta() = default;
|
||||
|
||||
virtual Status
|
||||
CreateTable(TableSchema &table_schema) = 0;
|
||||
virtual Status CreateTable(TableSchema &table_schema) = 0;
|
||||
|
||||
virtual Status
|
||||
DescribeTable(TableSchema &table_schema) = 0;
|
||||
virtual Status DescribeTable(TableSchema &table_schema) = 0;
|
||||
|
||||
virtual Status
|
||||
HasTable(const std::string &table_id, bool &has_or_not) = 0;
|
||||
virtual Status HasTable(const std::string &table_id, bool &has_or_not) = 0;
|
||||
|
||||
virtual Status
|
||||
AllTables(std::vector<TableSchema> &table_schema_array) = 0;
|
||||
virtual Status AllTables(std::vector<TableSchema> &table_schema_array) = 0;
|
||||
|
||||
virtual Status
|
||||
UpdateTableIndexParam(const std::string &table_id, const TableIndex& index) = 0;
|
||||
virtual Status UpdateTableIndexParam(const std::string &table_id, const TableIndex& index) = 0;
|
||||
|
||||
virtual Status
|
||||
UpdateTableFlag(const std::string &table_id, int64_t flag) = 0;
|
||||
virtual Status UpdateTableFlag(const std::string &table_id, int64_t flag) = 0;
|
||||
|
||||
virtual Status
|
||||
DeleteTable(const std::string &table_id) = 0;
|
||||
virtual Status DeleteTable(const std::string &table_id) = 0;
|
||||
|
||||
virtual Status
|
||||
DeleteTableFiles(const std::string &table_id) = 0;
|
||||
virtual Status DeleteTableFiles(const std::string &table_id) = 0;
|
||||
|
||||
virtual Status
|
||||
CreateTableFile(TableFileSchema &file_schema) = 0;
|
||||
virtual Status CreateTableFile(TableFileSchema &file_schema) = 0;
|
||||
|
||||
virtual Status
|
||||
DropPartitionsByDates(const std::string &table_id, const DatesT &dates) = 0;
|
||||
virtual Status DropPartitionsByDates(const std::string &table_id, const DatesT &dates) = 0;
|
||||
|
||||
virtual Status
|
||||
GetTableFiles(const std::string &table_id, const std::vector<size_t> &ids, TableFilesSchema &table_files) = 0;
|
||||
virtual Status GetTableFiles(const std::string &table_id,
|
||||
const std::vector<size_t> &ids,
|
||||
TableFilesSchema &table_files) = 0;
|
||||
|
||||
virtual Status
|
||||
UpdateTableFilesToIndex(const std::string &table_id) = 0;
|
||||
virtual Status UpdateTableFilesToIndex(const std::string &table_id) = 0;
|
||||
|
||||
virtual Status
|
||||
UpdateTableFile(TableFileSchema &file_schema) = 0;
|
||||
virtual Status UpdateTableFile(TableFileSchema &file_schema) = 0;
|
||||
|
||||
virtual Status
|
||||
UpdateTableFiles(TableFilesSchema &files) = 0;
|
||||
virtual Status UpdateTableFiles(TableFilesSchema &files) = 0;
|
||||
|
||||
virtual Status
|
||||
FilesToSearch(const std::string &table_id,
|
||||
const std::vector<size_t> &ids,
|
||||
const DatesT &partition,
|
||||
DatePartionedTableFilesSchema &files) = 0;
|
||||
virtual Status FilesToSearch(const std::string &table_id,
|
||||
const std::vector<size_t> &ids,
|
||||
const DatesT &partition,
|
||||
DatePartionedTableFilesSchema &files) = 0;
|
||||
|
||||
virtual Status
|
||||
FilesToMerge(const std::string &table_id, DatePartionedTableFilesSchema &files) = 0;
|
||||
virtual Status FilesToMerge(const std::string &table_id, DatePartionedTableFilesSchema &files) = 0;
|
||||
|
||||
virtual Status
|
||||
Size(uint64_t &result) = 0;
|
||||
virtual Status Size(uint64_t &result) = 0;
|
||||
|
||||
virtual Status
|
||||
Archive() = 0;
|
||||
virtual Status Archive() = 0;
|
||||
|
||||
virtual Status
|
||||
FilesToIndex(TableFilesSchema &) = 0;
|
||||
virtual Status FilesToIndex(TableFilesSchema &) = 0;
|
||||
|
||||
virtual Status
|
||||
FilesByType(const std::string &table_id,
|
||||
const std::vector<int> &file_types,
|
||||
std::vector<std::string>& file_ids) = 0;
|
||||
virtual Status FilesByType(const std::string &table_id,
|
||||
const std::vector<int> &file_types,
|
||||
std::vector<std::string>& file_ids) = 0;
|
||||
|
||||
virtual Status
|
||||
DescribeTableIndex(const std::string &table_id, TableIndex& index) = 0;
|
||||
virtual Status DescribeTableIndex(const std::string &table_id, TableIndex& index) = 0;
|
||||
|
||||
virtual Status
|
||||
DropTableIndex(const std::string &table_id) = 0;
|
||||
virtual Status DropTableIndex(const std::string &table_id) = 0;
|
||||
|
||||
virtual Status
|
||||
CleanUp() = 0;
|
||||
virtual Status CleanUp() = 0;
|
||||
|
||||
virtual Status
|
||||
CleanUpFilesWithTTL(uint16_t) = 0;
|
||||
virtual Status CleanUpFilesWithTTL(uint16_t) = 0;
|
||||
|
||||
virtual Status
|
||||
DropAll() = 0;
|
||||
virtual Status DropAll() = 0;
|
||||
|
||||
virtual Status
|
||||
Count(const std::string &table_id, uint64_t &result) = 0;
|
||||
|
||||
static DateT
|
||||
GetDate(const std::time_t &t, int day_delta = 0);
|
||||
|
||||
static DateT
|
||||
GetDate();
|
||||
|
||||
static DateT
|
||||
GetDateWithDelta(int day_delta);
|
||||
virtual Status Count(const std::string &table_id, uint64_t &result) = 0;
|
||||
|
||||
}; // MetaData
|
||||
|
||||
|
|
|
@ -41,6 +41,18 @@ Status HandleException(const std::string &desc, std::exception &e) {
|
|||
|
||||
}
|
||||
|
||||
MySQLMetaImpl::MySQLMetaImpl(const DBMetaOptions &options_, const int &mode)
|
||||
: options_(options_),
|
||||
mode_(mode) {
|
||||
Initialize();
|
||||
}
|
||||
|
||||
MySQLMetaImpl::~MySQLMetaImpl() {
|
||||
if (mode_ != Options::MODE::READ_ONLY) {
|
||||
CleanUp();
|
||||
}
|
||||
}
|
||||
|
||||
Status MySQLMetaImpl::NextTableId(std::string &table_id) {
|
||||
std::stringstream ss;
|
||||
SimpleIDGenerator g;
|
||||
|
@ -57,12 +69,6 @@ Status MySQLMetaImpl::NextFileId(std::string &file_id) {
|
|||
return Status::OK();
|
||||
}
|
||||
|
||||
MySQLMetaImpl::MySQLMetaImpl(const DBMetaOptions &options_, const int &mode)
|
||||
: options_(options_),
|
||||
mode_(mode) {
|
||||
Initialize();
|
||||
}
|
||||
|
||||
Status MySQLMetaImpl::Initialize() {
|
||||
if (!boost::filesystem::is_directory(options_.path)) {
|
||||
auto ret = boost::filesystem::create_directory(options_.path);
|
||||
|
@ -202,15 +208,6 @@ Status MySQLMetaImpl::DropPartitionsByDates(const std::string &table_id,
|
|||
}
|
||||
|
||||
try {
|
||||
|
||||
auto yesterday = GetDateWithDelta(-1);
|
||||
|
||||
for (auto &date : dates) {
|
||||
if (date >= yesterday) {
|
||||
return Status::Error("Could not delete partitions within 2 days");
|
||||
}
|
||||
}
|
||||
|
||||
std::stringstream dateListSS;
|
||||
for (auto &date : dates) {
|
||||
dateListSS << std::to_string(date) << ", ";
|
||||
|
@ -229,7 +226,8 @@ Status MySQLMetaImpl::DropPartitionsByDates(const std::string &table_id,
|
|||
Query dropPartitionsByDatesQuery = connectionPtr->query();
|
||||
|
||||
dropPartitionsByDatesQuery << "UPDATE TableFiles " <<
|
||||
"SET file_type = " << std::to_string(TableFileSchema::TO_DELETE) << " " <<
|
||||
"SET file_type = " << std::to_string(TableFileSchema::TO_DELETE) << "," <<
|
||||
"updated_time = " << utils::GetMicroSecTimeStamp() << " " <<
|
||||
"WHERE table_id = " << quote << table_id << " AND " <<
|
||||
"date in (" << dateListStr << ");";
|
||||
|
||||
|
@ -877,7 +875,7 @@ Status MySQLMetaImpl::AllTables(std::vector<TableSchema> &table_schema_array) {
|
|||
|
||||
Status MySQLMetaImpl::CreateTableFile(TableFileSchema &file_schema) {
|
||||
if (file_schema.date_ == EmptyDate) {
|
||||
file_schema.date_ = Meta::GetDate();
|
||||
file_schema.date_ = utils::GetDate();
|
||||
}
|
||||
TableSchema table_schema;
|
||||
table_schema.table_id_ = file_schema.table_id_;
|
||||
|
@ -2031,12 +2029,6 @@ Status MySQLMetaImpl::DropAll() {
|
|||
return Status::OK();
|
||||
}
|
||||
|
||||
MySQLMetaImpl::~MySQLMetaImpl() {
|
||||
if (mode_ != Options::MODE::READ_ONLY) {
|
||||
CleanUp();
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace meta
|
||||
} // namespace engine
|
||||
} // namespace milvus
|
||||
|
|
|
@ -24,6 +24,7 @@ using namespace mysqlpp;
|
|||
class MySQLMetaImpl : public Meta {
|
||||
public:
|
||||
MySQLMetaImpl(const DBMetaOptions &options_, const int &mode);
|
||||
~MySQLMetaImpl();
|
||||
|
||||
Status CreateTable(TableSchema &table_schema) override;
|
||||
|
||||
|
@ -86,8 +87,6 @@ class MySQLMetaImpl : public Meta {
|
|||
|
||||
Status Count(const std::string &table_id, uint64_t &result) override;
|
||||
|
||||
virtual ~MySQLMetaImpl();
|
||||
|
||||
private:
|
||||
Status NextFileId(std::string &file_id);
|
||||
Status NextTableId(std::string &table_id);
|
||||
|
|
|
@ -68,6 +68,15 @@ using ConnectorT = decltype(StoragePrototype(""));
|
|||
static std::unique_ptr<ConnectorT> ConnectorPtr;
|
||||
using ConditionT = decltype(c(&TableFileSchema::id_) == 1UL);
|
||||
|
||||
SqliteMetaImpl::SqliteMetaImpl(const DBMetaOptions &options_)
|
||||
: options_(options_) {
|
||||
Initialize();
|
||||
}
|
||||
|
||||
SqliteMetaImpl::~SqliteMetaImpl() {
|
||||
CleanUp();
|
||||
}
|
||||
|
||||
Status SqliteMetaImpl::NextTableId(std::string &table_id) {
|
||||
std::stringstream ss;
|
||||
SimpleIDGenerator g;
|
||||
|
@ -84,11 +93,6 @@ Status SqliteMetaImpl::NextFileId(std::string &file_id) {
|
|||
return Status::OK();
|
||||
}
|
||||
|
||||
SqliteMetaImpl::SqliteMetaImpl(const DBMetaOptions &options_)
|
||||
: options_(options_) {
|
||||
Initialize();
|
||||
}
|
||||
|
||||
Status SqliteMetaImpl::Initialize() {
|
||||
if (!boost::filesystem::is_directory(options_.path)) {
|
||||
auto ret = boost::filesystem::create_directory(options_.path);
|
||||
|
@ -111,7 +115,7 @@ Status SqliteMetaImpl::Initialize() {
|
|||
|
||||
// PXU TODO: Temp solution. Will fix later
|
||||
Status SqliteMetaImpl::DropPartitionsByDates(const std::string &table_id,
|
||||
const DatesT &dates) {
|
||||
const DatesT &dates) {
|
||||
if (dates.size() == 0) {
|
||||
return Status::OK();
|
||||
}
|
||||
|
@ -124,20 +128,13 @@ Status SqliteMetaImpl::DropPartitionsByDates(const std::string &table_id,
|
|||
}
|
||||
|
||||
try {
|
||||
auto yesterday = GetDateWithDelta(-1);
|
||||
|
||||
for (auto &date : dates) {
|
||||
if (date >= yesterday) {
|
||||
return Status::Error("Could not delete partitions with 2 days");
|
||||
}
|
||||
}
|
||||
|
||||
//multi-threads call sqlite update may get exception('bad logic', etc), so we add a lock here
|
||||
std::lock_guard<std::mutex> meta_lock(meta_mutex_);
|
||||
|
||||
ConnectorPtr->update_all(
|
||||
set(
|
||||
c(&TableFileSchema::file_type_) = (int) TableFileSchema::TO_DELETE
|
||||
c(&TableFileSchema::file_type_) = (int) TableFileSchema::TO_DELETE,
|
||||
c(&TableFileSchema::updated_time_) = utils::GetMicroSecTimeStamp()
|
||||
),
|
||||
where(
|
||||
c(&TableFileSchema::table_id_) == table_id and
|
||||
|
@ -543,7 +540,7 @@ Status SqliteMetaImpl::AllTables(std::vector<TableSchema>& table_schema_array) {
|
|||
|
||||
Status SqliteMetaImpl::CreateTableFile(TableFileSchema &file_schema) {
|
||||
if (file_schema.date_ == EmptyDate) {
|
||||
file_schema.date_ = Meta::GetDate();
|
||||
file_schema.date_ = utils::GetDate();
|
||||
}
|
||||
TableSchema table_schema;
|
||||
table_schema.table_id_ = file_schema.table_id_;
|
||||
|
@ -1214,10 +1211,6 @@ Status SqliteMetaImpl::DropAll() {
|
|||
return Status::OK();
|
||||
}
|
||||
|
||||
SqliteMetaImpl::~SqliteMetaImpl() {
|
||||
CleanUp();
|
||||
}
|
||||
|
||||
} // namespace meta
|
||||
} // namespace engine
|
||||
} // namespace milvus
|
||||
|
|
|
@ -20,6 +20,7 @@ auto StoragePrototype(const std::string &path);
|
|||
class SqliteMetaImpl : public Meta {
|
||||
public:
|
||||
explicit SqliteMetaImpl(const DBMetaOptions &options_);
|
||||
~SqliteMetaImpl();
|
||||
|
||||
Status CreateTable(TableSchema &table_schema) override;
|
||||
|
||||
|
@ -80,8 +81,6 @@ class SqliteMetaImpl : public Meta {
|
|||
|
||||
Status Count(const std::string &table_id, uint64_t &result) override;
|
||||
|
||||
~SqliteMetaImpl() override;
|
||||
|
||||
private:
|
||||
Status NextFileId(std::string &file_id);
|
||||
Status NextTableId(std::string &table_id);
|
||||
|
|
|
@ -93,6 +93,7 @@ namespace {
|
|||
return;
|
||||
}
|
||||
|
||||
//range: [start_day, end_day)
|
||||
for (long i = 0; i < days; i++) {
|
||||
time_t tt_day = tt_start + DAY_SECONDS * i;
|
||||
tm tm_day;
|
||||
|
|
|
@ -293,18 +293,15 @@ TEST_F(DBTest, PRELOADTABLE_TEST) {
|
|||
ASSERT_STATS(stat);
|
||||
ASSERT_EQ(table_info_get.dimension_, TABLE_DIM);
|
||||
|
||||
engine::IDNumbers vector_ids;
|
||||
engine::IDNumbers target_ids;
|
||||
|
||||
int64_t nb = 100000;
|
||||
int64_t nb = VECTOR_COUNT;
|
||||
std::vector<float> xb;
|
||||
BuildVectors(nb, xb);
|
||||
|
||||
int loop = 5;
|
||||
|
||||
for (auto i=0; i<loop; ++i) {
|
||||
db_->InsertVectors(TABLE_NAME, nb, xb.data(), target_ids);
|
||||
ASSERT_EQ(target_ids.size(), nb);
|
||||
engine::IDNumbers vector_ids;
|
||||
db_->InsertVectors(TABLE_NAME, nb, xb.data(), vector_ids);
|
||||
ASSERT_EQ(vector_ids.size(), nb);
|
||||
}
|
||||
|
||||
engine::TableIndex index;
|
||||
|
@ -342,9 +339,6 @@ TEST_F(DBTest2, ARHIVE_DISK_CHECK) {
|
|||
ASSERT_STATS(stat);
|
||||
ASSERT_EQ(table_info_get.dimension_, TABLE_DIM);
|
||||
|
||||
engine::IDNumbers vector_ids;
|
||||
engine::IDNumbers target_ids;
|
||||
|
||||
uint64_t size;
|
||||
db_->Size(size);
|
||||
|
||||
|
@ -354,6 +348,7 @@ TEST_F(DBTest2, ARHIVE_DISK_CHECK) {
|
|||
|
||||
int loop = INSERT_LOOP;
|
||||
for (auto i=0; i<loop; ++i) {
|
||||
engine::IDNumbers vector_ids;
|
||||
db_->InsertVectors(TABLE_NAME, nb, xb.data(), vector_ids);
|
||||
std::this_thread::sleep_for(std::chrono::microseconds(1));
|
||||
}
|
||||
|
@ -378,20 +373,17 @@ TEST_F(DBTest2, DELETE_TEST) {
|
|||
db_->HasTable(TABLE_NAME, has_table);
|
||||
ASSERT_TRUE(has_table);
|
||||
|
||||
engine::IDNumbers vector_ids;
|
||||
|
||||
uint64_t size;
|
||||
db_->Size(size);
|
||||
|
||||
int64_t nb = INSERT_LOOP;
|
||||
int64_t nb = VECTOR_COUNT;
|
||||
std::vector<float> xb;
|
||||
BuildVectors(nb, xb);
|
||||
|
||||
int loop = 20;
|
||||
for (auto i=0; i<loop; ++i) {
|
||||
db_->InsertVectors(TABLE_NAME, nb, xb.data(), vector_ids);
|
||||
std::this_thread::sleep_for(std::chrono::microseconds(1));
|
||||
}
|
||||
engine::IDNumbers vector_ids;
|
||||
stat = db_->InsertVectors(TABLE_NAME, nb, xb.data(), vector_ids);
|
||||
engine::TableIndex index;
|
||||
stat = db_->CreateIndex(TABLE_NAME, index);
|
||||
|
||||
std::vector<engine::meta::DateT> dates;
|
||||
stat = db_->DeleteTable(TABLE_NAME, dates);
|
||||
|
@ -420,25 +412,31 @@ TEST_F(DBTest2, DELETE_BY_RANGE_TEST) {
|
|||
db_->HasTable(TABLE_NAME, has_table);
|
||||
ASSERT_TRUE(has_table);
|
||||
|
||||
engine::IDNumbers vector_ids;
|
||||
|
||||
uint64_t size;
|
||||
db_->Size(size);
|
||||
ASSERT_EQ(size, 0UL);
|
||||
|
||||
int64_t nb = INSERT_LOOP;
|
||||
int64_t nb = VECTOR_COUNT;
|
||||
std::vector<float> xb;
|
||||
BuildVectors(nb, xb);
|
||||
|
||||
int loop = 20;
|
||||
for (auto i=0; i<loop; ++i) {
|
||||
db_->InsertVectors(TABLE_NAME, nb, xb.data(), vector_ids);
|
||||
std::this_thread::sleep_for(std::chrono::microseconds(1));
|
||||
}
|
||||
engine::IDNumbers vector_ids;
|
||||
stat = db_->InsertVectors(TABLE_NAME, nb, xb.data(), vector_ids);
|
||||
engine::TableIndex index;
|
||||
stat = db_->CreateIndex(TABLE_NAME, index);
|
||||
|
||||
db_->Size(size);
|
||||
ASSERT_NE(size, 0UL);
|
||||
|
||||
std::vector<engine::meta::DateT> dates;
|
||||
std::string start_value = CurrentTmDate(-3);
|
||||
std::string end_value = CurrentTmDate(-2);
|
||||
std::string start_value = CurrentTmDate();
|
||||
std::string end_value = CurrentTmDate(1);
|
||||
ConvertTimeRangeToDBDates(start_value, end_value, dates);
|
||||
|
||||
db_->DeleteTable(TABLE_NAME, dates);
|
||||
stat = db_->DeleteTable(TABLE_NAME, dates);
|
||||
ASSERT_STATS(stat);
|
||||
|
||||
uint64_t row_count = 0;
|
||||
db_->GetTableRowCount(TABLE_NAME, row_count);
|
||||
ASSERT_EQ(row_count, 0UL);
|
||||
}
|
|
@ -74,21 +74,21 @@ TEST_F(MetaTest, TABLE_FILE_TEST) {
|
|||
ASSERT_EQ(table_file.file_type_, new_file_type);
|
||||
|
||||
meta::DatesT dates;
|
||||
dates.push_back(meta::Meta::GetDate());
|
||||
dates.push_back(utils::GetDate());
|
||||
status = impl_->DropPartitionsByDates(table_file.table_id_, dates);
|
||||
ASSERT_FALSE(status.ok());
|
||||
ASSERT_TRUE(status.ok());
|
||||
|
||||
dates.clear();
|
||||
for (auto i=2; i < 10; ++i) {
|
||||
dates.push_back(meta::Meta::GetDateWithDelta(-1*i));
|
||||
dates.push_back(utils::GetDateWithDelta(-1*i));
|
||||
}
|
||||
status = impl_->DropPartitionsByDates(table_file.table_id_, dates);
|
||||
ASSERT_TRUE(status.ok());
|
||||
|
||||
table_file.date_ = meta::Meta::GetDateWithDelta(-2);
|
||||
table_file.date_ = utils::GetDateWithDelta(-2);
|
||||
status = impl_->UpdateTableFile(table_file);
|
||||
ASSERT_TRUE(status.ok());
|
||||
ASSERT_EQ(table_file.date_, meta::Meta::GetDateWithDelta(-2));
|
||||
ASSERT_EQ(table_file.date_, utils::GetDateWithDelta(-2));
|
||||
ASSERT_FALSE(table_file.file_type_ == meta::TableFileSchema::TO_DELETE);
|
||||
|
||||
dates.clear();
|
||||
|
|
|
@ -105,7 +105,7 @@ TEST(DBMiscTest, META_TEST) {
|
|||
time_t tt;
|
||||
time( &tt );
|
||||
int delta = 10;
|
||||
engine::meta::DateT dt = impl.GetDate(tt, delta);
|
||||
engine::meta::DateT dt = engine::utils::GetDate(tt, delta);
|
||||
ASSERT_GT(dt, 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ TEST_F(DISABLED_MySQLTest, TABLE_FILE_TEST) {
|
|||
ASSERT_EQ(table_file.file_type_, meta::TableFileSchema::NEW);
|
||||
|
||||
meta::DatesT dates;
|
||||
dates.push_back(meta::Meta::GetDate());
|
||||
dates.push_back(utils::GetDate());
|
||||
status = impl.DropPartitionsByDates(table_file.table_id_, dates);
|
||||
ASSERT_FALSE(status.ok());
|
||||
|
||||
|
@ -110,15 +110,15 @@ TEST_F(DISABLED_MySQLTest, TABLE_FILE_TEST) {
|
|||
|
||||
dates.clear();
|
||||
for (auto i=2; i < 10; ++i) {
|
||||
dates.push_back(meta::Meta::GetDateWithDelta(-1*i));
|
||||
dates.push_back(utils::GetDateWithDelta(-1*i));
|
||||
}
|
||||
status = impl.DropPartitionsByDates(table_file.table_id_, dates);
|
||||
ASSERT_TRUE(status.ok());
|
||||
|
||||
table_file.date_ = meta::Meta::GetDateWithDelta(-2);
|
||||
table_file.date_ = utils::GetDateWithDelta(-2);
|
||||
status = impl.UpdateTableFile(table_file);
|
||||
ASSERT_TRUE(status.ok());
|
||||
ASSERT_EQ(table_file.date_, meta::Meta::GetDateWithDelta(-2));
|
||||
ASSERT_EQ(table_file.date_, utils::GetDateWithDelta(-2));
|
||||
ASSERT_FALSE(table_file.file_type_ == meta::TableFileSchema::TO_DELETE);
|
||||
|
||||
dates.clear();
|
||||
|
|
Loading…
Reference in New Issue