未验证 提交 6cb65a3a 编写于 作者: C Cai Yudong 提交者: GitHub

fix clang-tidy warnings (#3344)

Signed-off-by: Nyudong.cai <yudong.cai@zilliz.com>
上级 fd7c2554
......@@ -42,22 +42,9 @@ TimeRecorder::PrintTimeRecord(const std::string& msg, double span) {
str_log += ")";
switch (log_level_) {
case 0: {
case 0:
std::cout << str_log << std::endl;
break;
}
case 1: {
LOG_KNOWHERE_DEBUG_ << str_log;
break;
}
// case 2: {
// LOG_KNOWHERE_TRACE_ << str_log;
// break;
// }
// case 3: {
// LOG_KNOWHERE_WARNING_ << str_log;
// break;
// }
default:
LOG_KNOWHERE_DEBUG_ << str_log;
break;
......
......@@ -23,7 +23,7 @@ namespace knowhere {
class Index : public milvus::cache::DataObj {
public:
virtual BinarySet
Serialize(const Config& config = Config()) = 0;
Serialize(const Config& config) = 0;
virtual void
Load(const BinarySet&) = 0;
......
......@@ -24,12 +24,15 @@
namespace milvus {
namespace knowhere {
#define DEFAULT_MAX_DIM 32768
#define DEFAULT_MIN_DIM 1
#define DEFAULT_MAX_K 16384
#define DEFAULT_MIN_K 1
#define DEFAULT_MIN_ROWS 1 // minimum size for build index
#define DEFAULT_MAX_ROWS 50000000
static const int64_t MIN_NLIST = 1;
static const int64_t MAX_NLIST = 1LL << 20;
static const int64_t MIN_NPROBE = 1;
static const int64_t MAX_NPROBE = MAX_NLIST;
static const int64_t DEFAULT_MIN_DIM = 1;
static const int64_t DEFAULT_MAX_DIM = 32768;
static const int64_t DEFAULT_MIN_ROWS = 1; // minimum size for build index
static const int64_t DEFAULT_MAX_ROWS = 50000000;
static const std::vector<std::string> METRICS{knowhere::Metric::L2, knowhere::Metric::IP};
#define CheckIntByRange(key, min, max) \
if (!oricfg.contains(key) || !oricfg[key].is_number_integer() || oricfg[key].get<int64_t>() > max || \
......@@ -59,7 +62,6 @@ namespace knowhere {
bool
ConfAdapter::CheckTrain(Config& oricfg, const IndexMode mode) {
static std::vector<std::string> METRICS{knowhere::Metric::L2, knowhere::Metric::IP};
CheckIntByRange(knowhere::meta::DIM, DEFAULT_MIN_DIM, DEFAULT_MAX_DIM);
CheckStrByValues(knowhere::Metric::TYPE, METRICS);
return true;
......@@ -67,6 +69,8 @@ ConfAdapter::CheckTrain(Config& oricfg, const IndexMode mode) {
bool
ConfAdapter::CheckSearch(Config& oricfg, const IndexType type, const IndexMode mode) {
const int64_t DEFAULT_MIN_K = 1;
const int64_t DEFAULT_MAX_K = 16384;
CheckIntByRange(knowhere::meta::TOPK, DEFAULT_MIN_K - 1, DEFAULT_MAX_K);
return true;
}
......@@ -85,9 +89,6 @@ MatchNlist(int64_t size, int64_t nlist) {
bool
IVFConfAdapter::CheckTrain(Config& oricfg, const IndexMode mode) {
static int64_t MAX_NLIST = 999999;
static int64_t MIN_NLIST = 1;
CheckIntByRange(knowhere::IndexParams::nlist, MIN_NLIST, MAX_NLIST);
CheckIntByRange(knowhere::meta::ROWS, DEFAULT_MIN_ROWS, DEFAULT_MAX_ROWS);
......@@ -109,14 +110,11 @@ IVFConfAdapter::CheckTrain(Config& oricfg, const IndexMode mode) {
bool
IVFConfAdapter::CheckSearch(Config& oricfg, const IndexType type, const IndexMode mode) {
static int64_t MIN_NPROBE = 1;
static int64_t MAX_NPROBE = 999999; // todo(linxj): [1, nlist]
if (mode == IndexMode::MODE_GPU) {
#ifdef MILVUS_GPU_VERSION
CheckIntByRange(knowhere::IndexParams::nprobe, MIN_NPROBE, faiss::gpu::getMaxKSelection());
#endif
} else {
#endif
CheckIntByRange(knowhere::IndexParams::nprobe, MIN_NPROBE, MAX_NPROBE);
}
......@@ -125,7 +123,7 @@ IVFConfAdapter::CheckSearch(Config& oricfg, const IndexType type, const IndexMod
bool
IVFSQConfAdapter::CheckTrain(Config& oricfg, const IndexMode mode) {
static int64_t DEFAULT_NBITS = 8;
const int64_t DEFAULT_NBITS = 8;
oricfg[knowhere::IndexParams::nbits] = DEFAULT_NBITS;
return IVFConfAdapter::CheckTrain(oricfg, mode);
......@@ -133,10 +131,7 @@ IVFSQConfAdapter::CheckTrain(Config& oricfg, const IndexMode mode) {
bool
IVFPQConfAdapter::CheckTrain(Config& oricfg, const IndexMode mode) {
static int64_t DEFAULT_NBITS = 8;
static int64_t MAX_NLIST = 999999;
static int64_t MIN_NLIST = 1;
static std::vector<std::string> METRICS{knowhere::Metric::L2, knowhere::Metric::IP};
const int64_t DEFAULT_NBITS = 8;
oricfg[knowhere::IndexParams::nbits] = DEFAULT_NBITS;
......@@ -174,8 +169,8 @@ IVFPQConfAdapter::GetValidMList(int64_t dimension, std::vector<int64_t>& resset)
* Only 1, 2, 3, 4, 6, 8, 10, 12, 16, 20, 24, 28, 32 dims per sub-quantizer are currently supported with
* no precomputed codes. Precomputed codes supports any number of dimensions, but will involve memory overheads.
*/
static std::vector<int64_t> support_dim_per_subquantizer{32, 28, 24, 20, 16, 12, 10, 8, 6, 4, 3, 2, 1};
static std::vector<int64_t> support_subquantizer{96, 64, 56, 48, 40, 32, 28, 24, 20, 16, 12, 8, 4, 3, 2, 1};
static const std::vector<int64_t> support_dim_per_subquantizer{32, 28, 24, 20, 16, 12, 10, 8, 6, 4, 3, 2, 1};
static const std::vector<int64_t> support_subquantizer{96, 64, 56, 48, 40, 32, 28, 24, 20, 16, 12, 8, 4, 3, 2, 1};
for (const auto& dimperquantizer : support_dim_per_subquantizer) {
if (!(dimension % dimperquantizer)) {
......@@ -190,15 +185,14 @@ IVFPQConfAdapter::GetValidMList(int64_t dimension, std::vector<int64_t>& resset)
bool
NSGConfAdapter::CheckTrain(Config& oricfg, const IndexMode mode) {
static int64_t MIN_KNNG = 5;
static int64_t MAX_KNNG = 300;
static int64_t MIN_SEARCH_LENGTH = 10;
static int64_t MAX_SEARCH_LENGTH = 300;
static int64_t MIN_OUT_DEGREE = 5;
static int64_t MAX_OUT_DEGREE = 300;
static int64_t MIN_CANDIDATE_POOL_SIZE = 50;
static int64_t MAX_CANDIDATE_POOL_SIZE = 1000;
static std::vector<std::string> METRICS{knowhere::Metric::L2, knowhere::Metric::IP};
const int64_t MIN_KNNG = 5;
const int64_t MAX_KNNG = 300;
const int64_t MIN_SEARCH_LENGTH = 10;
const int64_t MAX_SEARCH_LENGTH = 300;
const int64_t MIN_OUT_DEGREE = 5;
const int64_t MAX_OUT_DEGREE = 300;
const int64_t MIN_CANDIDATE_POOL_SIZE = 50;
const int64_t MAX_CANDIDATE_POOL_SIZE = 1000;
CheckStrByValues(knowhere::Metric::TYPE, METRICS);
CheckIntByRange(knowhere::meta::ROWS, DEFAULT_MIN_ROWS, DEFAULT_MAX_ROWS);
......@@ -325,9 +319,9 @@ RHNSWSQConfAdapter::CheckSearch(Config& oricfg, const IndexType type, const Inde
bool
BinIDMAPConfAdapter::CheckTrain(Config& oricfg, const IndexMode mode) {
static std::vector<std::string> METRICS{knowhere::Metric::HAMMING, knowhere::Metric::JACCARD,
knowhere::Metric::TANIMOTO, knowhere::Metric::SUBSTRUCTURE,
knowhere::Metric::SUPERSTRUCTURE};
static const std::vector<std::string> METRICS{knowhere::Metric::HAMMING, knowhere::Metric::JACCARD,
knowhere::Metric::TANIMOTO, knowhere::Metric::SUBSTRUCTURE,
knowhere::Metric::SUPERSTRUCTURE};
CheckIntByRange(knowhere::meta::DIM, DEFAULT_MIN_DIM, DEFAULT_MAX_DIM);
CheckStrByValues(knowhere::Metric::TYPE, METRICS);
......@@ -337,10 +331,8 @@ BinIDMAPConfAdapter::CheckTrain(Config& oricfg, const IndexMode mode) {
bool
BinIVFConfAdapter::CheckTrain(Config& oricfg, const IndexMode mode) {
static std::vector<std::string> METRICS{knowhere::Metric::HAMMING, knowhere::Metric::JACCARD,
knowhere::Metric::TANIMOTO};
static int64_t MAX_NLIST = 999999;
static int64_t MIN_NLIST = 1;
static const std::vector<std::string> METRICS{knowhere::Metric::HAMMING, knowhere::Metric::JACCARD,
knowhere::Metric::TANIMOTO};
CheckIntByRange(knowhere::meta::ROWS, DEFAULT_MIN_ROWS, DEFAULT_MAX_ROWS);
CheckIntByRange(knowhere::meta::DIM, DEFAULT_MIN_DIM, DEFAULT_MAX_DIM);
......
......@@ -30,7 +30,7 @@ class IndexAnnoy : public VecIndex {
}
BinarySet
Serialize(const Config& config = Config()) override;
Serialize(const Config& config) override;
void
Load(const BinarySet& index_binary) override;
......
......@@ -33,10 +33,10 @@ class BinaryIDMAP : public VecIndex, public FaissBaseBinaryIndex {
}
BinarySet
Serialize(const Config& config = Config()) override;
Serialize(const Config&) override;
void
Load(const BinarySet& index_binary) override;
Load(const BinarySet&) override;
void
Train(const DatasetPtr&, const Config&) override;
......
......@@ -36,7 +36,7 @@ class BinaryIVF : public VecIndex, public FaissBaseBinaryIndex {
}
BinarySet
Serialize(const Config& config = Config()) override;
Serialize(const Config& config) override;
void
BuildAll(const DatasetPtr& dataset_ptr, const Config& config) override {
......
......@@ -29,7 +29,7 @@ class IndexHNSW : public VecIndex {
}
BinarySet
Serialize(const Config& config = Config()) override;
Serialize(const Config& config) override;
void
Load(const BinarySet& index_binary) override;
......
......@@ -31,7 +31,7 @@ class IDMAP : public VecIndex, public FaissBaseIndex {
}
BinarySet
Serialize(const Config& config = Config()) override;
Serialize(const Config&) override;
void
Load(const BinarySet&) override;
......
......@@ -36,7 +36,7 @@ class IVF : public VecIndex, public FaissBaseIndex {
}
BinarySet
Serialize(const Config& config = Config()) override;
Serialize(const Config&) override;
void
Load(const BinarySet&) override;
......
......@@ -35,7 +35,7 @@ class NSG : public VecIndex {
}
BinarySet
Serialize(const Config& config = Config()) override;
Serialize(const Config&) override;
void
Load(const BinarySet&) override;
......
......@@ -89,7 +89,7 @@ IndexRHNSWFlat::Train(const DatasetPtr& dataset_ptr, const Config& config) {
auto idx = new faiss::IndexRHNSWFlat(int(dim), config[IndexParams::M], metric_type);
idx->hnsw.efConstruction = config[IndexParams::efConstruction];
index_ = std::shared_ptr<faiss::Index>(idx);
index_->train(rows, (float*)p_data);
index_->train(rows, reinterpret_cast<const float*>(p_data));
} catch (std::exception& e) {
KNOWHERE_THROW_MSG(e.what());
}
......
......@@ -35,7 +35,7 @@ class IndexRHNSWFlat : public IndexRHNSW {
IndexRHNSWFlat(int d, int M, MetricType metric = Metric::L2);
BinarySet
Serialize(const Config& config = Config()) override;
Serialize(const Config& config) override;
void
Load(const BinarySet& index_binary) override;
......
......@@ -34,7 +34,7 @@ class IndexRHNSWPQ : public IndexRHNSW {
IndexRHNSWPQ(int d, int pq_m, int M);
BinarySet
Serialize(const Config& config = Config()) override;
Serialize(const Config& config) override;
void
Load(const BinarySet& index_binary) override;
......
......@@ -34,7 +34,7 @@ class IndexRHNSWSQ : public IndexRHNSW {
IndexRHNSWSQ(int d, faiss::QuantizerType qtype, int M, MetricType metric = Metric::L2);
BinarySet
Serialize(const Config& config = Config()) override;
Serialize(const Config& config) override;
void
Load(const BinarySet& index_binary) override;
......
......@@ -28,7 +28,7 @@ class CPUSPTAGRNG : public VecIndex {
public:
BinarySet
Serialize(const Config& config = Config()) override;
Serialize(const Config& config) override;
void
Load(const BinarySet& index_array) override;
......
......@@ -67,9 +67,7 @@ IVFSQHybrid::CopyGpuToCpu(const Config& config) {
faiss::Index* host_index = faiss::gpu::index_gpu_to_cpu(device_index);
if (auto* ivf_index = dynamic_cast<faiss::IndexIVF*>(host_index)) {
if (ivf_index != nullptr) {
ivf_index->to_readonly();
}
ivf_index->to_readonly();
ivf_index->backup_quantizer();
}
......
......@@ -170,7 +170,7 @@ TEST_P(AnnoyTest, annoy_serialize) {
{
// serialize index
index_->BuildAll(base_dataset, conf);
auto binaryset = index_->Serialize();
auto binaryset = index_->Serialize(milvus::knowhere::Config());
auto bin_data = binaryset.GetByName("annoy_index_data");
std::string filename1 = "/tmp/annoy_test_data_serialize.bin";
......
......@@ -51,7 +51,7 @@ TEST_P(BinaryIDMAPTest, binaryidmap_basic) {
// null faiss index
{
ASSERT_ANY_THROW(index_->Serialize());
ASSERT_ANY_THROW(index_->Serialize(conf));
ASSERT_ANY_THROW(index_->Query(query_dataset, conf));
ASSERT_ANY_THROW(index_->Add(nullptr, conf));
ASSERT_ANY_THROW(index_->AddWithoutIds(nullptr, conf));
......@@ -67,7 +67,7 @@ TEST_P(BinaryIDMAPTest, binaryidmap_basic) {
AssertAnns(result, nq, k);
// PrintResult(result, nq, k);
auto binaryset = index_->Serialize();
auto binaryset = index_->Serialize(conf);
auto new_index = std::make_shared<milvus::knowhere::BinaryIDMAP>();
new_index->Load(binaryset);
auto result2 = new_index->Query(query_dataset, conf);
......@@ -112,7 +112,7 @@ TEST_P(BinaryIDMAPTest, binaryidmap_serialize) {
// PrintResult(re_result, nq, k);
EXPECT_EQ(index_->Count(), nb);
EXPECT_EQ(index_->Dim(), dim);
auto binaryset = index_->Serialize();
auto binaryset = index_->Serialize(conf);
auto bin = binaryset.GetByName("BinaryIVF");
std::string filename = "/tmp/bianryidmap_test_serialize.bin";
......
......@@ -62,7 +62,7 @@ TEST_P(BinaryIVFTest, binaryivf_basic) {
// null faiss index
{
ASSERT_ANY_THROW(index_->Serialize());
ASSERT_ANY_THROW(index_->Serialize(conf));
ASSERT_ANY_THROW(index_->Query(query_dataset, conf));
ASSERT_ANY_THROW(index_->Add(nullptr, conf));
ASSERT_ANY_THROW(index_->AddWithoutIds(nullptr, conf));
......@@ -131,7 +131,7 @@ TEST_P(BinaryIVFTest, binaryivf_serialize) {
index_->BuildAll(base_dataset, conf);
// index_->set_index_model(model);
// index_->Add(base_dataset, conf);
auto binaryset = index_->Serialize();
auto binaryset = index_->Serialize(conf);
auto bin = binaryset.GetByName("BinaryIVF");
std::string filename = "/tmp/binaryivf_test_serialize.bin";
......
......@@ -58,7 +58,7 @@ TEST_F(SingleIndexTest, IVFSQHybrid) {
EXPECT_EQ(index_->Count(), nb);
EXPECT_EQ(index_->Dim(), dim);
auto binaryset = index_->Serialize();
auto binaryset = index_->Serialize(conf);
{
// copy cpu to gpu
auto cpu_idx = std::make_shared<milvus::knowhere::IVFSQHybrid>(DEVICEID);
......
......@@ -66,7 +66,7 @@ TEST_P(HNSWTest, HNSW_basic) {
EXPECT_EQ(index_->Dim(), dim);
// Serialize and Load before Query
milvus::knowhere::BinarySet bs = index_->Serialize();
milvus::knowhere::BinarySet bs = index_->Serialize(conf);
int64_t dim = base_dataset->Get<int64_t>(milvus::knowhere::meta::DIM);
int64_t rows = base_dataset->Get<int64_t>(milvus::knowhere::meta::ROWS);
......@@ -96,7 +96,7 @@ TEST_P(HNSWTest, HNSW_delete) {
}
// Serialize and Load before Query
milvus::knowhere::BinarySet bs = index_->Serialize();
milvus::knowhere::BinarySet bs = index_->Serialize(conf);
int64_t dim = base_dataset->Get<int64_t>(milvus::knowhere::meta::DIM);
int64_t rows = base_dataset->Get<int64_t>(milvus::knowhere::meta::ROWS);
......
......@@ -72,7 +72,7 @@ TEST_P(IDMAPTest, idmap_basic) {
// null faiss index
{
ASSERT_ANY_THROW(index_->Serialize());
ASSERT_ANY_THROW(index_->Serialize(conf));
ASSERT_ANY_THROW(index_->Query(query_dataset, conf));
ASSERT_ANY_THROW(index_->Add(nullptr, conf));
ASSERT_ANY_THROW(index_->AddWithoutIds(nullptr, conf));
......@@ -95,7 +95,7 @@ TEST_P(IDMAPTest, idmap_basic) {
#endif
}
auto binaryset = index_->Serialize();
auto binaryset = index_->Serialize(conf);
auto new_index = std::make_shared<milvus::knowhere::IDMAP>();
new_index->Load(binaryset);
auto result2 = new_index->Query(query_dataset, conf);
......@@ -158,7 +158,7 @@ TEST_P(IDMAPTest, idmap_serialize) {
// PrintResult(re_result, nq, k);
EXPECT_EQ(index_->Count(), nb);
EXPECT_EQ(index_->Dim(), dim);
auto binaryset = index_->Serialize();
auto binaryset = index_->Serialize(conf);
auto bin = binaryset.GetByName("IVF");
std::string filename = "/tmp/idmap_test_serialize.bin";
......@@ -216,10 +216,10 @@ TEST_P(IDMAPTest, idmap_copy) {
fiu_init(0);
fiu_enable("GPUIDMP.SerializeImpl.throw_exception", 1, nullptr, 0);
ASSERT_ANY_THROW(clone_index->Serialize());
ASSERT_ANY_THROW(clone_index->Serialize(conf));
fiu_disable("GPUIDMP.SerializeImpl.throw_exception");
auto binary = clone_index->Serialize();
auto binary = clone_index->Serialize(conf);
clone_index->Load(binary);
auto new_result = clone_index->Query(query_dataset, conf);
AssertAnns(new_result, nq, k);
......
......@@ -196,7 +196,7 @@ TEST_P(IVFTest, ivf_serialize) {
// serialize index
index_->Train(base_dataset, conf_);
index_->Add(base_dataset, conf_);
auto binaryset = index_->Serialize();
auto binaryset = index_->Serialize(conf_);
auto bin = binaryset.GetByName("IVF");
std::string filename = "/tmp/ivf_test_serialize.bin";
......@@ -340,7 +340,7 @@ TEST_P(IVFTest, invalid_gpu_source) {
fiu_init(0);
fiu_enable("GPUIVF.SerializeImpl.throw_exception", 1, nullptr, 0);
ASSERT_ANY_THROW(index_->Serialize());
ASSERT_ANY_THROW(index_->Serialize(conf_));
fiu_disable("GPUIVF.SerializeImpl.throw_exception");
fiu_enable("GPUIVF.search_impl.invald_index", 1, nullptr, 0);
......
......@@ -56,7 +56,7 @@ TEST_P(RHNSWFlatTest, HNSW_basic) {
AssertAnns(result1, nq, k);
// Serialize and Load before Query
milvus::knowhere::BinarySet bs = index_->Serialize();
milvus::knowhere::BinarySet bs = index_->Serialize(conf);
auto tmp_index = std::make_shared<milvus::knowhere::IndexRHNSWFlat>();
......@@ -122,7 +122,7 @@ TEST_P(RHNSWFlatTest, HNSW_serialize) {
{
index_->Train(base_dataset, conf);
index_->Add(base_dataset, conf);
auto binaryset = index_->Serialize();
auto binaryset = index_->Serialize(conf);
std::string index_type = index_->index_type();
std::string idx_name = index_type + "_Index";
std::string dat_name = index_type + "_Data";
......
......@@ -53,7 +53,7 @@ TEST_P(RHNSWPQTest, HNSW_basic) {
EXPECT_EQ(index_->Dim(), dim);
// Serialize and Load before Query
milvus::knowhere::BinarySet bs = index_->Serialize();
milvus::knowhere::BinarySet bs = index_->Serialize(conf);
auto result1 = index_->Query(query_dataset, conf);
// AssertAnns(result1, nq, k);
......@@ -121,7 +121,7 @@ TEST_P(RHNSWPQTest, HNSW_serialize) {
{
index_->Train(base_dataset, conf);
index_->Add(base_dataset, conf);
auto binaryset = index_->Serialize();
auto binaryset = index_->Serialize(conf);
auto bin_idx = binaryset.GetByName(index_->index_type() + "_Index");
auto bin_dat = binaryset.GetByName(index_->index_type() + "_Data");
......
......@@ -54,7 +54,7 @@ TEST_P(RHNSWSQ8Test, HNSW_basic) {
EXPECT_EQ(index_->Dim(), dim);
// Serialize and Load before Query
milvus::knowhere::BinarySet bs = index_->Serialize();
milvus::knowhere::BinarySet bs = index_->Serialize(conf);
auto result1 = index_->Query(query_dataset, conf);
AssertAnns(result1, nq, k);
......@@ -122,7 +122,7 @@ TEST_P(RHNSWSQ8Test, HNSW_serialize) {
{
index_->Train(base_dataset, conf);
index_->Add(base_dataset, conf);
auto binaryset = index_->Serialize();
auto binaryset = index_->Serialize(conf);
auto bin_idx = binaryset.GetByName(index_->index_type() + "_Index");
auto bin_dat = binaryset.GetByName(index_->index_type() + "_Data");
......
......@@ -39,10 +39,10 @@ print_help(const std::string& app_name) {
void
print_banner() {
std::cout << std::endl;
std::cout << " __ _________ _ ____ ______ " << std::endl;
std::cout << " / |/ / _/ /| | / / / / / __/ " << std::endl;
std::cout << " / /|_/ // // /_| |/ / /_/ /\\ \\ " << std::endl;
std::cout << " /_/ /_/___/____/___/\\____/___/ " << std::endl;
std::cout << R"( __ _________ _ ____ ______ )" << std::endl;
std::cout << R"( / |/ / _/ /| | / / / / / __/ )" << std::endl;
std::cout << R"( / /|_/ // // /_| |/ / /_/ /\ \ )" << std::endl;
std::cout << R"( /_/ /_/___/____/___/\____/___/ )" << std::endl;
std::cout << std::endl;
std::cout << "Welcome to use Milvus!" << std::endl;
std::cout << "Milvus " << BUILD_TYPE << " version: v" << MILVUS_VERSION << ", built at " << BUILD_TIME << ", with "
......
......@@ -32,10 +32,6 @@ Scheduler::Scheduler(ResourceMgrPtr res_mgr) : running_(false), res_mgr_(std::mo
std::bind(&Scheduler::OnFinishTask, this, std::placeholders::_1)));
}
Scheduler::~Scheduler() {
res_mgr_ = nullptr;
}
void
Scheduler::Start() {
running_ = true;
......
......@@ -29,8 +29,7 @@ namespace scheduler {
class Scheduler : public interface::dumpable {
public:
explicit Scheduler(ResourceMgrPtr res_mgr);
~Scheduler();
virtual ~Scheduler() = default;
Scheduler(const Scheduler&) = delete;
Scheduler(Scheduler&&) = delete;
......
......@@ -179,7 +179,7 @@ SegmentWriter::WriteBloomFilter() {
segment::IdBloomFilterPtr bloom_filter_ptr;
ss_codec.GetIdBloomFilterFormat()->Create(fs_ptr_, file_path, bloom_filter_ptr);
int64_t* uids = (int64_t*)(uid_data->data_.data());
auto uids = reinterpret_cast<int64_t*>(uid_data->data_.data());
int64_t row_count = segment_ptr_->GetRowCount();
for (int64_t i = 0; i < row_count; i++) {
bloom_filter_ptr->Add(uids[i]);
......
......@@ -245,8 +245,8 @@ ValidateDbURI(const std::string& uri) {
std::string hostRegex = "(.*)";
std::string portRegex = "(.*)";
std::string dbNameRegex = "(.*)";
std::string uriRegexStr = dialectRegex + "\\:\\/\\/" + usernameRegex + "\\:" + passwordRegex + "\\@" + hostRegex +
"\\:" + portRegex + "\\/" + dbNameRegex;
std::string uriRegexStr = dialectRegex + R"(\:\/\/)" + usernameRegex + R"(\:)" + passwordRegex + R"(\@)" +
hostRegex + R"(\:)" + portRegex + R"(\/)" + dbNameRegex;
std::regex uriRegex(uriRegexStr);
std::smatch pieces_match;
......@@ -296,7 +296,7 @@ ValidateStoragePath(const std::string& path) {
// and path must start with '/'.
// examples below are invalid
// '/a//a', '/a--/a', '/-a/a', '/a@#/a', 'aaa/sfs'
std::string path_pattern = "^\\/(\\w+-?\\/?)+$";
std::string path_pattern = R"(^\/(\w+-?\/?)+$)";
std::regex regex(path_pattern);
return std::regex_match(path, regex) ? Status::OK() : Status(SERVER_INVALID_ARGUMENT, "Invalid file path");
......
......@@ -13,7 +13,6 @@
#include "utils/Log.h"
#include <execinfo.h>
#include <signal.h>
#include <string>
namespace milvus {
......
......@@ -30,27 +30,24 @@ Status::Status(StatusCode code, const std::string& msg) {
state_ = result;
}
Status::Status() : state_(nullptr) {
}
Status::~Status() {
delete state_;
}
Status::Status(const Status& s) : state_(nullptr) {
Status::Status(const Status& s) {
CopyFrom(s);
}
Status::Status(Status&& s) {
MoveFrom(s);
}
Status&
Status::operator=(const Status& s) {
CopyFrom(s);
return *this;
}
Status::Status(Status&& s) : state_(nullptr) {
MoveFrom(s);
}
Status&
Status::operator=(Status&& s) {
MoveFrom(s);
......
......@@ -31,16 +31,16 @@ using StatusCode = ErrorCode;
class Status {
public:
Status(StatusCode code, const std::string& msg);
Status();
~Status();
Status() = default;
virtual ~Status();
Status(const Status& s);
Status(Status&& s);
Status&
operator=(const Status& s);
Status(Status&& s);
Status&
operator=(Status&& s);
......
......@@ -31,42 +31,36 @@ TimeRecorder::GetTimeSpanStr(double span) {
void
TimeRecorder::PrintTimeRecord(const std::string& msg, double span) {
std::string str_log;
if (!header_.empty())
if (!header_.empty()) {
str_log += header_ + ": ";
}
str_log += msg;
str_log += " (";
str_log += TimeRecorder::GetTimeSpanStr(span);
str_log += ")";
switch (log_level_) {
case 0: {
case 0:
LOG_SERVER_TRACE_ << str_log;
break;
}
case 1: {
case 1:
LOG_SERVER_DEBUG_ << str_log;
break;
}
case 2: {
case 2:
LOG_SERVER_INFO_ << str_log;
break;
}
case 3: {
case 3:
LOG_SERVER_WARNING_ << str_log;
break;
}
case 4: {
case 4:
LOG_SERVER_ERROR_ << str_log;
break;
}
case 5: {
case 5:
LOG_SERVER_FATAL_ << str_log;
break;
}
default: {
default:
LOG_SERVER_INFO_ << str_log;
break;
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册