| 535 | using VisitorFunc = std::function<void(SimpleVector<T>*, SimpleVector<T>*)>; |
| 536 | |
| 537 | void runTest(const VisitorFunc& visitor) { |
| 538 | int32_t count = 5; |
| 539 | for (auto& typeA : kAllTypes) { |
| 540 | LOG(INFO) << "TypeA: " << typeA; |
| 541 | if (!isValidBiasOrDictionary<T>(typeA)) { |
| 542 | continue; |
| 543 | } |
| 544 | |
| 545 | const bool constA = (typeA == VectorEncoding::Simple::CONSTANT); |
| 546 | int32_t cardinalityA = constA ? 1 : count; |
| 547 | |
| 548 | auto data = genTestDataWithSequences<T>( |
| 549 | count, |
| 550 | cardinalityA, |
| 551 | false /* isSorted */, |
| 552 | true /* includeNulls */, |
| 553 | 0 /* sequenceCount */, |
| 554 | 0 /* sequenceLength */, |
| 555 | false /* useFullTypeRange */, |
| 556 | 2006 /* seed */); |
| 557 | auto vectorA = maker_.encodedVector(typeA, data.data()); |
| 558 | |
| 559 | for (auto& typeB : kAllTypes) { |
| 560 | LOG(INFO) << "TypeB: " << typeB; |
| 561 | if (!isValidBiasOrDictionary<T>(typeB) || |
| 562 | (typeB == VectorEncoding::Simple::BIASED && constA)) { |
| 563 | continue; |
| 564 | } |
| 565 | |
| 566 | const bool constB = (typeB == VectorEncoding::Simple::CONSTANT); |
| 567 | std::vector<std::optional<T>> dataB; |
| 568 | dataB.reserve(vectorA->size()); |
| 569 | |
| 570 | for (size_t i = 0; i < count; ++i) { |
| 571 | // construct b as a constant array same as A or as the reverse of A |
| 572 | auto pos = constB ? 0 : count - i - 1; |
| 573 | if (vectorA->isNullAt(pos)) { |
| 574 | dataB.push_back(std::nullopt); |
| 575 | } else { |
| 576 | dataB.push_back(vectorA->valueAt(pos)); |
| 577 | } |
| 578 | } |
| 579 | auto vectorB = maker_.encodedVector(typeB, dataB); |
| 580 | visitor(vectorA.get(), vectorB.get()); |
| 581 | } |
| 582 | } |
| 583 | } |
| 584 | }; |
| 585 | BOLT_TYPED_TEST_SUITE(SimpleVectorBinaryTypedTest, SimpleTypes); |
| 586 | |