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

Function writeToOutputStream

c++/test/TestBlockBuffer.cc:84–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82 }
83
84 void writeToOutputStream(uint64_t blockSize) {
85 MemoryOutputStream outputStream(DEFAULT_MEM_STREAM_SIZE);
86 MemoryPool* pool = getDefaultPool();
87 BlockBuffer buffer(*pool, blockSize);
88 uint64_t totalBufferSize = 10240;
89 while (buffer.size() < totalBufferSize) {
90 BlockBuffer::Block block = buffer.getNextBlock();
91 uint64_t blockNumber = buffer.getBlockNumber();
92 for (uint64_t j = 0; j < block.size; ++j) {
93 if (blockNumber % 2 == 0) {
94 block.data[j] = static_cast<char>('A' + (blockNumber + j) % 26);
95 } else {
96 block.data[j] = static_cast<char>('a' + (blockNumber + j) % 26);
97 }
98 }
99 }
100 buffer.resize(totalBufferSize);
101 // flush data buffer into output stream
102 buffer.writeTo(&outputStream, nullptr);
103 // verify data buffer
104 uint64_t dataIndex = 0;
105 for (uint64_t i = 0; i < buffer.getBlockNumber(); ++i) {
106 BlockBuffer::Block block = buffer.getBlock(i);
107 for (uint64_t j = 0; j < block.size; ++j) {
108 EXPECT_EQ(outputStream.getData()[dataIndex++], block.data[j]);
109 }
110 }
111 }
112
113 TEST(TestBlockBuffer, write_to) {
114 // test block size < natural write size

Callers 1

TESTFunction · 0.85

Calls 8

getDefaultPoolFunction · 0.85
getNextBlockMethod · 0.80
getBlockNumberMethod · 0.80
getBlockMethod · 0.80
sizeMethod · 0.65
writeToMethod · 0.65
resizeMethod · 0.45
getDataMethod · 0.45

Tested by

no test coverage detected