diff --git a/cpp/src/db/id_generators.cpp b/cpp/src/db/id_generators.cpp index 8296a4048f..3541048413 100644 --- a/cpp/src/db/id_generators.cpp +++ b/cpp/src/db/id_generators.cpp @@ -1,32 +1,37 @@ #include #include -#inlcude "id_generators.h" +#include "id_generators.h" -using std::chrono; -namespace vecengine { +namespace zilliz { +namespace vecwise { +namespace engine { IDGenerator::~IDGenerator() {} IDNumber SimpleIDGenerator::getNextIDNumber() { - auto now = chrono::system_clock::now(); - auto micros = duration_cast(now.time_since_epoch()).count(); - return micros * MAX_IDS_PER_MICRO + auto now = std::chrono::system_clock::now(); + auto micros = std::chrono::duration_cast( + now.time_since_epoch()).count(); + return micros * MAX_IDS_PER_MICRO; } IDNumbers&& SimpleIDGenerator::getNextIDNumbers(size_t n) { assert(n < MAX_IDS_PER_MICRO); - auto now = chrono::system_clock::now(); - auto micros = duration_cast(now.time_since_epoch()).count(); + auto now = std::chrono::system_clock::now(); + auto micros = std::chrono::duration_cast( + now.time_since_epoch()).count(); micros *= MAX_IDS_PER_MICRO; IDNumbers ids = IDNumbers(n); for (int pos=0; pos #include "types.h" @@ -24,7 +23,7 @@ public: virtual IDNumbers&& getNextIDNumbers(size_t n_) override; private: - const MAX_IDS_PER_MICRO = 1000; + const size_t MAX_IDS_PER_MICRO = 1000; }; // SimpleIDGenerator @@ -32,5 +31,3 @@ private: } // namespace engine } // namespace vecwise } // namespace zilliz - -#endif // UTILS_ID_GENERATORS_H_ diff --git a/cpp/src/db/types.h b/cpp/src/db/types.h index 185fb73641..7fd33a0787 100644 --- a/cpp/src/db/types.h +++ b/cpp/src/db/types.h @@ -1,5 +1,4 @@ -#ifndef VECENGINE_TYPES_H_ -#define VECENGINE_TYPES_H_ +#pragma once #include @@ -7,13 +6,11 @@ namespace zilliz { namespace vecwise { namespace engine { -#define uint64_t IDNumber; -#define IDNumber* IDNumberPtr; -#define std::vector IDNumbers; +typedef uint64_t IDNumber; +typedef IDNumber* IDNumberPtr; +typedef std::vector IDNumbers; } // namespace engine } // namespace vecwise } // namespace zilliz - -#endif // VECENGINE_TYPES_H_