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 2019/10/22 23:15:54 UTC

[orc] 01/04: ORC-552: Fix c++ compilation for centos 6 and 8, and MacOs 10.14.

This is an automated email from the ASF dual-hosted git repository.

omalley pushed a commit to branch branch-1.6
in repository https://gitbox.apache.org/repos/asf/orc.git

commit 1328fd8afb3082aa4ed39efd560eef0bac884bd7
Author: Owen O'Malley <om...@apache.org>
AuthorDate: Mon Oct 14 14:40:06 2019 -0700

    ORC-552: Fix c++ compilation for centos 6 and 8, and MacOs 10.14.
    
    Fixes #436
    
    Signed-off-by: Owen O'Malley <om...@apache.org>
---
 CMakeLists.txt                          |  6 +++-
 c++/src/ColumnPrinter.cc                | 56 ++++++++++++++++-----------------
 c++/src/Reader.cc                       |  9 +++---
 c++/src/Vector.cc                       | 35 +++++++++++----------
 c++/test/TestColumnReader.cc            |  3 ++
 cmake_modules/FindSnappy.cmake          |  2 +-
 cmake_modules/ThirdpartyToolchain.cmake |  2 +-
 7 files changed, 61 insertions(+), 52 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 15c6ecd..6102daf 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -81,7 +81,11 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
   set (WARN_FLAGS "${WARN_FLAGS} -Wno-covered-switch-default")
   set (WARN_FLAGS "${WARN_FLAGS} -Wno-missing-noreturn -Wno-unknown-pragmas")
   set (WARN_FLAGS "${WARN_FLAGS} -Wno-gnu-zero-variadic-macro-arguments")
-  set (WARN_FLAGS "${WARN_FLAGS} -Wconversion -Werror")
+  set (WARN_FLAGS "${WARN_FLAGS} -Wconversion")
+  if (CMAKE_HOST_APPLE AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "11.0")
+    set (WARN_FLAGS "${WARN_FLAGS} -Wno-c++2a-compat")
+  endif ()
+  set (WARN_FLAGS "${WARN_FLAGS} -Werror")
 elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
   set (WARN_FLAGS "-Wall -Wno-unknown-pragmas -Wconversion -Werror")
   if (CMAKE_CXX_COMPILER_VERSION STREQUAL "" OR
diff --git a/c++/src/ColumnPrinter.cc b/c++/src/ColumnPrinter.cc
index 379ef0b..b4b5860 100644
--- a/c++/src/ColumnPrinter.cc
+++ b/c++/src/ColumnPrinter.cc
@@ -289,8 +289,8 @@ namespace orc {
     return std::unique_ptr<ColumnPrinter>(result);
   }
 
-  VoidColumnPrinter::VoidColumnPrinter(std::string& buffer
-                                       ): ColumnPrinter(buffer) {
+  VoidColumnPrinter::VoidColumnPrinter(std::string& _buffer
+                                       ): ColumnPrinter(_buffer) {
     // PASS
   }
 
@@ -302,8 +302,8 @@ namespace orc {
     writeString(buffer, "null");
   }
 
-  LongColumnPrinter::LongColumnPrinter(std::string& buffer
-                                       ): ColumnPrinter(buffer),
+  LongColumnPrinter::LongColumnPrinter(std::string& _buffer
+                                       ): ColumnPrinter(_buffer),
                                           data(nullptr) {
     // PASS
   }
@@ -324,9 +324,9 @@ namespace orc {
     }
   }
 
-  DoubleColumnPrinter::DoubleColumnPrinter(std::string& buffer,
+  DoubleColumnPrinter::DoubleColumnPrinter(std::string& _buffer,
                                            const Type& type
-                                           ): ColumnPrinter(buffer),
+                                           ): ColumnPrinter(_buffer),
                                               data(nullptr),
                                               isFloat(type.getKind() == FLOAT){
     // PASS
@@ -348,8 +348,8 @@ namespace orc {
     }
   }
 
-  Decimal64ColumnPrinter::Decimal64ColumnPrinter(std::string& buffer
-                                                 ): ColumnPrinter(buffer),
+  Decimal64ColumnPrinter::Decimal64ColumnPrinter(std::string& _buffer
+                                                 ): ColumnPrinter(_buffer),
                                                     data(nullptr),
                                                     scale(0) {
     // PASS
@@ -398,8 +398,8 @@ namespace orc {
     }
   }
 
-  Decimal128ColumnPrinter::Decimal128ColumnPrinter(std::string& buffer
-                                                   ): ColumnPrinter(buffer),
+  Decimal128ColumnPrinter::Decimal128ColumnPrinter(std::string& _buffer
+                                                   ): ColumnPrinter(_buffer),
                                                       data(nullptr),
                                                       scale(0) {
      // PASS
@@ -419,8 +419,8 @@ namespace orc {
      }
    }
 
-  StringColumnPrinter::StringColumnPrinter(std::string& buffer
-                                           ): ColumnPrinter(buffer),
+  StringColumnPrinter::StringColumnPrinter(std::string& _buffer
+                                           ): ColumnPrinter(_buffer),
                                               start(nullptr),
                                               length(nullptr) {
     // PASS
@@ -470,9 +470,9 @@ namespace orc {
     }
   }
 
-  ListColumnPrinter::ListColumnPrinter(std::string& buffer,
+  ListColumnPrinter::ListColumnPrinter(std::string& _buffer,
                                        const Type& type
-                                       ): ColumnPrinter(buffer),
+                                       ): ColumnPrinter(_buffer),
                                           offsets(nullptr) {
     elementPrinter = createColumnPrinter(buffer, type.getSubtype(0));
   }
@@ -499,9 +499,9 @@ namespace orc {
     }
   }
 
