Skip to content

Commit

Permalink
Remove unsafe RowVector::resize call from HashProbe::fillFilterInput (#…
Browse files Browse the repository at this point in the history
…6869)

Summary: Pull Request resolved: #6869

Reviewed By: xiaoxmeng

Differential Revision: D49872243

Pulled By: mbasmanova

fbshipit-source-id: e6cac46db5cdbda7b580171ab66d466e5cac710a
  • Loading branch information
mbasmanova authored and facebook-github-bot committed Oct 3, 2023
1 parent ef02599 commit f5bbde6
Showing 1 changed file with 19 additions and 12 deletions.
31 changes: 19 additions & 12 deletions velox/exec/HashProbe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,18 @@ void extractColumns(
folly::Range<char**> rows,
folly::Range<const IdentityProjection*> projections,
memory::MemoryPool* pool,
const RowVectorPtr& result) {
const std::vector<TypePtr>& resultTypes,
std::vector<VectorPtr>& resultVectors) {
VELOX_CHECK_EQ(resultTypes.size(), resultVectors.size())
for (auto projection : projections) {
auto& child = result->childAt(projection.outputChannel);
const auto resultChannel = projection.outputChannel;
VELOX_CHECK_LT(resultChannel, resultVectors.size())

auto& child = resultVectors[resultChannel];
// TODO: Consider reuse of complex types.
if (!child || !BaseVector::isVectorWritable(child) ||
!child->isFlatEncoding()) {
child = BaseVector::create(
result->type()->childAt(projection.outputChannel), rows.size(), pool);
child = BaseVector::create(resultTypes[resultChannel], rows.size(), pool);
}
child->resize(rows.size());
table->rows()->extractColumn(
Expand Down Expand Up @@ -714,7 +718,8 @@ void HashProbe::fillOutput(vector_size_t size) {
folly::Range<char**>(outputTableRows_.data(), size),
tableOutputProjections_,
pool(),
output_);
outputType_->children(),
output_->children());
}
}

Expand Down Expand Up @@ -758,7 +763,8 @@ RowVectorPtr HashProbe::getBuildSideOutput() {
folly::Range<char**>(outputTableRows_.data(), numOut),
tableOutputProjections_,
pool(),
output_);
outputType_->children(),
output_->children());

if (isRightSemiProjectJoin(joinType_)) {
// Populate 'match' column.
Expand Down Expand Up @@ -973,13 +979,10 @@ RowVectorPtr HashProbe::getOutput() {
}

void HashProbe::fillFilterInput(vector_size_t size) {
if (!filterInput_) {
filterInput_ = BaseVector::create<RowVector>(filterInputType_, 1, pool());
}
filterInput_->resize(size);
std::vector<VectorPtr> filterColumns(filterInputType_->size());
for (auto projection : filterInputProjections_) {
ensureLoadedIfNotAtEnd(projection.inputChannel);
filterInput_->childAt(projection.outputChannel) = wrapChild(
filterColumns[projection.outputChannel] = wrapChild(
size, outputRowMapping_, input_->childAt(projection.inputChannel));
}

Expand All @@ -988,7 +991,11 @@ void HashProbe::fillFilterInput(vector_size_t size) {
folly::Range<char**>(outputTableRows_.data(), size),
filterTableProjections_,
pool(),
filterInput_);
filterInputType_->children(),
filterColumns);

filterInput_ = std::make_shared<RowVector>(
pool(), filterInputType_, nullptr, size, std::move(filterColumns));
}

void HashProbe::prepareFilterRowsForNullAwareJoin(
Expand Down

0 comments on commit f5bbde6

Please sign in to comment.