From 6ccf1aa9b878748c1cdd0ddc9eae238bcb01f417 Mon Sep 17 00:00:00 2001 From: Spade A <71589810+SpadeA-Tang@users.noreply.github.com> Date: Wed, 16 Jul 2025 15:34:51 +0800 Subject: [PATCH] fix: void copy when getting json chunk #43183 (#43202) master https://github.com/milvus-io/milvus/pull/43183 fix: https://github.com/milvus-io/milvus/issues/43182 --------- Signed-off-by: SpadeA --- internal/core/src/common/Json.h | 7 +++++++ internal/core/src/segcore/SegmentInterface.h | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/internal/core/src/common/Json.h b/internal/core/src/common/Json.h index e364bf2fc3..c088184a4f 100644 --- a/internal/core/src/common/Json.h +++ b/internal/core/src/common/Json.h @@ -90,6 +90,13 @@ class Json { cap); } + // WARN: this is used for fast non-copy construction, + // MUST make sure there at least SIMDJSON_PADDING bytes allocated + // after the string_view. + explicit Json(const std::string_view& data) + : Json(data.data(), data.size()) { + } + // WARN: this is used for fast non-copy construction, // MUST make sure that the data points to a memory that // with size at least len + SIMDJSON_PADDING diff --git a/internal/core/src/segcore/SegmentInterface.h b/internal/core/src/segcore/SegmentInterface.h index 66ee4bd474..e07ef02a0b 100644 --- a/internal/core/src/segcore/SegmentInterface.h +++ b/internal/core/src/segcore/SegmentInterface.h @@ -183,7 +183,7 @@ class SegmentInternalInterface : public SegmentInterface { std::vector res; res.reserve(string_views.size()); for (const auto& str_view : string_views) { - res.emplace_back(str_view); + res.emplace_back(Json(str_view)); } return {std::move(res), std::move(valid_data)}; }