Skip to content

Commit f2b9abe

Browse files
peterenescufacebook-github-bot
authored andcommitted
refactor(nimble): Preserve MAP spec in flat map column readers
Summary: A production issue S602695 VeloxRuntimeError blocking feature injection pipeline exposed an issue in the Nimble flat map reader. For context, earlier this half ROO feature injection was enabled in production and supported by both Velox map and flat map vector encodings. A particular pipeline was blocked this past weekend due to flat map reader crashing. A temporary mitigation was to use regular map instead of the flat map encoding as it appeared flat map reader was attempting to set values that were uninitialized by the reader. The culprit was how scan spec is constructed for flat map. Rather than appending all features to keys and values children, we should follow map scan spec construction by preserving the keys and values and create child columns using the preserved values child spec. Differential Revision: D89326920
1 parent 92779b3 commit f2b9abe

File tree

2 files changed

+16
-39
lines changed

2 files changed

+16
-39
lines changed

velox/dwio/common/SelectiveFlatMapColumnReader.cpp

Lines changed: 10 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -57,42 +57,16 @@ void SelectiveFlatMapColumnReader::getValues(
5757
auto* resultFlatMap = prepareResult(*result, keysVector_, rows.size());
5858
setComplexNulls(rows, *result);
5959

60-
for (const auto& childSpec : scanSpec_->children()) {
61-
VELOX_TRACE_HISTORY_PUSH("getValues %s", childSpec->fieldName().c_str());
62-
if (!childSpec->keepValues()) {
63-
continue;
64-
}
65-
66-
VELOX_CHECK(
67-
childSpec->readFromFile(),
68-
"Flatmap children must always be read from file.");
69-
70-
if (childSpec->subscript() == kConstantChildSpecSubscript) {
71-
continue;
72-
}
73-
74-
const auto channel = childSpec->channel();
75-
const auto index = childSpec->subscript();
76-
auto& childResult = resultFlatMap->mapValuesAt(channel);
77-
78-
VELOX_CHECK(
79-
!childSpec->deltaUpdate(),
80-
"Delta update not supported in flat map yet");
81-
VELOX_CHECK(
82-
!childSpec->isConstant(),
83-
"Flat map values cannot be constant in scanSpec.");
84-
VELOX_CHECK_EQ(
85-
childSpec->columnType(),
86-
velox::common::ScanSpec::ColumnType::kRegular,
87-
"Flat map only supports regular column types in scan spec.");
88-
89-
children_[index]->getValues(rows, &childResult);
90-
91-
for (size_t i = 0; i < children_.size(); ++i) {
92-
const auto& inMap = inMapBuffer(i);
93-
if (inMap) {
94-
resultFlatMap->inMapsAt(i, true) = inMap;
95-
}
60+
// Loop over column readers
61+
for (int i = 0; i < children_.size(); ++i) {
62+
auto& child = children_[i];
63+
VectorPtr values;
64+
child->getValues(rows, &values);
65+
resultFlatMap->mapValuesAt(i) = values;
66+
67+
const auto& inMap = inMapBuffer(i);
68+
if (inMap) {
69+
resultFlatMap->inMapsAt(i, true) = inMap;
9670
}
9771
}
9872
}

velox/vector/FlatMapVector.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,15 @@ void FlatMapVector::resize(vector_size_t newSize, bool setNotNull) {
123123
// to skip uniqueness check since effectively we are just changing
124124
// the length.
125125
if (newSize > oldSize) {
126-
VELOX_CHECK_EQ(
127-
values.use_count(), 1, "Resizing shared map values vector");
126+
if (values.use_count() > 1) {
127+
LOG(WARNING) << "Resizing shared map values vector";
128+
}
128129
values->resize(newSize, setNotNull);
129130

130131
if (i < inMaps_.size() && inMaps_[i] != nullptr) {
131-
VELOX_CHECK(inMaps_[i]->unique(), "Resizing shared in map vector");
132+
if (!inMaps_[i]->unique()) {
133+
LOG(WARNING) << "Resizing shared in map vector";
134+
}
132135
AlignedBuffer::reallocate<bool>(&inMaps_[i], newSize, 0);
133136
}
134137
}

0 commit comments

Comments
 (0)