diff --git a/velox/dwio/common/tests/utils/BatchMaker.cpp b/velox/dwio/common/tests/utils/BatchMaker.cpp index 52ce6973b80e..207677e9c428 100644 --- a/velox/dwio/common/tests/utils/BatchMaker.cpp +++ b/velox/dwio/common/tests/utils/BatchMaker.cpp @@ -41,7 +41,7 @@ template VectorPtr createScalar( size_t size, std::mt19937& gen, - std::function val, + std::function val, MemoryPool& pool, std::function isNullAt, const TypePtr type = CppToType::create()) { @@ -56,7 +56,7 @@ VectorPtr createScalar( auto notNull = isNotNull(gen, i, isNullAt); bits::setNull(nullsPtr, i, !notNull); if (notNull) { - valuesPtr[i] = val(); + valuesPtr[i] = val(i); } else { nullCount++; } @@ -86,7 +86,7 @@ VectorPtr BatchMaker::createVector( return createScalar( size, gen, - [&gen]() { return Random::rand32(0, 2, gen) == 0; }, + [&gen](size_t) { return Random::rand32(0, 2, gen) == 0; }, pool, isNullAt); } @@ -101,7 +101,7 @@ VectorPtr BatchMaker::createVector( return createScalar( size, gen, - [&gen]() { return static_cast(Random::rand32(gen)); }, + [&gen](size_t) { return static_cast(Random::rand32(gen)); }, pool, isNullAt); } @@ -116,7 +116,7 @@ VectorPtr BatchMaker::createVector( return createScalar( size, gen, - [&gen]() { return static_cast(Random::rand32(gen)); }, + [&gen](size_t) { return static_cast(Random::rand32(gen)); }, pool, isNullAt); } @@ -131,7 +131,7 @@ VectorPtr BatchMaker::createVector( return createScalar( size, gen, - [&gen]() { return static_cast(Random::rand32(gen)); }, + [&gen](size_t) { return static_cast(Random::rand32(gen)); }, pool, isNullAt); } @@ -144,7 +144,11 @@ VectorPtr BatchMaker::createVector( std::mt19937& gen, std::function isNullAt) { return createScalar( - size, gen, [&gen]() { return Random::rand64(gen); }, pool, isNullAt); + size, + gen, + [&gen](size_t) { return Random::rand64(gen); }, + pool, + isNullAt); } template <> @@ -157,7 +161,7 @@ VectorPtr BatchMaker::createVector( return createScalar( size, gen, - [&gen]() { return static_cast(Random::randDouble01(gen)); }, + [&gen](size_t) { return static_cast(Random::randDouble01(gen)); }, pool, isNullAt); } @@ -172,7 +176,7 @@ VectorPtr BatchMaker::createVector( return createScalar( size, gen, - [&gen]() { return Random::randDouble01(gen); }, + [&gen](size_t) { return Random::randDouble01(gen); }, pool, isNullAt); } @@ -187,7 +191,7 @@ VectorPtr BatchMaker::createVector( return createScalar( size, gen, - [&gen]() { + [&gen](size_t) { return HugeInt::build(Random::rand32(gen), Random::rand32(gen)); }, pool, @@ -270,7 +274,7 @@ VectorPtr BatchMaker::createVector( return createScalar( size, gen, - [&gen]() { + [&gen](size_t) { return Timestamp( TIME_OFFSET + Random::rand32(0, 60 * 60 * 24 * 365, gen), Random::rand32(0, 1'000'000, gen)); @@ -596,6 +600,32 @@ VectorPtr BatchMaker::createVector( &pool, type, nulls, size, offsets, lengths, keys, values, nullCount); } +template +VectorPtr BatchMaker::createOrderedVector( + const std::shared_ptr& type, + size_t size, + size_t base, + memory::MemoryPool& pool, + std::function isNullAt) { + VELOX_NYI(); +} + +template <> +VectorPtr BatchMaker::createOrderedVector( + const std::shared_ptr& type, + size_t size, + size_t base, + memory::MemoryPool& pool, + std::function isNullAt) { + std::mt19937 gen{0}; + return createScalar( + size, + gen, + [&base](size_t i) { return static_cast(i) + base; }, + pool, + isNullAt); +} + VectorPtr BatchMaker::createBatch( const std::shared_ptr& type, uint64_t capacity, diff --git a/velox/dwio/common/tests/utils/BatchMaker.h b/velox/dwio/common/tests/utils/BatchMaker.h index 10588f30702d..e1db818ab822 100644 --- a/velox/dwio/common/tests/utils/BatchMaker.h +++ b/velox/dwio/common/tests/utils/BatchMaker.h @@ -62,6 +62,14 @@ struct BatchMaker { std::mt19937 gen{seed}; return createVector(type, size, pool, gen, isNullAt); } + + template + static VectorPtr createOrderedVector( + const std::shared_ptr& type, + size_t size, + size_t base, + memory::MemoryPool& pool, + std::function isNullAt = nullptr); }; } // namespace facebook::velox::test