You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@orc.apache.org by om...@apache.org on 2017/05/16 16:27:11 UTC

orc git commit: ORC-173: Expose indexes as part of the C++ API.

Repository: orc
Updated Branches:
  refs/heads/master 77ed66829 -> 02055f733


ORC-173: Expose indexes as part of the C++ API.

Fixes #111

Signed-off-by: Owen O'Malley <om...@apache.org>


Project: http://git-wip-us.apache.org/repos/asf/orc/repo
Commit: http://git-wip-us.apache.org/repos/asf/orc/commit/02055f73
Tree: http://git-wip-us.apache.org/repos/asf/orc/tree/02055f73
Diff: http://git-wip-us.apache.org/repos/asf/orc/diff/02055f73

Branch: refs/heads/master
Commit: 02055f733234fa507a27198cc8ef20218dc573c8
Parents: 77ed668
Author: Deepak Majeti <de...@hpe.com>
Authored: Tue Apr 18 16:59:44 2017 -0400
Committer: Owen O'Malley <om...@apache.org>
Committed: Tue May 16 09:26:22 2017 -0700

----------------------------------------------------------------------
 c++/include/orc/Reader.hh                     |   2 +-
 c++/include/orc/Statistics.hh                 |  19 ++++++
 c++/src/Reader.cc                             |  65 ++++++++++++++++++---
 c++/src/Reader.hh                             |  23 +++++++-
 c++/src/Statistics.cc                         |  26 ++++++++-
 c++/src/Statistics.hh                         |  40 ++++++++++++-
 c++/test/CMakeLists.txt                       |   3 +-
 c++/test/TestStripeIndexStatistics.cc         |  63 ++++++++++++++++++++
 c++/test/TestTimestampStatistics.cc           |   2 +-
 examples/expected/orc_index_int_string.jsn.gz | Bin 0 -> 26554 bytes
 examples/orc_index_int_string.orc             | Bin 0 -> 11451 bytes
 tools/src/FileStatistics.cc                   |  57 +++++++++++++++---
 tools/test/TestMatch.cc                       |  11 ++++
 13 files changed, 288 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/orc/blob/02055f73/c++/include/orc/Reader.hh
----------------------------------------------------------------------
diff --git a/c++/include/orc/Reader.hh b/c++/include/orc/Reader.hh
index 3912bd7..077b4ce 100644
--- a/c++/include/orc/Reader.hh
+++ b/c++/include/orc/Reader.hh
@@ -325,7 +325,7 @@ namespace orc {
      * @param stripeIndex the stripe 0 to N-1 to get statistics about
      * @return the statistics about that stripe
      */
-    virtual ORC_UNIQUE_PTR<Statistics>
+    virtual ORC_UNIQUE_PTR<StripeStatistics>
     getStripeStatistics(uint64_t stripeIndex) const = 0;
 
     /**

http://git-wip-us.apache.org/repos/asf/orc/blob/02055f73/c++/include/orc/Statistics.hh
----------------------------------------------------------------------
diff --git a/c++/include/orc/Statistics.hh b/c++/include/orc/Statistics.hh
index 9643ec6..d6bc05a 100644
--- a/c++/include/orc/Statistics.hh
+++ b/c++/include/orc/Statistics.hh
@@ -367,6 +367,25 @@ namespace orc {
     virtual uint32_t getNumberOfColumns() const = 0;
   };
 
+  class StripeStatistics : public Statistics {
+  public:
+    virtual ~StripeStatistics();
+
+    /**
+     * Get the RowIndex statistics of a column id.
+     * @return one stripe RowIndex statistics
+     */
+    virtual const ColumnStatistics*
+                      getRowIndexStatistics(
+                          uint32_t columnId, uint32_t IndexId) const = 0;
+
+    /**
+     * Get the number of RowIndexes
+     * @return the number of RowIndex Statistics
+     */
+    virtual uint32_t getNumberOfRowIndexStats(uint32_t columnId) const = 0;
+  };
+
 
 }
 

