IMPALA-3924: Ubuntu16 support

One problem uncovered while trying to build Impala on Ubuntu16 is
that the functions 'isnan' and 'isinf' both appear in std::
(from <cmath>) and in boost::math::, but we're currently using
them without qualifiers in several places, leading to a conflict.

This patch prefaces all uses with 'std::' to disambiguate, and also
adds <cmath> imports to all files that use those functions, for
the sake of explicitness.

Another problem is that bin/make_impala.sh uses the system cmake,
which may not be compatible with the toolchain binaries. This patch
updates impala-config.sh to add the toolchain cmake to PATH, so
that we'll use it wherever we use cmake.

Change-Id: Iaa1520c1e4aa4175468ac342b14c1262fa745f7a
Reviewed-on: http://gerrit.cloudera.org:8080/3800
Reviewed-by: Matthew Jacobs <[email protected]>
Tested-by: Internal Jenkins


Project: http://git-wip-us.apache.org/repos/asf/incubator-impala/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-impala/commit/9ca292a1
Tree: http://git-wip-us.apache.org/repos/asf/incubator-impala/tree/9ca292a1
Diff: http://git-wip-us.apache.org/repos/asf/incubator-impala/diff/9ca292a1

Branch: refs/heads/master
Commit: 9ca292a1cce53cfb81217da93f6489422dabf9b5
Parents: b66829f
Author: Thomas Tauber-Marshall <[email protected]>
Authored: Wed Jul 27 16:32:07 2016 -0700
Committer: Internal Jenkins <[email protected]>
Committed: Wed Aug 10 06:26:03 2016 +0000

----------------------------------------------------------------------
 be/src/exprs/cast-functions-ir.cc |  4 +++-
 be/src/exprs/udf-builtins-ir.cc   |  4 ++--
 be/src/runtime/raw-value-ir.cc    | 18 +++++++++++-------
 be/src/runtime/raw-value.inline.h | 11 ++++++-----
 be/src/util/metrics-test.cc       | 10 +++++-----
 bin/bootstrap_toolchain.py        |  5 +++--
 bin/impala-config.sh              |  3 ++-
 7 files changed, 32 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/9ca292a1/be/src/exprs/cast-functions-ir.cc
----------------------------------------------------------------------
diff --git a/be/src/exprs/cast-functions-ir.cc 
b/be/src/exprs/cast-functions-ir.cc
index ad8d2db..9fa8268 100644
--- a/be/src/exprs/cast-functions-ir.cc
+++ b/be/src/exprs/cast-functions-ir.cc
@@ -17,6 +17,8 @@
 
 #include "exprs/cast-functions.h"
 
+#include <cmath>
+
 #include <boost/lexical_cast.hpp>
 
 #include "exprs/anyval-util.h"
