From 11a55b6ebba15bff1f8786a2bee29a05690c4436 Mon Sep 17 00:00:00 2001 From: Chengcheng Jin Date: Fri, 13 Dec 2024 12:51:18 +0000 Subject: [PATCH] address comments --- velox/serializers/CompactRowSerializer.cpp | 6 +++--- velox/serializers/RowSerializer.h | 10 +++++----- velox/serializers/UnsafeRowSerializer.cpp | 3 ++- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/velox/serializers/CompactRowSerializer.cpp b/velox/serializers/CompactRowSerializer.cpp index f1eaa41e239c..6bddcbbbf3dd 100644 --- a/velox/serializers/CompactRowSerializer.cpp +++ b/velox/serializers/CompactRowSerializer.cpp @@ -26,8 +26,8 @@ using TRowSize = uint32_t; class CompactRowVectorSerializer : public RowSerializer { public: - explicit CompactRowVectorSerializer(StreamArena* streamArena) - : RowSerializer(streamArena) {} + explicit CompactRowVectorSerializer(memory::MemoryPool* pool) + : RowSerializer(pool) {} private: void serializeRanges( @@ -75,7 +75,7 @@ CompactRowVectorSerde::createIterativeSerializer( int32_t /* numRows */, StreamArena* streamArena, const Options* /* options */) { - return std::make_unique(streamArena); + return std::make_unique(streamArena->pool()); } void CompactRowVectorSerde::deserialize( diff --git a/velox/serializers/RowSerializer.h b/velox/serializers/RowSerializer.h index 46d67c3702b8..f4bda8c45a6b 100644 --- a/velox/serializers/RowSerializer.h +++ b/velox/serializers/RowSerializer.h @@ -26,8 +26,7 @@ using TRowSize = uint32_t; template class RowSerializer : public IterativeVectorSerializer { public: - explicit RowSerializer(StreamArena* streamArena) - : pool_{streamArena->pool()} {} + explicit RowSerializer(memory::MemoryPool* pool) : pool_(pool) {} void append( const RowVectorPtr& vector, @@ -118,15 +117,16 @@ class RowSerializer : public IterativeVectorSerializer { protected: virtual void serializeRanges( - const Serializer& row, + const Serializer& rowSerializer, const folly::Range& ranges, char* rawBuffer, const std::vector& /*rowSize*/) { size_t offset = 0; for (auto& range : ranges) { - for (auto i = range.begin; i < range.begin + range.size; ++i) { + for (auto row = range.begin; row < range.begin + range.size; ++row) { // Write row data. - TRowSize size = row.serialize(i, rawBuffer + offset + sizeof(TRowSize)); + TRowSize size = + rowSerializer.serialize(row, rawBuffer + offset + sizeof(TRowSize)); // Write raw size. Needs to be in big endian order. *(TRowSize*)(rawBuffer + offset) = folly::Endian::big(size); diff --git a/velox/serializers/UnsafeRowSerializer.cpp b/velox/serializers/UnsafeRowSerializer.cpp index 3990f64c40ab..ee3a1c069bfe 100644 --- a/velox/serializers/UnsafeRowSerializer.cpp +++ b/velox/serializers/UnsafeRowSerializer.cpp @@ -34,7 +34,8 @@ UnsafeRowVectorSerde::createIterativeSerializer( int32_t /* numRows */, StreamArena* streamArena, const Options* /* options */) { - return std::make_unique>(streamArena); + return std::make_unique>( + streamArena->pool()); } void UnsafeRowVectorSerde::deserialize(