diff options
author | babenko <babenko@yandex-team.com> | 2024-01-25 19:09:19 +0300 |
---|---|---|
committer | Alexander Smirnov <alex@ydb.tech> | 2024-01-26 20:49:16 +0300 |
commit | 97a6113075180982290fb695fd24a666d2b7ceac (patch) | |
tree | 969b6c9e2246058d03b0d5c107a7f9c31c9c1046 | |
parent | 8f02fda318bb8a50e1712350512d4cb82fff229b (diff) | |
download | ydb-97a6113075180982290fb695fd24a666d2b7ceac.tar.gz |
Introduce TEnumIndexedArray as a refurbished version of TEnumIndexedVector
29 files changed, 323 insertions, 105 deletions
diff --git a/library/cpp/yt/misc/enum.h b/library/cpp/yt/misc/enum.h index 1494ca7907..9da79b9fd3 100644 --- a/library/cpp/yt/misc/enum.h +++ b/library/cpp/yt/misc/enum.h @@ -185,6 +185,7 @@ struct TEnumTraits<T, true> //////////////////////////////////////////////////////////////////////////////// +// TODO(babenko): drop in favor of TEnumIndexedArray //! A statically sized vector with elements of type |T| indexed by //! the items of enumeration type |E|. /*! diff --git a/library/cpp/yt/misc/enum_indexed_array-inl.h b/library/cpp/yt/misc/enum_indexed_array-inl.h new file mode 100644 index 0000000000..edda891683 --- /dev/null +++ b/library/cpp/yt/misc/enum_indexed_array-inl.h @@ -0,0 +1,73 @@ +#pragma once +#ifndef ENUM_INDEXED_ARRAY_INL_H_ +#error "Direct inclusion of this file is not allowed, include enum.h" +// For the sake of sane code completion. +#include "enum_indexed_array.h" +#endif + +#include <library/cpp/yt/assert/assert.h> + +namespace NYT { + +//////////////////////////////////////////////////////////////////////////////// + +template <class E, class T, E Min, E Max> +TEnumIndexedArray<E, T, Min, Max>::TEnumIndexedArray(std::initializer_list<std::pair<E, T>> elements) +{ + for (const auto& [index, value] : elements) { + (*this)[index] = value; + } +} + +template <class E, class T, E Min, E Max> +T& TEnumIndexedArray<E, T, Min, Max>::operator[] (E index) +{ + YT_ASSERT(IsValidIndex(index)); + return Items_[ToUnderlying(index) - ToUnderlying(Min)]; +} + +template <class E, class T, E Min, E Max> +const T& TEnumIndexedArray<E, T, Min, Max>::operator[] (E index) const +{ + return const_cast<TEnumIndexedArray&>(*this)[index]; +} + +template <class E, class T, E Min, E Max> +T* TEnumIndexedArray<E, T, Min, Max>::begin() +{ + return Items_.data(); +} + +template <class E, class T, E Min, E Max> +const T* TEnumIndexedArray<E, T, Min, Max>::begin() const +{ + return Items_.data(); +} + +template <class E, class T, E Min, E Max> +T* TEnumIndexedArray<E, T, Min, Max>::end() +{ + return begin() + Size; +} + +template <class E, class T, E Min, E Max> +const T* TEnumIndexedArray<E, T, Min, Max>::end() const +{ + return begin() + Size; +} + +template <class E, class T, E Min, E Max> +constexpr size_t TEnumIndexedArray<E, T, Min, Max>::size() const +{ + return Size; +} + +template <class E, class T, E Min, E Max> +bool TEnumIndexedArray<E, T, Min, Max>::IsValidIndex(E index) +{ + return index >= Min && index <= Max; +} + +//////////////////////////////////////////////////////////////////////////////// + +} // namespace NYT diff --git a/library/cpp/yt/misc/enum_indexed_array.h b/library/cpp/yt/misc/enum_indexed_array.h new file mode 100644 index 0000000000..8992456277 --- /dev/null +++ b/library/cpp/yt/misc/enum_indexed_array.h @@ -0,0 +1,64 @@ +#pragma once + +#include "enum.h" + +namespace NYT { + +//////////////////////////////////////////////////////////////////////////////// + +//! A statically sized vector with elements of type |T| indexed by +//! the items of enumeration type |E|. +/*! + * By default, valid indexes are in range from the minimum declared value of |E| + * to the maximum declared value of |E|. + * + * Items are value-initialized on construction. + */ +template < + class E, + class T, + E Min = TEnumTraits<E>::GetMinValue(), + E Max = TEnumTraits<E>::GetMaxValue() +> +class TEnumIndexedArray +{ +public: + static_assert(Min <= Max); + + using TIndex = E; + using TValue = T; + + constexpr TEnumIndexedArray() = default; + TEnumIndexedArray(std::initializer_list<std::pair<E, T>> elements); + + constexpr TEnumIndexedArray(const TEnumIndexedArray&) = default; + constexpr TEnumIndexedArray(TEnumIndexedArray&&) = default; + + constexpr TEnumIndexedArray& operator=(const TEnumIndexedArray&) = default; + constexpr TEnumIndexedArray& operator=(TEnumIndexedArray&&) = default; + + T& operator[] (E index); + const T& operator[] (E index) const; + + // STL interop. + T* begin(); + const T* begin() const; + T* end(); + const T* end() const; + + constexpr size_t size() const; + + static bool IsValidIndex(E index); + +private: + static constexpr size_t Size = static_cast<size_t>(Max) - static_cast<size_t>(Min) + 1; + std::array<T, Size> Items_{}; +}; + +//////////////////////////////////////////////////////////////////////////////// + +} // namespace NYT + +#define ENUM_INDEXED_ARRAY_INL_H_ +#include "enum_indexed_array-inl.h" +#undef ENUM_INDEXED_ARRAY_INL_H_ diff --git a/library/cpp/yt/misc/unittests/enum_indexed_array_ut.cpp b/library/cpp/yt/misc/unittests/enum_indexed_array_ut.cpp new file mode 100644 index 0000000000..4111c6f4fe --- /dev/null +++ b/library/cpp/yt/misc/unittests/enum_indexed_array_ut.cpp @@ -0,0 +1,45 @@ +#include <library/cpp/testing/gtest/gtest.h> + +#include <library/cpp/yt/misc/enum_indexed_array.h> + +namespace NYT { +namespace { + +//////////////////////////////////////////////////////////////////////////////// + +DEFINE_ENUM(EColor, + ((Red) (10)) + ((Green)(20)) + ((Blue) (30)) +); + +TEST(TEnumIndexedArrayTest, Size) +{ + TEnumIndexedArray<EColor, int> arr; + EXPECT_EQ(std::ssize(arr), 21); +} + +TEST(TEnumIndexedArrayTest, IsValidIndex) +{ + TEnumIndexedArray<EColor, int> arr; + EXPECT_TRUE(arr.IsValidIndex(EColor::Red)); + EXPECT_TRUE(arr.IsValidIndex(EColor::Green)); + EXPECT_TRUE(arr.IsValidIndex(EColor::Blue)); + EXPECT_TRUE(arr.IsValidIndex(static_cast<EColor>(11))); + EXPECT_FALSE(arr.IsValidIndex(static_cast<EColor>(9))); +} + +TEST(TEnumIndexedArrayTest, Simple) +{ + TEnumIndexedArray<EColor, int> arr; + EXPECT_EQ(arr[EColor::Red], 0); + arr[EColor::Red] = 1; + EXPECT_EQ(arr[EColor::Red], 1); + EXPECT_EQ(arr[EColor::Blue], 0); +} + +//////////////////////////////////////////////////////////////////////////////// + +} // namespace +} // namespace NYT + diff --git a/library/cpp/yt/misc/unittests/ya.make b/library/cpp/yt/misc/unittests/ya.make index 611edd7217..43e9f9b9ff 100644 --- a/library/cpp/yt/misc/unittests/ya.make +++ b/library/cpp/yt/misc/unittests/ya.make @@ -4,6 +4,7 @@ INCLUDE(${ARCADIA_ROOT}/library/cpp/yt/ya_cpp.make.inc) SRCS( enum_ut.cpp + enum_indexed_array_ut.cpp guid_ut.cpp preprocessor_ut.cpp strong_typedef_ut.cpp diff --git a/library/cpp/yt/string/format-inl.h b/library/cpp/yt/string/format-inl.h index c379af712a..c198fdcd65 100644 --- a/library/cpp/yt/string/format-inl.h +++ b/library/cpp/yt/string/format-inl.h @@ -12,6 +12,7 @@ #include <library/cpp/yt/small_containers/compact_vector.h> #include <library/cpp/yt/misc/enum.h> +#include <library/cpp/yt/misc/enum_indexed_array.h> #include <util/system/platform.h> @@ -393,6 +394,27 @@ struct TValueFormatter<THashMultiMap<K, V>> } }; +// TEnumIndexedArray +template <class E, class T> +struct TValueFormatter<TEnumIndexedArray<E, T>> +{ + static void Do(TStringBuilderBase* builder, const TEnumIndexedArray<E, T>& collection, TStringBuf format) + { + builder->AppendChar('{'); + bool firstItem = true; + for (const auto& index : TEnumTraits<E>::GetDomainValues()) { + if (!firstItem) { + builder->AppendString(DefaultJoinToStringDelimiter); + } + FormatValue(builder, index, format); + builder->AppendString(": "); + FormatValue(builder, collection[index], format); + firstItem = false; + } + builder->AppendChar('}'); + } +}; + // TEnumIndexedVector template <class E, class T> struct TValueFormatter<TEnumIndexedVector<E, T>> diff --git a/library/cpp/yt/string/unittests/enum_ut.cpp b/library/cpp/yt/string/unittests/enum_ut.cpp index 4059b3d2e6..91a8b04500 100644 --- a/library/cpp/yt/string/unittests/enum_ut.cpp +++ b/library/cpp/yt/string/unittests/enum_ut.cpp @@ -13,6 +13,7 @@ namespace { // Some compile-time sanity checks. DEFINE_ENUM(ESample, (One)(Two)); static_assert(TFormatTraits<ESample>::HasCustomFormatValue); +static_assert(TFormatTraits<TEnumIndexedArray<ESample, int>>::HasCustomFormatValue); static_assert(TFormatTraits<TEnumIndexedVector<ESample, int>>::HasCustomFormatValue); DEFINE_ENUM(EColor, diff --git a/library/cpp/ytalloc/api/fallback.cpp b/library/cpp/ytalloc/api/fallback.cpp index d094cf2e93..d7dca33f88 100644 --- a/library/cpp/ytalloc/api/fallback.cpp +++ b/library/cpp/ytalloc/api/fallback.cpp @@ -144,47 +144,47 @@ Y_WEAK void SetEnableMadvisePopulate(bool /*value*/) //////////////////////////////////////////////////////////////////////////////// -Y_WEAK TEnumIndexedVector<ETotalCounter, ssize_t> GetTotalAllocationCounters() +Y_WEAK TEnumIndexedArray<ETotalCounter, ssize_t> GetTotalAllocationCounters() { return {}; } -Y_WEAK TEnumIndexedVector<ESmallCounter, ssize_t> GetSmallAllocationCounters() +Y_WEAK TEnumIndexedArray<ESmallCounter, ssize_t> GetSmallAllocationCounters() { return {}; } -Y_WEAK TEnumIndexedVector<ELargeCounter, ssize_t> GetLargeAllocationCounters() +Y_WEAK TEnumIndexedArray<ELargeCounter, ssize_t> GetLargeAllocationCounters() { return {}; } -Y_WEAK std::array<TEnumIndexedVector<ESmallArenaCounter, ssize_t>, SmallRankCount> GetSmallArenaAllocationCounters() +Y_WEAK std::array<TEnumIndexedArray<ESmallArenaCounter, ssize_t>, SmallRankCount> GetSmallArenaAllocationCounters() { return {}; } -Y_WEAK std::array<TEnumIndexedVector<ELargeArenaCounter, ssize_t>, LargeRankCount> GetLargeArenaAllocationCounters() +Y_WEAK std::array<TEnumIndexedArray<ELargeArenaCounter, ssize_t>, LargeRankCount> GetLargeArenaAllocationCounters() { return {}; } -Y_WEAK TEnumIndexedVector<EHugeCounter, ssize_t> GetHugeAllocationCounters() +Y_WEAK TEnumIndexedArray<EHugeCounter, ssize_t> GetHugeAllocationCounters() { return {}; } -Y_WEAK TEnumIndexedVector<ESystemCounter, ssize_t> GetSystemAllocationCounters() +Y_WEAK TEnumIndexedArray<ESystemCounter, ssize_t> GetSystemAllocationCounters() { return {}; } -Y_WEAK TEnumIndexedVector<EUndumpableCounter, ssize_t> GetUndumpableAllocationCounters() +Y_WEAK TEnumIndexedArray<EUndumpableCounter, ssize_t> GetUndumpableAllocationCounters() { return {}; } -Y_WEAK TEnumIndexedVector<ETimingEventType, TTimingEventCounters> GetTimingEventCounters() +Y_WEAK TEnumIndexedArray<ETimingEventType, TTimingEventCounters> GetTimingEventCounters() { return {}; } diff --git a/library/cpp/ytalloc/api/ytalloc.h b/library/cpp/ytalloc/api/ytalloc.h index 219814def2..43ba48852d 100644 --- a/library/cpp/ytalloc/api/ytalloc.h +++ b/library/cpp/ytalloc/api/ytalloc.h @@ -3,6 +3,7 @@ #include <stddef.h> #include <library/cpp/yt/misc/enum.h> +#include <library/cpp/yt/misc/enum_indexed_array.h> #include <util/system/types.h> @@ -289,28 +290,28 @@ DEFINE_ENUM(ETotalCounter, ); // Returns statistics for all user allocations. -TEnumIndexedVector<ETotalCounter, ssize_t> GetTotalAllocationCounters(); +TEnumIndexedArray<ETotalCounter, ssize_t> GetTotalAllocationCounters(); // Returns statistics for small allocations; these are included into total statistics. -TEnumIndexedVector<ESmallCounter, ssize_t> GetSmallAllocationCounters(); +TEnumIndexedArray<ESmallCounter, ssize_t> GetSmallAllocationCounters(); // Returns statistics for large allocations; these are included into total statistics. -TEnumIndexedVector<ELargeCounter, ssize_t> GetLargeAllocationCounters(); +TEnumIndexedArray<ELargeCounter, ssize_t> GetLargeAllocationCounters(); // Returns per-arena statistics for small allocations; these are included into total statistics. -std::array<TEnumIndexedVector<ESmallArenaCounter, ssize_t>, SmallRankCount> GetSmallArenaAllocationCounters(); +std::array<TEnumIndexedArray<ESmallArenaCounter, ssize_t>, SmallRankCount> GetSmallArenaAllocationCounters(); // Returns per-arena statistics for large allocations; these are included into total statistics. -std::array<TEnumIndexedVector<ELargeArenaCounter, ssize_t>, LargeRankCount> GetLargeArenaAllocationCounters(); +std::array<TEnumIndexedArray<ELargeArenaCounter, ssize_t>, LargeRankCount> GetLargeArenaAllocationCounters(); // Returns statistics for huge allocations; these are included into total statistics. -TEnumIndexedVector<EHugeCounter, ssize_t> GetHugeAllocationCounters(); +TEnumIndexedArray<EHugeCounter, ssize_t> GetHugeAllocationCounters(); // Returns statistics for all system allocations; these are not included into total statistics. -TEnumIndexedVector<ESystemCounter, ssize_t> GetSystemAllocationCounters(); +TEnumIndexedArray<ESystemCounter, ssize_t> GetSystemAllocationCounters(); // Returns statistics for undumpable allocations. -TEnumIndexedVector<EUndumpableCounter, ssize_t> GetUndumpableAllocationCounters(); +TEnumIndexedArray<EUndumpableCounter, ssize_t> GetUndumpableAllocationCounters(); DEFINE_ENUM(ETimingEventType, (Mmap) @@ -333,7 +334,7 @@ struct TTimingEventCounters // Returns statistics for timing events happened since start. // See SetTimingEventThreshold. -TEnumIndexedVector<ETimingEventType, TTimingEventCounters> GetTimingEventCounters(); +TEnumIndexedArray<ETimingEventType, TTimingEventCounters> GetTimingEventCounters(); //////////////////////////////////////////////////////////////////////////////// @@ -349,7 +350,7 @@ struct TBacktrace struct TProfiledAllocation { TBacktrace Backtrace; - TEnumIndexedVector<EBasicCounter, ssize_t> Counters; + TEnumIndexedArray<EBasicCounter, ssize_t> Counters; }; // Returns statistics for profiled allocations (available when allocation diff --git a/library/cpp/ytalloc/impl/core-inl.h b/library/cpp/ytalloc/impl/core-inl.h index 64e95188f4..ba5128bd8d 100644 --- a/library/cpp/ytalloc/impl/core-inl.h +++ b/library/cpp/ytalloc/impl/core-inl.h @@ -940,14 +940,14 @@ class TTimingManager : public TEventLogManagerBase<TTimingEvent, TTimingManager> { public: - TEnumIndexedVector<ETimingEventType, TTimingEventCounters> GetTimingEventCounters() + TEnumIndexedArray<ETimingEventType, TTimingEventCounters> GetTimingEventCounters() { auto guard = Guard(EventLock_); return EventCounters_; } private: - TEnumIndexedVector<ETimingEventType, TTimingEventCounters> EventCounters_; + TEnumIndexedArray<ETimingEventType, TTimingEventCounters> EventCounters_; Y_POD_STATIC_THREAD(bool) DisabledForCurrentThread_; @@ -1523,13 +1523,13 @@ static_assert( "Wrong MaxMemoryTag"); template <class TCounter> -using TUntaggedTotalCounters = TEnumIndexedVector<EBasicCounter, TCounter>; +using TUntaggedTotalCounters = TEnumIndexedArray<EBasicCounter, TCounter>; template <class TCounter> struct TTaggedTotalCounterSet : public TSystemAllocatable { - std::array<TEnumIndexedVector<EBasicCounter, TCounter>, TaggedCounterSetSize> Counters; + std::array<TEnumIndexedArray<EBasicCounter, TCounter>, TaggedCounterSetSize> Counters; }; using TLocalTaggedBasicCounterSet = TTaggedTotalCounterSet<ssize_t>; @@ -1577,20 +1577,20 @@ struct TTotalCounters } }; -using TLocalSystemCounters = TEnumIndexedVector<ESystemCounter, ssize_t>; -using TGlobalSystemCounters = TEnumIndexedVector<ESystemCounter, std::atomic<ssize_t>>; +using TLocalSystemCounters = TEnumIndexedArray<ESystemCounter, ssize_t>; +using TGlobalSystemCounters = TEnumIndexedArray<ESystemCounter, std::atomic<ssize_t>>; -using TLocalSmallCounters = TEnumIndexedVector<ESmallArenaCounter, ssize_t>; -using TGlobalSmallCounters = TEnumIndexedVector<ESmallArenaCounter, std::atomic<ssize_t>>; +using TLocalSmallCounters = TEnumIndexedArray<ESmallArenaCounter, ssize_t>; +using TGlobalSmallCounters = TEnumIndexedArray<ESmallArenaCounter, std::atomic<ssize_t>>; -using TLocalLargeCounters = TEnumIndexedVector<ELargeArenaCounter, ssize_t>; -using TGlobalLargeCounters = TEnumIndexedVector<ELargeArenaCounter, std::atomic<ssize_t>>; +using TLocalLargeCounters = TEnumIndexedArray<ELargeArenaCounter, ssize_t>; +using TGlobalLargeCounters = TEnumIndexedArray<ELargeArenaCounter, std::atomic<ssize_t>>; -using TLocalHugeCounters = TEnumIndexedVector<EHugeCounter, ssize_t>; -using TGlobalHugeCounters = TEnumIndexedVector<EHugeCounter, std::atomic<ssize_t>>; +using TLocalHugeCounters = TEnumIndexedArray<EHugeCounter, ssize_t>; +using TGlobalHugeCounters = TEnumIndexedArray<EHugeCounter, std::atomic<ssize_t>>; -using TLocalUndumpableCounters = TEnumIndexedVector<EUndumpableCounter, ssize_t>; -using TGlobalUndumpableCounters = TEnumIndexedVector<EUndumpableCounter, std::atomic<ssize_t>>; +using TLocalUndumpableCounters = TEnumIndexedArray<EUndumpableCounter, ssize_t>; +using TGlobalUndumpableCounters = TEnumIndexedArray<EUndumpableCounter, std::atomic<ssize_t>>; Y_FORCE_INLINE ssize_t LoadCounter(ssize_t counter) { @@ -1750,7 +1750,7 @@ struct TThreadState std::array<bool, SmallRankCount> CachedChunkFull{}; #endif }; - TEnumIndexedVector<EAllocationKind, TSmallBlobCache> SmallBlobCache; + TEnumIndexedArray<EAllocationKind, TSmallBlobCache> SmallBlobCache; }; struct TThreadStateToRegistryNode @@ -2227,7 +2227,7 @@ public: } // Computes memory usage for a list of tags by aggregating counters across threads. - void GetTaggedMemoryCounters(const TMemoryTag* tags, size_t count, TEnumIndexedVector<EBasicCounter, ssize_t>* counters) + void GetTaggedMemoryCounters(const TMemoryTag* tags, size_t count, TEnumIndexedArray<EBasicCounter, ssize_t>* counters) { TMemoryTagGuard guard(NullMemoryTag); @@ -2260,7 +2260,7 @@ public: { TMemoryTagGuard guard(NullMemoryTag); - std::vector<TEnumIndexedVector<EBasicCounter, ssize_t>> counters; + std::vector<TEnumIndexedArray<EBasicCounter, ssize_t>> counters; counters.resize(count); GetTaggedMemoryCounters(tags, count, counters.data()); @@ -2269,9 +2269,9 @@ public: } } - TEnumIndexedVector<ETotalCounter, ssize_t> GetTotalAllocationCounters() + TEnumIndexedArray<ETotalCounter, ssize_t> GetTotalAllocationCounters() { - TEnumIndexedVector<ETotalCounter, ssize_t> result; + TEnumIndexedArray<ETotalCounter, ssize_t> result; auto accumulate = [&] (const auto& counters) { result[ETotalCounter::BytesAllocated] += LoadCounter(counters[EBasicCounter::BytesAllocated]); @@ -2312,9 +2312,9 @@ public: return result; } - TEnumIndexedVector<ESmallCounter, ssize_t> GetSmallAllocationCounters() + TEnumIndexedArray<ESmallCounter, ssize_t> GetSmallAllocationCounters() { - TEnumIndexedVector<ESmallCounter, ssize_t> result; + TEnumIndexedArray<ESmallCounter, ssize_t> result; auto totalCounters = GetTotalAllocationCounters(); result[ESmallCounter::BytesAllocated] = totalCounters[ETotalCounter::BytesAllocated]; @@ -2347,9 +2347,9 @@ public: return result; } - TEnumIndexedVector<ELargeCounter, ssize_t> GetLargeAllocationCounters() + TEnumIndexedArray<ELargeCounter, ssize_t> GetLargeAllocationCounters() { - TEnumIndexedVector<ELargeCounter, ssize_t> result; + TEnumIndexedArray<ELargeCounter, ssize_t> result; auto largeArenaCounters = GetLargeArenaAllocationCounters(); for (size_t rank = 0; rank < LargeRankCount; ++rank) { result[ESmallCounter::BytesAllocated] += largeArenaCounters[rank][ELargeArenaCounter::BytesAllocated]; @@ -2826,7 +2826,7 @@ private: } }; -TExplicitlyConstructableSingleton<TEnumIndexedVector<EAllocationKind, std::array<TExplicitlyConstructableSingleton<TSmallArenaAllocator>, SmallRankCount>>> SmallArenaAllocators; +TExplicitlyConstructableSingleton<TEnumIndexedArray<EAllocationKind, std::array<TExplicitlyConstructableSingleton<TSmallArenaAllocator>, SmallRankCount>>> SmallArenaAllocators; //////////////////////////////////////////////////////////////////////////////// @@ -3023,7 +3023,7 @@ private: std::array<TShardedFreeList<TChunkGroup>, SmallRankCount> RankToChunkGroups_; }; -TExplicitlyConstructableSingleton<TEnumIndexedVector<EAllocationKind, TExplicitlyConstructableSingleton<TGlobalSmallChunkCache>>> GlobalSmallChunkCaches; +TExplicitlyConstructableSingleton<TEnumIndexedArray<EAllocationKind, TExplicitlyConstructableSingleton<TGlobalSmallChunkCache>>> GlobalSmallChunkCaches; //////////////////////////////////////////////////////////////////////////////// @@ -4750,49 +4750,49 @@ void SetEnableMadvisePopulate(bool value) ConfigurationManager->SetEnableMadvisePopulate(value); } -TEnumIndexedVector<ETotalCounter, ssize_t> GetTotalAllocationCounters() +TEnumIndexedArray<ETotalCounter, ssize_t> GetTotalAllocationCounters() { InitializeGlobals(); return StatisticsManager->GetTotalAllocationCounters(); } -TEnumIndexedVector<ESystemCounter, ssize_t> GetSystemAllocationCounters() +TEnumIndexedArray<ESystemCounter, ssize_t> GetSystemAllocationCounters() { InitializeGlobals(); return StatisticsManager->GetSystemAllocationCounters(); } -TEnumIndexedVector<ESystemCounter, ssize_t> GetUndumpableAllocationCounters() +TEnumIndexedArray<ESystemCounter, ssize_t> GetUndumpableAllocationCounters() { InitializeGlobals(); return StatisticsManager->GetUndumpableAllocationCounters(); } -TEnumIndexedVector<ESmallCounter, ssize_t> GetSmallAllocationCounters() +TEnumIndexedArray<ESmallCounter, ssize_t> GetSmallAllocationCounters() { InitializeGlobals(); return StatisticsManager->GetSmallAllocationCounters(); } -TEnumIndexedVector<ESmallCounter, ssize_t> GetLargeAllocationCounters() +TEnumIndexedArray<ESmallCounter, ssize_t> GetLargeAllocationCounters() { InitializeGlobals(); return StatisticsManager->GetLargeAllocationCounters(); } -std::array<TEnumIndexedVector<ESmallArenaCounter, ssize_t>, SmallRankCount> GetSmallArenaAllocationCounters() +std::array<TEnumIndexedArray<ESmallArenaCounter, ssize_t>, SmallRankCount> GetSmallArenaAllocationCounters() { InitializeGlobals(); return StatisticsManager->GetSmallArenaAllocationCounters(); } -std::array<TEnumIndexedVector<ELargeArenaCounter, ssize_t>, LargeRankCount> GetLargeArenaAllocationCounters() +std::array<TEnumIndexedArray<ELargeArenaCounter, ssize_t>, LargeRankCount> GetLargeArenaAllocationCounters() { InitializeGlobals(); return StatisticsManager->GetLargeArenaAllocationCounters(); } -TEnumIndexedVector<EHugeCounter, ssize_t> GetHugeAllocationCounters() +TEnumIndexedArray<EHugeCounter, ssize_t> GetHugeAllocationCounters() { InitializeGlobals(); return StatisticsManager->GetHugeAllocationCounters(); @@ -4816,7 +4816,7 @@ std::vector<TProfiledAllocation> GetProfiledAllocationStatistics() } tags.push_back(AllocationProfilingUnknownMemoryTag); - std::vector<TEnumIndexedVector<EBasicCounter, ssize_t>> counters; + std::vector<TEnumIndexedArray<EBasicCounter, ssize_t>> counters; counters.resize(tags.size()); StatisticsManager->GetTaggedMemoryCounters(tags.data(), tags.size(), counters.data()); @@ -4838,7 +4838,7 @@ std::vector<TProfiledAllocation> GetProfiledAllocationStatistics() return statistics; } -TEnumIndexedVector<ETimingEventType, TTimingEventCounters> GetTimingEventCounters() +TEnumIndexedArray<ETimingEventType, TTimingEventCounters> GetTimingEventCounters() { InitializeGlobals(); return TimingManager->GetTimingEventCounters(); diff --git a/yt/yt/client/api/operation_client.h b/yt/yt/client/api/operation_client.h index 35d62da527..0d0ac82c0c 100644 --- a/yt/yt/client/api/operation_client.h +++ b/yt/yt/client/api/operation_client.h @@ -292,8 +292,8 @@ struct TListOperationsResult std::optional<THashMap<TString, i64>> PoolTreeCounts; std::optional<THashMap<TString, i64>> PoolCounts; std::optional<THashMap<TString, i64>> UserCounts; - std::optional<TEnumIndexedVector<NScheduler::EOperationState, i64>> StateCounts; - std::optional<TEnumIndexedVector<NScheduler::EOperationType, i64>> TypeCounts; + std::optional<TEnumIndexedArray<NScheduler::EOperationState, i64>> StateCounts; + std::optional<TEnumIndexedArray<NScheduler::EOperationType, i64>> TypeCounts; std::optional<i64> FailedJobsCount; bool Incomplete = false; }; @@ -338,8 +338,8 @@ void Serialize(const TJob& job, NYson::IYsonConsumer* consumer, TStringBuf idKey struct TListJobsStatistics { - TEnumIndexedVector<NJobTrackerClient::EJobState, i64> StateCounts; - TEnumIndexedVector<NJobTrackerClient::EJobType, i64> TypeCounts; + TEnumIndexedArray<NJobTrackerClient::EJobState, i64> StateCounts; + TEnumIndexedArray<NJobTrackerClient::EJobType, i64> TypeCounts; }; struct TListJobsResult diff --git a/yt/yt/client/api/public.h b/yt/yt/client/api/public.h index 7e6c250481..55a72dd3c5 100644 --- a/yt/yt/client/api/public.h +++ b/yt/yt/client/api/public.h @@ -14,6 +14,8 @@ #include <yt/yt/core/rpc/public.h> +#include <library/cpp/yt/misc/enum_indexed_array.h> + namespace NYT::NApi { //////////////////////////////////////////////////////////////////////////////// @@ -217,7 +219,7 @@ DEFINE_ENUM(EMaintenanceComponent, ); using TMaintenanceId = TGuid; -using TMaintenanceCounts = TEnumIndexedVector<EMaintenanceType, int>; +using TMaintenanceCounts = TEnumIndexedArray<EMaintenanceType, int>; //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/client/api/rpc_proxy/helpers.cpp b/yt/yt/client/api/rpc_proxy/helpers.cpp index 9562053d10..819a478b41 100644 --- a/yt/yt/client/api/rpc_proxy/helpers.cpp +++ b/yt/yt/client/api/rpc_proxy/helpers.cpp @@ -349,7 +349,7 @@ void FromProto( std::fill(result->StateCounts->begin(), result->StateCounts->end(), 0); for (const auto& stateCount: proto.state_counts().entries()) { auto state = ConvertOperationStateFromProto(stateCount.state()); - YT_VERIFY(result->StateCounts->IsDomainValue(state)); + YT_VERIFY(result->StateCounts->IsValidIndex(state)); YT_VERIFY((*result->StateCounts)[state] == 0); (*result->StateCounts)[state] = stateCount.count(); } @@ -361,7 +361,7 @@ void FromProto( std::fill(result->TypeCounts->begin(), result->TypeCounts->end(), 0); for (const auto& typeCount: proto.type_counts().entries()) { auto type = ConvertOperationTypeFromProto(typeCount.type()); - YT_VERIFY(result->TypeCounts->IsDomainValue(type)); + YT_VERIFY(result->TypeCounts->IsValidIndex(type)); YT_VERIFY((*result->TypeCounts)[type] == 0); (*result->TypeCounts)[type] = typeCount.count(); } @@ -1113,7 +1113,7 @@ void FromProto( std::fill(statistics->StateCounts.begin(), statistics->StateCounts.end(), 0); for (const auto& stateCount: protoStatistics.state_counts().entries()) { auto state = ConvertJobStateFromProto(stateCount.state()); - YT_VERIFY(statistics->StateCounts.IsDomainValue(state)); + YT_VERIFY(statistics->StateCounts.IsValidIndex(state)); YT_VERIFY(statistics->StateCounts[state] == 0); statistics->StateCounts[state] = stateCount.count(); } @@ -1121,7 +1121,7 @@ void FromProto( std::fill(statistics->TypeCounts.begin(), statistics->TypeCounts.end(), 0); for (const auto& typeCount: protoStatistics.type_counts().entries()) { auto type = ConvertJobTypeFromProto(typeCount.type()); - YT_VERIFY(statistics->TypeCounts.IsDomainValue(type)); + YT_VERIFY(statistics->TypeCounts.IsValidIndex(type)); YT_VERIFY(statistics->TypeCounts[type] == 0); statistics->TypeCounts[type] = typeCount.count(); } diff --git a/yt/yt/client/job_tracker_client/public.h b/yt/yt/client/job_tracker_client/public.h index 5e1886f458..d67e273715 100644 --- a/yt/yt/client/job_tracker_client/public.h +++ b/yt/yt/client/job_tracker_client/public.h @@ -19,7 +19,7 @@ extern const TOperationId NullOperationId; //////////////////////////////////////////////////////////////////////////////// // NB: Please keep the range of values small as this type -// is used as a key of TEnumIndexedVector. +// is used as a key of TEnumIndexedArray. DEFINE_ENUM(EJobType, // Scheduler jobs ((Map) ( 1)) @@ -58,7 +58,7 @@ constexpr auto FirstMasterJobType = EJobType::ReplicateChunk; constexpr auto LastMasterJobType = EJobType::ReincarnateChunk; // NB: Please keep the range of values small as this type -// is used as a key of TEnumIndexedVector. +// is used as a key of TEnumIndexedArray. DEFINE_ENUM(EJobState, ((Waiting) (0)) ((Running) (1)) diff --git a/yt/yt/client/table_client/blob_reader.cpp b/yt/yt/client/table_client/blob_reader.cpp index f40e28f031..551878b805 100644 --- a/yt/yt/client/table_client/blob_reader.cpp +++ b/yt/yt/client/table_client/blob_reader.cpp @@ -100,7 +100,7 @@ private: i64 Index_ = 0; i64 NextPartIndex_; - TEnumIndexedVector<EColumnType, std::optional<size_t>> ColumnIndex_; + TEnumIndexedArray<EColumnType, std::optional<size_t>> ColumnIndex_; TSharedRef ProcessRow() { diff --git a/yt/yt/client/tablet_client/table_mount_cache.h b/yt/yt/client/tablet_client/table_mount_cache.h index bba0a1e0c0..773f641aae 100644 --- a/yt/yt/client/tablet_client/table_mount_cache.h +++ b/yt/yt/client/tablet_client/table_mount_cache.h @@ -96,7 +96,7 @@ struct TTableMountInfo { NYPath::TYPath Path; NObjectClient::TObjectId TableId; - TEnumIndexedVector<ETableSchemaKind, NTableClient::TTableSchemaPtr> Schemas; + TEnumIndexedArray<ETableSchemaKind, NTableClient::TTableSchemaPtr> Schemas; // PhysicalPath points to a physical object, if current object is linked to some other object, then this field will point to the source. // When this field is not supported on the server-side, this path will be equal to object path. diff --git a/yt/yt/core/bus/tcp/config.h b/yt/yt/core/bus/tcp/config.h index 54020c6b08..3695a42093 100644 --- a/yt/yt/core/bus/tcp/config.h +++ b/yt/yt/core/bus/tcp/config.h @@ -40,7 +40,7 @@ public: THashMap<TString, std::vector<NNet::TIP6Network>> Networks; - TEnumIndexedVector<EMultiplexingBand, TMultiplexingBandConfigPtr> MultiplexingBands; + TEnumIndexedArray<EMultiplexingBand, TMultiplexingBandConfigPtr> MultiplexingBands; TTcpDispatcherConfigPtr ApplyDynamic(const TTcpDispatcherDynamicConfigPtr& dynamicConfig) const; @@ -66,7 +66,7 @@ public: std::optional<THashMap<TString, std::vector<NNet::TIP6Network>>> Networks; - std::optional<TEnumIndexedVector<EMultiplexingBand, TMultiplexingBandConfigPtr>> MultiplexingBands; + std::optional<TEnumIndexedArray<EMultiplexingBand, TMultiplexingBandConfigPtr>> MultiplexingBands; //! Used to store TLS/SSL certificate files. std::optional<TString> BusCertsDirectoryPath; diff --git a/yt/yt/core/bus/tcp/dispatcher.h b/yt/yt/core/bus/tcp/dispatcher.h index b4a4a61580..8a64a6af1d 100644 --- a/yt/yt/core/bus/tcp/dispatcher.h +++ b/yt/yt/core/bus/tcp/dispatcher.h @@ -12,6 +12,8 @@ #include <yt/yt/core/ytree/public.h> +#include <library/cpp/yt/misc/enum_indexed_array.h> + namespace NYT::NBus { //////////////////////////////////////////////////////////////////////////////// @@ -27,7 +29,7 @@ struct TBusNetworkCounters final { static constexpr bool EnableHazard = true; - TEnumIndexedVector<EMultiplexingBand, TBusNetworkBandCounters> PerBandCounters; + TEnumIndexedArray<EMultiplexingBand, TBusNetworkBandCounters> PerBandCounters; TBusNetworkStatistics ToStatistics() const; }; diff --git a/yt/yt/core/bus/tcp/dispatcher_impl.h b/yt/yt/core/bus/tcp/dispatcher_impl.h index 80495eaa65..76b01356c7 100644 --- a/yt/yt/core/bus/tcp/dispatcher_impl.h +++ b/yt/yt/core/bus/tcp/dispatcher_impl.h @@ -101,7 +101,7 @@ private: std::atomic<TTosLevel> TosLevel = DefaultTosLevel; }; - TEnumIndexedVector<EMultiplexingBand, TBandDescriptor> BandToDescriptor_; + TEnumIndexedArray<EMultiplexingBand, TBandDescriptor> BandToDescriptor_; }; //////////////////////////////////////////////////////////////////////////////// diff --git a/yt/yt/core/misc/protobuf_helpers-inl.h b/yt/yt/core/misc/protobuf_helpers-inl.h index e8d74b6c6f..887d11974a 100644 --- a/yt/yt/core/misc/protobuf_helpers-inl.h +++ b/yt/yt/core/misc/protobuf_helpers-inl.h @@ -337,11 +337,11 @@ typename std::enable_if_t<std::is_trivial_v<TValue>> SetPairValueImpl(TProtoPair template <class TSerializedArray, class T, class E, E Min, E Max> void ToProtoArrayImpl( TSerializedArray* serializedArray, - const TEnumIndexedVector<E, T, Min, Max>& originalArray) + const TEnumIndexedArray<E, T, Min, Max>& originalArray) { serializedArray->Clear(); for (auto key : TEnumTraits<E>::GetDomainValues()) { - if (originalArray.IsDomainValue(key)) { + if (originalArray.IsValidIndex(key)) { const auto& value = originalArray[key]; auto* pair = serializedArray->Add(); pair->set_key(static_cast<i32>(key)); @@ -352,17 +352,17 @@ void ToProtoArrayImpl( template <class T, class E, E Min, E Max, class TSerializedArray> void FromProtoArrayImpl( - TEnumIndexedVector<E, T, Min, Max>* originalArray, + TEnumIndexedArray<E, T, Min, Max>* originalArray, const TSerializedArray& serializedArray) { for (auto key : TEnumTraits<E>::GetDomainValues()) { - if (originalArray->IsDomainValue(key)) { + if (originalArray->IsValidIndex(key)) { (*originalArray)[key] = T{}; } } for (const auto& pair : serializedArray) { const auto& key = static_cast<E>(pair.key()); - if (originalArray->IsDomainValue(key)) { + if (originalArray->IsValidIndex(key)) { FromProto(&(*originalArray)[key], pair.value()); } } diff --git a/yt/yt/core/misc/serialize-inl.h b/yt/yt/core/misc/serialize-inl.h index 5269014db1..6a0948e051 100644 --- a/yt/yt/core/misc/serialize-inl.h +++ b/yt/yt/core/misc/serialize-inl.h @@ -10,6 +10,8 @@ #include <library/cpp/yt/small_containers/compact_flat_map.h> #include <library/cpp/yt/small_containers/compact_set.h> +#include <library/cpp/yt/misc/enum_indexed_array.h> + #include <optional> #include <variant> @@ -1356,17 +1358,17 @@ struct TOptionalListSerializer }; template <class TItemSerializer = TDefaultSerializer> -struct TEnumIndexedVectorSerializer +struct TEnumIndexedArraySerializer { template <class E, class T, class C, E Min, E Max> - static void Save(C& context, const TEnumIndexedVector<E, T, Min, Max>& vector) + static void Save(C& context, const TEnumIndexedArray<E, T, Min, Max>& vector) { using NYT::Save; auto keys = TEnumTraits<E>::GetDomainValues(); size_t count = 0; for (auto key : keys) { - if (!vector.IsDomainValue(key)) { + if (!vector.IsValidIndex(key)) { continue; } ++count; @@ -1375,7 +1377,7 @@ struct TEnumIndexedVectorSerializer TSizeSerializer::Save(context, count); for (auto key : keys) { - if (!vector.IsDomainValue(key)) { + if (!vector.IsValidIndex(key)) { continue; } Save(context, key); @@ -1384,7 +1386,7 @@ struct TEnumIndexedVectorSerializer } template <class E, class T, class C, E Min, E Max> - static void Load(C& context, TEnumIndexedVector<E, T, Min, Max>& vector) + static void Load(C& context, TEnumIndexedArray<E, T, Min, Max>& vector) { if constexpr (std::is_copy_assignable_v<T>) { std::fill(vector.begin(), vector.end(), T()); @@ -1403,7 +1405,7 @@ struct TEnumIndexedVectorSerializer auto key = LoadSuspended<E>(context); SERIALIZATION_DUMP_WRITE(context, "%v =>", key); SERIALIZATION_DUMP_INDENT(context) { - if (!vector.IsDomainValue(key)) { + if (!vector.IsValidIndex(key)) { T dummy; TItemSerializer::Load(context, dummy); } else { @@ -1967,9 +1969,9 @@ struct TSerializerTraits<THashMultiMap<K, V>, C, void> }; template <class E, class T, class C, E Min, E Max> -struct TSerializerTraits<TEnumIndexedVector<E, T, Min, Max>, C, void> +struct TSerializerTraits<TEnumIndexedArray<E, T, Min, Max>, C, void> { - using TSerializer = TEnumIndexedVectorSerializer<>; + using TSerializer = TEnumIndexedArraySerializer<>; }; template <class F, class S, class C> diff --git a/yt/yt/core/rpc/bus/channel.cpp b/yt/yt/core/rpc/bus/channel.cpp index 513fa531c1..e5d04ea83a 100644 --- a/yt/yt/core/rpc/bus/channel.cpp +++ b/yt/yt/core/rpc/bus/channel.cpp @@ -162,7 +162,7 @@ private: bool Terminated = false; }; - TEnumIndexedVector<EMultiplexingBand, TBandBucket> Buckets_; + TEnumIndexedArray<EMultiplexingBand, TBandBucket> Buckets_; std::atomic<bool> TerminationFlag_ = false; TAtomicObject<TError> TerminationError_; diff --git a/yt/yt/core/yson/pull_parser_deserialize-inl.h b/yt/yt/core/yson/pull_parser_deserialize-inl.h index c5e39e7df8..9d45eec2a7 100644 --- a/yt/yt/core/yson/pull_parser_deserialize-inl.h +++ b/yt/yt/core/yson/pull_parser_deserialize-inl.h @@ -281,7 +281,7 @@ void Deserialize( template <class E, class T, E Min, E Max> void Deserialize( - TEnumIndexedVector<E, T, Min, Max>& vector, + TEnumIndexedArray<E, T, Min, Max>& vector, TYsonPullParserCursor* cursor, std::enable_if_t<ArePullParserDeserializable<T>(), void*>) { @@ -289,7 +289,7 @@ void Deserialize( auto itemVisitor = [&] (TYsonPullParserCursor* cursor) { auto key = ExtractTo<E>(cursor); - if (!vector.IsDomainValue(key)) { + if (!vector.IsValidIndex(key)) { THROW_ERROR_EXCEPTION("Enum value %Qlv is out of supported range", key); } diff --git a/yt/yt/core/yson/pull_parser_deserialize.h b/yt/yt/core/yson/pull_parser_deserialize.h index 0a03fc775e..20cd57b68a 100644 --- a/yt/yt/core/yson/pull_parser_deserialize.h +++ b/yt/yt/core/yson/pull_parser_deserialize.h @@ -4,12 +4,14 @@ #include "pull_parser.h" +#include <library/cpp/yt/misc/enum_indexed_array.h> + namespace NYT::NYson { //////////////////////////////////////////////////////////////////////////////// -inline void SkipAttributes(TYsonPullParserCursor* cursor); -inline void MaybeSkipAttributes(TYsonPullParserCursor* cursor); +void SkipAttributes(TYsonPullParserCursor* cursor); +void MaybeSkipAttributes(TYsonPullParserCursor* cursor); //////////////////////////////////////////////////////////////////////////////// @@ -17,12 +19,12 @@ namespace NDetail { template <typename T, typename = void> struct TIsPullParserDeserializable - : std::false_type + : public std::false_type { }; template <typename T> struct TIsPullParserDeserializable<T, std::void_t<decltype(Deserialize(std::declval<T&>(), (NYson::TYsonPullParserCursor*)(nullptr)))>> - : std::true_type + : public std::true_type { }; template <typename T> @@ -145,7 +147,7 @@ void Deserialize( template <class E, class T, E Min, E Max> void Deserialize( - TEnumIndexedVector<E, T, Min, Max>& vector, + TEnumIndexedArray<E, T, Min, Max>& vector, TYsonPullParserCursor* cursor, std::enable_if_t<ArePullParserDeserializable<T>(), void*> = nullptr); diff --git a/yt/yt/core/ytalloc/bindings.cpp b/yt/yt/core/ytalloc/bindings.cpp index 33eb077a5b..72b866114d 100644 --- a/yt/yt/core/ytalloc/bindings.cpp +++ b/yt/yt/core/ytalloc/bindings.cpp @@ -127,7 +127,7 @@ private: void PushSmallArenaStatistics( NProfiling::ISensorWriter* writer, size_t rank, - const TEnumIndexedVector<ESmallArenaCounter, ssize_t>& counters) + const TEnumIndexedArray<ESmallArenaCounter, ssize_t>& counters) { NProfiling::TWithTagGuard withTagGuard(writer, "rank", ToString(rank)); PushAllocationCounterStatistics(writer, "/small_arena", counters); @@ -147,7 +147,7 @@ private: void PushLargeArenaStatistics( NProfiling::ISensorWriter* writer, size_t rank, - const TEnumIndexedVector<ELargeArenaCounter, ssize_t>& counters) + const TEnumIndexedArray<ELargeArenaCounter, ssize_t>& counters) { NProfiling::TWithTagGuard withTagGuard(writer, "rank", ToString(rank)); diff --git a/yt/yt/core/ytree/serialize-inl.h b/yt/yt/core/ytree/serialize-inl.h index 74a1ad9c4d..eea8f121b4 100644 --- a/yt/yt/core/ytree/serialize-inl.h +++ b/yt/yt/core/ytree/serialize-inl.h @@ -426,11 +426,11 @@ void Serialize(const C<T...>& value, NYson::IYsonConsumer* consumer) } template <class E, class T, E Min, E Max> -void Serialize(const TEnumIndexedVector<E, T, Min, Max>& vector, NYson::IYsonConsumer* consumer) +void Serialize(const TEnumIndexedArray<E, T, Min, Max>& vector, NYson::IYsonConsumer* consumer) { consumer->OnBeginMap(); for (auto key : TEnumTraits<E>::GetDomainValues()) { - if (!vector.IsDomainValue(key)) { + if (!vector.IsValidIndex(key)) { continue; } const auto& value = vector[key]; @@ -614,13 +614,13 @@ void Deserialize(C<T...>& value, INodePtr node) } template <class E, class T, E Min, E Max> -void Deserialize(TEnumIndexedVector<E, T, Min, Max>& vector, INodePtr node) +void Deserialize(TEnumIndexedArray<E, T, Min, Max>& vector, INodePtr node) { vector = {}; auto mapNode = node->AsMap(); for (const auto& [stringKey, child] : mapNode->GetChildren()) { auto key = ParseEnum<E>(stringKey); - if (!vector.IsDomainValue(key)) { + if (!vector.IsValidIndex(key)) { THROW_ERROR_EXCEPTION("Enum value %Qlv is out of supported range", key); } diff --git a/yt/yt/core/ytree/serialize.h b/yt/yt/core/ytree/serialize.h index 046f5f3e18..ed58a6f934 100644 --- a/yt/yt/core/ytree/serialize.h +++ b/yt/yt/core/ytree/serialize.h @@ -12,6 +12,8 @@ #include <library/cpp/yt/small_containers/compact_vector.h> +#include <library/cpp/yt/misc/enum_indexed_array.h> + #include <optional> namespace NYT::NYTree { @@ -138,9 +140,9 @@ void Serialize(const std::tuple<T...>& value, NYson::IYsonConsumer* consumer); template <template<typename...> class C, class... T, class K = typename C<T...>::key_type> void Serialize(const C<T...>& value, NYson::IYsonConsumer* consumer); -// TEnumIndexedVector +// TEnumIndexedArray template <class E, class T, E Min, E Max> -void Serialize(const TEnumIndexedVector<E, T, Min, Max>& value, NYson::IYsonConsumer* consumer); +void Serialize(const TEnumIndexedArray<E, T, Min, Max>& value, NYson::IYsonConsumer* consumer); // Subtypes of google::protobuf::Message template <class T> @@ -241,9 +243,9 @@ void Deserialize(std::tuple<T...>& value, INodePtr node); template <template<typename...> class C, class... T, class K = typename C<T...>::key_type> void Deserialize(C<T...>& value, INodePtr node); -// TEnumIndexedVector +// TEnumIndexedArray template <class E, class T, E Min, E Max> -void Deserialize(TEnumIndexedVector<E, T, Min, Max>& vector, INodePtr node); +void Deserialize(TEnumIndexedArray<E, T, Min, Max>& vector, INodePtr node); // Subtypes of google::protobuf::Message template <class T> diff --git a/yt/yt/library/column_converters/string_column_converter.cpp b/yt/yt/library/column_converters/string_column_converter.cpp index 68e1732386..f943d02e1c 100644 --- a/yt/yt/library/column_converters/string_column_converter.cpp +++ b/yt/yt/library/column_converters/string_column_converter.cpp @@ -274,9 +274,9 @@ private: } } - TEnumIndexedVector<EUnversionedStringSegmentType, ui64> GetEncodingMethodsCosts() const + TEnumIndexedArray<EUnversionedStringSegmentType, ui64> GetEncodingMethodsCosts() const { - TEnumIndexedVector<EUnversionedStringSegmentType, ui64> costs; + TEnumIndexedArray<EUnversionedStringSegmentType, ui64> costs; for (auto type : TEnumTraits<EUnversionedStringSegmentType>::GetDomainValues()) { costs[type] = GetSpecificEncodingMethodCosts(type); } diff --git a/yt/yt/library/formats/web_json_writer.cpp b/yt/yt/library/formats/web_json_writer.cpp index 582b2291a0..fdab73f878 100644 --- a/yt/yt/library/formats/web_json_writer.cpp +++ b/yt/yt/library/formats/web_json_writer.cpp @@ -343,7 +343,7 @@ private: std::vector<TLogicalTypePtr> Types_; std::vector<std::vector<int>> TableIndexToColumnIdToTypeIndex_; THashMap<std::pair<int, TString>, int> TableIndexAndColumnNameToTypeIndex_; - TEnumIndexedVector<EValueType, int> ValueTypeToTypeIndex_; + TEnumIndexedArray<EValueType, int> ValueTypeToTypeIndex_; private: int GetTypeIndex(int tableIndex, ui16 columnId, TStringBuf columnName, EValueType valueType) |