| 417 | |
| 418 | template <typename T> |
| 419 | void testDictionary( |
| 420 | vector_size_t size, |
| 421 | std::function<T(vector_size_t /*index*/)> valueAt, |
| 422 | const TypePtr& type = CppToType<T>::create()) { |
| 423 | BufferPtr indices = makeEvenIndices(size); |
| 424 | auto dictionarySize = size / 2; |
| 425 | auto flatVector = makeFlatVector<T>(size, valueAt, nullptr, type); |
| 426 | |
| 427 | auto dictionaryVector = std::dynamic_pointer_cast<DictionaryVector<T>>( |
| 428 | BaseVector::wrapInDictionary( |
| 429 | BufferPtr(nullptr), indices, dictionarySize, flatVector)); |
| 430 | auto check = [&](const auto& decoded) { |
| 431 | EXPECT_FALSE(decoded.isConstantMapping()); |
| 432 | EXPECT_FALSE(decoded.isIdentityMapping()); |
| 433 | for (int32_t i = 0; i < dictionaryVector->size(); i++) { |
| 434 | EXPECT_FALSE(decoded.isNullAt(i)) << "at " << i; |
| 435 | EXPECT_EQ(decoded.template valueAt<T>(i), dictionaryVector->valueAt(i)) |
| 436 | << "at " << i; |
| 437 | } |
| 438 | }; |
| 439 | |
| 440 | { |
| 441 | SelectivityVector selection(dictionarySize); |
| 442 | DecodedVector decoded(*dictionaryVector, selection); |
| 443 | check(decoded); |
| 444 | } |
| 445 | |
| 446 | { |
| 447 | DecodedVector decoded(*dictionaryVector); |
| 448 | check(decoded); |
| 449 | } |
| 450 | } |
| 451 | |
| 452 | SelectivityVector allSelected_; |
| 453 | SelectivityVector halfSelected_; |
nothing calls this directly
no test coverage detected