@@ -127,7 +129,7 @@ CAST_TO_STRING(BigIntVal);
   StringVal CastFunctions::CastToStringVal(FunctionContext* ctx, const 
float_type& val) { \
     if (val.is_null) return StringVal::null(); \
     /* val.val could be -nan, return "nan" instead */ \
-    if (isnan(val.val)) return StringVal("nan"); \
+    if (std::isnan(val.val)) return StringVal("nan"); \
     /* Add 1 to MAX_FLOAT_CHARS since snprintf adds a trailing '\0' */ \
     StringVal sv(ctx, MAX_FLOAT_CHARS + 1); \
     if (UNLIKELY(sv.is_null)) { \

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/9ca292a1/be/src/exprs/udf-builtins-ir.cc
----------------------------------------------------------------------
diff --git a/be/src/exprs/udf-builtins-ir.cc b/be/src/exprs/udf-builtins-ir.cc
index 73da797..376a0d0 100644
--- a/be/src/exprs/udf-builtins-ir.cc
+++ b/be/src/exprs/udf-builtins-ir.cc
@@ -95,12 +95,12 @@ BigIntVal UdfBuiltins::MinBigInt(FunctionContext* context) {
 
 BooleanVal UdfBuiltins::IsNan(FunctionContext* context, const DoubleVal& val) {
   if (val.is_null) return BooleanVal(false);
-  return BooleanVal(isnan(val.val));
+  return BooleanVal(std::isnan(val.val));
 }
 
 BooleanVal UdfBuiltins::IsInf(FunctionContext* context, const DoubleVal& val) {
   if (val.is_null) return BooleanVal(false);
-  return BooleanVal(isinf(val.val));
+  return BooleanVal(std::isinf(val.val));
 }
 
 // The units which can be used when Truncating a Timestamp

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/9ca292a1/be/src/runtime/raw-value-ir.cc
----------------------------------------------------------------------
diff --git a/be/src/runtime/raw-value-ir.cc b/be/src/runtime/raw-value-ir.cc
index 5cb1fb8..c0df4c9 100644
--- a/be/src/runtime/raw-value-ir.cc
+++ b/be/src/runtime/raw-value-ir.cc
@@ -15,9 +15,13 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#include "runtime/raw-value.inline.h"
+#include "runtime/raw-value.h"
+
+#include <cmath>
 
 #include "runtime/decimal-value.inline.h"
+#include "runtime/string-value.inline.h"
+#include "runtime/timestamp-value.h"
 
 using namespace impala;
 
@@ -52,17 +56,17 @@ int RawValue::Compare(const void* v1, const void* v2, const 
ColumnType& type) {
       // TODO: can this be faster? (just returning the difference has 
underflow problems)
       f1 = *reinterpret_cast<const float*>(v1);
       f2 = *reinterpret_cast<const float*>(v2);
-      if (UNLIKELY(isnan(f1) && isnan(f2))) return 0;
-      if (UNLIKELY(isnan(f1))) return -1;
-      if (UNLIKELY(isnan(f2))) return 1;
+      if (UNLIKELY(std::isnan(f1) && std::isnan(f2))) return 0;
+      if (UNLIKELY(std::isnan(f1))) return -1;
+      if (UNLIKELY(std::isnan(f2))) return 1;
       return f1 > f2 ? 1 : (f1 < f2 ? -1 : 0);
     case TYPE_DOUBLE:
       // TODO: can this be faster?
       d1 = *reinterpret_cast<const double*>(v1);
       d2 = *reinterpret_cast<const double*>(v2);
-      if (isnan(d1) && isnan(d2)) return 0;
-      if (isnan(d1)) return -1;
-      if (isnan(d2)) return 1;
+      if (std::isnan(d1) && std::isnan(d2)) return 0;
+      if (std::isnan(d1)) return -1;
+      if (std::isnan(d2)) return 1;
       return d1 > d2 ? 1 : (d1 < d2 ? -1 : 0);
     case TYPE_STRING:
     case TYPE_VARCHAR:

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/9ca292a1/be/src/runtime/raw-value.inline.h
----------------------------------------------------------------------
diff --git a/be/src/runtime/raw-value.inline.h 
b/be/src/runtime/raw-value.inline.h
index 72721af..a1f1d75 100644
--- a/be/src/runtime/raw-value.inline.h
+++ b/be/src/runtime/raw-value.inline.h
@@ -21,8 +21,9 @@
 
 #include "runtime/raw-value.h"
 
+#include <cmath>
+
 #include <boost/functional/hash.hpp>
-#include <math.h>
 
 #include "common/logging.h"
 #include "runtime/decimal-value.inline.h"
@@ -340,12 +341,12 @@ inline void RawValue::PrintValue(const void* value, const 
ColumnType& type, int
         float val = *reinterpret_cast<const float*>(value);
         if (LIKELY(std::isfinite(val))) {
           *stream << val;
-        } else if (isinf(val)) {
+        } else if (std::isinf(val)) {
           // 'Infinity' is Java's text representation of inf. By staying close 
to Java, we
           // allow Hive to read text tables containing non-finite values 
produced by
           // Impala. (The same logic applies to 'NaN', below).
           *stream << (val < 0 ? "-Infinity" : "Infinity");
-        } else if (isnan(val)) {
+        } else if (std::isnan(val)) {
           *stream << "NaN";
         }
       }
@@ -355,10 +356,10 @@ inline void RawValue::PrintValue(const void* value, const 
ColumnType& type, int
         double val = *reinterpret_cast<const double*>(value);
         if (LIKELY(std::isfinite(val))) {
           *stream << val;
-        } else if (isinf(val)) {
+        } else if (std::isinf(val)) {
           // See TYPE_FLOAT for rationale.
           *stream << (val < 0 ? "-Infinity" : "Infinity");
-        } else if (isnan(val)) {
+        } else if (std::isnan(val)) {
           *stream << "NaN";
         }
       }

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/9ca292a1/be/src/util/metrics-test.cc
----------------------------------------------------------------------
diff --git a/be/src/util/metrics-test.cc b/be/src/util/metrics-test.cc
index 028d88b..9b8cbbd 100644
--- a/be/src/util/metrics-test.cc
+++ b/be/src/util/metrics-test.cc
@@ -15,16 +15,16 @@
 // specific language governing permissions and limitations
 // under the License.
 
-#include "util/metrics.h"
-#include "util/collection-metrics.h"
-#include "util/memory-metrics.h"
-
+#include <cmath>
 #include <gtest/gtest.h>
 #include <boost/scoped_ptr.hpp>
 #include <limits>
 #include <map>
 
+#include "util/collection-metrics.h"
 #include "util/jni-util.h"
+#include "util/memory-metrics.h"
+#include "util/metrics.h"
 #include "util/thread.h"
 
 #include "common/names.h"
@@ -130,7 +130,7 @@ TEST_F(MetricsTest, NonFiniteValues) {
   AssertValue(gauge, inf, "inf");
   double nan = numeric_limits<double>::quiet_NaN();
   gauge->set_value(nan);
-  EXPECT_TRUE(isnan(gauge->value()));
+  EXPECT_TRUE(std::isnan(gauge->value()));
   EXPECT_TRUE(gauge->ToHumanReadable() == "nan");
 }
 

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/9ca292a1/bin/bootstrap_toolchain.py
----------------------------------------------------------------------
diff --git a/bin/bootstrap_toolchain.py b/bin/bootstrap_toolchain.py
index f45f6a6..d8621c4 100755
--- a/bin/bootstrap_toolchain.py
+++ b/bin/bootstrap_toolchain.py
@@ -51,6 +51,7 @@ OS_MAPPING = {
   "ubuntu14.04" : "ec2-package-ubuntu-14-04",
   "ubuntu15.04" : "ec2-package-ubuntu-14-04",
   "ubuntu15.10" : "ec2-package-ubuntu-14-04",
+  "ubuntu16.04" : "ec2-package-ubuntu-16-04",
 }
 
 def try_get_platform_release_label():
@@ -343,8 +344,8 @@ if __name__ == "__main__":
   if not os.path.exists(toolchain_root):
     os.makedirs(toolchain_root)
 
-  packages = ["avro", "binutils", "boost", "breakpad", "bzip2", "gcc", 
"gflags", "glog",
-      "gperftools", "gtest", "kudu", "llvm", ("llvm", "3.8.0-asserts-p1"), 
"lz4",
+  packages = ["avro", "binutils", "boost", "breakpad", "bzip2", "cmake", 
"gcc", "gflags",
+      "glog", "gperftools", "gtest", "kudu", "llvm", ("llvm", 
"3.8.0-asserts-p1"), "lz4",
       "openldap", "rapidjson", "re2", "snappy", "thrift", "tpc-h", "tpc-ds", 
"zlib"]
   bootstrap(toolchain_root, packages)
 

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/9ca292a1/bin/impala-config.sh
----------------------------------------------------------------------
diff --git a/bin/impala-config.sh b/bin/impala-config.sh
index d3340fa..5983e87 100755
--- a/bin/impala-config.sh
+++ b/bin/impala-config.sh
@@ -252,6 +252,7 @@ export IMPALA_BINUTILS_VERSION=2.26-p1
 export IMPALA_BOOST_VERSION=1.57.0
 export IMPALA_BREAKPAD_VERSION=20150612-p1
 export IMPALA_BZIP2_VERSION=1.0.6-p1
+export IMPALA_CMAKE_VERSION=3.2.3-p1
 export IMPALA_CYRUS_SASL_VERSION=2.1.23
 export IMPALA_GCC_VERSION=4.9.2
 export IMPALA_GFLAGS_VERSION=2.0
@@ -309,7 +310,7 @@ export 
IMPALA_AUX_WORKLOAD_DIR=$IMPALA_AUX_TEST_HOME/testdata/workloads
 export IMPALA_DATASET_DIR=$IMPALA_HOME/testdata/datasets
 export IMPALA_AUX_DATASET_DIR=$IMPALA_AUX_TEST_HOME/testdata/datasets
 export IMPALA_COMMON_DIR=$IMPALA_HOME/common
-export PATH=$IMPALA_HOME/bin:$PATH
+export 
PATH=$IMPALA_HOME/bin:$IMPALA_TOOLCHAIN/cmake-$IMPALA_CMAKE_VERSION/bin/:$PATH
 
 # The directory in which all the thirdparty CDH components live.
 if [ "${DOWNLOAD_CDH_COMPONENTS}" = true ]; then

Reply via email to