Skip to content

Commit

Permalink
More mutable properties from vectors (#8737)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #8737

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

fbshipit-source-id: 890002715d15e0382a00efc6eb9da6bb4c7b1401
  • Loading branch information
helfman authored and facebook-github-bot committed Apr 1, 2024
1 parent c8c284d commit 8aceb24
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pyvelox/pyvelox.h
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,9 @@ static void registerTypedVectors(
[](DictionaryVectorPtr<NativeType> vec) {
return DictionaryIndices{vec->indices()};
})
.def("values", &DictionaryVector<NativeType>::valueVector);
.def("values", [](DictionaryVectorPtr<NativeType> vec) {
return vec->valueVector();
});
}

static void addVectorBindings(
Expand Down
4 changes: 4 additions & 0 deletions velox/vector/BaseVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
4 changes: 4 additions & 0 deletions velox/vector/ConstantVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,10 @@ class ConstantVector final : public SimpleVector<T> {
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 {
Expand Down
8 changes: 8 additions & 0 deletions velox/vector/DictionaryVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,18 @@ class DictionaryVector : public SimpleVector<T> {
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_;
}
Expand Down
4 changes: 4 additions & 0 deletions velox/vector/SequenceVector.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,10 @@ class SequenceVector : public SimpleVector<T> {
return sequenceValues_;
}

VectorPtr& valueVector() override {
return sequenceValues_;
}

BufferPtr getSequenceLengths() const {
return sequenceLengths_;
}
Expand Down

0 comments on commit 8aceb24

Please sign in to comment.