-  MapColumnPrinter::MapColumnPrinter(std::string& buffer,
+  MapColumnPrinter::MapColumnPrinter(std::string& _buffer,
                                      const Type& type
-                                     ): ColumnPrinter(buffer),
+                                     ): ColumnPrinter(_buffer),
                                         offsets(nullptr) {
     keyPrinter = createColumnPrinter(buffer, type.getSubtype(0));
     elementPrinter = createColumnPrinter(buffer, type.getSubtype(1));
@@ -534,9 +534,9 @@ namespace orc {
     }
   }
 
-  UnionColumnPrinter::UnionColumnPrinter(std::string& buffer,
+  UnionColumnPrinter::UnionColumnPrinter(std::string& _buffer,
                                            const Type& type
-                                         ): ColumnPrinter(buffer),
+                                         ): ColumnPrinter(_buffer),
                                             tags(nullptr),
                                             offsets(nullptr) {
     for(unsigned int i=0; i < type.getSubtypeCount(); ++i) {
@@ -577,9 +577,9 @@ namespace orc {
     }
   }
 
-  StructColumnPrinter::StructColumnPrinter(std::string& buffer,
+  StructColumnPrinter::StructColumnPrinter(std::string& _buffer,
                                            const Type& type
-                                           ): ColumnPrinter(buffer) {
+                                           ): ColumnPrinter(_buffer) {
     for(unsigned int i=0; i < type.getSubtypeCount(); ++i) {
       fieldNames.push_back(type.getFieldName(i));
       fieldPrinter.push_back(createColumnPrinter(buffer,
@@ -621,8 +621,8 @@ namespace orc {
     }
   }
 
-  DateColumnPrinter::DateColumnPrinter(std::string& buffer
-                                       ): ColumnPrinter(buffer),
+  DateColumnPrinter::DateColumnPrinter(std::string& _buffer
+                                       ): ColumnPrinter(_buffer),
                                           data(nullptr) {
     // PASS
   }
@@ -647,8 +647,8 @@ namespace orc {
     data = dynamic_cast<const LongVectorBatch&>(batch).data.data();
   }
 
-  BooleanColumnPrinter::BooleanColumnPrinter(std::string& buffer
-                                             ): ColumnPrinter(buffer),
+  BooleanColumnPrinter::BooleanColumnPrinter(std::string& _buffer
+                                             ): ColumnPrinter(_buffer),
                                                 data(nullptr) {
     // PASS
   }
@@ -666,8 +666,8 @@ namespace orc {
     data = dynamic_cast<const LongVectorBatch&>(batch).data.data();
   }
 
-  BinaryColumnPrinter::BinaryColumnPrinter(std::string& buffer
-                                           ): ColumnPrinter(buffer),
+  BinaryColumnPrinter::BinaryColumnPrinter(std::string& _buffer
+                                           ): ColumnPrinter(_buffer),
                                               start(nullptr),
                                               length(nullptr) {
     // PASS
@@ -697,8 +697,8 @@ namespace orc {
     length = dynamic_cast<const StringVectorBatch&>(batch).length.data();
   }
 
-  TimestampColumnPrinter::TimestampColumnPrinter(std::string& buffer
-                                                 ): ColumnPrinter(buffer),
+  TimestampColumnPrinter::TimestampColumnPrinter(std::string& _buffer
+                                                 ): ColumnPrinter(_buffer),
                                                     seconds(nullptr),
                                                     nanoseconds(nullptr) {
     // PASS
diff --git a/c++/src/Reader.cc b/c++/src/Reader.cc
index a814fbc..ad87c15 100644
--- a/c++/src/Reader.cc
+++ b/c++/src/Reader.cc
@@ -346,10 +346,11 @@ namespace orc {
     // store position providers for selected colimns
     std::unordered_map<uint64_t, PositionProvider> positionProviders;
 
-    for (const auto& rowIndex : rowIndexes) {
-      uint64_t colId = rowIndex.first;
+    for (auto rowIndex = rowIndexes.cbegin();
+         rowIndex != rowIndexes.cend(); ++rowIndex) {
+      uint64_t colId = rowIndex->first;
       const proto::RowIndexEntry& entry =
-        rowIndex.second.entry(static_cast<int32_t>(rowGroupEntryId));
+        rowIndex->second.entry(static_cast<int32_t>(rowGroupEntryId));
 
       // copy index positions for a specific column
       positions.push_back({});
@@ -357,7 +358,7 @@ namespace orc {
       for (int pos = 0; pos != entry.positions_size(); ++pos) {
         position.push_back(entry.positions(pos));
       }
-      positionProviders.emplace(std::make_pair(colId, PositionProvider(position)));
+      positionProviders.insert(std::make_pair(colId, PositionProvider(position)));
     }
 
     reader->seekToRowGroup(positionProviders);
diff --git a/c++/src/Vector.cc b/c++/src/Vector.cc
index afb7cfa..14c0ded 100644
--- a/c++/src/Vector.cc
+++ b/c++/src/Vector.cc
@@ -61,9 +61,9 @@ namespace orc {
     return false;
   }
 
-  LongVectorBatch::LongVectorBatch(uint64_t capacity, MemoryPool& pool
-                     ): ColumnVectorBatch(capacity, pool),
-                        data(pool, capacity) {
+  LongVectorBatch::LongVectorBatch(uint64_t _capacity, MemoryPool& pool
+                     ): ColumnVectorBatch(_capacity, pool),
+                        data(pool, _capacity) {
     // PASS
   }
 
@@ -93,9 +93,9 @@ namespace orc {
         static_cast<uint64_t>(data.capacity() * sizeof(int64_t));
   }
 
-  DoubleVectorBatch::DoubleVectorBatch(uint64_t capacity, MemoryPool& pool
-                   ): ColumnVectorBatch(capacity, pool),
-                      data(pool, capacity) {
+  DoubleVectorBatch::DoubleVectorBatch(uint64_t _capacity, MemoryPool& pool
+                   ): ColumnVectorBatch(_capacity, pool),
+                      data(pool, _capacity) {
     // PASS
   }
 
@@ -131,10 +131,11 @@ namespace orc {
     // PASS
   }
 
-  EncodedStringVectorBatch::EncodedStringVectorBatch(uint64_t capacity, MemoryPool& pool)
-                      : StringVectorBatch(capacity, pool),
+  EncodedStringVectorBatch::EncodedStringVectorBatch(uint64_t _capacity,
+                                                     MemoryPool& pool)
+                      : StringVectorBatch(_capacity, pool),
                         dictionary(),
-                        index(pool, capacity) {
+                        index(pool, _capacity) {
     // PASS
   }
 
@@ -148,10 +149,10 @@ namespace orc {
     return buffer.str();
   }
 
-  StringVectorBatch::StringVectorBatch(uint64_t capacity, MemoryPool& pool
-               ): ColumnVectorBatch(capacity, pool),
-                  data(pool, capacity),
-                  length(pool, capacity),
+  StringVectorBatch::StringVectorBatch(uint64_t _capacity, MemoryPool& pool
+               ): ColumnVectorBatch(_capacity, pool),
+                  data(pool, _capacity),
+                  length(pool, _capacity),
                   blob(pool) {
     // PASS
   }
@@ -478,12 +479,12 @@ namespace orc {
     return value.toDecimalString(scale);
   }
 
-  TimestampVectorBatch::TimestampVectorBatch(uint64_t capacity,
+  TimestampVectorBatch::TimestampVectorBatch(uint64_t _capacity,
                                              MemoryPool& pool
-                                             ): ColumnVectorBatch(capacity,
+                                             ): ColumnVectorBatch(_capacity,
                                                                   pool),
-                                                data(pool, capacity),
-                                                nanoseconds(pool, capacity) {
+                                                data(pool, _capacity),
+                                                nanoseconds(pool, _capacity) {
     // PASS
   }
 
diff --git a/c++/test/TestColumnReader.cc b/c++/test/TestColumnReader.cc
index 9444616..9f8d8b8 100644
--- a/c++/test/TestColumnReader.cc
+++ b/c++/test/TestColumnReader.cc
@@ -33,6 +33,9 @@
   DIAGNOSTIC_IGNORE("-Winconsistent-missing-override")
   DIAGNOSTIC_IGNORE("-Wmissing-variable-declarations")
 #endif
+#ifdef __GNUC__
+  DIAGNOSTIC_IGNORE("-Wparentheses")
+#endif
 
 namespace orc {
   using ::testing::TestWithParam;
diff --git a/cmake_modules/FindSnappy.cmake b/cmake_modules/FindSnappy.cmake
index 6cf64be..5aeb88e 100644
--- a/cmake_modules/FindSnappy.cmake
+++ b/cmake_modules/FindSnappy.cmake
@@ -30,7 +30,7 @@ find_path (SNAPPY_INCLUDE_DIR snappy.h HINTS
 
 find_library (SNAPPY_LIBRARIES NAMES snappy HINTS
   ${_snappy_path}
-  PATH_SUFFIXES "lib")
+  PATH_SUFFIXES "lib" "lib64")
 
 if (SNAPPY_INCLUDE_DIR AND SNAPPY_LIBRARIES)
   set (SNAPPY_FOUND TRUE)
diff --git a/cmake_modules/ThirdpartyToolchain.cmake b/cmake_modules/ThirdpartyToolchain.cmake
index 74f0e61..b70540b 100644
--- a/cmake_modules/ThirdpartyToolchain.cmake
+++ b/cmake_modules/ThirdpartyToolchain.cmake
@@ -67,7 +67,7 @@ else ()
   set(SNAPPY_INCLUDE_DIR "${SNAPPY_HOME}/include")
   set(SNAPPY_STATIC_LIB "${SNAPPY_HOME}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}snappy${CMAKE_STATIC_LIBRARY_SUFFIX}")
   set(SNAPPY_CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${SNAPPY_HOME}
-                        -DBUILD_SHARED_LIBS=OFF)
+                        -DBUILD_SHARED_LIBS=OFF -DCMAKE_INSTALL_LIBDIR=lib)
 
   ExternalProject_Add (snappy_ep
     URL "https://github.com/google/snappy/archive/${SNAPPY_VERSION}.tar.gz"