diff --git a/velox/dwio/common/FlatMapHelper.h b/velox/dwio/common/FlatMapHelper.h index 3a67af06c206..c9653429c08c 100644 --- a/velox/dwio/common/FlatMapHelper.h +++ b/velox/dwio/common/FlatMapHelper.h @@ -67,6 +67,7 @@ void initializeFlatVector( if (!vector) { vector = std::make_shared>( &pool, + CppToType::create(), hasNulls ? AlignedBuffer::allocate(size, &pool) : nullptr, 0 /*length*/, AlignedBuffer::allocate(size, &pool), diff --git a/velox/dwio/common/tests/utils/BatchMaker.cpp b/velox/dwio/common/tests/utils/BatchMaker.cpp index 37ab92596f74..23546985517f 100644 --- a/velox/dwio/common/tests/utils/BatchMaker.cpp +++ b/velox/dwio/common/tests/utils/BatchMaker.cpp @@ -453,7 +453,12 @@ VectorPtr createScalarMapKeys( } return std::make_shared>( - &pool, BufferPtr(nullptr), totalKeys, values, std::vector{}); + &pool, + CppToType::create(), + BufferPtr(nullptr), + totalKeys, + values, + std::vector{}); } VectorPtr createBinaryMapKeys( diff --git a/velox/dwio/common/tests/utils/MapBuilder.h b/velox/dwio/common/tests/utils/MapBuilder.h index 4ba3d496e941..300645a46d71 100644 --- a/velox/dwio/common/tests/utils/MapBuilder.h +++ b/velox/dwio/common/tests/utils/MapBuilder.h @@ -29,8 +29,7 @@ class MapBuilder { using rows = std::vector>; static VectorPtr create(memory::MemoryPool& pool, rows rows) { - const std::shared_ptr type = - CppToType>::create(); + const auto type = CppToType>::create(); auto items = 0; for (auto& row : rows) { if (row.has_value()) { @@ -38,17 +37,14 @@ class MapBuilder { } } - BufferPtr nulls = - AlignedBuffer::allocate(bits::nbytes(rows.size()), &pool); + BufferPtr nulls = allocateNulls(rows.size(), &pool); auto* nullsPtr = nulls->asMutable(); size_t nullCount = 0; - BufferPtr offsets = - AlignedBuffer::allocate(rows.size(), &pool); + BufferPtr offsets = allocateOffsets(rows.size(), &pool); auto* offsetsPtr = offsets->asMutable(); - BufferPtr lengths = - AlignedBuffer::allocate(rows.size(), &pool); + BufferPtr lengths = allocateSizes(rows.size(), &pool); auto* lengthsPtr = lengths->asMutable(); BufferPtr keys = AlignedBuffer::allocate(items, &pool); @@ -57,8 +53,7 @@ class MapBuilder { BufferPtr values = AlignedBuffer::allocate(items, &pool); auto* valuesPtr = values->asMutable(); - BufferPtr valueNulls = - AlignedBuffer::allocate(bits::nbytes(items), &pool); + BufferPtr valueNulls = allocateNulls(items, &pool); auto* valueNullsPtr = valueNulls->asMutable(); size_t valueNullCount = 0; @@ -103,12 +98,14 @@ class MapBuilder { lengths, std::make_shared>( &pool, + type->childAt(0), BufferPtr(nullptr), items /*length*/, keys, std::vector()), std::make_shared>( &pool, + type->childAt(1), valueNulls, items /*length*/, values, diff --git a/velox/dwio/dwrf/reader/ColumnReader.cpp b/velox/dwio/dwrf/reader/ColumnReader.cpp index e9e1baa438d7..e387af2b106a 100644 --- a/velox/dwio/dwrf/reader/ColumnReader.cpp +++ b/velox/dwio/dwrf/reader/ColumnReader.cpp @@ -234,7 +234,12 @@ VectorPtr makeFlatVector( size_t length, BufferPtr values) { auto flatVector = std::make_shared>( - pool, nulls, length, values, std::vector()); + pool, + CppToType::create(), + nulls, + length, + values, + std::vector()); flatVector->setNullCount(nullCount); return flatVector; } @@ -1344,6 +1349,7 @@ void StringDictionaryColumnReader::readFlatVector( } else { result = std::make_shared>( &memoryPool_, + VARCHAR(), nulls, numValues, data, diff --git a/velox/dwio/dwrf/test/ColumnWriterIndexTests.cpp b/velox/dwio/dwrf/test/ColumnWriterIndexTests.cpp index 85d1e589996b..fbfc63bedfd7 100644 --- a/velox/dwio/dwrf/test/ColumnWriterIndexTests.cpp +++ b/velox/dwio/dwrf/test/ColumnWriterIndexTests.cpp @@ -92,7 +92,12 @@ VectorPtr prepBatchImpl( } auto batch = std::make_shared>( - pool, nulls, size, values, std::vector()); + pool, + CppToType::create(), + nulls, + size, + values, + std::vector()); batch->setNullCount(nullCount); return batch; } @@ -102,7 +107,7 @@ VectorPtr prepStringBatchImpl( MemoryPool* pool, std::function genData, std::function genNulls) { - BufferPtr nulls = AlignedBuffer::allocate(bits::nbytes(size), pool); + BufferPtr nulls = allocateNulls(size, pool); auto* nullsPtr = nulls->asMutable(); size_t nullCount = 0; @@ -138,7 +143,7 @@ VectorPtr prepStringBatchImpl( } auto batch = std::make_shared>( - pool, nulls, size, values, std::move(dataChunks)); + pool, VARCHAR(), nulls, size, values, std::move(dataChunks)); batch->setNullCount(nullCount); return batch; } @@ -564,7 +569,7 @@ class BinaryColumnWriterEncodingIndexTest protected: VectorPtr prepBatch(size_t size, MemoryPool* pool) override { - BufferPtr nulls = AlignedBuffer::allocate(bits::nbytes(size), pool); + BufferPtr nulls = allocateNulls(size, pool); auto* nullsPtr = nulls->asMutable(); size_t nullCount = 0; @@ -589,7 +594,7 @@ class BinaryColumnWriterEncodingIndexTest } auto batch = std::make_shared>( - pool, nulls, size, values, std::vector{data}); + pool, VARCHAR(), nulls, size, values, std::vector{data}); batch->setNullCount(nullCount); return batch; } @@ -1152,14 +1157,14 @@ class ListColumnWriterEncodingIndexTest protected: VectorPtr prepBatch(size_t size, MemoryPool* pool) override { - auto nulls = AlignedBuffer::allocate(bits::nbytes(size), pool); + auto nulls = allocateNulls(size, pool); auto* nullsPtr = nulls->asMutable(); size_t nullCount = 0; - auto offsets = AlignedBuffer::allocate(size, pool); + auto offsets = allocateOffsets(size, pool); auto* offsetsPtr = offsets->asMutable(); - auto lengths = AlignedBuffer::allocate(size, pool); + auto lengths = allocateSizes(size, pool); auto* lengthsPtr = lengths->asMutable(); size_t value = 0; @@ -1218,14 +1223,14 @@ class MapColumnWriterEncodingIndexTest protected: VectorPtr prepBatch(size_t size, MemoryPool* pool) override { - auto nulls = AlignedBuffer::allocate(bits::nbytes(size), pool); + auto nulls = allocateNulls(size, pool); auto* nullsPtr = nulls->asMutable(); size_t nullCount = 0; - auto offsets = AlignedBuffer::allocate(size, pool); + auto offsets = allocateOffsets(size, pool); auto* offsetsPtr = offsets->asMutable(); - auto lengths = AlignedBuffer::allocate(size, pool); + auto lengths = allocateSizes(size, pool); auto* lengthsPtr = lengths->asMutable(); size_t value = 0; @@ -1289,12 +1294,12 @@ class FlatMapColumnWriterEncodingIndexTest protected: VectorPtr prepBatch(size_t size, MemoryPool* pool) override { - auto offsets = AlignedBuffer::allocate(size, pool); + auto offsets = allocateOffsets(size, pool); auto* offsetsPtr = offsets->asMutable(); auto offsets2 = AlignedBuffer::allocate(size, pool); auto* offsets2Ptr = offsets2->asMutable(); - auto lengths = AlignedBuffer::allocate(size, pool); + auto lengths = allocateSizes(size, pool); auto* lengthsPtr = lengths->asMutable(); auto lengths2 = AlignedBuffer::allocate(size, pool); auto* lengths2Ptr = lengths2->asMutable(); @@ -1384,7 +1389,7 @@ class StructColumnWriterEncodingIndexTest } VectorPtr prepBatch(size_t size, MemoryPool* pool, bool isRoot) override { - auto nulls = AlignedBuffer::allocate(bits::nbytes(size), pool); + auto nulls = allocateNulls(size, pool); auto* nullsPtr = nulls->asMutable(); size_t nullCount = 0; diff --git a/velox/dwio/dwrf/test/ColumnWriterStatsTests.cpp b/velox/dwio/dwrf/test/ColumnWriterStatsTests.cpp index e0906e47d504..fad03fe62b7f 100644 --- a/velox/dwio/dwrf/test/ColumnWriterStatsTests.cpp +++ b/velox/dwio/dwrf/test/ColumnWriterStatsTests.cpp @@ -219,97 +219,99 @@ VectorPtr makeFlatVector( size_t length, BufferPtr values) { auto flatVector = std::make_shared>( - &pool, nulls, length, values, std::vector()); + &pool, + CppToType::create(), + nulls, + length, + values, + std::vector()); flatVector->setNullCount(nullCount); return flatVector; } TEST_F(ColumnWriterStatsTest, Bool) { - auto populateBoolBatch = [](MemoryPool& pool, - VectorPtr* vector, - size_t size) { - BufferPtr nulls = AlignedBuffer::allocate(bits::nbytes(size), &pool); - auto* nullsPtr = nulls->asMutable(); - size_t nullCount = 0; - - BufferPtr values = AlignedBuffer::allocate(size, &pool); - auto valuesPtr = values->asMutable(); - - for (size_t i = 0; i < size; ++i) { - bool isNull = i & 1; - bits::setNull(nullsPtr, i, isNull); - if (isNull) { - ++nullCount; - } else { - bits::setBit(valuesPtr, i, static_cast(i & 2)); - } - } + auto populateBoolBatch = + [](MemoryPool& pool, VectorPtr* vector, size_t size) { + BufferPtr nulls = allocateNulls(size, &pool); + auto* nullsPtr = nulls->asMutable(); + size_t nullCount = 0; + + BufferPtr values = AlignedBuffer::allocate(size, &pool); + auto valuesPtr = values->asMutable(); + + for (size_t i = 0; i < size; ++i) { + bool isNull = i & 1; + bits::setNull(nullsPtr, i, isNull); + if (isNull) { + ++nullCount; + } else { + bits::setBit(valuesPtr, i, static_cast(i & 2)); + } + } - *vector = makeFlatVector(pool, nulls, nullCount, size, values); - return std::vector{size, size}; - }; + *vector = makeFlatVector(pool, nulls, nullCount, size, values); + return std::vector{size, size}; + }; verifyTypeStats(*pool_, "struct", populateBoolBatch); } TEST_F(ColumnWriterStatsTest, TinyInt) { - auto populateTinyIntBatch = [](MemoryPool& pool, - VectorPtr* vector, - size_t size) { - BufferPtr nulls = AlignedBuffer::allocate(bits::nbytes(size), &pool); - auto* nullsPtr = nulls->asMutable(); - size_t nullCount = 0; + auto populateTinyIntBatch = + [](MemoryPool& pool, VectorPtr* vector, size_t size) { + BufferPtr nulls = allocateNulls(size, &pool); + auto* nullsPtr = nulls->asMutable(); + size_t nullCount = 0; - BufferPtr values = AlignedBuffer::allocate(size, &pool); - auto valuesPtr = values->asMutable(); + BufferPtr values = AlignedBuffer::allocate(size, &pool); + auto valuesPtr = values->asMutable(); - for (auto i = 0; i < size; i++) { - bool isNull = i & 1; - bits::setNull(nullsPtr, i, isNull); - if (isNull) { - ++nullCount; - } else { - valuesPtr[i] = static_cast(i); - } - } + for (auto i = 0; i < size; i++) { + bool isNull = i & 1; + bits::setNull(nullsPtr, i, isNull); + if (isNull) { + ++nullCount; + } else { + valuesPtr[i] = static_cast(i); + } + } - *vector = makeFlatVector(pool, nulls, nullCount, size, values); - return std::vector{size, size}; - }; + *vector = makeFlatVector(pool, nulls, nullCount, size, values); + return std::vector{size, size}; + }; verifyTypeStats(*pool_, "struct", populateTinyIntBatch); } TEST_F(ColumnWriterStatsTest, SmallInt) { - auto populateSmallIntBatch = [](MemoryPool& pool, - VectorPtr* vector, - size_t size) { - BufferPtr nulls = AlignedBuffer::allocate(bits::nbytes(size), &pool); - auto* nullsPtr = nulls->asMutable(); - size_t nullCount = 0; + auto populateSmallIntBatch = + [](MemoryPool& pool, VectorPtr* vector, size_t size) { + BufferPtr nulls = allocateNulls(size, &pool); + auto* nullsPtr = nulls->asMutable(); + size_t nullCount = 0; - BufferPtr values = AlignedBuffer::allocate(size, &pool); - auto valuesPtr = values->asMutable(); + BufferPtr values = AlignedBuffer::allocate(size, &pool); + auto valuesPtr = values->asMutable(); - for (auto i = 0; i < size; i++) { - bool isNull = i & 1; - bits::setNull(nullsPtr, i, isNull); - if (isNull) { - ++nullCount; - } else { - valuesPtr[i] = static_cast(i); - } - } + for (auto i = 0; i < size; i++) { + bool isNull = i & 1; + bits::setNull(nullsPtr, i, isNull); + if (isNull) { + ++nullCount; + } else { + valuesPtr[i] = static_cast(i); + } + } - size_t totalSize = - nullCount * NULL_SIZE + (size - nullCount) * sizeof(int16_t); - *vector = makeFlatVector(pool, nulls, nullCount, size, values); - return std::vector{totalSize, totalSize}; - }; + size_t totalSize = + nullCount * NULL_SIZE + (size - nullCount) * sizeof(int16_t); + *vector = makeFlatVector(pool, nulls, nullCount, size, values); + return std::vector{totalSize, totalSize}; + }; verifyTypeStats(*pool_, "struct", populateSmallIntBatch); } TEST_F(ColumnWriterStatsTest, Int) { auto populateIntBatch = [](MemoryPool& pool, VectorPtr* vector, size_t size) { - BufferPtr nulls = AlignedBuffer::allocate(bits::nbytes(size), &pool); + BufferPtr nulls = allocateNulls(size, &pool); auto* nullsPtr = nulls->asMutable(); size_t nullCount = 0; @@ -335,36 +337,35 @@ TEST_F(ColumnWriterStatsTest, Int) { } TEST_F(ColumnWriterStatsTest, Long) { - auto populateLongBatch = [](MemoryPool& pool, - VectorPtr* vector, - size_t size) { - BufferPtr nulls = AlignedBuffer::allocate(bits::nbytes(size), &pool); - auto* nullsPtr = nulls->asMutable(); - size_t nullCount = 0; + auto populateLongBatch = + [](MemoryPool& pool, VectorPtr* vector, size_t size) { + BufferPtr nulls = allocateNulls(size, &pool); + auto* nullsPtr = nulls->asMutable(); + size_t nullCount = 0; - BufferPtr values = AlignedBuffer::allocate(size, &pool); - auto valuesPtr = values->asMutable(); + BufferPtr values = AlignedBuffer::allocate(size, &pool); + auto valuesPtr = values->asMutable(); - for (auto i = 0; i < size; i++) { - bool isNull = i & 1; - bits::setNull(nullsPtr, i, isNull); - if (isNull) { - ++nullCount; - } else { - valuesPtr[i] = static_cast(i); - } - } + for (auto i = 0; i < size; i++) { + bool isNull = i & 1; + bits::setNull(nullsPtr, i, isNull); + if (isNull) { + ++nullCount; + } else { + valuesPtr[i] = static_cast(i); + } + } - size_t totalSize = - nullCount * NULL_SIZE + (size - nullCount) * sizeof(int64_t); - *vector = makeFlatVector(pool, nulls, nullCount, size, values); - return std::vector{totalSize, totalSize}; - }; + size_t totalSize = + nullCount * NULL_SIZE + (size - nullCount) * sizeof(int64_t); + *vector = makeFlatVector(pool, nulls, nullCount, size, values); + return std::vector{totalSize, totalSize}; + }; verifyTypeStats(*pool_, "struct", populateLongBatch); } auto populateFloatBatch = [](MemoryPool& pool, VectorPtr* vector, size_t size) { - BufferPtr nulls = AlignedBuffer::allocate(bits::nbytes(size), &pool); + BufferPtr nulls = allocateNulls(size, &pool); auto* nullsPtr = nulls->asMutable(); size_t nullCount = 0; @@ -391,31 +392,30 @@ TEST_F(ColumnWriterStatsTest, Float) { } TEST_F(ColumnWriterStatsTest, Double) { - auto populateDoubleBatch = [](MemoryPool& pool, - VectorPtr* vector, - size_t size) { - BufferPtr nulls = AlignedBuffer::allocate(bits::nbytes(size), &pool); - auto* nullsPtr = nulls->asMutable(); - size_t nullCount = 0; + auto populateDoubleBatch = + [](MemoryPool& pool, VectorPtr* vector, size_t size) { + BufferPtr nulls = allocateNulls(size, &pool); + auto* nullsPtr = nulls->asMutable(); + size_t nullCount = 0; - BufferPtr values = AlignedBuffer::allocate(size, &pool); - auto valuesPtr = values->asMutable(); + BufferPtr values = AlignedBuffer::allocate(size, &pool); + auto valuesPtr = values->asMutable(); - for (auto i = 0; i < size; i++) { - bool isNull = i & 1; - bits::setNull(nullsPtr, i, isNull); - if (isNull) { - ++nullCount; - } else { - valuesPtr[i] = static_cast(i); - } - } + for (auto i = 0; i < size; i++) { + bool isNull = i & 1; + bits::setNull(nullsPtr, i, isNull); + if (isNull) { + ++nullCount; + } else { + valuesPtr[i] = static_cast(i); + } + } - size_t totalSize = - nullCount * NULL_SIZE + (size - nullCount) * sizeof(double); - *vector = makeFlatVector(pool, nulls, nullCount, size, values); - return std::vector{totalSize, totalSize}; - }; + size_t totalSize = + nullCount * NULL_SIZE + (size - nullCount) * sizeof(double); + *vector = makeFlatVector(pool, nulls, nullCount, size, values); + return std::vector{totalSize, totalSize}; + }; verifyTypeStats(*pool_, "struct", populateDoubleBatch); } @@ -465,7 +465,7 @@ TEST_F(ColumnWriterStatsTest, Timestamp) { auto populateTimestampBatch = [](MemoryPool& pool, VectorPtr* vector, size_t size) { - BufferPtr nulls = AlignedBuffer::allocate(bits::nbytes(size), &pool); + BufferPtr nulls = allocateNulls(size, &pool); auto* nullsPtr = nulls->asMutable(); size_t nullCount = 0; @@ -495,14 +495,14 @@ TEST_F(ColumnWriterStatsTest, List) { auto populateListBatch = [](MemoryPool& pool, VectorPtr* vector, size_t size) { - BufferPtr nulls = AlignedBuffer::allocate(bits::nbytes(size), &pool); + BufferPtr nulls = allocateNulls(size, &pool); auto* nullsPtr = nulls->asMutable(); size_t nullCount = 0; - auto offsets = AlignedBuffer::allocate(size, &pool); + auto offsets = allocateOffsets(size, &pool); auto* offsetsPtr = offsets->asMutable(); - auto lengths = AlignedBuffer::allocate(size, &pool); + auto lengths = allocateSizes(size, &pool); auto* lengthsPtr = lengths->asMutable(); size_t childSize = 0; @@ -539,14 +539,14 @@ TEST_F(ColumnWriterStatsTest, List) { TEST_F(ColumnWriterStatsTest, Map) { auto populateMapBatch = [](MemoryPool& pool, VectorPtr* vector, size_t size) { - BufferPtr nulls = AlignedBuffer::allocate(bits::nbytes(size), &pool); + BufferPtr nulls = allocateNulls(size, &pool); auto* nullsPtr = nulls->asMutable(); size_t nullCount = 0; - auto offsets = AlignedBuffer::allocate(size, &pool); + auto offsets = allocateOffsets(size, &pool); auto* offsetsPtr = offsets->asMutable(); - auto lengths = AlignedBuffer::allocate(size, &pool); + auto lengths = allocateSizes(size, &pool); auto* lengthsPtr = lengths->asMutable(); size_t childSize = 0; @@ -596,54 +596,53 @@ TEST_F(ColumnWriterStatsTest, Map) { } TEST_F(ColumnWriterStatsTest, Struct) { - auto populateStructBatch = [](MemoryPool& pool, - VectorPtr* vector, - size_t size) { - BufferPtr nulls = AlignedBuffer::allocate(bits::nbytes(size), &pool); - auto* nullsPtr = nulls->asMutable(); - size_t nullCount = 0; - - for (auto i = 0; i < size; i++) { - bool isNull = i & 1; - bits::setNull(nullsPtr, i, isNull); - if (isNull) { - ++nullCount; - } - } + auto populateStructBatch = + [](MemoryPool& pool, VectorPtr* vector, size_t size) { + BufferPtr nulls = allocateNulls(size, &pool); + auto* nullsPtr = nulls->asMutable(); + size_t nullCount = 0; - // set 0 for node 0 and node 1 size and backfill it after computing child - // node sizes. - std::vector nodeSizePerStride = {0, 0}; - std::vector children; - for (auto child = 0; child < 2; child++) { - VectorPtr childVector; - populateFloatBatch(pool, &childVector, size); - children.push_back(childVector); - - size_t floatBatchSize = 0; - for (auto i = 0; i < size; i++) { - // Count only float sizes, when struct is not null. - if (!bits::isBitNull(nullsPtr, i)) { - floatBatchSize += - childVector->isNullAt(i) ? NULL_SIZE : sizeof(float); + for (auto i = 0; i < size; i++) { + bool isNull = i & 1; + bits::setNull(nullsPtr, i, isNull); + if (isNull) { + ++nullCount; + } } - } - nodeSizePerStride.push_back(floatBatchSize); - } - *vector = std::make_shared( - &pool, - CppToType>::create(), - nulls, - size, - children, - nullCount); - nodeSizePerStride.at(0) = - nullCount + nodeSizePerStride.at(2) + nodeSizePerStride.at(3); - nodeSizePerStride.at(1) = - nullCount + nodeSizePerStride.at(2) + nodeSizePerStride.at(3); - return nodeSizePerStride; - }; + // set 0 for node 0 and node 1 size and backfill it after computing + // child node sizes. + std::vector nodeSizePerStride = {0, 0}; + std::vector children; + for (auto child = 0; child < 2; child++) { + VectorPtr childVector; + populateFloatBatch(pool, &childVector, size); + children.push_back(childVector); + + size_t floatBatchSize = 0; + for (auto i = 0; i < size; i++) { + // Count only float sizes, when struct is not null. + if (!bits::isBitNull(nullsPtr, i)) { + floatBatchSize += + childVector->isNullAt(i) ? NULL_SIZE : sizeof(float); + } + } + nodeSizePerStride.push_back(floatBatchSize); + } + *vector = std::make_shared( + &pool, + CppToType>::create(), + nulls, + size, + children, + nullCount); + nodeSizePerStride.at(0) = + nullCount + nodeSizePerStride.at(2) + nodeSizePerStride.at(3); + nodeSizePerStride.at(1) = + nullCount + nodeSizePerStride.at(2) + nodeSizePerStride.at(3); + + return nodeSizePerStride; + }; verifyTypeStats( *pool_, "struct>", diff --git a/velox/dwio/dwrf/test/ColumnWriterTests.cpp b/velox/dwio/dwrf/test/ColumnWriterTests.cpp index d329ea77a5b1..360663d46b22 100644 --- a/velox/dwio/dwrf/test/ColumnWriterTests.cpp +++ b/velox/dwio/dwrf/test/ColumnWriterTests.cpp @@ -197,8 +197,7 @@ VectorPtr populateBatch( BufferPtr values = AlignedBuffer::allocate(data.size(), pool); auto valuesPtr = values->asMutableRange(); - BufferPtr nulls = - AlignedBuffer::allocate(bits::nbytes(data.size()), pool); + BufferPtr nulls = allocateNulls(data.size(), pool); auto* nullsPtr = nulls->asMutable(); size_t index = 0; size_t nullCount = 0; @@ -214,7 +213,12 @@ VectorPtr populateBatch( } auto batch = std::make_shared>( - pool, nulls, data.size(), values, std::vector{}); + pool, + CppToType::create(), + nulls, + data.size(), + values, + std::vector{}); batch->setNullCount(nullCount); return batch; } @@ -1926,8 +1930,7 @@ struct IntegerColumnWriterTypedTestCase { auto pool = getDefaultMemoryPool(); // Prepare input - BufferPtr nulls = - AlignedBuffer::allocate(bits::nbytes(size), pool.get()); + BufferPtr nulls = allocateNulls(size, pool.get()); auto* nullsPtr = nulls->asMutable(); size_t nullCount = 0; @@ -1963,7 +1966,12 @@ struct IntegerColumnWriterTypedTestCase { } auto batch = std::make_shared>( - pool.get(), nulls, size, values, std::vector()); + pool.get(), + CppToType::create(), + nulls, + size, + values, + std::vector()); batch->setNullCount(nullCount); // Set up writer. @@ -3139,7 +3147,7 @@ struct StringColumnWriterTestCase { FlatVectorPtr generateStringSlice( size_t strideIndex, MemoryPool* pool) const { - auto nulls = AlignedBuffer::allocate(bits::nbytes(size), pool); + auto nulls = allocateNulls(size, pool); auto* nullsPtr = nulls->asMutable(); auto values = AlignedBuffer::allocate(size, pool); @@ -3175,7 +3183,7 @@ struct StringColumnWriterTestCase { } auto stringVector = std::make_shared>( - pool, nulls, size, values, std::move(dataChunks)); + pool, VARCHAR(), nulls, size, values, std::move(dataChunks)); stringVector->setNullCount(nullCount); return stringVector; } diff --git a/velox/dwio/dwrf/test/E2EWriterTests.cpp b/velox/dwio/dwrf/test/E2EWriterTests.cpp index b62d6f82f213..0acc24fcfb30 100644 --- a/velox/dwio/dwrf/test/E2EWriterTests.cpp +++ b/velox/dwio/dwrf/test/E2EWriterTests.cpp @@ -733,8 +733,7 @@ TEST(E2EWriterTests, mapStatsMultiStrides) { } TEST(E2EWriterTests, PartialStride) { - HiveTypeParser parser; - auto type = parser.parse("struct"); + auto type = ROW({"bool_val"}, {INTEGER()}); auto pool = memory::getDefaultMemoryPool(); size_t size = 1'000; @@ -748,7 +747,7 @@ TEST(E2EWriterTests, PartialStride) { options.schema = type; Writer writer{options, std::move(sink), *pool}; - auto nulls = AlignedBuffer::allocate(bits::nbytes(size), pool.get()); + auto nulls = allocateNulls(size, pool.get()); auto* nullsPtr = nulls->asMutable(); size_t nullCount = 0; @@ -770,7 +769,12 @@ TEST(E2EWriterTests, PartialStride) { type, size, std::make_shared>( - pool.get(), nulls, size, values, std::vector())); + pool.get(), + type->childAt(0), + nulls, + size, + values, + std::vector())); writer.write(batch); writer.close(); @@ -1224,6 +1228,7 @@ VectorPtr createKeysImpl( auto vector = std::make_shared>( &pool, + CppToType::create(), nullptr, size, AlignedBuffer::allocate(size, &pool), diff --git a/velox/dwio/dwrf/test/FloatColumnWriterBenchmark.cpp b/velox/dwio/dwrf/test/FloatColumnWriterBenchmark.cpp index df1ec3eee943..e0f405248341 100644 --- a/velox/dwio/dwrf/test/FloatColumnWriterBenchmark.cpp +++ b/velox/dwio/dwrf/test/FloatColumnWriterBenchmark.cpp @@ -65,6 +65,7 @@ void runBenchmark(int nullEvery) { vector = std::make_shared>( pool.get(), + REAL(), nullCount == 0 ? nullptr : nulls, kVectorSize, values, diff --git a/velox/dwio/dwrf/test/TestColumnReader.cpp b/velox/dwio/dwrf/test/TestColumnReader.cpp index c5b2cf346e8b..f8f15d13367a 100644 --- a/velox/dwio/dwrf/test/TestColumnReader.cpp +++ b/velox/dwio/dwrf/test/TestColumnReader.cpp @@ -4265,6 +4265,7 @@ TEST_P(TestColumnReader, testPresentStreamChange) { auto pool = &streams_.getMemoryPool(); VectorPtr toReset = std::make_shared>( pool, + INTEGER(), AlignedBuffer::allocate(1, pool), 1, AlignedBuffer::allocate(1, pool), @@ -4315,6 +4316,7 @@ TEST_P(TestColumnReader, testStructVectorTypeChange) { auto pool = &streams_.getMemoryPool(); VectorPtr toReset = std::make_shared>( pool, + REAL(), nullptr, 1, AlignedBuffer::allocate(1, pool), @@ -4370,6 +4372,7 @@ TEST_P(TestColumnReader, testListVectorTypeChange) { auto pool = &streams_.getMemoryPool(); VectorPtr elements = std::make_shared>( pool, + TINYINT(), nullptr, 1, AlignedBuffer::allocate(1, pool), @@ -4450,6 +4453,7 @@ TEST_P(TestColumnReader, testMapVectorTypeChange) { auto pool = &streams_.getMemoryPool(); VectorPtr toReset = std::make_shared>( pool, + TINYINT(), nullptr, 1, AlignedBuffer::allocate(1, pool), diff --git a/velox/dwio/dwrf/test/TestStatisticsBuilderUtils.cpp b/velox/dwio/dwrf/test/TestStatisticsBuilderUtils.cpp index 290287eec4ef..803f940bb04f 100644 --- a/velox/dwio/dwrf/test/TestStatisticsBuilderUtils.cpp +++ b/velox/dwio/dwrf/test/TestStatisticsBuilderUtils.cpp @@ -36,7 +36,12 @@ std::shared_ptr> makeFlatVector( size_t length, BufferPtr values) { return std::make_shared>( - pool, nulls, length, values, std::vector{}); + pool, + CppToType::create(), + nulls, + length, + values, + std::vector{}); } template @@ -47,15 +52,6 @@ std::shared_ptr> makeFlatVectorNoNulls( return makeFlatVector(pool, BufferPtr(nullptr), 0, length, values); } -BufferPtr allocateNulls( - size_t length, - facebook::velox::memory::MemoryPool* pool, - bool defaultValue = false) { - auto numBytes = bits::nbytes(length); - return AlignedBuffer::allocate( - numBytes, pool, defaultValue ? bits::kNullByte : bits::kNotNullByte); -} - TEST(TestStatisticsBuilderUtils, addIntegerValues) { IntegerStatisticsBuilder builder{options}; diff --git a/velox/expression/EvalCtx.cpp b/velox/expression/EvalCtx.cpp index 835fc151db21..1a1c2498375e 100644 --- a/velox/expression/EvalCtx.cpp +++ b/velox/expression/EvalCtx.cpp @@ -127,6 +127,7 @@ void EvalCtx::ensureErrorsVectorSize(ErrorVectorPtr& vector, vector_size_t size) if (!vector) { vector = std::make_shared( pool(), + OpaqueType::create(), AlignedBuffer::allocate(size, pool(), true) /*nulls*/, size /*length*/, AlignedBuffer::allocate( diff --git a/velox/functions/lib/IsNull.cpp b/velox/functions/lib/IsNull.cpp index 3c948776bc66..a0b34e6f7e35 100644 --- a/velox/functions/lib/IsNull.cpp +++ b/velox/functions/lib/IsNull.cpp @@ -30,7 +30,7 @@ class IsNullFunction : public exec::VectorFunction { void apply( const SelectivityVector& rows, std::vector& args, - const TypePtr& /* outputType */, + const TypePtr& /*outputType*/, exec::EvalCtx& context, VectorPtr& result) const override { auto* arg = args[0].get(); @@ -78,7 +78,12 @@ class IsNullFunction : public exec::VectorFunction { } auto localResult = std::make_shared>( - pool, nullptr, rows.size(), isNull, std::vector{}); + pool, + BOOLEAN(), + nullptr, + rows.size(), + isNull, + std::vector{}); context.moveOrCopyResult(localResult, rows, result); } diff --git a/velox/functions/prestosql/Not.cpp b/velox/functions/prestosql/Not.cpp index 6f8202212c18..220a1ad19da1 100644 --- a/velox/functions/prestosql/Not.cpp +++ b/velox/functions/prestosql/Not.cpp @@ -52,6 +52,7 @@ class NotFunction : public exec::VectorFunction { auto localResult = std::make_shared>( context.pool(), + BOOLEAN(), nullptr, rows.size(), negated, diff --git a/velox/functions/prestosql/benchmarks/CardinalityBenchmark.cpp b/velox/functions/prestosql/benchmarks/CardinalityBenchmark.cpp index 8e0c1b01ec58..99c7f84d21d0 100644 --- a/velox/functions/prestosql/benchmarks/CardinalityBenchmark.cpp +++ b/velox/functions/prestosql/benchmarks/CardinalityBenchmark.cpp @@ -43,7 +43,12 @@ VectorPtr fastCardinality(const VectorPtr& vector) { } return std::make_shared>( - vector->pool(), nullptr, numRows, values, std::vector{}); + vector->pool(), + BIGINT(), + nullptr, + numRows, + values, + std::vector{}); } class CardinalityVectorFunction : public exec::VectorFunction { diff --git a/velox/vector/BaseVector.cpp b/velox/vector/BaseVector.cpp index 0c6d1a96e8fb..3257266a2ac5 100644 --- a/velox/vector/BaseVector.cpp +++ b/velox/vector/BaseVector.cpp @@ -345,6 +345,7 @@ VectorPtr BaseVector::createInternal( BufferPtr nulls = AlignedBuffer::allocate(size, pool, bits::kNull); return std::make_shared>( pool, + UNKNOWN(), nulls, size, BufferPtr(nullptr), @@ -355,12 +356,6 @@ VectorPtr BaseVector::createInternal( true /*isSorted*/, 0 /*representedBytes*/); } - case TypeKind::SHORT_DECIMAL: { - return createEmpty(size, pool, type); - } - case TypeKind::LONG_DECIMAL: { - return createEmpty(size, pool, type); - } default: return VELOX_DYNAMIC_SCALAR_TYPE_DISPATCH_ALL( createEmpty, kind, size, pool, type); diff --git a/velox/vector/BiasVector-inl.h b/velox/vector/BiasVector-inl.h index b1624df7cc13..435e8207cbb1 100644 --- a/velox/vector/BiasVector-inl.h +++ b/velox/vector/BiasVector-inl.h @@ -85,6 +85,7 @@ std::unique_ptr> BiasVector::hashAll() const { } return std::make_unique>( BaseVector::pool_, + BIGINT(), BufferPtr(nullptr), BaseVector::length_, hashes, diff --git a/velox/vector/DictionaryVector-inl.h b/velox/vector/DictionaryVector-inl.h index 5706bbebfc58..9f214a5e2b8c 100644 --- a/velox/vector/DictionaryVector-inl.h +++ b/velox/vector/DictionaryVector-inl.h @@ -163,6 +163,7 @@ std::unique_ptr> DictionaryVector::hashAll() const { } return std::make_unique>( BaseVector::pool_, + BIGINT(), BufferPtr(nullptr), BaseVector::length_, hashes, diff --git a/velox/vector/FlatVector-inl.h b/velox/vector/FlatVector-inl.h index cb187bdad6fa..0c560c1148c2 100644 --- a/velox/vector/FlatVector-inl.h +++ b/velox/vector/FlatVector-inl.h @@ -109,6 +109,7 @@ std::unique_ptr> FlatVector::hashAll() const { } return std::make_unique>( BaseVector::pool_, + BIGINT(), BufferPtr(nullptr), BaseVector::length_, std::move(hashBuffer), diff --git a/velox/vector/FlatVector.h b/velox/vector/FlatVector.h index 4eeb16440ba9..4fafa5e2307b 100644 --- a/velox/vector/FlatVector.h +++ b/velox/vector/FlatVector.h @@ -26,8 +26,7 @@ #include "velox/vector/SimpleVector.h" #include "velox/vector/TypeAliases.h" -namespace facebook { -namespace velox { +namespace facebook::velox { // FlatVector is marked final to allow for inlining on virtual methods called // on a pointer that has the static type FlatVector; this can be a @@ -54,33 +53,7 @@ class FlatVector final : public SimpleVector { FlatVector( velox::memory::MemoryPool* pool, - BufferPtr nulls, - size_t length, - BufferPtr values, - std::vector&& stringBuffers, - const SimpleVectorStats& stats = {}, - std::optional distinctValueCount = std::nullopt, - std::optional nullCount = std::nullopt, - std::optional isSorted = std::nullopt, - std::optional representedBytes = std::nullopt, - std::optional storageByteCount = std::nullopt) - : FlatVector( - pool, - CppToType::create(), - std::move(nulls), - length, - values, - std::move(stringBuffers), - stats, - distinctValueCount, - nullCount, - isSorted, - representedBytes, - storageByteCount) {} - - FlatVector( - velox::memory::MemoryPool* pool, - const std::shared_ptr& type, + const TypePtr& type, BufferPtr nulls, size_t length, BufferPtr values, @@ -536,7 +509,6 @@ void FlatVector::prepareForReuse(); template using FlatVectorPtr = std::shared_ptr>; -} // namespace velox -} // namespace facebook +} // namespace facebook::velox #include "velox/vector/FlatVector-inl.h" diff --git a/velox/vector/SequenceVector-inl.h b/velox/vector/SequenceVector-inl.h index bd8f92b3ce1c..0313fb857af7 100644 --- a/velox/vector/SequenceVector-inl.h +++ b/velox/vector/SequenceVector-inl.h @@ -99,6 +99,7 @@ std::unique_ptr> SequenceVector::hashAll() const { } auto hashValues = std::make_shared>( BaseVector::pool_, + BIGINT(), BufferPtr(nullptr), sequenceCount, hashes, diff --git a/velox/vector/tests/DecodedVectorTest.cpp b/velox/vector/tests/DecodedVectorTest.cpp index 410ed2e37cc5..71be47df6a44 100644 --- a/velox/vector/tests/DecodedVectorTest.cpp +++ b/velox/vector/tests/DecodedVectorTest.cpp @@ -1059,11 +1059,11 @@ TEST_F(DecodedVectorTest, noValues) { // Tests decoding a flat vector that consists of all nulls and has // no values() buffer. constexpr vector_size_t kSize = 100; - auto nulls = AlignedBuffer::allocate( - bits::nwords(kSize), pool_.get(), bits::kNull64); + auto vector = std::make_shared>( pool_.get(), - std::move(nulls), + INTEGER(), + allocateNulls(kSize, pool(), bits::kNull), kSize, BufferPtr(nullptr), std::vector{}); diff --git a/velox/vector/tests/VectorTest.cpp b/velox/vector/tests/VectorTest.cpp index 9e28e981a7b9..1985ef3c2cb6 100644 --- a/velox/vector/tests/VectorTest.cpp +++ b/velox/vector/tests/VectorTest.cpp @@ -28,7 +28,6 @@ #include "velox/vector/SimpleVector.h" #include "velox/vector/TypeAliases.h" #include "velox/vector/VectorTypeUtils.h" -#include "velox/vector/tests/utils/VectorMaker.h" #include "velox/vector/tests/utils/VectorTestBase.h" using namespace facebook::velox; @@ -1149,14 +1148,9 @@ TEST_F(VectorTest, unknown) { TEST_F(VectorTest, copyBoolAllNullFlatVector) { const vector_size_t size = 1'000; - BufferPtr nulls = - AlignedBuffer::allocate(size, pool_.get(), bits::kNull); - auto allNulls = std::make_shared>( - pool_.get(), nulls, size, BufferPtr(nullptr), std::vector{}); + auto allNulls = makeAllNullFlatVector(size); - auto vectorMaker = std::make_unique(pool_.get()); - auto copy = vectorMaker->flatVector( - size, [](auto row) { return row % 2 == 0; }); + auto copy = makeFlatVector(size, [](auto row) { return row % 2 == 0; }); // Copy first 10 rows from allNulls. SelectivityVector rows(10); @@ -1174,17 +1168,9 @@ TEST_F(VectorTest, copyBoolAllNullFlatVector) { TEST_F(VectorTest, copyToAllNullsFlatVector) { // Create all-nulls flat vector with values buffer unset. const vector_size_t size = 1'000; - BufferPtr nulls = - AlignedBuffer::allocate(size, pool_.get(), bits::kNull); - auto allNulls = std::make_shared>( - pool_.get(), - nulls, - size, - nullptr /* values buffer */, - std::vector{}); + auto allNulls = makeAllNullFlatVector(size); - auto vectorMaker = std::make_unique(pool_.get()); - auto source = vectorMaker->flatVector({0, 1, 2, 3, 4}); + auto source = makeFlatVector({0, 1, 2, 3, 4}); allNulls->copy(source.get(), 0, 0, 3); @@ -1196,12 +1182,7 @@ TEST_F(VectorTest, copyToAllNullsFlatVector) { } // Reset allNulls vector back to all nulls. - allNulls = std::make_shared>( - pool_.get(), - nulls, - size, - nullptr /* values buffer */, - std::vector{}); + allNulls = makeAllNullFlatVector(size); SelectivityVector rows(4); allNulls->copy(source.get(), rows, nullptr); @@ -1215,12 +1196,10 @@ TEST_F(VectorTest, copyToAllNullsFlatVector) { } TEST_F(VectorTest, wrapInConstant) { - auto vectorMaker = std::make_unique(pool_.get()); - // wrap flat vector const vector_size_t size = 1'000; - auto flatVector = vectorMaker->flatVector( - size, [](auto row) { return row; }, test::VectorMaker::nullEvery(7)); + auto flatVector = makeFlatVector( + size, [](auto row) { return row; }, nullEvery(7)); auto constVector = std::dynamic_pointer_cast>( BaseVector::wrapInConstant(size, 5, flatVector)); @@ -1335,10 +1314,9 @@ TEST_F(VectorTest, setFlatVectorStringView) { } TEST_F(VectorTest, resizeAtConstruction) { - using T = int64_t; const size_t realSize = 10; - vector_size_t oldByteSize = BaseVector::byteSize(realSize); + vector_size_t oldByteSize = BaseVector::byteSize(realSize); BufferPtr values = AlignedBuffer::allocate(oldByteSize, pool_.get()); EXPECT_EQ(oldByteSize, values->size()); @@ -1354,8 +1332,9 @@ TEST_F(VectorTest, resizeAtConstruction) { EXPECT_EQ(curCapacity, values->capacity()); // Now create a FlatVector with the resized buffer. - auto flat = std::make_shared>( + auto flat = std::make_shared>( pool_.get(), + BIGINT(), BufferPtr(nullptr), realSize, std::move(values), @@ -1366,9 +1345,8 @@ TEST_F(VectorTest, resizeAtConstruction) { } TEST_F(VectorTest, resizeStringAsciiness) { - auto vectorMaker = std::make_unique(pool_.get()); std::vector stringInput = {"hellow", "how", "are"}; - auto flatVector = vectorMaker->flatVector(stringInput); + auto flatVector = makeFlatVector(stringInput); auto stringVector = flatVector->as>(); SelectivityVector rows(stringInput.size()); stringVector->computeAndSetIsAscii(rows); @@ -1378,16 +1356,15 @@ TEST_F(VectorTest, resizeStringAsciiness) { } TEST_F(VectorTest, copyNoRows) { - auto maker = std::make_unique(pool_.get()); { - auto source = maker->flatVectorNullable({1, 2, 3}); + auto source = makeFlatVector({1, 2, 3}); auto target = BaseVector::create(INTEGER(), 10, pool_.get()); SelectivityVector rows(3, false); target->copy(source.get(), rows, nullptr); } { - auto source = maker->flatVectorNullable({"a", "b", "c"}); + auto source = makeFlatVector({"a", "b", "c"}); auto target = BaseVector::create(VARCHAR(), 10, pool_.get()); SelectivityVector rows(3, false); target->copy(source.get(), rows, nullptr); @@ -1395,13 +1372,12 @@ TEST_F(VectorTest, copyNoRows) { } TEST_F(VectorTest, copyAscii) { - auto maker = std::make_unique(pool_.get()); std::vector stringData = {"a", "b", "c"}; - auto source = maker->flatVector(stringData); + auto source = makeFlatVector(stringData); SelectivityVector all(stringData.size()); source->setAllIsAscii(true); - auto other = maker->flatVector(stringData); + auto other = makeFlatVector(stringData); other->copy(source.get(), all, nullptr); auto ascii = other->isAscii(all); ASSERT_TRUE(ascii.has_value()); @@ -1424,8 +1400,7 @@ TEST_F(VectorTest, copyAscii) { ascii = other->isAscii(all); ASSERT_FALSE(ascii.has_value()); - std::vector moreData = {"a", "b", "c", "d"}; - auto largerSource = maker->flatVector(moreData); + auto largerSource = makeFlatVector({"a", "b", "c", "d"}); vector_size_t sourceMappings[] = {3, 2, 1, 0}; some.setAll(); some.setValid(0, false); @@ -1440,14 +1415,12 @@ TEST_F(VectorTest, copyAscii) { } TEST_F(VectorTest, compareNan) { - auto vectorMaker = std::make_unique(pool_.get()); - // Double input. { std::vector doubleInput = {1.1, std::nan("nan"), 0.9}; - auto flatVector1 = vectorMaker->flatVector(doubleInput); - auto flatVector2 = vectorMaker->flatVector(doubleInput); + auto flatVector1 = makeFlatVector(doubleInput); + auto flatVector2 = makeFlatVector(doubleInput); for (size_t i = 0; i < doubleInput.size(); ++i) { EXPECT_TRUE(flatVector1->equalValueAt(flatVector2.get(), i, i)); @@ -1458,8 +1431,8 @@ TEST_F(VectorTest, compareNan) { { std::vector floatInput = {1.1, std::nanf("nan"), 0.9}; - auto flatVector1 = vectorMaker->flatVector(floatInput); - auto flatVector2 = vectorMaker->flatVector(floatInput); + auto flatVector1 = makeFlatVector(floatInput); + auto flatVector2 = makeFlatVector(floatInput); for (size_t i = 0; i < floatInput.size(); ++i) { EXPECT_TRUE(flatVector1->equalValueAt(flatVector2.get(), i, i)); @@ -1590,33 +1563,22 @@ TEST_F(VectorCreateConstantTest, scalar) { } TEST_F(VectorCreateConstantTest, complex) { - { - auto type = ARRAY(INTEGER()); - test::VectorMaker maker{pool_.get()}; - testComplexConstant( - type, - maker.arrayVector( - 1, [](auto) { return 10; }, [](auto i) { return i; })); - } - { - auto type = MAP(INTEGER(), REAL()); - test::VectorMaker maker{pool_.get()}; - testComplexConstant( - type, - maker.mapVector( - 1, - [](auto) { return 10; }, - [](auto i) { return i; }, - [](auto i) { return i; })); - } - { - auto type = ROW({{"c0", INTEGER()}}); - test::VectorMaker maker{pool_.get()}; - testComplexConstant( - type, maker.rowVector({maker.flatVector(1, [](auto i) { - return i; - })})); - } + testComplexConstant( + ARRAY(INTEGER()), + makeArrayVector( + 1, [](auto) { return 10; }, [](auto i) { return i; })); + + testComplexConstant( + MAP(INTEGER(), REAL()), + makeMapVector( + 1, + [](auto) { return 10; }, + [](auto i) { return i; }, + [](auto i) { return i; })); + + testComplexConstant( + ROW({{"c0", INTEGER()}}), + makeRowVector({makeFlatVector(1, [](auto i) { return i; })})); } TEST_F(VectorCreateConstantTest, null) { @@ -1755,8 +1717,7 @@ TEST_F(VectorTest, clearNulls) { TEST_F(VectorTest, setStringToNull) { constexpr int32_t kSize = 100; - auto vectorMaker = std::make_unique(pool_.get()); - auto target = vectorMaker->flatVector( + auto target = makeFlatVector( kSize, [](auto /*row*/) { return StringView("Non-inlined string"); }); target->setNull(kSize - 1, true); auto unknownNull = std::make_shared>( @@ -1776,7 +1737,12 @@ TEST_F(VectorTest, setStringToNull) { auto nulls = AlignedBuffer::allocate( bits::nwords(kSize), pool_.get(), bits::kNull64); auto flatNulls = std::make_shared>( - pool_.get(), nulls, kSize, BufferPtr(nullptr), std::vector()); + pool_.get(), + UNKNOWN(), + nulls, + kSize, + BufferPtr(nullptr), + std::vector()); rows.setValid(6, true); rows.updateBounds(); target->copy(flatNulls.get(), rows, nullptr); @@ -1800,24 +1766,22 @@ TEST_F(VectorTest, clearAllNulls) { } TEST_F(VectorTest, constantSetNull) { - auto vectorMaker = std::make_unique(pool_.get()); - auto vector = vectorMaker->constantVector({{0}}); + auto vector = makeConstant(123, 10); - EXPECT_THROW(vector->setNull(0, true), VeloxRuntimeError); + VELOX_ASSERT_THROW( + vector->setNull(0, true), "setNull not supported on ConstantVector"); } /// Test lazy vector wrapped in multiple layers of dictionaries. TEST_F(VectorTest, multipleDictionariesOverLazy) { - auto vectorMaker = std::make_unique(pool_.get()); - vector_size_t size = 10; auto indices = makeIndices(size, [&](auto row) { return size - row - 1; }); auto lazy = std::make_shared( pool_.get(), INTEGER(), size, - std::make_unique(vectorMaker->flatVector( - size, [](auto row) { return row; }))); + std::make_unique( + makeFlatVector(size, [](auto row) { return row; }))); auto dict = BaseVector::wrapInDictionary( nullptr, @@ -1832,13 +1796,10 @@ TEST_F(VectorTest, multipleDictionariesOverLazy) { /// Test lazy loading of nested dictionary vector TEST_F(VectorTest, selectiveLoadingOfLazyDictionaryNested) { - auto vectorMaker = std::make_unique(pool_.get()); - vector_size_t size = 10; auto indices = makeIndices(size, [&](auto row) { return (row % 2 == 0) ? row : 0; }); - auto data = - vectorMaker->flatVector(size, [](auto row) { return row; }); + auto data = makeFlatVector(size, [](auto row) { return row; }); auto loader = std::make_unique(data); auto loaderPtr = loader.get(); @@ -1900,7 +1861,6 @@ TEST_F(VectorTest, nestedLazy) { } TEST_F(VectorTest, dictionaryResize) { - auto vectorMaker = std::make_unique(pool_.get()); vector_size_t size = 10; std::vector elements{0, 1, 2, 3, 4}; auto makeIndicesFn = [&]() {