This is an automated email from the ASF dual-hosted git repository.
wesm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new 3d77ce6 ARROW-4167: [C++][Gandiva] Switch to arrow/util/variant
3d77ce6 is described below
commit 3d77ce62730132f6b6299ab7ea7929bcb9b8779d
Author: Pindikura Ravindra <[email protected]>
AuthorDate: Fri Jan 18 09:30:12 2019 -0600
ARROW-4167: [C++][Gandiva] Switch to arrow/util/variant
Author: Pindikura Ravindra <[email protected]>
Closes #3425 from pravindra/variant and squashes the following commits:
94bb9f509 <Pindikura Ravindra> ARROW-4167: remove ref to boost variant in
glib
2b2ddecde <Pindikura Ravindra> ARROW-4167: switch to arrow/util/variant
---
c_glib/gandiva-glib/node.cpp | 2 +-
cpp/src/arrow/util/variant.h | 1 +
cpp/src/gandiva/like_holder.cc | 2 +-
cpp/src/gandiva/literal_holder.h | 6 +++---
cpp/src/gandiva/llvm_generator.cc | 34 +++++++++++++++++-----------------
cpp/src/gandiva/node.h | 4 ++--
cpp/src/gandiva/to_date_holder.cc | 4 ++--
7 files changed, 27 insertions(+), 26 deletions(-)
diff --git a/c_glib/gandiva-glib/node.cpp b/c_glib/gandiva-glib/node.cpp
index a3814c1..b2adf85 100644
--- a/c_glib/gandiva-glib/node.cpp
+++ b/c_glib/gandiva-glib/node.cpp
@@ -33,7 +33,7 @@ ggandiva_literal_node_get(GGandivaLiteralNode *node)
{
auto gandiva_literal_node =
std::static_pointer_cast<gandiva::LiteralNode>(ggandiva_node_get_raw(GGANDIVA_NODE(node)));
- return boost::get<Type>(gandiva_literal_node->holder());
+ return gandiva_literal_node->holder().get<Type>();
}
G_BEGIN_DECLS
diff --git a/cpp/src/arrow/util/variant.h b/cpp/src/arrow/util/variant.h
index cb6500a..fecaa51 100644
--- a/cpp/src/arrow/util/variant.h
+++ b/cpp/src/arrow/util/variant.h
@@ -19,6 +19,7 @@
#define ARROW_UTIL_VARIANT_H
#include "arrow/vendored/variant/variant.hpp" // IWYU pragma: export
+#include "arrow/vendored/variant/variant_io.hpp"
namespace arrow {
namespace util {
diff --git a/cpp/src/gandiva/like_holder.cc b/cpp/src/gandiva/like_holder.cc
index 051b75b..f4bbc51 100644
--- a/cpp/src/gandiva/like_holder.cc
+++ b/cpp/src/gandiva/like_holder.cc
@@ -73,7 +73,7 @@ Status LikeHolder::Make(const FunctionNode& node,
std::shared_ptr<LikeHolder>* h
Status::Invalid(
"'like' function requires a string literal as the second
parameter"));
- return Make(boost::get<std::string>(literal->holder()), holder);
+ return Make(literal->holder().get<std::string>(), holder);
}
Status LikeHolder::Make(const std::string& sql_pattern,
diff --git a/cpp/src/gandiva/literal_holder.h b/cpp/src/gandiva/literal_holder.h
index ad6afce..17f3799 100644
--- a/cpp/src/gandiva/literal_holder.h
+++ b/cpp/src/gandiva/literal_holder.h
@@ -20,7 +20,7 @@
#include <string>
-#include <boost/variant.hpp>
+#include <arrow/util/variant.h>
#include <arrow/type.h>
#include "gandiva/decimal_full.h"
@@ -28,8 +28,8 @@
namespace gandiva {
using LiteralHolder =
- boost::variant<bool, float, double, int8_t, int16_t, int32_t, int64_t,
uint8_t,
- uint16_t, uint32_t, uint64_t, std::string, Decimal128Full>;
+ arrow::util::variant<bool, float, double, int8_t, int16_t, int32_t,
int64_t, uint8_t,
+ uint16_t, uint32_t, uint64_t, std::string,
Decimal128Full>;
} // namespace gandiva
diff --git a/cpp/src/gandiva/llvm_generator.cc
b/cpp/src/gandiva/llvm_generator.cc
index 9ddbe93..17e0224 100644
--- a/cpp/src/gandiva/llvm_generator.cc
+++ b/cpp/src/gandiva/llvm_generator.cc
@@ -527,52 +527,52 @@ void LLVMGenerator::Visitor::Visit(const LiteralDex& dex)
{
switch (dex.type()->id()) {
case arrow::Type::BOOL:
- value = types->i1_constant(boost::get<bool>(dex.holder()));
+ value = types->i1_constant(dex.holder().get<bool>());
break;
case arrow::Type::UINT8:
- value = types->i8_constant(boost::get<uint8_t>(dex.holder()));
+ value = types->i8_constant(dex.holder().get<uint8_t>());
break;
case arrow::Type::UINT16:
- value = types->i16_constant(boost::get<uint16_t>(dex.holder()));
+ value = types->i16_constant(dex.holder().get<uint16_t>());
break;
case arrow::Type::UINT32:
- value = types->i32_constant(boost::get<uint32_t>(dex.holder()));
+ value = types->i32_constant(dex.holder().get<uint32_t>());
break;
case arrow::Type::UINT64:
- value = types->i64_constant(boost::get<uint64_t>(dex.holder()));
+ value = types->i64_constant(dex.holder().get<uint64_t>());
break;
case arrow::Type::INT8:
- value = types->i8_constant(boost::get<int8_t>(dex.holder()));
+ value = types->i8_constant(dex.holder().get<int8_t>());
break;
case arrow::Type::INT16:
- value = types->i16_constant(boost::get<int16_t>(dex.holder()));
+ value = types->i16_constant(dex.holder().get<int16_t>());
break;
case arrow::Type::INT32:
- value = types->i32_constant(boost::get<int32_t>(dex.holder()));
+ value = types->i32_constant(dex.holder().get<int32_t>());
break;
case arrow::Type::INT64:
- value = types->i64_constant(boost::get<int64_t>(dex.holder()));
+ value = types->i64_constant(dex.holder().get<int64_t>());
break;
case arrow::Type::FLOAT:
- value = types->float_constant(boost::get<float>(dex.holder()));
+ value = types->float_constant(dex.holder().get<float>());
break;
case arrow::Type::DOUBLE:
- value = types->double_constant(boost::get<double>(dex.holder()));
+ value = types->double_constant(dex.holder().get<double>());
break;
case arrow::Type::STRING:
case arrow::Type::BINARY: {
- const std::string& str = boost::get<std::string>(dex.holder());
+ const std::string& str = dex.holder().get<std::string>();
llvm::Constant* str_int_cast = types->i64_constant((int64_t)str.c_str());
value = llvm::ConstantExpr::getIntToPtr(str_int_cast,
types->i8_ptr_type());
@@ -581,24 +581,24 @@ void LLVMGenerator::Visitor::Visit(const LiteralDex& dex)
{
}
case arrow::Type::DATE64:
- value = types->i64_constant(boost::get<int64_t>(dex.holder()));
+ value = types->i64_constant(dex.holder().get<int64_t>());
break;
case arrow::Type::TIME32:
- value = types->i32_constant(boost::get<int32_t>(dex.holder()));
+ value = types->i32_constant(dex.holder().get<int32_t>());
break;
case arrow::Type::TIME64:
- value = types->i64_constant(boost::get<int64_t>(dex.holder()));
+ value = types->i64_constant(dex.holder().get<int64_t>());
break;
case arrow::Type::TIMESTAMP:
- value = types->i64_constant(boost::get<int64_t>(dex.holder()));
+ value = types->i64_constant(dex.holder().get<int64_t>());
break;
case arrow::Type::DECIMAL: {
// build code for struct
- auto decimal_value = boost::get<Decimal128Full>(dex.holder());
+ auto decimal_value = dex.holder().get<Decimal128Full>();
auto int_value =
llvm::ConstantInt::get(llvm::Type::getInt128Ty(*generator_->context()),
decimal_value.value().ToIntegerString(), 10);
diff --git a/cpp/src/gandiva/node.h b/cpp/src/gandiva/node.h
index d31924a..77cde68 100644
--- a/cpp/src/gandiva/node.h
+++ b/cpp/src/gandiva/node.h
@@ -76,12 +76,12 @@ class LiteralNode : public Node {
// The default formatter prints in decimal can cause a loss in precision.
so,
// print in hex. Can't use hexfloat since gcc 4.9 doesn't support it.
if (return_type()->id() == arrow::Type::DOUBLE) {
- double dvalue = boost::get<double>(holder_);
+ double dvalue = holder_.get<double>();
uint64_t bits;
memcpy(&bits, &dvalue, sizeof(bits));
ss << " raw(" << std::hex << bits << ")";
} else if (return_type()->id() == arrow::Type::FLOAT) {
- float fvalue = boost::get<float>(holder_);
+ float fvalue = holder_.get<float>();
uint32_t bits;
memcpy(&bits, &fvalue, sizeof(bits));
ss << " raw(" << std::hex << bits << ")";
diff --git a/cpp/src/gandiva/to_date_holder.cc
b/cpp/src/gandiva/to_date_holder.cc
index b512934..f73d05f 100644
--- a/cpp/src/gandiva/to_date_holder.cc
+++ b/cpp/src/gandiva/to_date_holder.cc
@@ -44,7 +44,7 @@ Status ToDateHolder::Make(const FunctionNode& node,
return Status::Invalid(
"'to_date' function requires a string literal as the second
parameter");
}
- auto pattern = boost::get<std::string>(literal_pattern->holder());
+ auto pattern = literal_pattern->holder().get<std::string>();
auto literal_suppress_errors =
dynamic_cast<LiteralNode*>(node.children().at(2).get());
if (literal_pattern == nullptr) {
@@ -57,7 +57,7 @@ Status ToDateHolder::Make(const FunctionNode& node,
return Status::Invalid(
"'to_date' function requires a int literal as the third parameter");
}
- auto suppress_errors = boost::get<int>(literal_suppress_errors->holder());
+ auto suppress_errors = literal_suppress_errors->holder().get<int>();
return Make(pattern, suppress_errors, holder);
}