diff --git a/src/impl/MilvusClientImpl.cpp b/src/impl/MilvusClientImpl.cpp index 712a88d..38c8a8f 100644 --- a/src/impl/MilvusClientImpl.cpp +++ b/src/impl/MilvusClientImpl.cpp @@ -141,7 +141,7 @@ MilvusClientImpl::LoadCollection(const std::string& collection_name, int replica }; auto wait_for_status = [this, &collection_name, &progress_monitor](const proto::common::Status&) { - return waitForStatus( + return WaitForStatus( [&collection_name, this](Progress& progress) -> Status { CollectionsInfo collections_info; auto collection_names = std::vector{collection_name}; @@ -259,7 +259,7 @@ MilvusClientImpl::ShowCollections(const std::vector& collection_nam }; auto post = [&collections_info](const proto::milvus::ShowCollectionsResponse& response) { - for (size_t i = 0; i < response.collection_ids_size(); i++) { + for (int i = 0; i < response.collection_ids_size(); i++) { auto inmemory_percentage = 0; if (response.inmemory_percentages_size() > i) { inmemory_percentage = response.inmemory_percentages(i); @@ -331,7 +331,7 @@ MilvusClientImpl::LoadPartitions(const std::string& collection_name, const std:: }; auto wait_for_status = [this, &collection_name, &partition_names, &progress_monitor](const proto::common::Status&) { - return waitForStatus( + return WaitForStatus( [&collection_name, &partition_names, this](Progress& progress) -> Status { PartitionsInfo partitions_info; auto status = ShowPartitions(collection_name, partition_names, partitions_info); @@ -422,7 +422,7 @@ MilvusClientImpl::ShowPartitions(const std::string& collection_name, const std:: if (count > 0) { partitions_info.reserve(count); } - for (size_t i = 0; i < count; ++i) { + for (int i = 0; i < count; ++i) { partitions_info.emplace_back(response.partition_names(i), response.partitionids(i), response.created_timestamps(i), response.inmemory_percentages(i)); } @@ -499,7 +499,7 @@ MilvusClientImpl::CreateIndex(const std::string& collection_name, const IndexDes }; auto wait_for_status = [&collection_name, &index_desc, &progress_monitor, this](const proto::common::Status&) { - return waitForStatus( + return WaitForStatus( [&collection_name, &index_desc, this](Progress& progress) -> Status { IndexState index_state; auto status = GetIndexState(collection_name, index_desc.FieldName(), index_state); @@ -539,13 +539,13 @@ MilvusClientImpl::DescribeIndex(const std::string& collection_name, const std::s auto post = [&index_desc](const proto::milvus::DescribeIndexResponse& response) { auto count = response.index_descriptions_size(); - for (size_t i = 0; i < count; ++i) { + for (int i = 0; i < count; ++i) { auto& field_name = response.index_descriptions(i).field_name(); auto& index_name = response.index_descriptions(i).index_name(); index_desc.SetFieldName(field_name); index_desc.SetIndexName(index_name); auto index_params_size = response.index_descriptions(i).params_size(); - for (size_t j = 0; j < index_params_size; ++j) { + for (int j = 0; j < index_params_size; ++j) { const auto& key = response.index_descriptions(i).params(j).key(); const auto& value = response.index_descriptions(i).params(j).value(); if (key == milvus::KeyIndexType()) { @@ -759,19 +759,20 @@ MilvusClientImpl::Search(const SearchArguments& arguments, SearchResults& result const auto& scores = result_data.scores(); const auto& fields_data = result_data.fields_data(); auto num_of_queries = result_data.num_queries(); - std::vector topks(num_of_queries, result_data.top_k()); + std::vector topks{}; + topks.reserve(result_data.topks_size()); for (int i = 0; i < result_data.topks_size(); ++i) { - topks[i] = result_data.topks(i); + topks.emplace_back(result_data.topks(i)); } std::vector single_results; single_results.reserve(num_of_queries); - size_t offset{0}; - for (int64_t i = 0; i < num_of_queries; ++i) { + int offset{0}; + for (int i = 0; i < num_of_queries; ++i) { std::vector item_scores; std::vector item_field_data; auto item_topk = topks[i]; item_scores.reserve(item_topk); - for (int64_t j = 0; j < item_topk; ++j) { + for (int j = 0; j < item_topk; ++j) { item_scores.emplace_back(scores.at(offset + j)); } item_field_data.reserve(fields_data.size()); @@ -842,7 +843,7 @@ MilvusClientImpl::CalcDistance(const CalcDistanceArguments& arguments, DistanceA } // suppose vectors is not empty, already checked by Validate() - data_array->set_dim(vectors[0].size()); + data_array->set_dim(static_cast(vectors[0].size())); } else { auto data_ptr = std::static_pointer_cast(arg_vectors); auto& str = *data_array->mutable_binary_vector(); @@ -853,7 +854,7 @@ MilvusClientImpl::CalcDistance(const CalcDistanceArguments& arguments, DistanceA for (auto& vector : vectors) { str.append(vector); } - data_array->set_dim(dimensions); + data_array->set_dim(static_cast(dimensions)); } } else if (arg_vectors->Type() == DataType::INT64) { @@ -960,7 +961,7 @@ MilvusClientImpl::Flush(const std::vector& collection_names, const return Status::OK(); } - return waitForStatus( + return WaitForStatus( [&segment_count, &flush_segments, &finished_count, this](Progress& p) -> Status { p.total_ = segment_count; @@ -1117,7 +1118,7 @@ MilvusClientImpl::ManualCompaction(const std::string& collection_name, uint64_t return status; } - auto pre = [&collection_name, &travel_timestamp, &collection_desc]() { + auto pre = [&travel_timestamp, &collection_desc]() { proto::milvus::ManualCompactionRequest rpc_request; rpc_request.set_collectionid(collection_desc.ID()); rpc_request.set_timetravel(travel_timestamp); @@ -1223,7 +1224,7 @@ MilvusClientImpl::ListCredUsers(std::vector& users) { } Status -MilvusClientImpl::waitForStatus(std::function query_function, +MilvusClientImpl::WaitForStatus(const std::function& query_function, const ProgressMonitor& progress_monitor) { // no need to check if (progress_monitor.CheckTimeout() == 0) { diff --git a/src/impl/MilvusClientImpl.h b/src/impl/MilvusClientImpl.h index 0edacab..c71be7c 100644 --- a/src/impl/MilvusClientImpl.h +++ b/src/impl/MilvusClientImpl.h @@ -186,8 +186,8 @@ class MilvusClientImpl : public MilvusClient { * @param [in] progress_monitor timeout setting for waiting progress * @return Status, the final status */ - Status - waitForStatus(std::function query_function, const ProgressMonitor& progress_monitor); + static Status + WaitForStatus(const std::function& query_function, const ProgressMonitor& progress_monitor); /** * @brief template for public api call @@ -195,7 +195,7 @@ class MilvusClientImpl : public MilvusClient { */ template Status - apiHandler(std::function validate, std::function pre, + apiHandler(const std::function& validate, std::function pre, Status (MilvusConnection::*rpc)(const Request&, Response&, const GrpcOpts&), std::function wait_for_status, std::function post, const GrpcOpts& options = GrpcOpts{}) { @@ -215,7 +215,7 @@ class MilvusClientImpl : public MilvusClient { auto status = std::bind(rpc, connection_.get(), std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)(rpc_request, rpc_response, options); if (!status.IsOk()) { - // resp's status already checked in connection class + // response's status already checked in connection class return status; } diff --git a/src/impl/MilvusConnection.cpp b/src/impl/MilvusConnection.cpp index 2b2c907..7b66b04 100644 --- a/src/impl/MilvusConnection.cpp +++ b/src/impl/MilvusConnection.cpp @@ -20,7 +20,6 @@ #include #include "grpcpp/security/credentials.h" -#include "milvus/types/ConnectParam.h" using grpc::Channel; using grpc::ClientContext; @@ -63,8 +62,8 @@ MilvusConnection::~MilvusConnection() { Status MilvusConnection::Connect(const ConnectParam& param) { authorization_value_ = param.Authorizations(); - std::shared_ptr creds{nullptr}; - auto& uri = param.Uri(); + std::shared_ptr credentials{nullptr}; + auto uri = param.Uri(); ::grpc::ChannelArguments args; args.SetMaxSendMessageSize(-1); // max send message size: 2GB @@ -74,12 +73,12 @@ MilvusConnection::Connect(const ConnectParam& param) { if (!param.ServerName().empty()) { args.SetSslTargetNameOverride(param.ServerName()); } - creds = createTlsCredentials(param.Cert(), param.Key(), param.CaCert()); + credentials = createTlsCredentials(param.Cert(), param.Key(), param.CaCert()); } else { - creds = ::grpc::InsecureChannelCredentials(); + credentials = ::grpc::InsecureChannelCredentials(); } - channel_ = ::grpc::CreateCustomChannel(uri, creds, args); + channel_ = ::grpc::CreateCustomChannel(uri, credentials, args); auto connected = channel_->WaitForConnected(std::chrono::system_clock::now() + std::chrono::milliseconds{param.ConnectTimeout()}); if (connected) { @@ -175,7 +174,7 @@ MilvusConnection::DropPartition(const proto::milvus::DropPartitionRequest& reque Status MilvusConnection::HasPartition(const proto::milvus::HasPartitionRequest& request, proto::milvus::BoolResponse& response, const GrpcContextOptions& options) { - return grpcCall("HasParition", &Stub::HasPartition, request, response, options); + return grpcCall("HasPartition", &Stub::HasPartition, request, response, options); } Status diff --git a/src/impl/MilvusConnection.h b/src/impl/MilvusConnection.h index aa53948..5f275df 100644 --- a/src/impl/MilvusConnection.h +++ b/src/impl/MilvusConnection.h @@ -238,23 +238,23 @@ class MilvusConnection { std::shared_ptr channel_; std::string authorization_value_{}; - Status - statusByProtoResponse(const proto::common::Status& status) { - if (status.error_code() != proto::common::ErrorCode::Success) { + static Status + StatusByProtoResponse(const proto::common::Status& status) { + if (status.code() != proto::common::ErrorCode::Success) { return Status{StatusCode::SERVER_FAILED, status.reason()}; } return Status::OK(); } template - Status - statusByProtoResponse(const Response& response) { + static Status + StatusByProtoResponse(const Response& response) { const auto& status = response.status(); - return statusByProtoResponse(status); + return StatusByProtoResponse(status); } - StatusCode - statusCodeFromGrpcStatus(const ::grpc::Status& grpc_status) { + static StatusCode + StatusCodeFromGrpcStatus(const ::grpc::Status& grpc_status) { if (grpc_status.error_code() == ::grpc::StatusCode::DEADLINE_EXCEEDED) { return StatusCode::TIMEOUT; } @@ -284,10 +284,10 @@ class MilvusConnection { ::grpc::Status grpc_status = (stub_.get()->*func)(&context, request, &response); if (!grpc_status.ok()) { - return {statusCodeFromGrpcStatus(grpc_status), grpc_status.error_message()}; + return {StatusCodeFromGrpcStatus(grpc_status), grpc_status.error_message()}; } - return statusByProtoResponse(response); + return StatusByProtoResponse(response); } }; diff --git a/src/impl/Status.cpp b/src/impl/Status.cpp index 7ad613c..f34677d 100644 --- a/src/impl/Status.cpp +++ b/src/impl/Status.cpp @@ -16,8 +16,6 @@ #include "milvus/Status.h" -#include - namespace milvus { Status::Status(StatusCode code, std::string msg) : code_(code), msg_(std::move(msg)) { diff --git a/src/impl/TypeUtils.cpp b/src/impl/TypeUtils.cpp index 0447d7a..ae213d0 100644 --- a/src/impl/TypeUtils.cpp +++ b/src/impl/TypeUtils.cpp @@ -406,7 +406,7 @@ CreateProtoFieldData(const BinaryVecFieldData& field) { for (const auto& item : data) { std::copy(item.begin(), item.end(), std::back_inserter(vectors_data)); } - ret->set_dim(dim); + ret->set_dim(static_cast(dim)); return ret; } @@ -416,11 +416,11 @@ CreateProtoFieldData(const FloatVecFieldData& field) { auto& data = field.Data(); auto dim = data.front().size(); auto& vectors_data = *(ret->mutable_float_vector()->mutable_data()); - vectors_data.Reserve(data.size() * dim); + vectors_data.Reserve(static_cast(data.size() * dim)); for (const auto& item : data) { vectors_data.Add(item.begin(), item.end()); } - ret->set_dim(dim); + ret->set_dim(static_cast(dim)); return ret; } diff --git a/src/impl/types/CalcDistanceArguments.cpp b/src/impl/types/CalcDistanceArguments.cpp index 2302743..202aa50 100644 --- a/src/impl/types/CalcDistanceArguments.cpp +++ b/src/impl/types/CalcDistanceArguments.cpp @@ -16,8 +16,6 @@ #include "milvus/types/CalcDistanceArguments.h" -#include -#include #include #include diff --git a/src/impl/types/CollectionStat.cpp b/src/impl/types/CollectionStat.cpp index 3d05456..c060f90 100644 --- a/src/impl/types/CollectionStat.cpp +++ b/src/impl/types/CollectionStat.cpp @@ -29,7 +29,7 @@ CollectionStat::RowCount() const { // TODO: throw exception or log return 0; } - return std::atoll(iter->second.c_str()); + return std::strtoll(iter->second.c_str(), nullptr, 10); } void diff --git a/src/impl/types/CompactionState.cpp b/src/impl/types/CompactionState.cpp index 4c8ded4..4e05cd6 100644 --- a/src/impl/types/CompactionState.cpp +++ b/src/impl/types/CompactionState.cpp @@ -16,8 +16,6 @@ #include "milvus/types/CompactionState.h" -#include - namespace milvus { CompactionState::CompactionState() = default; diff --git a/src/impl/types/ConnectParam.cpp b/src/impl/types/ConnectParam.cpp index 3464c1f..7ac68d7 100644 --- a/src/impl/types/ConnectParam.cpp +++ b/src/impl/types/ConnectParam.cpp @@ -40,7 +40,7 @@ ConnectParam::Port() const { return port_; } -const std::string +std::string ConnectParam::Uri() const { return host_ + ":" + std::to_string(port_); } diff --git a/src/impl/types/FieldSchema.cpp b/src/impl/types/FieldSchema.cpp index 010a4d3..cd4c0c7 100644 --- a/src/impl/types/FieldSchema.cpp +++ b/src/impl/types/FieldSchema.cpp @@ -100,7 +100,7 @@ uint32_t FieldSchema::Dimension() const { auto iter = type_params_.find(FieldDim()); if (iter != type_params_.end()) { - return std::atol(iter->second.c_str()); + return std::strtol(iter->second.c_str(), nullptr, 10); } return 0; } @@ -124,7 +124,7 @@ uint32_t FieldSchema::MaxLength() const { auto iter = type_params_.find(FieldMaxLength()); if (iter != type_params_.end()) { - return std::atol(iter->second.c_str()); + return std::strtol(iter->second.c_str(), nullptr, 10); } return 0; } diff --git a/src/impl/types/HybirdTimestamp.cpp b/src/impl/types/HybridTimestamp.cpp similarity index 57% rename from src/impl/types/HybirdTimestamp.cpp rename to src/impl/types/HybridTimestamp.cpp index c650d79..bcd27b5 100644 --- a/src/impl/types/HybirdTimestamp.cpp +++ b/src/impl/types/HybridTimestamp.cpp @@ -14,47 +14,47 @@ // See the License for the specific language governing permissions and // limitations under the License. -#include "milvus/types/HybirdTimestamp.h" +#include "milvus/types/HybridTimestamp.h" namespace milvus { -HybirdTimestamp::HybirdTimestamp() = default; +HybridTimestamp::HybridTimestamp() = default; -HybirdTimestamp::HybirdTimestamp(uint64_t ts) : ts_(ts) { +HybridTimestamp::HybridTimestamp(uint64_t ts) : ts_(ts) { } -HybirdTimestamp::HybirdTimestamp(uint64_t physical, uint64_t logical) - : ts_((physical << milvus::HybirdtsLogicalBits()) + logical) { +HybridTimestamp::HybridTimestamp(uint64_t physical, uint64_t logical) + : ts_((physical << milvus::HybridTsLogicalBits()) + logical) { } uint64_t -HybirdTimestamp::Timestamp() const { +HybridTimestamp::Timestamp() const { return ts_; } uint64_t -HybirdTimestamp::Logical() const { - return ts_ & milvus::HybirdtsLogicalBitsMask(); +HybridTimestamp::Logical() const { + return ts_ & milvus::HybridTsLogicalBitsMask(); } uint64_t -HybirdTimestamp::Physical() const { - return ts_ >> milvus::HybirdtsLogicalBits(); +HybridTimestamp::Physical() const { + return ts_ >> milvus::HybridTsLogicalBits(); } -HybirdTimestamp& -HybirdTimestamp::operator+=(uint64_t milliseconds) { - ts_ += (milliseconds << milvus::HybirdtsLogicalBits()); +HybridTimestamp& +HybridTimestamp::operator+=(uint64_t milliseconds) { + ts_ += (milliseconds << milvus::HybridTsLogicalBits()); return *this; } -HybirdTimestamp -HybirdTimestamp::operator+(uint64_t milliseconds) { +HybridTimestamp +HybridTimestamp::operator+(uint64_t milliseconds) const { return {Physical() + milliseconds, Logical()}; } -HybirdTimestamp -HybirdTimestamp::CreateFromUnixtime(uint64_t epoch_in_milliseconds) { +HybridTimestamp +HybridTimestamp::CreateFromUnixTime(uint64_t epoch_in_milliseconds) { return {epoch_in_milliseconds, 0}; } } // namespace milvus diff --git a/src/impl/types/PartitionStat.cpp b/src/impl/types/PartitionStat.cpp index ebd47b4..425fa61 100644 --- a/src/impl/types/PartitionStat.cpp +++ b/src/impl/types/PartitionStat.cpp @@ -24,7 +24,7 @@ PartitionStat::RowCount() const { // TODO: throw exception or log return 0; } - return std::atoll(iter->second.c_str()); + return std::strtoll(iter->second.c_str(), nullptr, 10); } void diff --git a/src/impl/types/SearchResults.cpp b/src/impl/types/SearchResults.cpp index 1a7168e..a2c5b95 100644 --- a/src/impl/types/SearchResults.cpp +++ b/src/impl/types/SearchResults.cpp @@ -37,7 +37,7 @@ SingleResult::OutputFields() const { return output_fields_; } -const FieldDataPtr +FieldDataPtr SingleResult::OutputField(const std::string& name) const { for (const auto& output_field : output_fields_) { if (output_field->Name() == name) { diff --git a/src/include/milvus/MilvusClient.h b/src/include/milvus/MilvusClient.h index e87b23b..f515ce6 100644 --- a/src/include/milvus/MilvusClient.h +++ b/src/include/milvus/MilvusClient.h @@ -30,7 +30,7 @@ #include "types/DistanceArray.h" #include "types/DmlResults.h" #include "types/FieldData.h" -#include "types/HybirdTimestamp.h" +#include "types/HybridTimestamp.h" #include "types/IndexDesc.h" #include "types/IndexState.h" #include "types/PartitionInfo.h" @@ -174,11 +174,11 @@ class MilvusClient { const ProgressMonitor& progress_monitor = ProgressMonitor::Forever()) = 0; /** - * If the collection_names is empty, list all collections brief informations. \n + * If the collection_names is empty, list all collections brief information's. \n * If the collection_names is specified, return the specified collection's loading process state. * * @param [in] collection_names name array of collections - * @param [out] collections_info brief informations of the collections + * @param [out] collections_info brief information's of the collections * @return Status operation successfully or not */ virtual Status @@ -258,12 +258,12 @@ class MilvusClient { const ProgressMonitor& progress_monitor = ProgressMonitor::Forever()) = 0; /** - * If the partition_names is empty, list all partitions brief informations. \n + * If the partition_names is empty, list all partitions brief information's. \n * If the partition_names is specified, return the specified partition's loading process state. * * @param [in] collection_name name of the collection * @param [in] partition_names name array of the partitions - * @param [out] partitions_info brief informations of the partitions + * @param [out] partitions_info brief information's of the partitions * @return Status operation successfully or not */ virtual Status @@ -385,7 +385,7 @@ class MilvusClient { DmlResults& results) = 0; /** - * Searche a collection based on the given parameters and return results. + * Search a collection based on the given parameters and return results. * * @param [in] arguments search arguments * @param [out] results search results @@ -424,7 +424,7 @@ class MilvusClient { /** * Flush insert buffer into storage. \n - * To makesure the buffer persisted successfully, it calls GetFlushState() to check related segments state. + * To make sure the buffer persisted successfully, it calls GetFlushState() to check related segments state. * * @param [in] collection_names specify target collection names, if this array is empty, will flush all collections * @param [in] progress_monitor timeout setting for waiting progress. Set ProgressMonitor::NoWait() to return @@ -477,7 +477,7 @@ class MilvusClient { GetMetrics(const std::string& request, std::string& response, std::string& component_name) = 0; /** - * Rebalance sealed segments from one query node to others. + * Rebalanced sealed segments from one query node to others. * * @param [in] src_node the source query node id * @param [in] dst_nodes the destiny query nodes id array diff --git a/src/include/milvus/types/ConnectParam.h b/src/include/milvus/types/ConnectParam.h index 3a221c0..730a9da 100644 --- a/src/include/milvus/types/ConnectParam.h +++ b/src/include/milvus/types/ConnectParam.h @@ -50,7 +50,7 @@ class ConnectParam { /** * @brief Uri for connecting to the milvus. */ - const std::string + std::string Uri() const; /** diff --git a/src/include/milvus/types/Constants.h b/src/include/milvus/types/Constants.h index 03583c9..216a165 100644 --- a/src/include/milvus/types/Constants.h +++ b/src/include/milvus/types/Constants.h @@ -22,7 +22,7 @@ namespace milvus { /** * @brief Global definition for row count label */ -inline const std::string +inline std::string KeyRowCount() { return "row_count"; } @@ -30,7 +30,7 @@ KeyRowCount() { /** * @brief Global definition for index type label */ -inline const std::string +inline std::string KeyIndexType() { return "index_type"; } @@ -38,7 +38,7 @@ KeyIndexType() { /** * @brief Global definition for metric type label */ -inline const std::string +inline std::string KeyMetricType() { return "metric_type"; } @@ -46,7 +46,7 @@ KeyMetricType() { /** * @brief Global definition for metric type label */ -inline const std::string +inline std::string KeyParams() { return "params"; } @@ -54,7 +54,7 @@ KeyParams() { /** * @brief Global definition for vector dimension label */ -inline const std::string +inline std::string FieldDim() { return "dim"; } @@ -62,7 +62,7 @@ FieldDim() { /** * @brief Max length field name for varchar field */ -inline const std::string +inline std::string FieldMaxLength() { return "max_length"; } @@ -84,17 +84,17 @@ GuaranteeEventuallyTs() { } /** - * @brief The logical bits in hybird timestamp + * @brief The logical bits in hybrid timestamp */ -constexpr size_t inline HybirdtsLogicalBits() { +constexpr size_t inline HybridTsLogicalBits() { return 18; } /** - * @brief The logical bits mask for hybird timestamp + * @brief The logical bits mask for hybrid timestamp */ -constexpr uint64_t inline HybirdtsLogicalBitsMask() { - return (1 << HybirdtsLogicalBits()) - 1; +constexpr uint64_t inline HybridTsLogicalBitsMask() { + return (1 << HybridTsLogicalBits()) - 1; } } // namespace milvus diff --git a/src/include/milvus/types/DistanceArray.h b/src/include/milvus/types/DistanceArray.h index dee9458..8466b0a 100644 --- a/src/include/milvus/types/DistanceArray.h +++ b/src/include/milvus/types/DistanceArray.h @@ -83,7 +83,7 @@ class DistanceArray { SetIntDistance(std::vector>&& distance_array); /** - * @brief Float distance 2-d arraywe called. + * @brief Float distance 2-d array we called. * Assume the vectors_left: L_1, L_2, L_3 \n * Assume the vectors_right: R_a, R_b \n * Distance between L_n and R_m we called "D_n_m" \n diff --git a/src/include/milvus/types/FieldData.h b/src/include/milvus/types/FieldData.h index 4400405..bf827a3 100644 --- a/src/include/milvus/types/FieldData.h +++ b/src/include/milvus/types/FieldData.h @@ -31,7 +31,7 @@ class Field { const std::string& Name() const; /** - * @brief Get field data tpye + * @brief Get field data type */ DataType Type() const; @@ -53,7 +53,7 @@ class Field { using FieldDataPtr = std::shared_ptr; /** - * @brief Template class represents column-based data of a field. Avaiable inheritance classes: \n + * @brief Template class represents column-based data of a field. Available inheritance classes: \n * BoolFieldData for boolean scalar field \n * Int8FieldData for 8-bits integer scalar field \n * Int16FieldData for 16-bits integer scalar field \n @@ -96,13 +96,13 @@ class FieldData : public Field { /** * @brief Add element to field data */ - StatusCode + virtual StatusCode Add(const T& element); /** * @brief Add element to field data */ - StatusCode + virtual StatusCode Add(T&& element); /** @@ -114,13 +114,13 @@ class FieldData : public Field { /** * @brief Field elements array */ - const std::vector& + virtual const std::vector& Data() const; /** * @brief Field elements array */ - std::vector& + virtual std::vector& Data(); private: @@ -159,13 +159,13 @@ class BinaryVecFieldData : public FieldData& - Data() const; + Data() const override; /** * @brief Field elements array */ std::vector& - Data(); + Data() override; /** * @brief Data export as uint8_t's vector @@ -177,14 +177,14 @@ class BinaryVecFieldData : public FieldData type_params_; diff --git a/src/include/milvus/types/HybirdTimestamp.h b/src/include/milvus/types/HybridTimestamp.h similarity index 70% rename from src/include/milvus/types/HybirdTimestamp.h rename to src/include/milvus/types/HybridTimestamp.h index 30767f8..26be4c8 100644 --- a/src/include/milvus/types/HybirdTimestamp.h +++ b/src/include/milvus/types/HybridTimestamp.h @@ -22,25 +22,25 @@ namespace milvus { template -struct _is_std_duration; +struct is_std_duration; -template -struct _is_std_duration> { +template +struct is_std_duration> { static const bool value = true; }; /** - * @brief Hybird Timestamp + * @brief Hybrid Timestamp */ -class HybirdTimestamp { +class HybridTimestamp { uint64_t ts_{0}; public: - HybirdTimestamp(); + HybridTimestamp(); - explicit HybirdTimestamp(uint64_t ts); + explicit HybridTimestamp(uint64_t ts); - HybirdTimestamp(uint64_t physical, uint64_t logical); + HybridTimestamp(uint64_t physical, uint64_t logical); /** * @brief Hybird timestamp value @@ -64,8 +64,8 @@ class HybirdTimestamp { * @brief Increase duration in physical part * */ - template ::value, bool> = true> - HybirdTimestamp& + template ::value, bool> = true> + HybridTimestamp& operator+=(Duration duration) { auto milliseconds = std::chrono::duration_cast(duration).count(); return *this += milliseconds; @@ -75,19 +75,19 @@ class HybirdTimestamp { * @brief Increase milliseconds in physical part * * @param milliseconds - * @return HybirdTimestamp + * @return HybridTimestamp */ - HybirdTimestamp& + HybridTimestamp& operator+=(uint64_t milliseconds); /** * @brief Add duration in physical part * * @param duration Duration - * @return HybirdTimestamp + * @return HybridTimestamp */ - template ::value, bool> = true> - HybirdTimestamp + template ::value, bool> = true> + HybridTimestamp operator+(Duration duration) { auto milliseconds = std::chrono::duration_cast(duration).count(); return *this + milliseconds; @@ -97,15 +97,15 @@ class HybirdTimestamp { * @brief Add milliseconds in physical part * * @param milliseconds - * @return HybirdTimestamp + * @return HybridTimestamp */ - HybirdTimestamp - operator+(uint64_t milliseconds); + HybridTimestamp + operator+(uint64_t milliseconds) const; /** - * @brief Create hybird timestamp from unix time + * @brief Create hybrid timestamp from unix time */ - static HybirdTimestamp - CreateFromUnixtime(uint64_t epoch_in_milliseconds); + static HybridTimestamp + CreateFromUnixTime(uint64_t epoch_in_milliseconds); }; } // namespace milvus diff --git a/src/include/milvus/types/ProgressMonitor.h b/src/include/milvus/types/ProgressMonitor.h index 434eb4e..1009cda 100644 --- a/src/include/milvus/types/ProgressMonitor.h +++ b/src/include/milvus/types/ProgressMonitor.h @@ -40,7 +40,7 @@ struct Progress { Done() const; /** - * @brief How much work is finised + * @brief How much work is finished */ uint32_t finished_ = 0; @@ -108,7 +108,7 @@ class ProgressMonitor { /** * @brief Set call back function to receive progress notification. * - * @param [in] func call back function to recieve progress notification. + * @param [in] func call back function to receive progress notification. */ void SetCallbackFunc(CallbackFunc func); diff --git a/src/include/milvus/types/SearchResults.h b/src/include/milvus/types/SearchResults.h index 0a3e521..5cc1a36 100644 --- a/src/include/milvus/types/SearchResults.h +++ b/src/include/milvus/types/SearchResults.h @@ -40,7 +40,7 @@ struct SingleResult { Scores() const; /** - * @brief Topk id array of one target vecotor + * @brief Topk id array of one target vector */ const IDArray& Ids() const; @@ -54,7 +54,7 @@ struct SingleResult { /** * @brief Get an output field by name */ - const FieldDataPtr + FieldDataPtr OutputField(const std::string& name) const; private: diff --git a/test/it/TestCalcDistance.cpp b/test/it/TestCalcDistance.cpp index 9725712..fed2172 100644 --- a/test/it/TestCalcDistance.cpp +++ b/test/it/TestCalcDistance.cpp @@ -52,9 +52,9 @@ TEST_F(MilvusMockedTest, CalcDistanceFloat) { .WillOnce([&](::grpc::ServerContext*, const CalcDistanceRequest* request, CalcDistanceResults* response) { // validate params auto& params = request->params(); - for (int i = 0; i < params.size(); ++i) { - if (params[i].key() == "metric") { - EXPECT_EQ(params[i].value(), "IP"); + for (const auto& param : params) { + if (param.key() == "metric") { + EXPECT_EQ(param.value(), "IP"); } } @@ -140,9 +140,9 @@ TEST_F(MilvusMockedTest, CalcDistanceBinary) { .WillOnce([&](::grpc::ServerContext*, const CalcDistanceRequest* request, CalcDistanceResults* response) { // validate metric auto& params = request->params(); - for (int i = 0; i < params.size(); ++i) { - if (params[i].key() == "metric") { - EXPECT_EQ(params[i].value(), "HAMMING"); + for (const auto& param : params) { + if (param.key() == "metric") { + EXPECT_EQ(param.value(), "HAMMING"); } } @@ -164,7 +164,7 @@ TEST_F(MilvusMockedTest, CalcDistanceBinary) { auto& binary_array = data_arr.binary_vector(); EXPECT_GE(binary_array.length(), offset + element.size()); for (auto i = 0; i < element.size(); ++i) { - EXPECT_EQ(binary_array.data()[offset + i], element[i]); + EXPECT_EQ(binary_array[offset + i], element[i]); } }; @@ -224,9 +224,9 @@ TEST_F(MilvusMockedTest, CalcDistanceIDArray) { .WillOnce([&](::grpc::ServerContext*, const CalcDistanceRequest* request, CalcDistanceResults* response) { // validate metric auto& params = request->params(); - for (int i = 0; i < params.size(); ++i) { - if (params[i].key() == "metric") { - EXPECT_EQ(params[i].value(), "L2"); + for (const auto& param : params) { + if (param.key() == "metric") { + EXPECT_EQ(param.value(), "L2"); } } diff --git a/test/it/TestCompact.cpp b/test/it/TestCompact.cpp index c767b1b..2d0c40f 100644 --- a/test/it/TestCompact.cpp +++ b/test/it/TestCompact.cpp @@ -41,8 +41,7 @@ TEST_F(MilvusMockedTest, GetCompactionStateFoo) { const int64_t completed_id = 102; EXPECT_CALL(service_, GetCompactionState(_, Property(&GetCompactionStateRequest::compactionid, compaction_id), _)) - .WillOnce([executing_id, timeout_id, completed_id](::grpc::ServerContext*, const GetCompactionStateRequest*, - GetCompactionStateResponse* response) { + .WillOnce([&](::grpc::ServerContext*, const GetCompactionStateRequest*, GetCompactionStateResponse* response) { response->set_executingplanno(executing_id); response->set_timeoutplanno(timeout_id); response->set_completedplanno(completed_id); @@ -112,8 +111,7 @@ TEST_F(MilvusMockedTest, ManualCompactionFoo) { EXPECT_CALL(service_, DescribeCollection(_, Property(&DescribeCollectionRequest::collection_name, collection_name), _)) - .WillOnce([collection_id](::grpc::ServerContext*, const DescribeCollectionRequest*, - DescribeCollectionResponse* response) { + .WillOnce([&](::grpc::ServerContext*, const DescribeCollectionRequest*, DescribeCollectionResponse* response) { response->set_collectionid(collection_id); return ::grpc::Status{}; }); @@ -122,8 +120,7 @@ TEST_F(MilvusMockedTest, ManualCompactionFoo) { AllOf(Property(&ManualCompactionRequest::collectionid, collection_id), Property(&ManualCompactionRequest::timetravel, travel_ts)), _)) - .WillOnce([compaction_id](::grpc::ServerContext*, const ManualCompactionRequest*, - ManualCompactionResponse* response) { + .WillOnce([&](::grpc::ServerContext*, const ManualCompactionRequest*, ManualCompactionResponse* response) { response->set_compactionid(compaction_id); return ::grpc::Status{}; }); @@ -178,8 +175,7 @@ TEST_F(MilvusMockedTest, GetCompactionPlansFoo) { EXPECT_CALL(service_, GetCompactionStateWithPlans(_, Property(&GetCompactionPlansRequest::compactionid, compaction_id), _)) - .WillOnce([&sources, &target](::grpc::ServerContext*, const GetCompactionPlansRequest*, - GetCompactionPlansResponse* response) { + .WillOnce([&](::grpc::ServerContext*, const GetCompactionPlansRequest*, GetCompactionPlansResponse* response) { auto info = response->add_mergeinfos(); for (auto i : sources) { info->add_sources(i); diff --git a/test/it/TestCreateCollection.cpp b/test/it/TestCreateCollection.cpp index fb49fed..3f17218 100644 --- a/test/it/TestCreateCollection.cpp +++ b/test/it/TestCreateCollection.cpp @@ -70,7 +70,7 @@ TEST_F(MilvusMockedTest, CreateCollectionFooFailed) { EXPECT_CALL(service_, CreateCollection(_, Property(&CreateCollectionRequest::collection_name, "Foo"), _)) .WillOnce([error_code](::grpc::ServerContext*, const CreateCollectionRequest* request, ::milvus::proto::common::Status* status) { - status->set_error_code(error_code); + status->set_code(error_code); return ::grpc::Status{::grpc::StatusCode::UNKNOWN, ""}; }); auto status = client_->CreateCollection(collection_schema); diff --git a/test/it/TestCreateIndex.cpp b/test/it/TestCreateIndex.cpp index 895bfc9..5b90059 100644 --- a/test/it/TestCreateIndex.cpp +++ b/test/it/TestCreateIndex.cpp @@ -76,7 +76,7 @@ TEST_F(MilvusMockedTest, TestCreateIndexFlushFailedInstantly) { EXPECT_CALL(service_, Flush(_, AllOf(Property(&FlushRequest::collection_names, ElementsAre(collection_name))), _)) .WillOnce([&](::grpc::ServerContext*, const FlushRequest*, FlushResponse* resp) { - resp->mutable_status()->set_error_code(::milvus::proto::common::ErrorCode::UnexpectedError); + resp->mutable_status()->set_code(::milvus::proto::common::ErrorCode::UnexpectedError); return ::grpc::Status{}; }); @@ -117,7 +117,7 @@ TEST_F(MilvusMockedTest, TestCreateIndexWithProgress) { EXPECT_EQ(params[milvus::KeyMetricType()], std::to_string(metric_type)); EXPECT_EQ(params[milvus::KeyParams()], "{\"nlist\":1024}"); - status->set_error_code(milvus::proto::common::ErrorCode::Success); + status->set_code(milvus::proto::common::ErrorCode::Success); return ::grpc::Status{}; }); @@ -164,7 +164,7 @@ TEST_F(MilvusMockedTest, TestCreateIndexFailed) { Property(&CreateIndexRequest::field_name, field_name)), _)) .WillRepeatedly([](::grpc::ServerContext*, const CreateIndexRequest*, ::milvus::proto::common::Status* status) { - status->set_error_code(milvus::proto::common::ErrorCode::Success); + status->set_code(milvus::proto::common::ErrorCode::Success); return ::grpc::Status{}; }); diff --git a/test/it/TestCreatePartition.cpp b/test/it/TestCreatePartition.cpp index 1e80296..747e296 100644 --- a/test/it/TestCreatePartition.cpp +++ b/test/it/TestCreatePartition.cpp @@ -59,7 +59,7 @@ TEST_F(MilvusMockedTest, CreatePartitionFooFailed) { _)) .WillOnce([error_code](::grpc::ServerContext*, const CreatePartitionRequest* request, ::milvus::proto::common::Status* status) { - status->set_error_code(error_code); + status->set_code(error_code); return ::grpc::Status{::grpc::StatusCode::UNKNOWN, ""}; }); auto status = client_->CreatePartition(collection, partition); diff --git a/test/it/TestCredential.cpp b/test/it/TestCredential.cpp index 8fc002a..02e344c 100644 --- a/test/it/TestCredential.cpp +++ b/test/it/TestCredential.cpp @@ -54,7 +54,7 @@ TEST_F(MilvusMockedTest, CreateCredentialError) { _)) .WillOnce([](::grpc::ServerContext*, const CreateCredentialRequest* request, ::milvus::proto::common::Status* status) { - status->set_error_code(milvus::proto::common::ErrorCode::CreateCredentialFailure); + status->set_code(milvus::proto::common::ErrorCode::CreateCredentialFailure); return ::grpc::Status{}; }); auto status = client_->CreateCredential("username", "password"); diff --git a/test/it/TestDescribeCollection.cpp b/test/it/TestDescribeCollection.cpp index 59d2ab8..23310ce 100644 --- a/test/it/TestDescribeCollection.cpp +++ b/test/it/TestDescribeCollection.cpp @@ -43,8 +43,7 @@ TEST_F(MilvusMockedTest, DescribeCollectionFoo) { EXPECT_CALL(service_, DescribeCollection( _, Property(&DescribeCollectionRequest::collection_name, collection_schema.Name()), _)) - .WillOnce([&collection_id, &shards_num, &aliases, &created_ts, &collection_schema]( - ::grpc::ServerContext*, const DescribeCollectionRequest*, DescribeCollectionResponse* response) { + .WillOnce([&](::grpc::ServerContext*, const DescribeCollectionRequest*, DescribeCollectionResponse* response) { response->set_collectionid(collection_id); response->set_shards_num(shards_num); for (auto& alias : aliases) { diff --git a/test/it/TestDescribeIndex.cpp b/test/it/TestDescribeIndex.cpp index 667468f..b500508 100644 --- a/test/it/TestDescribeIndex.cpp +++ b/test/it/TestDescribeIndex.cpp @@ -59,7 +59,7 @@ TEST_F(MilvusMockedTest, DescribeIndexFoo) { kv = index_desc_ptr->add_params(); kv->set_key(milvus::KeyParams()); - kv->set_value("{\"nlist\": 1024}"); + kv->set_value(R"({"nlist": 1024})"); return ::grpc::Status{}; }); diff --git a/test/it/TestDropCollection.cpp b/test/it/TestDropCollection.cpp index 6f03f44..da988a2 100644 --- a/test/it/TestDropCollection.cpp +++ b/test/it/TestDropCollection.cpp @@ -63,7 +63,7 @@ TEST_F(MilvusMockedTest, DropCollectionFooFailed) { EXPECT_CALL(service_, DropCollection(_, Property(&DropCollectionRequest::collection_name, collection_name), _)) .WillOnce([error_code](::grpc::ServerContext*, const DropCollectionRequest*, ::milvus::proto::common::Status* status) { - status->set_error_code(error_code); + status->set_code(error_code); return ::grpc::Status{::grpc::StatusCode::UNKNOWN, "Collection drop failed. Internal error"}; }); auto status = client_->DropCollection(collection_name); diff --git a/test/it/TestDropIndex.cpp b/test/it/TestDropIndex.cpp index 93366fd..0dbd34d 100644 --- a/test/it/TestDropIndex.cpp +++ b/test/it/TestDropIndex.cpp @@ -56,7 +56,7 @@ TEST_F(MilvusMockedTest, DropIndexFooFailed) { _)) .WillOnce([error_code](::grpc::ServerContext*, const DropIndexRequest* request, ::milvus::proto::common::Status* status) { - status->set_error_code(error_code); + status->set_code(error_code); return ::grpc::Status{::grpc::StatusCode::UNKNOWN, ""}; }); auto status = client_->DropIndex(collection_name, field_name); diff --git a/test/it/TestDropPartition.cpp b/test/it/TestDropPartition.cpp index dbcd5f6..ee765a6 100644 --- a/test/it/TestDropPartition.cpp +++ b/test/it/TestDropPartition.cpp @@ -59,7 +59,7 @@ TEST_F(MilvusMockedTest, DropPartitionFooFailed) { _)) .WillOnce([error_code](::grpc::ServerContext*, const DropPartitionRequest* request, ::milvus::proto::common::Status* status) { - status->set_error_code(error_code); + status->set_code(error_code); return ::grpc::Status{::grpc::StatusCode::UNKNOWN, ""}; }); auto status = client_->DropPartition(collection, partition); diff --git a/test/it/TestFlush.cpp b/test/it/TestFlush.cpp index 3f46524..c9b2e80 100644 --- a/test/it/TestFlush.cpp +++ b/test/it/TestFlush.cpp @@ -64,7 +64,7 @@ TEST_F(MilvusMockedTest, FlushFailure) { EXPECT_CALL(service_, Flush(_, AllOf(Property(&FlushRequest::collection_names_size, collections.size())), _)) .WillOnce([](::grpc::ServerContext*, const FlushRequest*, FlushResponse* response) { - response->mutable_status()->set_error_code(::milvus::proto::common::ErrorCode::UnexpectedError); + response->mutable_status()->set_code(::milvus::proto::common::ErrorCode::UnexpectedError); return ::grpc::Status{}; }); @@ -171,7 +171,7 @@ TEST_F(MilvusMockedTest, FlushGetStateFailure) { .Times(1) .WillRepeatedly( [](::grpc::ServerContext*, const GetFlushStateRequest* request, GetFlushStateResponse* response) { - response->mutable_status()->set_error_code(::milvus::proto::common::ErrorCode::UnexpectedError); + response->mutable_status()->set_code(::milvus::proto::common::ErrorCode::UnexpectedError); return ::grpc::Status{}; }); diff --git a/test/it/TestGetCollectionsStatistics.cpp b/test/it/TestGetCollectionsStatistics.cpp index 683e0c2..0fbbad7 100644 --- a/test/it/TestGetCollectionsStatistics.cpp +++ b/test/it/TestGetCollectionsStatistics.cpp @@ -87,7 +87,7 @@ TEST_F(MilvusMockedTest, GetCollectionStatisticsWithFlushFailure) { EXPECT_CALL(service_, Flush(_, AllOf(Property(&FlushRequest::collection_names, ElementsAre(collection))), _)) .WillOnce([](::grpc::ServerContext*, const FlushRequest*, FlushResponse* response) { - response->mutable_status()->set_error_code(::milvus::proto::common::ErrorCode::UnexpectedError); + response->mutable_status()->set_code(::milvus::proto::common::ErrorCode::UnexpectedError); return ::grpc::Status{}; }); diff --git a/test/it/TestGetPartitionStatistics.cpp b/test/it/TestGetPartitionStatistics.cpp index e328e54..6f81076 100644 --- a/test/it/TestGetPartitionStatistics.cpp +++ b/test/it/TestGetPartitionStatistics.cpp @@ -77,7 +77,7 @@ TEST_F(MilvusMockedTest, GetPartitionStatisticsWithFlushFailure) { EXPECT_CALL(service_, Flush(_, AllOf(Property(&FlushRequest::collection_names, ElementsAre(collection))), _)) .WillOnce([](::grpc::ServerContext*, const FlushRequest*, FlushResponse* response) { - response->mutable_status()->set_error_code(::milvus::proto::common::ErrorCode::UnexpectedError); + response->mutable_status()->set_code(::milvus::proto::common::ErrorCode::UnexpectedError); return ::grpc::Status{}; }); diff --git a/test/it/TestGetQuerySegmentInfo.cpp b/test/it/TestGetQuerySegmentInfo.cpp index 85cf78f..c5c261e 100644 --- a/test/it/TestGetQuerySegmentInfo.cpp +++ b/test/it/TestGetQuerySegmentInfo.cpp @@ -61,6 +61,7 @@ TEST_F(MilvusMockedTest, GetQuerySegmentInfoFoo) { info->set_state(milvus::SegmentStateCast(info_exp.State())); info->set_index_name(info_exp.IndexName()); info->set_indexid(info_exp.IndexID()); + // TODO: nodeid deprecated info->set_nodeid(info_exp.NodeID()); } return ::grpc::Status{}; diff --git a/test/it/TestLoadCollection.cpp b/test/it/TestLoadCollection.cpp index aa2dcb3..ced16a7 100644 --- a/test/it/TestLoadCollection.cpp +++ b/test/it/TestLoadCollection.cpp @@ -70,6 +70,7 @@ TEST_F(MilvusMockedTest, LoadCollectionFooWithProgress) { response->add_collection_ids(1); response->add_collection_names("dummy"); response->add_created_utc_timestamps(10000); + // TODO: deprecated response->add_inmemory_percentages((++called_times) * 10); return ::grpc::Status{}; }); diff --git a/test/it/TestLoadPartitions.cpp b/test/it/TestLoadPartitions.cpp index a21dc91..1c56b46 100644 --- a/test/it/TestLoadPartitions.cpp +++ b/test/it/TestLoadPartitions.cpp @@ -68,7 +68,7 @@ TEST_F(MilvusMockedTest, LoadPartitionsFailure) { Property(&LoadPartitionsRequest::partition_names_size, partitions.size())), _)) .WillOnce([](::grpc::ServerContext*, const LoadPartitionsRequest*, milvus::proto::common::Status* response) { - response->set_error_code(::milvus::proto::common::ErrorCode::UnexpectedError); + response->set_code(::milvus::proto::common::ErrorCode::UnexpectedError); return ::grpc::Status{}; }); @@ -128,6 +128,7 @@ TEST_F(MilvusMockedTest, LoadPartitionsWithQueryStatusSuccess) { // time 7: 80%, 100%, 100%, 100%, 100% -->{4, 5} // time 8: 90%, 100%, 100%, 100%, 100% -->{4, 5} // time 9: 100%, 100%, 100%, 100%, 100% -->{5, 5} + // TODO: deprecated response->add_inmemory_percentages(std::min(index * 10 * show_partitions_called, 100)); } return ::grpc::Status{}; @@ -175,9 +176,10 @@ TEST_F(MilvusMockedTest, LoadPartitionsWithQueryStatusOomFailure) { response->add_partition_names(partition); response->add_partitionids(0); response->add_created_timestamps(0); + // TODO: deprecated response->add_inmemory_percentages(10); } - response->mutable_status()->set_error_code(::milvus::proto::common::ErrorCode::OutOfMemory); + response->mutable_status()->set_code(::milvus::proto::common::ErrorCode::OutOfMemory); return ::grpc::Status{}; }); @@ -220,6 +222,7 @@ TEST_F(MilvusMockedTest, LoadPartitionsWithQueryStatusTimeout) { response->add_partition_names(partition); response->add_partitionids(0); response->add_created_timestamps(0); + // TODO: deprecated response->add_inmemory_percentages(0); } return ::grpc::Status{}; diff --git a/test/it/TestReleasePartitions.cpp b/test/it/TestReleasePartitions.cpp index bb086d6..de2ea4a 100644 --- a/test/it/TestReleasePartitions.cpp +++ b/test/it/TestReleasePartitions.cpp @@ -52,7 +52,7 @@ TEST_F(MilvusMockedTest, ReleasePartitionsFailure) { Property(&ReleasePartitionsRequest::partition_names_size, partitions.size())), _)) .WillOnce([](::grpc::ServerContext*, const ReleasePartitionsRequest*, milvus::proto::common::Status* response) { - response->set_error_code(::milvus::proto::common::ErrorCode::UnexpectedError); + response->set_code(::milvus::proto::common::ErrorCode::UnexpectedError); return ::grpc::Status{}; }); diff --git a/test/it/TestSearch.cpp b/test/it/TestSearch.cpp index c6f5345..3771b3c 100644 --- a/test/it/TestSearch.cpp +++ b/test/it/TestSearch.cpp @@ -20,6 +20,7 @@ #include #include #include +#include #include "TypeUtils.h" #include "mocks/MilvusMockedTest.h" @@ -40,7 +41,7 @@ using ::testing::UnorderedElementsAre; namespace { struct TestKv { - TestKv(const std::string& key, const std::string& value) : key_(key), value_(value) { + TestKv(std::string key, std::string value) : key_(std::move(key)), value_(std::move(value)) { } std::string key_; std::string value_; @@ -115,7 +116,7 @@ DoSearchVectors(testing::StrictMock<::milvus::MilvusMockedService>& service_, EXPECT_EQ(json_params["nprobe"].get(), 10); // check placeholder - auto placeholder_group_payload = request->placeholder_group(); + const auto& placeholder_group_payload = request->placeholder_group(); milvus::proto::common::PlaceholderGroup placeholder_group; placeholder_group.ParseFromString(placeholder_group_payload); EXPECT_EQ(placeholder_group.placeholders_size(), 1); @@ -129,7 +130,7 @@ DoSearchVectors(testing::StrictMock<::milvus::MilvusMockedService>& service_, EXPECT_EQ(test_vector, vector); } - response->mutable_status()->set_error_code(milvus::proto::common::ErrorCode::Success); + response->mutable_status()->set_code(milvus::proto::common::ErrorCode::Success); auto* results = response->mutable_results(); results->set_top_k(10); results->set_num_queries(2); diff --git a/test/it/TestShowPartitions.cpp b/test/it/TestShowPartitions.cpp index 8773c2f..c69abdb 100644 --- a/test/it/TestShowPartitions.cpp +++ b/test/it/TestShowPartitions.cpp @@ -45,6 +45,7 @@ TEST_F(MilvusMockedTest, ShowPartitionsQueryAll) { response->add_partition_names(partition.Name()); response->add_partitionids(partition.Id()); response->add_created_timestamps(partition.CreatedUtcTimestamp()); + // TODO: deprecated response->add_inmemory_percentages(partition.InMemoryPercentage()); } return ::grpc::Status{}; @@ -79,6 +80,7 @@ TEST_F(MilvusMockedTest, ShowPartitionsQueryLoadingPercent) { response->add_partition_names(partition.Name()); response->add_partitionids(partition.Id()); response->add_created_timestamps(partition.CreatedUtcTimestamp()); + // TODO: deprecated response->add_inmemory_percentages(partition.InMemoryPercentage()); } return ::grpc::Status{}; diff --git a/test/st/MilvusServerTest.h b/test/st/MilvusServerTest.h index 5a8b40a..11d8f5f 100644 --- a/test/st/MilvusServerTest.h +++ b/test/st/MilvusServerTest.h @@ -37,13 +37,13 @@ waitMilvusServerReady(const PythonMilvusServer& server) { auto client = milvus::MilvusClient::Create(); auto param = server.TestClientParam(); client->Connect(*param); - auto status = client->HasCollection("nosuchcollection", has); + auto status = client->HasCollection("no_such", has); while (!status.IsOk() && retry++ < max_retry) { std::this_thread::sleep_for(std::chrono::seconds{5}); client = milvus::MilvusClient::Create(); client->Connect(*param); - status = client->HasCollection("nosuchcollection", has); + status = client->HasCollection("no_such", has); std::cout << "Wait milvus start done, try: " << retry << ", status: " << status.Message() << std::endl; } std::cout << "Wait milvus start done, status: " << status.Message() << std::endl; diff --git a/test/st/TestConnectWithTls.cpp b/test/st/TestConnectWithTls.cpp index 8321bec..134d3c1 100644 --- a/test/st/TestConnectWithTls.cpp +++ b/test/st/TestConnectWithTls.cpp @@ -22,9 +22,6 @@ #include #include "MilvusServerTest.h" -#include "milvus/MilvusClient.h" -#include "milvus/Status.h" -#include "milvus/types/ConnectParam.h" using testing::UnorderedElementsAre; using testing::UnorderedElementsAreArray; @@ -73,7 +70,7 @@ class MilvusServerTestWithTlsMode : public MilvusServerTest { void SetUp() override { generate_certificates(); - std::array path; + std::array path{}; getcwd(path.data(), path.size()); std::string pwd = path.data(); server_.SetTls(Mode, pwd + "/certs/server.crt", pwd + "/certs/server.key", pwd + "/certs/ca.crt"); diff --git a/test/st/TestConnectWithUser.cpp b/test/st/TestConnectWithUser.cpp index a7445e4..9c63aeb 100644 --- a/test/st/TestConnectWithUser.cpp +++ b/test/st/TestConnectWithUser.cpp @@ -19,7 +19,6 @@ #include #include "MilvusServerTest.h" -#include "milvus/Status.h" using milvus::test::MilvusServerTest; using testing::UnorderedElementsAre; diff --git a/test/ut/TestFieldData.cpp b/test/ut/TestFieldData.cpp index f903c64..86a38a2 100644 --- a/test/ut/TestFieldData.cpp +++ b/test/ut/TestFieldData.cpp @@ -199,9 +199,9 @@ TEST_F(FieldDataTest, GeneralTesting) { } { - std::string name{"foo"}; + std::string field_name{"foo"}; const std::vector elements{"\x01\x02", "\x03\x04"}; - milvus::BinaryVecFieldData data{name, elements}; + milvus::BinaryVecFieldData data{field_name, elements}; std::vector> expected{{1, 2}, {3, 4}}; EXPECT_EQ(data.DataAsUnsignedChars(), expected); diff --git a/test/ut/TestHybirdTimestamp.cpp b/test/ut/TestHybirdTimestamp.cpp index 6c5c20f..8b89a01 100644 --- a/test/ut/TestHybirdTimestamp.cpp +++ b/test/ut/TestHybirdTimestamp.cpp @@ -16,17 +16,17 @@ #include -#include "milvus/types/HybirdTimestamp.h" +#include "milvus/types/HybridTimestamp.h" -class HybirdTimestampTest : public ::testing::Test {}; +class HybridTimestampTest : public ::testing::Test {}; -TEST_F(HybirdTimestampTest, GeneralTesting) { - milvus::HybirdTimestamp foo{}; +TEST_F(HybridTimestampTest, GeneralTesting) { + milvus::HybridTimestamp foo{}; EXPECT_EQ(foo.Timestamp(), 0); EXPECT_EQ(foo.Logical(), 0); EXPECT_EQ(foo.Physical(), 0); - milvus::HybirdTimestamp bar{1, 1}; + milvus::HybridTimestamp bar{1, 1}; EXPECT_EQ(bar.Timestamp(), (1 << 18) + 1); EXPECT_EQ(bar.Logical(), 1); EXPECT_EQ(bar.Physical(), 1); @@ -43,12 +43,12 @@ TEST_F(HybirdTimestampTest, GeneralTesting) { EXPECT_EQ(bar.Logical(), 0); EXPECT_EQ(bar.Physical(), 2001); - bar = milvus::HybirdTimestamp::CreateFromUnixtime(1000); + bar = milvus::HybridTimestamp::CreateFromUnixTime(1000); EXPECT_EQ(bar.Logical(), 0); EXPECT_EQ(bar.Physical(), 1000); - milvus::HybirdTimestamp ts_a = milvus::HybirdTimestamp::CreateFromUnixtime(3); - milvus::HybirdTimestamp ts_b{ts_a.Timestamp()}; + milvus::HybridTimestamp ts_a = milvus::HybridTimestamp::CreateFromUnixTime(3); + milvus::HybridTimestamp ts_b{ts_a.Timestamp()}; EXPECT_EQ(ts_a.Logical(), ts_b.Logical()); EXPECT_EQ(ts_a.Physical(), ts_b.Physical()); } diff --git a/test/ut/TestIndexDesc.cpp b/test/ut/TestIndexDesc.cpp index 72f2d98..e4bc84e 100644 --- a/test/ut/TestIndexDesc.cpp +++ b/test/ut/TestIndexDesc.cpp @@ -41,17 +41,17 @@ TEST_F(IndexDescTest, GeneralTesting) { TEST_F(IndexDescTest, ValidationTestingPossitive) { for (const auto& test_data : { - std::make_tuple(milvus::IndexType::IVF_FLAT, milvus::MetricType::L2, "{\"nlist\": 1024}"), - std::make_tuple(milvus::IndexType::IVF_SQ8, milvus::MetricType::L2, "{\"nlist\": 1024}"), - std::make_tuple(milvus::IndexType::IVF_PQ, milvus::MetricType::L2, "{\"nlist\": 1024, \"m\": 8}"), + std::make_tuple(milvus::IndexType::IVF_FLAT, milvus::MetricType::L2, R"({"nlist": 1024})"), + std::make_tuple(milvus::IndexType::IVF_SQ8, milvus::MetricType::L2, R"({"nlist": 1024})"), + std::make_tuple(milvus::IndexType::IVF_PQ, milvus::MetricType::L2, R"({"nlist": 1024, "m": 8})"), std::make_tuple(milvus::IndexType::IVF_PQ, milvus::MetricType::L2, - "{\"nlist\": 1024, \"m\": 8, \"nbits\": 12}"), - std::make_tuple(milvus::IndexType::HNSW, milvus::MetricType::L2, "{\"M\": 4, \"efConstruction\": 12}"), + R"({"nlist": 1024, "m": 8, "nbits": 12})"), + std::make_tuple(milvus::IndexType::HNSW, milvus::MetricType::L2, R"({"M": 4, "efConstruction": 12})"), std::make_tuple(milvus::IndexType::IVF_HNSW, milvus::MetricType::L2, - "{\"nlist\": 1024, \"M\": 4, \"efConstruction\": 12}"), + R"({"nlist": 1024, "M": 4, "efConstruction": 12})"), std::make_tuple(milvus::IndexType::RHNSW_PQ, milvus::MetricType::L2, - "{\"PQM\": 32, \"M\": 4, \"efConstruction\": 12}"), - std::make_tuple(milvus::IndexType::ANNOY, milvus::MetricType::L2, "{\"n_trees\": 12}"), + R"({"PQM": 32, "M": 4, "efConstruction": 12})"), + std::make_tuple(milvus::IndexType::ANNOY, milvus::MetricType::L2, R"({"n_trees": 12})"), std::make_tuple(milvus::IndexType::BIN_IVF_FLAT, milvus::MetricType::JACCARD, ""), std::make_tuple(milvus::IndexType::BIN_IVF_FLAT, milvus::MetricType::TANIMOTO, ""), std::make_tuple(milvus::IndexType::BIN_IVF_FLAT, milvus::MetricType::HAMMING, ""), @@ -68,13 +68,13 @@ TEST_F(IndexDescTest, ValidationTestingPossitive) { TEST_F(IndexDescTest, ValidationTestingNegative) { for (const auto& test_data : { - std::make_tuple(milvus::IndexType::IVF_FLAT, milvus::MetricType::JACCARD, "{\"nlist\": 1024}"), - std::make_tuple(milvus::IndexType::BIN_IVF_FLAT, milvus::MetricType::SUBSTRUCTURE, "{\"nlist\": 1024}"), - std::make_tuple(milvus::IndexType::IVF_FLAT, milvus::MetricType::IP, "{\"nlist\": 0}"), - std::make_tuple(milvus::IndexType::IVF_FLAT, milvus::MetricType::IP, "{\"nlist\": \"1024\"}"), - std::make_tuple(milvus::IndexType::IVF_FLAT, milvus::MetricType::IP, "{\"nlist\": 65537}"), - std::make_tuple(milvus::IndexType::ANNOY, milvus::MetricType::IP, "{\"nlist\": 65537}"), - std::make_tuple(milvus::IndexType::BIN_IVF_FLAT, milvus::MetricType::IP, "{\"nlist\": 1024}"), + std::make_tuple(milvus::IndexType::IVF_FLAT, milvus::MetricType::JACCARD, R"({"nlist": 1024})"), + std::make_tuple(milvus::IndexType::BIN_IVF_FLAT, milvus::MetricType::SUBSTRUCTURE, R"({"nlist": 1024})"), + std::make_tuple(milvus::IndexType::IVF_FLAT, milvus::MetricType::IP, R"({"nlist": 0})"), + std::make_tuple(milvus::IndexType::IVF_FLAT, milvus::MetricType::IP, R"({"nlist": "1024"})"), + std::make_tuple(milvus::IndexType::IVF_FLAT, milvus::MetricType::IP, R"({"nlist": 65537})"), + std::make_tuple(milvus::IndexType::ANNOY, milvus::MetricType::IP, R"({"nlist": 65537})"), + std::make_tuple(milvus::IndexType::BIN_IVF_FLAT, milvus::MetricType::IP, R"({"nlist": 1024})"), }) { milvus::IndexDesc index_desc{"foo", "index", std::get<0>(test_data), std::get<1>(test_data), 0}; index_desc.ExtraParamsFromJson(std::get<2>(test_data)); diff --git a/test/ut/TestQueryArguments.cpp b/test/ut/TestQueryArguments.cpp index d98a811..9c64524 100644 --- a/test/ut/TestQueryArguments.cpp +++ b/test/ut/TestQueryArguments.cpp @@ -23,7 +23,7 @@ class QueryArgumentsTest : public ::testing::Test {}; TEST_F(QueryArgumentsTest, GeneralTesting) { milvus::QueryArguments arguments; - std::string empty_name = ""; + std::string empty_name; std::string collection_name = "test"; arguments.SetCollectionName(collection_name); EXPECT_FALSE(arguments.SetCollectionName(empty_name).IsOk()); diff --git a/test/ut/TestSearchArguments.cpp b/test/ut/TestSearchArguments.cpp index 780b89b..bd1bd92 100644 --- a/test/ut/TestSearchArguments.cpp +++ b/test/ut/TestSearchArguments.cpp @@ -24,7 +24,7 @@ TEST_F(SearchArgumentsTest, GeneralTesting) { milvus::SearchArguments arguments; EXPECT_EQ(arguments.TargetVectors(), nullptr); - std::string empty_name = ""; + std::string empty_name; std::string collection_name = "test"; arguments.SetCollectionName(collection_name); EXPECT_FALSE(arguments.SetCollectionName(empty_name).IsOk()); diff --git a/test/ut/TestTypeUtils.cpp b/test/ut/TestTypeUtils.cpp index 76761d9..8a47839 100644 --- a/test/ut/TestTypeUtils.cpp +++ b/test/ut/TestTypeUtils.cpp @@ -16,7 +16,6 @@ #include -#include #include #include "TypeUtils.h"