MCPcopy Create free account
hub / github.com/apache/orc / testSetOutputBufferCapacity

Function testSetOutputBufferCapacity

c++/test/TestWriter.cc:2004–2053  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2002 }
2003
2004 void testSetOutputBufferCapacity(uint64_t capacity) {
2005 MemoryOutputStream memStream(DEFAULT_MEM_STREAM_SIZE);
2006 MemoryPool* pool = getDefaultPool();
2007 size_t rowCount = 1000;
2008 {
2009 auto type = std::unique_ptr<Type>(Type::buildTypeFromString("struct<col1:int,col2:int>"));
2010 WriterOptions options;
2011 options.setStripeSize(1024 * 1024)
2012 .setCompressionBlockSize(64 * 1024)
2013 .setMemoryBlockSize(1024)
2014 .setCompression(CompressionKind_NONE)
2015 .setMemoryPool(pool)
2016 .setRowIndexStride(1000)
2017 .setCompressionBlockSize(capacity);
2018
2019 auto writer = createWriter(*type, &memStream, options);
2020 auto batch = writer->createRowBatch(rowCount);
2021 auto& structBatch = dynamic_cast<StructVectorBatch&>(*batch);
2022 auto& longBatch1 = dynamic_cast<LongVectorBatch&>(*structBatch.fields[0]);
2023 auto& longBatch2 = dynamic_cast<LongVectorBatch&>(*structBatch.fields[1]);
2024 structBatch.numElements = rowCount;
2025 longBatch1.numElements = rowCount;
2026 longBatch2.numElements = rowCount;
2027 for (size_t i = 0; i < rowCount; ++i) {
2028 longBatch1.data[i] = static_cast<int64_t>(i * 100);
2029 longBatch2.data[i] = static_cast<int64_t>(i * 300);
2030 }
2031 writer->add(*batch);
2032 writer->close();
2033 }
2034 // read orc file & check the data
2035 {
2036 std::unique_ptr<InputStream> inStream(
2037 new MemoryInputStream(memStream.getData(), memStream.getLength()));
2038 ReaderOptions readerOptions;
2039 readerOptions.setMemoryPool(*pool);
2040 std::unique_ptr<Reader> reader = createReader(std::move(inStream), readerOptions);
2041 std::unique_ptr<RowReader> rowReader = createRowReader(reader.get());
2042 auto batch = rowReader->createRowBatch(rowCount);
2043 EXPECT_TRUE(rowReader->next(*batch));
2044 EXPECT_EQ(rowCount, batch->numElements);
2045 auto& structBatch = dynamic_cast<StructVectorBatch&>(*batch);
2046 auto& longBatch1 = dynamic_cast<LongVectorBatch&>(*structBatch.fields[0]);
2047 auto& longBatch2 = dynamic_cast<LongVectorBatch&>(*structBatch.fields[1]);
2048 for (size_t i = 0; i < rowCount; ++i) {
2049 EXPECT_EQ(longBatch1.data[i], static_cast<int64_t>(i * 100));
2050 EXPECT_EQ(longBatch2.data[i], static_cast<int64_t>(i * 300));
2051 }
2052 }
2053 }
2054
2055 TEST(WriterTest, setOutputBufferCapacity) {
2056 // compression block size > output buffer capacity

Callers 1

TESTFunction · 0.85

Calls 11

getDefaultPoolFunction · 0.85
createWriterFunction · 0.70
createReaderFunction · 0.70
createRowReaderFunction · 0.70
addMethod · 0.65
closeMethod · 0.65
getLengthMethod · 0.65
nextMethod · 0.65
createRowBatchMethod · 0.45
getDataMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected