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

Function printStatistics

tools/src/FileStatistics.cc:27–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

25#include <string>
26
27void printStatistics(const char* filename, bool withIndex) {
28 orc::ReaderOptions opts;
29 std::unique_ptr<orc::Reader> reader;
30 reader = orc::createReader(orc::readFile(std::string(filename), opts.getReaderMetrics()), opts);
31 // print out all selected columns statistics.
32 std::unique_ptr<orc::Statistics> colStats = reader->getStatistics();
33 std::cout << "File " << filename << " has " << colStats->getNumberOfColumns() << " columns"
34 << std::endl;
35 for (uint32_t i = 0; i < colStats->getNumberOfColumns(); ++i) {
36 std::cout << "*** Column " << i << " ***" << std::endl;
37 std::cout << colStats->getColumnStatistics(i)->toString() << std::endl;
38 }
39
40 // test stripe statistics
41 std::unique_ptr<orc::StripeStatistics> stripeStats;
42 std::cout << "File " << filename << " has " << reader->getNumberOfStripes() << " stripes"
43 << std::endl;
44 if (reader->getNumberOfStripeStatistics() == 0) {
45 std::cout << "File " << filename << " doesn't have stripe statistics" << std::endl;
46 } else {
47 for (unsigned int j = 0; j < reader->getNumberOfStripeStatistics(); j++) {
48 stripeStats = reader->getStripeStatistics(j);
49 std::cout << "*** Stripe " << j << " ***" << std::endl << std::endl;
50
51 for (unsigned int k = 0; k < stripeStats->getNumberOfColumns(); ++k) {
52 std::cout << "--- Column " << k << " ---" << std::endl;
53 std::cout << stripeStats->getColumnStatistics(k)->toString() << std::endl;
54 if (withIndex) {
55 for (unsigned int r = 0; r < stripeStats->getNumberOfRowIndexStats(k); ++r) {
56 std::cout << "--- RowIndex " << r << " ---" << std::endl;
57 std::cout << stripeStats->getRowIndexStatistics(k, r)->toString() << std::endl;
58 }
59 }
60 }
61 }
62 }
63}
64
65int main(int argc, char* argv[]) {
66 static struct option longOptions[] = {{"help", no_argument, nullptr, 'h'},

Callers 1

mainFunction · 0.85

Calls 12

readFileFunction · 0.85
getNumberOfStripesMethod · 0.80
getStatisticsMethod · 0.65
getStripeStatisticsMethod · 0.65
createReaderFunction · 0.50
getReaderMetricsMethod · 0.45
getNumberOfColumnsMethod · 0.45
toStringMethod · 0.45
getColumnStatisticsMethod · 0.45
getRowIndexStatisticsMethod · 0.45

Tested by

no test coverage detected