http://git-wip-us.apache.org/repos/asf/orc/blob/02055f73/c++/src/Reader.cc
----------------------------------------------------------------------
diff --git a/c++/src/Reader.cc b/c++/src/Reader.cc
index fe8608a..18a2910 100644
--- a/c++/src/Reader.cc
+++ b/c++/src/Reader.cc
@@ -35,6 +35,11 @@
 
 namespace orc {
 
+  const WriterVersionImpl &WriterVersionImpl::VERSION_HIVE_8732() {
+    static const WriterVersionImpl version(WriterVersion_HIVE_8732);
+    return version;
+  }
+
   uint64_t getCompressionBlockSize(const proto::PostScript& ps) {
     if (ps.has_compressionblocksize()) {
       return ps.compressionblocksize();
@@ -111,7 +116,8 @@ namespace orc {
     }
   }
 
-  void ColumnSelector::updateSelected(std::vector<bool>& selectedColumns, const RowReaderOptions& options) {
+  void ColumnSelector::updateSelected(std::vector<bool>& selectedColumns,
+                                      const RowReaderOptions& options) {
     selectedColumns.assign(static_cast<size_t>(contents->footer->types_size()), false);
     if (contents->schema->getKind() == STRUCT && options.getIndexesSet()) {
       for(std::list<uint64_t>::const_iterator field = options.getInclude().begin();
@@ -136,7 +142,8 @@ namespace orc {
     selectedColumns[0] = true; // column 0 is selected by default
   }
 
-  void ColumnSelector::updateSelectedByFieldId(std::vector<bool>& selectedColumns, uint64_t fieldId) {
+  void ColumnSelector::updateSelectedByFieldId(std::vector<bool>& selectedColumns,
+                                               uint64_t fieldId) {
     if (fieldId < contents->schema->getSubtypeCount()) {
       selectChildren(selectedColumns, *contents->schema->getSubtype(fieldId));
     } else {
@@ -159,7 +166,8 @@ namespace orc {
     }
   }
 
-  void ColumnSelector::updateSelectedByName(std::vector<bool>& selectedColumns, const std::string& fieldName) {
+  void ColumnSelector::updateSelectedByName(std::vector<bool>& selectedColumns,
+                                            const std::string& fieldName) {
     std::map<std::string, uint64_t>::const_iterator ite = nameIdMap.find(fieldName);
     if (ite != nameIdMap.end()) {
       updateSelectedByTypeId(selectedColumns, ite->second);
@@ -463,6 +471,40 @@ namespace orc {
     throw std::range_error("key not found");
   }
 
+  void ReaderImpl::getRowIndexStatistics(
+           uint64_t stripeOffset, const proto::StripeFooter& currentStripeFooter,
+           std::vector<std::vector<proto::ColumnStatistics> >* indexStats) const {
+    int num_streams = currentStripeFooter.streams_size();
+    uint64_t offset = stripeOffset;
+    for (int i = 0; i < num_streams; i++) {
+      const proto::Stream& stream = currentStripeFooter.streams(i);
+      uint64_t length = static_cast<uint64_t>(stream.length());
+      if (static_cast<StreamKind>(stream.kind()) == StreamKind::StreamKind_ROW_INDEX) {
+        std::unique_ptr<SeekableInputStream> pbStream =
+          createDecompressor(contents->compression,
+                  std::unique_ptr<SeekableInputStream>
+                  (new SeekableFileInputStream(contents->stream.get(),
+                                                offset,
+                                                length,
+                                                *contents->pool)),
+                  contents->blockSize,
+                  *(contents->pool));
+
+        proto::RowIndex rowIndex;
+        if (!rowIndex.ParseFromZeroCopyStream(pbStream.get())) {
+          throw ParseError("Failed to parse RowIndex from stripe footer");
+        }
+        int num_entries = rowIndex.entry_size();
+        size_t column = static_cast<size_t>(stream.column());
+        for (int j = 0; j < num_entries; j++) {
+          const proto::RowIndexEntry& entry = rowIndex.entry(j);
+          (*indexStats)[column].push_back(entry.statistics());
+        }
+      }
+      offset += length;
+    }
+  }
+
   bool ReaderImpl::hasMetadataValue(const std::string& key) const {
     for(int i=0; i < footer->metadata_size(); ++i) {
       if (footer->metadata(i).name() == key) {
@@ -476,7 +518,7 @@ namespace orc {
     return *(contents->schema.get());
   }
 
-  std::unique_ptr<Statistics>
+  std::unique_ptr<StripeStatistics>
   ReaderImpl::getStripeStatistics(uint64_t stripeIndex) const {
     if (!isMetadataLoaded) {
       readMetadata();
@@ -484,19 +526,26 @@ namespace orc {
     if (metadata.get() == nullptr) {
       throw std::logic_error("No stripe statistics in file");
     }
+    size_t num_cols = static_cast<size_t>(
+                          metadata->stripestats(
+                              static_cast<int>(stripeIndex)).colstats_size());
+    std::vector<std::vector<proto::ColumnStatistics> > indexStats(num_cols);
+
     proto::StripeInformation currentStripeInfo =
         footer->stripes(static_cast<int>(stripeIndex));
     proto::StripeFooter currentStripeFooter =
         getStripeFooter(currentStripeInfo, *contents.get());
 
+    getRowIndexStatistics(currentStripeInfo.offset(), currentStripeFooter, &indexStats);
+
     const Timezone& writerTZ =
       currentStripeFooter.has_writertimezone() ?
         getTimezoneByName(currentStripeFooter.writertimezone()) :
         getLocalTimezone();
     StatContext statContext(hasCorrectStatistics(), &writerTZ);
-    return std::unique_ptr<Statistics>
-      (new StatisticsImpl(metadata->stripestats
-                          (static_cast<int>(stripeIndex)), statContext));
+    return std::unique_ptr<StripeStatistics>
+           (new StripeStatisticsImpl(metadata->stripestats(static_cast<int>(stripeIndex)),
+                                                   indexStats, statContext));
   }
 
   std::unique_ptr<Statistics> ReaderImpl::getStatistics() const {
@@ -540,7 +589,7 @@ namespace orc {
   }
 
   bool ReaderImpl::hasCorrectStatistics() const {
-    return getWriterVersion() != WriterVersion_ORIGINAL;
+    return !WriterVersionImpl::VERSION_HIVE_8732().compareGT(getWriterVersion());
   }
 
   void ReaderImpl::checkOrcVersion() {

http://git-wip-us.apache.org/repos/asf/orc/blob/02055f73/c++/src/Reader.hh
----------------------------------------------------------------------
diff --git a/c++/src/Reader.hh b/c++/src/Reader.hh
index 02f2260..837d831 100644
--- a/c++/src/Reader.hh
+++ b/c++/src/Reader.hh
@@ -33,6 +33,24 @@ namespace orc {
   static const uint64_t DIRECTORY_SIZE_GUESS = 16 * 1024;
 
   /**
+  * WriterVersion Implementation
+  */
+  class WriterVersionImpl {
+  private:
+    WriterVersion version;
+  public:
+    // Known Versions with issues resolved
+    // The static method below is to fix global constructors Clang warning
+    static const WriterVersionImpl& VERSION_HIVE_8732();
+
+    WriterVersionImpl(WriterVersion ver) : version(ver) {}
+
+    bool compareGT(const WriterVersion other) const {
+      return version > other;
+    }
+  };
+
+  /**
   * State shared between Reader and Row Reader
   */
   struct FileContents {
@@ -172,6 +190,9 @@ namespace orc {
     // internal methods
     void readMetadata() const;
     void checkOrcVersion();
+    void getRowIndexStatistics(uint64_t stripeOffset,
+                               const proto::StripeFooter& currentStripeFooter,
+                               std::vector<std::vector<proto::ColumnStatistics> >* indexStats) const;
 
     // metadata
     mutable std::unique_ptr<proto::Metadata> metadata;
@@ -218,7 +239,7 @@ namespace orc {
 
     const std::string& getStreamName() const override;
 
-    std::unique_ptr<Statistics>
+    std::unique_ptr<StripeStatistics>
     getStripeStatistics(uint64_t stripeIndex) const override;
 
     std::unique_ptr<RowReader> createRowReader() const override;

http://git-wip-us.apache.org/repos/asf/orc/blob/02055f73/c++/src/Statistics.cc
----------------------------------------------------------------------
diff --git a/c++/src/Statistics.cc b/c++/src/Statistics.cc
index 54da928..9bbc3f1 100644
--- a/c++/src/Statistics.cc
+++ b/c++/src/Statistics.cc
@@ -47,7 +47,8 @@ namespace orc {
     }
   }
 
-  StatisticsImpl::StatisticsImpl(const proto::StripeStatistics& stripeStats, const StatContext& statContext) {
+  StatisticsImpl::StatisticsImpl(const proto::StripeStatistics& stripeStats,
+                                 const StatContext& statContext) {
     for(int i = 0; i < stripeStats.colstats_size(); i++) {
       colStats.push_back(convertColumnStatistics(stripeStats.colstats(i), statContext));
     }
@@ -71,6 +72,29 @@ namespace orc {
     // PASS
   }
 
+  StripeStatistics::~StripeStatistics() {
+    // PASS
+  }
+
+  StripeStatisticsImpl::~StripeStatisticsImpl() {
+    // PASS
+  }
+
+  StripeStatisticsImpl::StripeStatisticsImpl(const proto::StripeStatistics& stripeStats,
+                                 std::vector<std::vector<proto::ColumnStatistics> >& indexStats,
+                                 const StatContext& statContext) {
+    columnStats.reset(new StatisticsImpl(stripeStats, statContext));
+    rowIndexStats.resize(indexStats.size());
+    for(size_t i = 0; i < rowIndexStats.size(); i++) {
+      for(size_t j = 0; j < indexStats[i].size(); j++) {
+        rowIndexStats[i].push_back(
+            std::shared_ptr<const ColumnStatistics>(
+                convertColumnStatistics(indexStats[i][j], statContext)));
+      }
+    }
+  }
+
+
   ColumnStatistics::~ColumnStatistics() {
     // PASS
   }

http://git-wip-us.apache.org/repos/asf/orc/blob/02055f73/c++/src/Statistics.hh
----------------------------------------------------------------------
diff --git a/c++/src/Statistics.hh b/c++/src/Statistics.hh
index de9c9f3..3a5996b 100644
--- a/c++/src/Statistics.hh
+++ b/c++/src/Statistics.hh
@@ -657,7 +657,8 @@ namespace orc {
     StatisticsImpl& operator=(const StatisticsImpl&);
 
   public:
-    StatisticsImpl(const proto::StripeStatistics& stripeStats, const StatContext& statContext);
+    StatisticsImpl(const proto::StripeStatistics& stripeStats,
+                   const StatContext& statContext);
 
     StatisticsImpl(const proto::Footer& footer, const StatContext& statContext);
 
@@ -675,6 +676,43 @@ namespace orc {
     }
   };
 
+  class StripeStatisticsImpl: public StripeStatistics {
+  private:
+    std::unique_ptr<StatisticsImpl> columnStats;
+    std::vector<std::vector<std::shared_ptr<const ColumnStatistics> > > rowIndexStats;
+
+    // DELIBERATELY NOT IMPLEMENTED
+    StripeStatisticsImpl(const StripeStatisticsImpl&);
+    StripeStatisticsImpl& operator=(const StripeStatisticsImpl&);
+
+  public:
+    StripeStatisticsImpl(const proto::StripeStatistics& stripeStats,
+                   std::vector<std::vector<proto::ColumnStatistics> >& indexStats,
+                   const StatContext& statContext);
+
+    virtual const ColumnStatistics* getColumnStatistics(uint32_t columnId
+                                                        ) const override {
+      return columnStats->getColumnStatistics(columnId);
+    }
+
+    uint32_t getNumberOfColumns() const override {
+      return columnStats->getNumberOfColumns();
+    }
+
+    virtual const ColumnStatistics* getRowIndexStatistics(uint32_t columnId, uint32_t rowIndex
+                                                        ) const override {
+      // check id indices are valid
+      return rowIndexStats[columnId][rowIndex].get();
+    }
+
+    virtual ~StripeStatisticsImpl();
+
+    uint32_t getNumberOfRowIndexStats(uint32_t columnId) const override {
+      return static_cast<uint32_t>(rowIndexStats[columnId].size());
+    }
+  };
+
+
 }// namespace
 
 #endif

http://git-wip-us.apache.org/repos/asf/orc/blob/02055f73/c++/test/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/c++/test/CMakeLists.txt b/c++/test/CMakeLists.txt
index 83c48a3..29f5f6c 100644
--- a/c++/test/CMakeLists.txt
+++ b/c++/test/CMakeLists.txt
@@ -31,8 +31,9 @@ add_executable (orc-test
   TestInt128.cc
   TestReader.cc
   TestRle.cc
-  TestTimezone.cc
+  TestStripeIndexStatistics.cc
   TestTimestampStatistics.cc
+  TestTimezone.cc
   TestType.cc
 )
 

http://git-wip-us.apache.org/repos/asf/orc/blob/02055f73/c++/test/TestStripeIndexStatistics.cc
----------------------------------------------------------------------
diff --git a/c++/test/TestStripeIndexStatistics.cc b/c++/test/TestStripeIndexStatistics.cc
new file mode 100644
index 0000000..342bafb
--- /dev/null
+++ b/c++/test/TestStripeIndexStatistics.cc
@@ -0,0 +1,63 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "orc/OrcFile.hh"
+#include "orc/Reader.hh"
+
+#include "Adaptor.hh"
+
+#include "wrap/gmock.h"
+#include "wrap/gtest-wrapper.h"
+
+namespace orc {
+
+  TEST(TestStripeIndexStatistics, testIndexStatistics) {
+
+    std::stringstream ss;
+    if(const char* example_dir = std::getenv("ORC_EXAMPLE_DIR")) {
+      ss << example_dir;
+    } else {
+      ss << "../../../examples";
+    }
+    ss << "/orc_index_int_string.orc";
+    std::unique_ptr<orc::Reader> reader =
+      createReader(readLocalFile(ss.str().c_str()), ReaderOptions());
+
+    std::unique_ptr<orc::StripeStatistics> stripeStats = reader->getStripeStatistics(0);
+    EXPECT_EQ(3, stripeStats->getNumberOfRowIndexStats(0));
+    EXPECT_EQ(3, stripeStats->getNumberOfRowIndexStats(1));
+    EXPECT_EQ(3, stripeStats->getNumberOfRowIndexStats(2));
+
+    const orc::IntegerColumnStatistics* intColStats;
+    intColStats = reinterpret_cast<const orc::IntegerColumnStatistics*>(stripeStats->getRowIndexStatistics(1, 0));
+    EXPECT_EQ("Data type: Integer\nValues: 2000\nMinimum: 1\nMaximum: 2000\nSum: 2001000\n", intColStats->toString());
+    intColStats = reinterpret_cast<const orc::IntegerColumnStatistics*>(stripeStats->getRowIndexStatistics(1, 1));
+    EXPECT_EQ("Data type: Integer\nValues: 2000\nMinimum: 2001\nMaximum: 4000\nSum: 6001000\n", intColStats->toString());
+    intColStats = reinterpret_cast<const orc::IntegerColumnStatistics*>(stripeStats->getRowIndexStatistics(1, 2));
+    EXPECT_EQ("Data type: Integer\nValues: 2000\nMinimum: 4001\nMaximum: 6000\nSum: 10001000\n", intColStats->toString());
+
+    const orc::StringColumnStatistics* stringColStats;
+    stringColStats = reinterpret_cast<const orc::StringColumnStatistics*>(stripeStats->getRowIndexStatistics(2, 0));
+    EXPECT_EQ("Data type: String\nValues: 2000\nMinimum: 1000\nMaximum: 9a\nTotal length: 7892\n", stringColStats->toString());
+    stringColStats = reinterpret_cast<const orc::StringColumnStatistics*>(stripeStats->getRowIndexStatistics(2, 1));
+    EXPECT_EQ("Data type: String\nValues: 2000\nMinimum: 2001\nMaximum: 4000\nTotal length: 8000\n", stringColStats->toString());
+    stringColStats = reinterpret_cast<const orc::StringColumnStatistics*>(stripeStats->getRowIndexStatistics(2, 2));
+    EXPECT_EQ("Data type: String\nValues: 2000\nMinimum: 4001\nMaximum: 6000\nTotal length: 8000\n", stringColStats->toString());
+  }
+
+}  // namespace

http://git-wip-us.apache.org/repos/asf/orc/blob/02055f73/c++/test/TestTimestampStatistics.cc
----------------------------------------------------------------------
diff --git a/c++/test/TestTimestampStatistics.cc b/c++/test/TestTimestampStatistics.cc
index 8fe47f2..b5ce2a7 100644
--- a/c++/test/TestTimestampStatistics.cc
+++ b/c++/test/TestTimestampStatistics.cc
@@ -42,7 +42,7 @@ namespace orc {
     const orc::TimestampColumnStatistics* footerColStats =
         reinterpret_cast<const orc::TimestampColumnStatistics*>(footerStats.get());
 
-    std::unique_ptr<orc::Statistics> stripeStats = reader->getStripeStatistics(0);
+    std::unique_ptr<orc::StripeStatistics> stripeStats = reader->getStripeStatistics(0);
     const orc::TimestampColumnStatistics* stripeColStats =
         reinterpret_cast<const orc::TimestampColumnStatistics*>(stripeStats->getColumnStatistics(0));
 

http://git-wip-us.apache.org/repos/asf/orc/blob/02055f73/examples/expected/orc_index_int_string.jsn.gz
----------------------------------------------------------------------
diff --git a/examples/expected/orc_index_int_string.jsn.gz b/examples/expected/orc_index_int_string.jsn.gz
new file mode 100644
index 0000000..4e6de3d
Binary files /dev/null and b/examples/expected/orc_index_int_string.jsn.gz differ

http://git-wip-us.apache.org/repos/asf/orc/blob/02055f73/examples/orc_index_int_string.orc
----------------------------------------------------------------------
diff --git a/examples/orc_index_int_string.orc b/examples/orc_index_int_string.orc
new file mode 100644
index 0000000..17f9072
Binary files /dev/null and b/examples/orc_index_int_string.orc differ

http://git-wip-us.apache.org/repos/asf/orc/blob/02055f73/tools/src/FileStatistics.cc
----------------------------------------------------------------------
diff --git a/tools/src/FileStatistics.cc b/tools/src/FileStatistics.cc
index 010baaa..72edffd 100644
--- a/tools/src/FileStatistics.cc
+++ b/tools/src/FileStatistics.cc
@@ -19,12 +19,13 @@
 #include "orc/ColumnPrinter.hh"
 #include "Exceptions.hh"
 
+#include <getopt.h>
 #include <string>
 #include <memory>
 #include <iostream>
 #include <string>
 
-void printStatistics(const char *filename) {
+void printStatistics(const char *filename, bool withIndex) {
 
   orc::ReaderOptions opts;
   std::unique_ptr<orc::Reader> reader;
@@ -40,7 +41,7 @@ void printStatistics(const char *filename) {
   }
 
   // test stripe statistics
-  std::unique_ptr<orc::Statistics> stripeStats;
+  std::unique_ptr<orc::StripeStatistics> stripeStats;
   std::cout << "File " << filename << " has " << reader->getNumberOfStripes()
             << " stripes"  << std::endl;
   if (reader->getNumberOfStripeStatistics() == 0) {
@@ -55,21 +56,59 @@ void printStatistics(const char *filename) {
         std::cout << "--- Column " << k << " ---" << std::endl;
         std::cout << stripeStats->getColumnStatistics(k)->toString()
                   << std::endl;
+        if (withIndex) {
+          for(unsigned int r = 0; r < stripeStats->getNumberOfRowIndexStats(k); ++r) {
+            std::cout << "--- RowIndex " << r << " ---" << std::endl;
+            std::cout << stripeStats->getRowIndexStatistics(k, r)->toString()
+                      << std::endl;
+          }
+        }
       }
     }
   }
 }
 
 int main(int argc, char* argv[]) {
-  if (argc < 2) {
-    std::cout << "Usage: orc-statistics <filename>\n";
+  static struct option longOptions[] = {
+    {"help", no_argument, ORC_NULLPTR, 'h'},
+    {"withIndex", no_argument, ORC_NULLPTR, 'i'},
+    {ORC_NULLPTR, 0, ORC_NULLPTR, 0}
+  };
+  const char* filename = NULL;
+  bool withIndex = false;
+  bool helpFlag = false;
+  int opt;
+  do {
+    opt = getopt_long(argc, argv, "hi", longOptions, ORC_NULLPTR);
+    switch (opt) {
+    case '?':
+    case 'h':
+      helpFlag = true;
+      opt = -1;
+      break;
+    case 'i':
+      withIndex = true;
+      break;
+    }
+  } while (opt != -1);
+  argc -= optind;
+  argv += optind;
+
+  if (argc < 1 || helpFlag) {
+    std::cerr
+      << "Usage: orc-statistics [-h] [--help] [-i] [--withIndex]"
+      << " <filenames>\n";
+    exit(1);
   }
 
-  try {
-    printStatistics(argv[1]);
-  } catch (std::exception& ex) {
-    std::cerr << "Caught exception: " << ex.what() << "\n";
-    return 1;
+  for(int i=0; i < argc; ++i) {
+      filename = argv[i];
+      try {
+          printStatistics(filename, withIndex);
+      } catch (std::exception& ex) {
+          std::cerr << "Caught exception: " << ex.what() << "\n";
+          return 1;
+      }
   }
 
   return 0;

http://git-wip-us.apache.org/repos/asf/orc/blob/02055f73/tools/test/TestMatch.cc
----------------------------------------------------------------------
diff --git a/tools/test/TestMatch.cc b/tools/test/TestMatch.cc
index e9ce23b..5bf7a40 100644
--- a/tools/test/TestMatch.cc
+++ b/tools/test/TestMatch.cc
@@ -455,6 +455,17 @@ namespace orc {
                                        262144,
                                        10000,
                                        std::map<std::string, std::string>()),
+                    OrcFileDescription("orc_index_int_string.orc",
+                                       "orc_index_int_string.jsn.gz",
+                                       ("struct<_col0:int,_col1:varchar(4)>"),
+                                       "0.12",
+                                       6000,
+                                       11280,
+                                       1,
+                                       CompressionKind_ZLIB,
+                                       262144,
+                                       2000,
+                                       std::map<std::string, std::string>()),
                     OrcFileDescription("over1k_bloom.orc",
                                        "over1k_bloom.jsn.gz",
                                        "struct<_col0:tinyint,_col1:smallint,"