diff options
author | babenko <babenko@yandex-team.com> | 2023-06-06 18:53:47 +0300 |
---|---|---|
committer | babenko <babenko@yandex-team.com> | 2023-06-06 18:53:47 +0300 |
commit | f662d68f5a0c839f02969571c1fbba97c7711be4 (patch) | |
tree | 2b3139782772eac6c64732bc4935667eb34a3a8d /library/cpp/yt | |
parent | d0bbc6698a9beab10362d6e0ac5ad09e5497f94f (diff) | |
download | ydb-f662d68f5a0c839f02969571c1fbba97c7711be4.tar.gz |
Copy cached responses in TObjectServiceCache
Diffstat (limited to 'library/cpp/yt')
-rw-r--r-- | library/cpp/yt/memory/ref.cpp | 15 | ||||
-rw-r--r-- | library/cpp/yt/memory/ref.h | 4 |
2 files changed, 19 insertions, 0 deletions
diff --git a/library/cpp/yt/memory/ref.cpp b/library/cpp/yt/memory/ref.cpp index d48277f84c..31680b6c61 100644 --- a/library/cpp/yt/memory/ref.cpp +++ b/library/cpp/yt/memory/ref.cpp @@ -386,6 +386,21 @@ TString TSharedRefArray::ToString() const return result; } +TSharedRefArray TSharedRefArray::MakeCopy( + const TSharedRefArray& array, + TRefCountedTypeCookie tagCookie) +{ + TSharedRefArrayBuilder builder( + array.Size(), + array.ByteSize(), + tagCookie); + for (const auto& part : array) { + auto partCopy = builder.AllocateAndAdd(part.Size()); + ::memcpy(partCopy.Begin(), part.Begin(), part.Size()); + } + return builder.Finish(); +} + //////////////////////////////////////////////////////////////////////////////// TSharedRefArrayBuilder::TSharedRefArrayBuilder( diff --git a/library/cpp/yt/memory/ref.h b/library/cpp/yt/memory/ref.h index 78b5cf58cb..a47188180c 100644 --- a/library/cpp/yt/memory/ref.h +++ b/library/cpp/yt/memory/ref.h @@ -302,6 +302,10 @@ public: std::vector<TSharedRef> ToVector() const; TString ToString() const; + //! Creates a copy of a given TSharedRefArray. + //! The memory is marked with a given tag. + static TSharedRefArray MakeCopy(const TSharedRefArray& array, TRefCountedTypeCookie tagCookie); + private: friend class TSharedRefArrayBuilder; |