Skip to content

Commit

Permalink
Specialize vector readers for constant and flat primitives. (facebook…
Browse files Browse the repository at this point in the history
…incubator#1956)

Summary:
Pull Request resolved: facebookincubator#1956

This diff adds a special path in the simple function adapter for flat and constant encodings.

To avoid the memory blowing up, the logic is as the following:
1. If Args<=2 : specialize for all encodings and all combinations.
2. If all args are constant or flat: use ConstantFlatReader.
3. Else: use normal readers

Reviewed By: kevinwilfong, mbasmanova

Differential Revision: D37639207

fbshipit-source-id: 77c2371720379c328378825b2b2d50a7d21790d2
  • Loading branch information
laithsakka authored and facebook-github-bot committed Aug 18, 2022
1 parent 09a5740 commit f265487
Show file tree
Hide file tree
Showing 6 changed files with 361 additions and 232 deletions.
13 changes: 10 additions & 3 deletions velox/expression/EvalCtx.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#pragma once

#include <functional>

#include "velox/common/base/Portability.h"
#include "velox/core/QueryCtx.h"
#include "velox/vector/ComplexVector.h"
Expand Down Expand Up @@ -434,15 +436,20 @@ class LocalDecodedVector {
LocalDecodedVector(LocalDecodedVector&& other) noexcept
: context_{other.context_}, vector_{std::move(other.vector_)} {}

void operator=(LocalDecodedVector&& other) {
context_ = other.context_;
vector_ = std::move(other.vector_);
}

~LocalDecodedVector() {
if (vector_) {
context_.releaseDecodedVector(std::move(vector_));
context_.get().releaseDecodedVector(std::move(vector_));
}
}

DecodedVector* FOLLY_NONNULL get() {
if (!vector_) {
vector_ = context_.getDecodedVector();
vector_ = context_.get().getDecodedVector();
}
return vector_.get();
}
Expand All @@ -469,7 +476,7 @@ class LocalDecodedVector {
}

private:
core::ExecCtx& context_;
std::reference_wrapper<core::ExecCtx> context_;
std::unique_ptr<DecodedVector> vector_;
};

Expand Down
Loading

0 comments on commit f265487

Please sign in to comment.