From 5d56bbcfbbe68e0b83b689aeee1078d988f874a1 Mon Sep 17 00:00:00 2001 From: Yoav Helfman Date: Tue, 26 Mar 2024 16:13:22 -0700 Subject: [PATCH] More mutable properties from vectors (#8737) Summary: Exposing additional mutable properties (indices and valuesVector) from DictionaryVector without requiring a shared pointer (and messing up ref counting). Reviewed By: Yuhta, pedroerp Differential Revision: D53693084 --- velox/vector/BaseVector.h | 4 ++++ velox/vector/ConstantVector.h | 4 ++++ velox/vector/DictionaryVector.h | 8 ++++++++ velox/vector/SequenceVector.h | 4 ++++ 4 files changed, 20 insertions(+) diff --git a/velox/vector/BaseVector.h b/velox/vector/BaseVector.h index e37faa977c8ed..0756886b839c9 100644 --- a/velox/vector/BaseVector.h +++ b/velox/vector/BaseVector.h @@ -623,6 +623,10 @@ class BaseVector { VELOX_UNSUPPORTED("Vector is not a wrapper"); } + virtual VectorPtr& valueVector() { + VELOX_UNSUPPORTED("Vector is not a wrapper"); + } + virtual BaseVector* loadedVector() { return this; } diff --git a/velox/vector/ConstantVector.h b/velox/vector/ConstantVector.h index 3903d18a8e957..18ff32198f702 100644 --- a/velox/vector/ConstantVector.h +++ b/velox/vector/ConstantVector.h @@ -249,6 +249,10 @@ class ConstantVector final : public SimpleVector { return valueVector_; } + VectorPtr& valueVector() override { + return valueVector_; + } + // Index of the element of the base vector that determines the value of this // constant vector. vector_size_t index() const { diff --git a/velox/vector/DictionaryVector.h b/velox/vector/DictionaryVector.h index d452bd0ebcab0..c08c5569bc965 100644 --- a/velox/vector/DictionaryVector.h +++ b/velox/vector/DictionaryVector.h @@ -121,10 +121,18 @@ class DictionaryVector : public SimpleVector { return indices_; } + inline BufferPtr& indices() { + return indices_; + } + const VectorPtr& valueVector() const override { return dictionaryValues_; } + VectorPtr& valueVector() override { + return dictionaryValues_; + } + BufferPtr wrapInfo() const override { return indices_; } diff --git a/velox/vector/SequenceVector.h b/velox/vector/SequenceVector.h index 3120262a49263..03b25edb6bbc7 100644 --- a/velox/vector/SequenceVector.h +++ b/velox/vector/SequenceVector.h @@ -126,6 +126,10 @@ class SequenceVector : public SimpleVector { return sequenceValues_; } + VectorPtr& valueVector() override { + return sequenceValues_; + } + BufferPtr getSequenceLengths() const { return sequenceLengths_; }