From 1dca18d3d39985d287d66b39d3309f8f84b3d249 Mon Sep 17 00:00:00 2001 From: Cai Yudong Date: Thu, 23 Dec 2021 10:31:15 +0800 Subject: [PATCH] Use std::numeric_limits instead of MAXFLOAT to fix porting issue (#13954) Signed-off-by: yudong.cai --- internal/core/src/segcore/ReduceStructure.h | 6 +++--- internal/core/src/segcore/reduce_c.cpp | 4 +++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/internal/core/src/segcore/ReduceStructure.h b/internal/core/src/segcore/ReduceStructure.h index 586bf2c97..bf2c09111 100644 --- a/internal/core/src/segcore/ReduceStructure.h +++ b/internal/core/src/segcore/ReduceStructure.h @@ -9,7 +9,7 @@ // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express // or implied. See the License for the specific language governing permissions and limitations under the License -#include +#include #include "common/Consts.h" #include "common/Types.h" @@ -56,11 +56,11 @@ struct SearchResultPair { distance_ = search_result_->distances_.at(offset_); } else { primary_key_ = INVALID_ID; - distance_ = MAXFLOAT; + distance_ = std::numeric_limits::max(); } } else { primary_key_ = INVALID_ID; - distance_ = MAXFLOAT; + distance_ = std::numeric_limits::max(); } } }; diff --git a/internal/core/src/segcore/reduce_c.cpp b/internal/core/src/segcore/reduce_c.cpp index 8a7e706d3..f79d3b3b8 100644 --- a/internal/core/src/segcore/reduce_c.cpp +++ b/internal/core/src/segcore/reduce_c.cpp @@ -9,6 +9,7 @@ // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express // or implied. See the License for the specific language governing permissions and limitations under the License +#include #include #include @@ -142,7 +143,8 @@ ReduceResultData(std::vector& search_results, int64_t nq, int64_t for (int j = 0; j < search_records[i].size(); j++) { auto& offset = search_records[i][j]; primary_keys.push_back(offset != INVALID_OFFSET ? search_result->primary_keys_[offset] : INVALID_ID); - distances.push_back(offset != INVALID_OFFSET ? search_result->distances_[offset] : MAXFLOAT); + distances.push_back(offset != INVALID_OFFSET ? search_result->distances_[offset] + : std::numeric_limits::max()); ids.push_back(offset != INVALID_OFFSET ? search_result->ids_[offset] : INVALID_ID); } -- GitLab