| 202 | private: |
| 203 | template <TypeKind Kind> |
| 204 | void implForPrimitiveKey( |
| 205 | const SelectivityVector& rows, |
| 206 | vector_size_t mapSize, |
| 207 | std::vector<VectorPtr>& args, |
| 208 | exec::DecodedArgs& decodedArgs, |
| 209 | VectorPtr& result) const { |
| 210 | using NativeType = typename TypeTraits<Kind>::NativeType; |
| 211 | auto mapResult = result->as<MapVector>(); |
| 212 | auto rawSizes = mapResult->mutableSizes(rows.end())->asMutable<int32_t>(); |
| 213 | auto rawOffsets = |
| 214 | mapResult->mutableOffsets(rows.end())->asMutable<int32_t>(); |
| 215 | |
| 216 | auto& keysResult = mapResult->mapKeys(); |
| 217 | auto& valuesResult = mapResult->mapValues(); |
| 218 | vector_size_t offset = keysResult->size(); |
| 219 | |
| 220 | std::vector<const SimpleVector<NativeType>*> argsKeySimpleVector; |
| 221 | argsKeySimpleVector.reserve(mapSize); |
| 222 | for (vector_size_t i = 0; i < mapSize; i++) { |
| 223 | argsKeySimpleVector.emplace_back( |
| 224 | decodedArgs.at(i * 2)->base()->as<SimpleVector<NativeType>>()); |
| 225 | } |
| 226 | std::vector<SelectivityVector> argsSelectivity( |
| 227 | rows.end(), SelectivityVector(mapSize, false)); |
| 228 | folly::F14FastMap<NativeType, vector_size_t> keyToArgsIndex; |
| 229 | keyToArgsIndex.reserve(mapSize); |
| 230 | |
| 231 | rows.applyToSelected([&](vector_size_t row) { |
| 232 | for (vector_size_t i = 0; i < mapSize; i++) { |
| 233 | auto decodedkey = decodedArgs.at(i * 2); |
| 234 | BOLT_USER_CHECK( |
| 235 | !decodedkey->isNullAt(row), "Cannot use null as map key!"); |
| 236 | auto key = argsKeySimpleVector[i]; |
| 237 | auto keyRow = decodedkey->index(row); |
| 238 | if constexpr (Policy == EXCEPTION) { |
| 239 | BOLT_USER_CHECK( |
| 240 | keyToArgsIndex.insert({key->valueAt(keyRow), i}).second, |
| 241 | DuplicateKeyExceptionInfo); |
| 242 | } else if constexpr (Policy == FIRST_WIN) { |
| 243 | keyToArgsIndex.insert({key->valueAt(keyRow), i}); |
| 244 | } else if constexpr (Policy == LAST_WIN) { |
| 245 | keyToArgsIndex.insert_or_assign(key->valueAt(keyRow), i); |
| 246 | } else { |
| 247 | BOLT_UNREACHABLE(); |
| 248 | } |
| 249 | } |
| 250 | |
| 251 | rawSizes[row] = keyToArgsIndex.size(); |
| 252 | rawOffsets[row] = offset; |
| 253 | offset += keyToArgsIndex.size(); |
| 254 | auto& argsSelec = argsSelectivity[row]; |
| 255 | for (const auto& [_, argsIndex] : keyToArgsIndex) { |
| 256 | argsSelec.setValid(argsIndex, true); |
| 257 | } |
| 258 | argsSelec.updateBounds(); |
| 259 | keyToArgsIndex.clear(); |
| 260 | }); |
| 261 |
nothing calls this directly
no test coverage detected