diff options
author | babenko <babenko@yandex-team.com> | 2024-04-19 23:42:47 +0300 |
---|---|---|
committer | babenko <babenko@yandex-team.com> | 2024-04-19 23:55:53 +0300 |
commit | f96c3c433e52fe4051c0fb14ba23b115a99d8b51 (patch) | |
tree | b7ea6a35f4d32debfff824c7aceaf765f36e9071 /library/cpp/yt/memory/tls_scratch-inl.h | |
parent | a8818e9bb2e10cbd941538218d96926809e1c25f (diff) | |
download | ydb-f96c3c433e52fe4051c0fb14ba23b115a99d8b51.tar.gz |
Avoid passing columnPresenceBuffer around
ed3889fb0e8fb71a059686f7c4133e9058935718
Diffstat (limited to 'library/cpp/yt/memory/tls_scratch-inl.h')
-rw-r--r-- | library/cpp/yt/memory/tls_scratch-inl.h | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/library/cpp/yt/memory/tls_scratch-inl.h b/library/cpp/yt/memory/tls_scratch-inl.h new file mode 100644 index 0000000000..32c26d67c0 --- /dev/null +++ b/library/cpp/yt/memory/tls_scratch-inl.h @@ -0,0 +1,28 @@ +#ifndef TLS_SCRATH_INL_H_ +#error "Direct inclusion of this file is not allowed, include tls_scratch.h" +// For the sake of sane code completion. +#include "tls_scratch.h" +#endif + +#include <library/cpp/yt/misc/tls.h> + +namespace NYT { + +//////////////////////////////////////////////////////////////////////////////// + +template <class T> +TMutableRange<T> GetTlsScratchBuffer(size_t size) +{ + // This is a workround for std::vector<bool>. + using TBoxed = std::array<T, 1>; + YT_THREAD_LOCAL(std::vector<TBoxed>) tlsVector; + auto& vector = GetTlsRef(tlsVector); + vector.reserve(size); + auto range = TMutableRange(reinterpret_cast<T*>(vector.data()), size); + std::fill(range.begin(), range.end(), T()); + return range; +} + +//////////////////////////////////////////////////////////////////////////////// + +} // namespace NYT |