MCPcopy Index your code
hub / github.com/apache/orc / processFile

Function processFile

tools/src/FileMemory.cc:59–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57TestMemoryPool::~TestMemoryPool() {}
58
59void processFile(const char* filename, const orc::RowReaderOptions& rowReaderOpts,
60 uint64_t batchSize) {
61 orc::ReaderOptions readerOpts;
62 std::unique_ptr<orc::MemoryPool> pool(new TestMemoryPool());
63 readerOpts.setMemoryPool(*(pool.get()));
64
65 std::unique_ptr<orc::Reader> reader = orc::createReader(
66 orc::readFile(std::string(filename), readerOpts.getReaderMetrics()), readerOpts);
67 std::unique_ptr<orc::RowReader> rowReader = reader->createRowReader(rowReaderOpts);
68
69 std::unique_ptr<orc::ColumnVectorBatch> batch = rowReader->createRowBatch(batchSize);
70 uint64_t readerMemory;
71 if (rowReaderOpts.getIndexesSet()) {
72 readerMemory = reader->getMemoryUseByFieldId(rowReaderOpts.getInclude());
73 } else if (rowReaderOpts.getNamesSet()) {
74 readerMemory = reader->getMemoryUseByName(rowReaderOpts.getIncludeNames());
75 } else if (rowReaderOpts.getTypeIdsSet()) {
76 readerMemory = reader->getMemoryUseByTypeId(rowReaderOpts.getInclude());
77 } else {
78 // default is to select all columns
79 readerMemory = reader->getMemoryUseByName({});
80 }
81
82 uint64_t batchMemory = batch->getMemoryUsage();
83 while (rowReader->next(*batch)) {
84 }
85 uint64_t actualMemory = static_cast<TestMemoryPool*>(pool.get())->getMaxMemory();
86 std::cout << "Reader memory estimate: " << readerMemory << "\nBatch memory estimate: ";
87 if (batch->hasVariableLength()) {
88 std::cout << "Cannot estimate because reading ARRAY or MAP columns";
89 } else {
90 std::cout << batchMemory << "\nTotal memory estimate: " << readerMemory + batchMemory;
91 }
92 std::cout << "\nActual max memory used: " << actualMemory << "\n";
93}
94
95int main(int argc, char* argv[]) {
96 uint64_t batchSize = 1000;

Callers 1

mainFunction · 0.85

Calls 15

readFileFunction · 0.85
getIndexesSetMethod · 0.80
getMemoryUseByFieldIdMethod · 0.80
getIncludeMethod · 0.80
getNamesSetMethod · 0.80
getMemoryUseByNameMethod · 0.80
getTypeIdsSetMethod · 0.80
getMemoryUseByTypeIdMethod · 0.80
getMaxMemoryMethod · 0.80
hasVariableLengthMethod · 0.80
nextMethod · 0.65
createReaderFunction · 0.50

Tested by

no test coverage detected