From d41eec6f10c4450993bfd9d71afaf6b7c8992ecf Mon Sep 17 00:00:00 2001 From: Spade A <71589810+SpadeA-Tang@users.noreply.github.com> Date: Tue, 8 Jul 2025 15:28:46 +0800 Subject: [PATCH] fix: void copy when getting json chunk (#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 0aa91a558f..970d3621df 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 1bb0e5a8fa..33d4f55727 100644 --- a/internal/core/src/segcore/SegmentInterface.h +++ b/internal/core/src/segcore/SegmentInterface.h @@ -196,7 +196,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 PinWrapper< std::pair, FixedVector>>(