| 203 | } |
| 204 | |
| 205 | void DecodedVector::applyDictionaryWrapper( |
| 206 | const BaseVector& dictionaryVector, |
| 207 | const SelectivityVector* rows) { |
| 208 | if (size_ == 0 || (rows && !rows->hasSelections())) { |
| 209 | // No further processing is needed. |
| 210 | return; |
| 211 | } |
| 212 | |
| 213 | auto newIndices = dictionaryVector.wrapInfo()->as<vector_size_t>(); |
| 214 | auto newNulls = dictionaryVector.rawNulls(); |
| 215 | if (newNulls) { |
| 216 | hasExtraNulls_ = true; |
| 217 | mayHaveNulls_ = true; |
| 218 | // if we have both nulls for parent and the wrapped vectors, and nulls |
| 219 | // buffer is not copied, make a copy because we may need to |
| 220 | // change it when iterating through wrapped vector |
| 221 | if (!nulls_ || nullsNotCopied()) { |
| 222 | copyNulls(end(rows)); |
| 223 | } |
| 224 | } |
| 225 | auto copiedNulls = copiedNulls_.data(); |
| 226 | auto currentIndices = indices_; |
| 227 | if (indicesNotCopied()) { |
| 228 | copiedIndices_.resize(size_); |
| 229 | indices_ = copiedIndices_.data(); |
| 230 | } |
| 231 | |
| 232 | applyToRows(rows, [&](vector_size_t row) { |
| 233 | if (!nulls_ || !bits::isBitNull(nulls_, row)) { |
| 234 | auto wrappedIndex = currentIndices[row]; |
| 235 | if (newNulls && bits::isBitNull(newNulls, wrappedIndex)) { |
| 236 | bits::setNull(copiedNulls, row); |
| 237 | } else { |
| 238 | copiedIndices_[row] = newIndices[wrappedIndex]; |
| 239 | } |
| 240 | } |
| 241 | }); |
| 242 | } |
| 243 | |
| 244 | void DecodedVector::fillInIndices() { |
| 245 | if (isConstantMapping_) { |