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
commit 7a2f1472346a6c4912adecb11e832fd167202ab2 Author: Praveen <[email protected]> AuthorDate: Tue Oct 9 15:39:35 2018 +0530 [Gandiva] Modify as per arrow code base. Change-Id: I77d796da9558fab13127e533be14be9a01978068 --- cpp/src/arrow/pretty_print.cc | 31 ++++++---- cpp/src/arrow/pretty_print.h | 8 ++- cpp/src/gandiva/arrow.h | 1 + cpp/src/gandiva/compiled_expr.h | 4 +- cpp/src/gandiva/date_utils.cc | 39 +++++++------ cpp/src/gandiva/date_utils.h | 31 +++++----- cpp/src/gandiva/eval_batch.h | 4 +- cpp/src/gandiva/execution_context.cc | 29 +++++----- cpp/src/gandiva/execution_context.h | 27 +++++---- cpp/src/gandiva/expr_decomposer.cc | 10 ++-- cpp/src/gandiva/expr_decomposer.h | 8 +-- cpp/src/gandiva/expr_decomposer_test.cc | 2 +- cpp/src/gandiva/expr_validator.cc | 2 +- cpp/src/gandiva/filter_cache_key.h | 13 ++--- cpp/src/gandiva/function_holder_registry.h | 2 +- cpp/src/gandiva/function_holder_stubs.cc | 10 ++-- cpp/src/gandiva/jni/CMakeLists.txt | 2 +- cpp/src/gandiva/jni/symbols.map | 16 ++++++ cpp/src/gandiva/like_holder.cc | 6 +- cpp/src/gandiva/like_holder.h | 2 +- cpp/src/gandiva/like_holder_test.cc | 2 +- cpp/src/gandiva/llvm_generator.cc | 66 +++++++++++----------- cpp/src/gandiva/llvm_generator.h | 56 +++++++++--------- cpp/src/gandiva/llvm_generator_test.cc | 4 +- cpp/src/gandiva/native_function.h | 6 +- cpp/src/gandiva/node.h | 42 +++++++------- cpp/src/gandiva/precompiled/CMakeLists.txt | 1 + cpp/src/gandiva/precompiled/arithmetic_ops.cc | 2 +- cpp/src/gandiva/precompiled/arithmetic_ops_test.cc | 8 ++- cpp/src/gandiva/precompiled/bitmap.cc | 6 +- cpp/src/gandiva/precompiled/context_helper.cc | 29 +++++----- cpp/src/gandiva/precompiled/extended_math_ops.cc | 57 ++++++++++--------- .../gandiva/precompiled/extended_math_ops_test.cc | 31 +++++----- cpp/src/gandiva/precompiled/string_ops.cc | 16 +++--- cpp/src/gandiva/precompiled/string_ops_test.cc | 10 +++- cpp/src/gandiva/precompiled/time.cc | 31 +++++----- cpp/src/gandiva/precompiled/time_test.cc | 24 ++++---- cpp/src/gandiva/precompiled/types.h | 28 ++++----- cpp/src/gandiva/projector_cache_key.h | 17 +++--- cpp/src/gandiva/selection_vector_impl.h | 4 +- cpp/src/gandiva/symbols-helpers.map | 16 ++++++ cpp/src/gandiva/tests/date_time_test.cc | 3 +- cpp/src/gandiva/tests/projector_test.cc | 14 ++--- cpp/src/gandiva/to_date_holder.cc | 61 ++++++++++---------- cpp/src/gandiva/to_date_holder.h | 43 +++++++------- cpp/src/gandiva/to_date_holder_test.cc | 35 ++++++------ .../arrow/gandiva/evaluator/ProjectorTest.java | 2 +- 47 files changed, 474 insertions(+), 387 deletions(-) diff --git a/cpp/src/arrow/pretty_print.cc b/cpp/src/arrow/pretty_print.cc index 73908bf..20a9d41 100644 --- a/cpp/src/arrow/pretty_print.cc +++ b/cpp/src/arrow/pretty_print.cc @@ -41,8 +41,13 @@ using internal::checked_cast; class PrettyPrinter { public: - PrettyPrinter(int indent, int indent_size, int window, std::ostream* sink) - : indent_(indent), indent_size_(indent_size), window_(window), sink_(sink) {} + PrettyPrinter(int indent, int indent_size, int window, bool skip_new_lines, + std::ostream* sink) + : indent_(indent), + indent_size_(indent_size), + window_(window), + skip_new_lines_(skip_new_lines), + sink_(sink) {} void Write(const char* data); void Write(const std::string& data); @@ -59,6 +64,7 @@ class PrettyPrinter { int indent_; int indent_size_; int window_; + bool skip_new_lines_; std::ostream* sink_; }; @@ -93,6 +99,9 @@ void PrettyPrinter::WriteIndented(const std::string& data) { } void PrettyPrinter::Newline() { + if (skip_new_lines_) { + return; + } (*sink_) << "\n"; Indent(); } @@ -106,8 +115,8 @@ void PrettyPrinter::Indent() { class ArrayPrinter : public PrettyPrinter { public: ArrayPrinter(const Array& array, int indent, int indent_size, int window, - const std::string& null_rep, std::ostream* sink) - : PrettyPrinter(indent, indent_size, window, sink), + const std::string& null_rep, bool skip_new_lines, std::ostream* sink) + : PrettyPrinter(indent, indent_size, window, skip_new_lines, sink), array_(array), null_rep_(null_rep) {} @@ -340,14 +349,14 @@ Status ArrayPrinter::WriteValidityBitmap(const Array& array) { } Status PrettyPrint(const Array& arr, int indent, std::ostream* sink) { - ArrayPrinter printer(arr, indent, 2, 10, "null", sink); + ArrayPrinter printer(arr, indent, 2, 10, "null", false, sink); return printer.Print(); } Status PrettyPrint(const Array& arr, const PrettyPrintOptions& options, std::ostream* sink) { ArrayPrinter printer(arr, options.indent, options.indent_size, options.window, - options.null_rep, sink); + options.null_rep, options.skip_new_lines, sink); return printer.Print(); } @@ -385,7 +394,8 @@ Status PrettyPrint(const ChunkedArray& chunked_arr, const PrettyPrintOptions& op skip_comma = true; } else { ArrayPrinter printer(*chunked_arr.chunk(i), indent + options.indent_size, - options.indent_size, window, options.null_rep, sink); + options.indent_size, window, options.null_rep, + options.skip_new_lines, sink); RETURN_NOT_OK(printer.Print()); } } @@ -425,8 +435,9 @@ Status DebugPrint(const Array& arr, int indent) { class SchemaPrinter : public PrettyPrinter { public: SchemaPrinter(const Schema& schema, int indent, int indent_size, int window, - std::ostream* sink) - : PrettyPrinter(indent, indent_size, window, sink), schema_(schema) {} + bool skip_new_lines, std::ostream* sink) + : PrettyPrinter(indent, indent_size, window, skip_new_lines, sink), + schema_(schema) {} Status PrintType(const DataType& type); Status PrintField(const Field& field); @@ -480,7 +491,7 @@ Status SchemaPrinter::PrintField(const Field& field) { Status PrettyPrint(const Schema& schema, const PrettyPrintOptions& options, std::ostream* sink) { SchemaPrinter printer(schema, options.indent, options.indent_size, options.window, - sink); + options.skip_new_lines, sink); return printer.Print(); } diff --git a/cpp/src/arrow/pretty_print.h b/cpp/src/arrow/pretty_print.h index 0cd454c..45c1431 100644 --- a/cpp/src/arrow/pretty_print.h +++ b/cpp/src/arrow/pretty_print.h @@ -32,11 +32,12 @@ class Status; struct PrettyPrintOptions { PrettyPrintOptions(int indent_arg, int window_arg = 10, int indent_size_arg = 2, - std::string null_rep_arg = "null") + std::string null_rep_arg = "null", bool skip_new_lines_arg = false) : indent(indent_arg), indent_size(indent_size_arg), window(window_arg), - null_rep(null_rep_arg) {} + null_rep(null_rep_arg), + skip_new_lines(skip_new_lines_arg) {} /// Number of spaces to shift entire formatted object to the right int indent; @@ -49,6 +50,9 @@ struct PrettyPrintOptions { /// String to use for representing a null value, defaults to "null" std::string null_rep; + + /// Skip new lines between elements, defaults to false + bool skip_new_lines; }; /// \brief Print human-readable representation of RecordBatch diff --git a/cpp/src/gandiva/arrow.h b/cpp/src/gandiva/arrow.h index 34cf517..f6d0855 100644 --- a/cpp/src/gandiva/arrow.h +++ b/cpp/src/gandiva/arrow.h @@ -23,6 +23,7 @@ #include <arrow/array.h> #include <arrow/builder.h> +#include <arrow/pretty_print.h> #include <arrow/record_batch.h> #include <arrow/type.h> diff --git a/cpp/src/gandiva/compiled_expr.h b/cpp/src/gandiva/compiled_expr.h index db98842..2f23971 100644 --- a/cpp/src/gandiva/compiled_expr.h +++ b/cpp/src/gandiva/compiled_expr.h @@ -23,8 +23,8 @@ namespace gandiva { -using EvalFunc = int (*)(uint8_t **buffers, uint8_t **local_bitmaps, - int64_t execution_ctx_ptr, int record_count); +using EvalFunc = int (*)(uint8_t** buffers, uint8_t** local_bitmaps, + int64_t execution_ctx_ptr, int64_t record_count); /// \brief Tracks the compiled state for one expression. class CompiledExpr { diff --git a/cpp/src/gandiva/date_utils.cc b/cpp/src/gandiva/date_utils.cc index 3841a88..1b60e10 100644 --- a/cpp/src/gandiva/date_utils.cc +++ b/cpp/src/gandiva/date_utils.cc @@ -1,16 +1,19 @@ -// Copyright (C) 2017-2018 Dremio Corporation +// 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 // -// Licensed 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 // -// 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. +// 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 <algorithm> #include <memory> @@ -39,19 +42,17 @@ std::vector<std::string> DateUtils::GetMatches(std::string pattern, bool exactMa return matches; } -std::vector<std::string> DateUtils::GetPotentialMatches(std::string pattern) { +std::vector<std::string> DateUtils::GetPotentialMatches(const std::string& pattern) { return GetMatches(pattern, false); } -std::vector<std::string> DateUtils::GetExactMatches(std::string pattern) { +std::vector<std::string> DateUtils::GetExactMatches(const std::string& pattern) { return GetMatches(pattern, true); } /** - * Validates and converts {@param format} to the strptime equivalent + * Validates and converts format to the strptime equivalent * - * @param format date format - * @return date format converted to strptime format */ Status DateUtils::ToInternalFormat(const std::string& format, std::shared_ptr<std::string>* internal_format) { @@ -107,7 +108,7 @@ Status DateUtils::ToInternalFormat(const std::string& format, // check how many matches we have for our buffer std::vector<std::string> potentialList = GetPotentialMatches(buffer.str()); - int potentialCount = potentialList.size(); + int64_t potentialCount = potentialList.size(); if (potentialCount >= 1) { // one potential and the length match @@ -125,7 +126,6 @@ Status DateUtils::ToInternalFormat(const std::string& format, std::string lookAheadPattern = (buffer.str() + format.at(i + 1)); std::transform(lookAheadPattern.begin(), lookAheadPattern.end(), lookAheadPattern.begin(), ::tolower); - ; bool lookAheadMatched = false; // we can query potentialList to see if it has anything that matches the @@ -151,7 +151,6 @@ Status DateUtils::ToInternalFormat(const std::string& format, if (matched) { std::string match = buffer.str(); std::transform(match.begin(), match.end(), match.begin(), ::tolower); - ; builder << sql_date_format_to_boost_map_[match]; buffer.str(""); continue; @@ -175,7 +174,7 @@ Status DateUtils::ToInternalFormat(const std::string& format, builder << sql_date_format_to_boost_map_[exactMatches[0]]; } else { // we didn't successfully parse the entire string - int pos = format.length() - buffer.str().length(); + int64_t pos = format.length() - buffer.str().length(); std::stringstream err_msg; err_msg << "Invalid date format string '" << format << "' at position " << pos; return Status::Invalid(err_msg.str()); diff --git a/cpp/src/gandiva/date_utils.h b/cpp/src/gandiva/date_utils.h index 664554e..cac7bff 100644 --- a/cpp/src/gandiva/date_utils.h +++ b/cpp/src/gandiva/date_utils.h @@ -1,20 +1,25 @@ -// Copyright (C) 2017-2018 Dremio Corporation +// 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 // -// Licensed 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 // -// 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. +// 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. #ifndef TO_DATE_HELPER_H #define TO_DATE_HELPER_H +#include <memory> +#include <string> #include <unordered_map> #include <vector> @@ -41,9 +46,9 @@ class DateUtils { static std::vector<std::string> GetMatches(std::string pattern, bool exactMatch); - static std::vector<std::string> GetPotentialMatches(std::string pattern); + static std::vector<std::string> GetPotentialMatches(const std::string& pattern); - static std::vector<std::string> GetExactMatches(std::string pattern); + static std::vector<std::string> GetExactMatches(const std::string& pattern); }; #ifdef GDV_HELPERS diff --git a/cpp/src/gandiva/eval_batch.h b/cpp/src/gandiva/eval_batch.h index c6501b9..9977e62 100644 --- a/cpp/src/gandiva/eval_batch.h +++ b/cpp/src/gandiva/eval_batch.h @@ -23,9 +23,9 @@ #include "arrow/util/logging.h" #include "gandiva/arrow.h" +#include "gandiva/execution_context.h" #include "gandiva/gandiva_aliases.h" #include "gandiva/local_bitmaps_holder.h" -#include "gandiva/execution_context.h" namespace gandiva { @@ -71,7 +71,7 @@ class EvalBatch { return local_bitmaps_holder_->GetLocalBitMapArray(); } - ExecutionContext *GetExecutionContext() const { return execution_context_.get(); } + ExecutionContext* GetExecutionContext() const { return execution_context_.get(); } private: /// number of records in the current batch. diff --git a/cpp/src/gandiva/execution_context.cc b/cpp/src/gandiva/execution_context.cc index d54bffd..1ff44c7 100644 --- a/cpp/src/gandiva/execution_context.cc +++ b/cpp/src/gandiva/execution_context.cc @@ -1,16 +1,19 @@ -// Copyright (C) 2017-2018 Dremio Corporation +// 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 // -// Licensed 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 // -// 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. +// 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 "gandiva/execution_context.h" @@ -19,7 +22,7 @@ namespace gandiva { namespace helpers { #endif -void ExecutionContext::set_error_msg(const char *error_msg) { +void ExecutionContext::set_error_msg(const char* error_msg) { if (error_msg_.get() == nullptr) { error_msg_.reset(new std::string(error_msg)); } @@ -37,7 +40,7 @@ bool ExecutionContext::has_error() const { } #ifdef GDV_HELPERS -} +} // namespace helpers #endif } // namespace gandiva diff --git a/cpp/src/gandiva/execution_context.h b/cpp/src/gandiva/execution_context.h index ed90232..8952abf 100644 --- a/cpp/src/gandiva/execution_context.h +++ b/cpp/src/gandiva/execution_context.h @@ -1,16 +1,19 @@ -// Copyright (C) 2017-2018 Dremio Corporation +// 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 // -// Licensed 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 // -// 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. +// 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. #ifndef ERROR_HOLDER_H #define ERROR_HOLDER_H @@ -35,7 +38,7 @@ class ExecutionContext { std::unique_ptr<std::string> error_msg_; }; #ifdef GDV_HELPERS -} +} // namespace helpers #endif } // namespace gandiva #endif // ERROR_HOLDER_H diff --git a/cpp/src/gandiva/expr_decomposer.cc b/cpp/src/gandiva/expr_decomposer.cc index c0e994d..b9017d5 100644 --- a/cpp/src/gandiva/expr_decomposer.cc +++ b/cpp/src/gandiva/expr_decomposer.cc @@ -49,7 +49,7 @@ Status ExprDecomposer::Visit(const FieldNode& node) { // Try and optimize a function node, by substituting with cheaper alternatives. // eg. replacing 'like' with 'starts_with' can save function calls at evaluation // time. -const FunctionNode ExprDecomposer::TryOptimize(const FunctionNode &node) { +const FunctionNode ExprDecomposer::TryOptimize(const FunctionNode& node) { if (node.descriptor()->name() == "like") { return LikeHolder::TryOptimize(node); } else { @@ -59,7 +59,7 @@ const FunctionNode ExprDecomposer::TryOptimize(const FunctionNode &node) { // Decompose a field node - wherever possible, merge the validity vectors of the // child nodes. -Status ExprDecomposer::Visit(const FunctionNode &in_node) { +Status ExprDecomposer::Visit(const FunctionNode& in_node) { auto node = TryOptimize(in_node); auto desc = node.descriptor(); FunctionSignature signature(desc->name(), desc->params(), desc->return_type()); @@ -116,7 +116,7 @@ Status ExprDecomposer::Visit(const FunctionNode &in_node) { } // Decompose an IfNode -Status ExprDecomposer::Visit(const IfNode &node) { +Status ExprDecomposer::Visit(const IfNode& node) { PushConditionEntry(node); auto status = node.condition()->Accept(*this); GANDIVA_RETURN_NOT_OK(status); @@ -247,12 +247,12 @@ bool ExprDecomposer::PopElseEntry(const IfNode& node) { return is_terminal_else; } -void ExprDecomposer::PushConditionEntry(const IfNode &node) { +void ExprDecomposer::PushConditionEntry(const IfNode& node) { std::unique_ptr<IfStackEntry> entry(new IfStackEntry(node, kStackEntryCondition)); if_entries_stack_.push(std::move(entry)); } -void ExprDecomposer::PopConditionEntry(const IfNode &node) { +void ExprDecomposer::PopConditionEntry(const IfNode& node) { DCHECK_EQ(if_entries_stack_.empty(), false) << "PopConditionEntry: found empty stack"; auto top = if_entries_stack_.top().get(); diff --git a/cpp/src/gandiva/expr_decomposer.h b/cpp/src/gandiva/expr_decomposer.h index 55e9d70..24511cc 100644 --- a/cpp/src/gandiva/expr_decomposer.h +++ b/cpp/src/gandiva/expr_decomposer.h @@ -61,14 +61,14 @@ class ExprDecomposer : public NodeVisitor { Status Visit(const BooleanNode& node) override; // Optimize a function node, if possible. - const FunctionNode TryOptimize(const FunctionNode &node); + const FunctionNode TryOptimize(const FunctionNode& node); enum StackEntryType { kStackEntryCondition, kStackEntryThen, kStackEntryElse }; // stack of if nodes. class IfStackEntry { public: - IfStackEntry(const IfNode &if_node, StackEntryType entry_type, + IfStackEntry(const IfNode& if_node, StackEntryType entry_type, bool is_terminal_else = false, int local_bitmap_idx = 0) : if_node_(if_node), entry_type_(entry_type), @@ -82,10 +82,10 @@ class ExprDecomposer : public NodeVisitor { }; // pop 'condition entry' into stack. - void PushConditionEntry(const IfNode &node); + void PushConditionEntry(const IfNode& node); // pop 'condition entry' from stack. - void PopConditionEntry(const IfNode &node); + void PopConditionEntry(const IfNode& node); // push 'then entry' to stack. returns either a new local bitmap or the parent's // bitmap (in case of nested if-else). diff --git a/cpp/src/gandiva/expr_decomposer_test.cc b/cpp/src/gandiva/expr_decomposer_test.cc index 0421dfe..dff50af 100644 --- a/cpp/src/gandiva/expr_decomposer_test.cc +++ b/cpp/src/gandiva/expr_decomposer_test.cc @@ -243,7 +243,7 @@ TEST_F(TestExprDecomposer, TestIfInCondition) { EXPECT_EQ(decomposer.if_entries_stack_.empty(), true); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/cpp/src/gandiva/expr_validator.cc b/cpp/src/gandiva/expr_validator.cc index ad6825e..849583f 100644 --- a/cpp/src/gandiva/expr_validator.cc +++ b/cpp/src/gandiva/expr_validator.cc @@ -140,7 +140,7 @@ Status ExprValidator::Visit(const BooleanNode& node) { return Status::ExpressionValidationError(ss.str()); } - for (auto &child : node.children()) { + for (auto& child : node.children()) { if (!child->return_type()->Equals(arrow::boolean())) { std::stringstream ss; ss << "Boolean expression has a child with return type " diff --git a/cpp/src/gandiva/filter_cache_key.h b/cpp/src/gandiva/filter_cache_key.h index 9b0e402..906dd52 100644 --- a/cpp/src/gandiva/filter_cache_key.h +++ b/cpp/src/gandiva/filter_cache_key.h @@ -30,7 +30,7 @@ namespace gandiva { class FilterCacheKey { public: FilterCacheKey(SchemaPtr schema, std::shared_ptr<Configuration> configuration, - Expression &expression) + Expression& expression) : schema_(schema), configuration_(configuration), uniqifier_(0) { static const int kSeedValue = 4; size_t result = kSeedValue; @@ -71,19 +71,16 @@ class FilterCacheKey { std::string ToString() const { std::stringstream ss; - ss << "Schema ["; - - // remove newlines from schema - auto schema_str = schema_->ToString(); - std::replace(schema_str.begin(), schema_str.end(), '\n', ','); - ss << schema_str << "] "; + // indent, window, indent_size, null_rep and skip new lines. + arrow::PrettyPrintOptions options{0, 10, 2, "null", true}; + PrettyPrint(*schema_.get(), options, &ss); ss << "Condition: [" << expression_as_string_ << "]"; return ss.str(); } private: - void UpdateUniqifier(const std::string expr) { + void UpdateUniqifier(const std::string& expr) { // caching of expressions with re2 patterns causes lock contention. So, use // multiple instances to reduce contention. if (expr.find(" like(") != std::string::npos) { diff --git a/cpp/src/gandiva/function_holder_registry.h b/cpp/src/gandiva/function_holder_registry.h index 93996c7..a6f4671 100644 --- a/cpp/src/gandiva/function_holder_registry.h +++ b/cpp/src/gandiva/function_holder_registry.h @@ -25,8 +25,8 @@ #include "gandiva/function_holder.h" #include "gandiva/like_holder.h" #include "gandiva/node.h" -#include "gandiva/to_date_holder.h" #include "gandiva/status.h" +#include "gandiva/to_date_holder.h" namespace gandiva { diff --git a/cpp/src/gandiva/function_holder_stubs.cc b/cpp/src/gandiva/function_holder_stubs.cc index 9708674..f37f653 100644 --- a/cpp/src/gandiva/function_holder_stubs.cc +++ b/cpp/src/gandiva/function_holder_stubs.cc @@ -26,13 +26,13 @@ extern "C" bool like_utf8_utf8(int64_t ptr, const char* data, int data_len, return (*holder)(std::string(data, data_len)); } -extern "C" int64_t to_date_utf8_utf8_int32(int64_t ptr, const char *data, int data_len, - bool in1_validity, const char *pattern, +extern "C" int64_t to_date_utf8_utf8_int32(int64_t ptr, const char* data, int data_len, + bool in1_validity, const char* pattern, int pattern_len, bool in2_validity, int32_t suppress_errors, bool in3_validity, - int64_t execution_context, bool *out_valid) { - gandiva::helpers::ToDateHolder *holder = - reinterpret_cast<gandiva::helpers::ToDateHolder *>(ptr); + int64_t execution_context, bool* out_valid) { + gandiva::helpers::ToDateHolder* holder = + reinterpret_cast<gandiva::helpers::ToDateHolder*>(ptr); return (*holder)(std::string(data, data_len), in1_validity, execution_context, out_valid); } diff --git a/cpp/src/gandiva/jni/CMakeLists.txt b/cpp/src/gandiva/jni/CMakeLists.txt index cd20b0e..1ddec11 100644 --- a/cpp/src/gandiva/jni/CMakeLists.txt +++ b/cpp/src/gandiva/jni/CMakeLists.txt @@ -75,7 +75,7 @@ target_include_directories(gandiva_jni # filter out everything that is not needed for the jni bridge # statically linked stdc++ has conflicts with stdc++ loaded by other libraries. if (NOT APPLE) -set_target_properties(gandiva_jni PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/src/jni/symbols.map") +set_target_properties(gandiva_jni PROPERTIES LINK_FLAGS "-Wl,--version-script=${CMAKE_SOURCE_DIR}/src/gandiva/jni/symbols.map") endif() # PROTOBUF is a private dependency i.e users of gandiva also will not have a dependency on protobuf. diff --git a/cpp/src/gandiva/jni/symbols.map b/cpp/src/gandiva/jni/symbols.map index a228500..a387ae1 100644 --- a/cpp/src/gandiva/jni/symbols.map +++ b/cpp/src/gandiva/jni/symbols.map @@ -1,3 +1,19 @@ +# 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. { global: extern "C++" { gandiva*; Java*; JNI*; }; local: *; diff --git a/cpp/src/gandiva/like_holder.cc b/cpp/src/gandiva/like_holder.cc index b790fb3..5f72a69 100644 --- a/cpp/src/gandiva/like_holder.cc +++ b/cpp/src/gandiva/like_holder.cc @@ -32,11 +32,11 @@ RE2 LikeHolder::ends_with_regex_(R"(\.\*(\w|\s)*)"); // Short-circuit pattern matches for the two common sub cases : // - starts_with and ends_with. -const FunctionNode LikeHolder::TryOptimize(const FunctionNode &node) { +const FunctionNode LikeHolder::TryOptimize(const FunctionNode& node) { std::shared_ptr<LikeHolder> holder; auto status = Make(node, &holder); if (status.ok()) { - std::string &pattern = holder->pattern_; + std::string& pattern = holder->pattern_; auto literal_type = node.children().at(1)->return_type(); if (RE2::FullMatch(pattern, starts_with_regex_)) { @@ -58,7 +58,7 @@ const FunctionNode LikeHolder::TryOptimize(const FunctionNode &node) { return node; } -Status LikeHolder::Make(const FunctionNode &node, std::shared_ptr<LikeHolder> *holder) { +Status LikeHolder::Make(const FunctionNode& node, std::shared_ptr<LikeHolder>* holder) { if (node.children().size() != 2) { return Status::Invalid("'like' function requires two parameters"); } diff --git a/cpp/src/gandiva/like_holder.h b/cpp/src/gandiva/like_holder.h index 3a88f4f..b023e08 100644 --- a/cpp/src/gandiva/like_holder.h +++ b/cpp/src/gandiva/like_holder.h @@ -42,7 +42,7 @@ class LikeHolder : public FunctionHolder { static Status Make(const std::string& sql_pattern, std::shared_ptr<LikeHolder>* holder); // Try and optimise a function node with a "like" pattern. - static const FunctionNode TryOptimize(const FunctionNode &node); + static const FunctionNode TryOptimize(const FunctionNode& node); /// Return true if the data matches the pattern. bool operator()(const std::string& data) { return RE2::FullMatch(data, regex_); } diff --git a/cpp/src/gandiva/like_holder_test.cc b/cpp/src/gandiva/like_holder_test.cc index baaba34..3e3cd37 100644 --- a/cpp/src/gandiva/like_holder_test.cc +++ b/cpp/src/gandiva/like_holder_test.cc @@ -115,7 +115,7 @@ TEST_F(TestLikeHolder, TestOptimise) { EXPECT_EQ(fnode.descriptor()->name(), "like"); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/cpp/src/gandiva/llvm_generator.cc b/cpp/src/gandiva/llvm_generator.cc index 2312b10..7713900 100644 --- a/cpp/src/gandiva/llvm_generator.cc +++ b/cpp/src/gandiva/llvm_generator.cc @@ -74,7 +74,7 @@ Status LLVMGenerator::Add(const ExpressionPtr expr, const FieldDescriptorPtr out Status LLVMGenerator::Build(const ExpressionVector& exprs) { Status status; - for (auto &expr : exprs) { + for (auto& expr : exprs) { auto output = annotator_.AddOutputFieldDescriptor(expr->result()); status = Add(expr, output); GANDIVA_RETURN_NOT_OK(status); @@ -101,7 +101,7 @@ Status LLVMGenerator::Execute(const arrow::RecordBatch& record_batch, auto eval_batch = annotator_.PrepareEvalBatch(record_batch, output_vector); DCHECK_GT(eval_batch->GetNumBuffers(), 0); - for (auto &compiled_expr : compiled_exprs_) { + for (auto& compiled_expr : compiled_exprs_) { // generate data/offset vectors. EvalFunc jit_function = compiled_expr->jit_function(); jit_function(eval_batch->GetBufferArray(), eval_batch->GetLocalBitMapArray(), @@ -169,8 +169,8 @@ llvm::Value* LLVMGenerator::GetLocalBitMapReference(llvm::Value* arg_bitmaps, in // // The C-code equivalent is : // ------------------------------ -// int expr_0(int64_t *addrs, int64_t *local_bitmaps, int 64_t execution_context_ptr, int -// nrecords) { +// int expr_0(int64_t *addrs, int64_t *local_bitmaps, +// int64_t execution_context_ptr, int64_t nrecords) { // int *outVec = (int *) addrs[5]; // int *c0Vec = (int *) addrs[1]; // int *c1Vec = (int *) addrs[3]; @@ -185,7 +185,7 @@ llvm::Value* LLVMGenerator::GetLocalBitMapReference(llvm::Value* arg_bitmaps, in // IR Code // -------- // -// define i32 @expr_0(i64* %args, i64* %local_bitmaps, i64 %execution_context_ptr, , i32 +// define i32 @expr_0(i64* %args, i64* %local_bitmaps, i64 %execution_context_ptr, , i64 // %nrecords) { entry: // %outmemAddr = getelementptr i64, i64* %args, i32 5 // %outmem = load i64, i64* %outmemAddr @@ -198,8 +198,8 @@ llvm::Value* LLVMGenerator::GetLocalBitMapReference(llvm::Value* arg_bitmaps, in // %c1Vec = inttoptr i64 %c1mem to i32* // br label %loop // loop: ; preds = %loop, %entry -// %loop_var = phi i32 [ 0, %entry ], [ %"loop_var+1", %loop ] -// %"loop_var+1" = add i32 %loop_var, 1 +// %loop_var = phi i64 [ 0, %entry ], [ %"loop_var+1", %loop ] +// %"loop_var+1" = add i64 %loop_var, 1 // %0 = getelementptr i32, i32* %c0Vec, i32 %loop_var // %c0 = load i32, i32* %0 // %1 = getelementptr i32, i32* %c1Vec, i32 %loop_var @@ -207,7 +207,7 @@ llvm::Value* LLVMGenerator::GetLocalBitMapReference(llvm::Value* arg_bitmaps, in // %add_int_int = call i32 @add_int_int(i32 %c0, i32 %c1) // %2 = getelementptr i32, i32* %outVec, i32 %loop_var // store i32 %add_int_int, i32* %2 -// %"loop_var < nrec" = icmp slt i32 %"loop_var+1", %nrecords +// %"loop_var < nrec" = icmp slt i64 %"loop_var+1", %nrecords // br i1 %"loop_var < nrec", label %loop, label %exit // exit: ; preds = %loop // ret i32 0 @@ -218,12 +218,12 @@ Status LLVMGenerator::CodeGenExprValue(DexPtr value_expr, FieldDescriptorPtr out llvm::IRBuilder<>& builder = ir_builder(); // Create fn prototype : - // int expr_1 (long **addrs, long **bitmaps, long *context_ptr, int nrec) - std::vector<llvm::Type *> arguments; + // int expr_1 (long **addrs, long **bitmaps, long *context_ptr, long nrec) + std::vector<llvm::Type*> arguments; arguments.push_back(types_->i64_ptr_type()); arguments.push_back(types_->i64_ptr_type()); arguments.push_back(types_->i64_type()); - arguments.push_back(types_->i32_type()); + arguments.push_back(types_->i64_type()); llvm::FunctionType* prototype = llvm::FunctionType::get(types_->i32_type(), arguments, false /*isVarArg*/); @@ -242,10 +242,10 @@ Status LLVMGenerator::CodeGenExprValue(DexPtr value_expr, FieldDescriptorPtr out llvm::Value* arg_local_bitmaps = &*args; arg_local_bitmaps->setName("local_bitmaps"); ++args; - llvm::Value *arg_context_ptr = &*args; + llvm::Value* arg_context_ptr = &*args; arg_context_ptr->setName("context_ptr"); ++args; - llvm::Value *arg_nrecords = &*args; + llvm::Value* arg_nrecords = &*args; arg_nrecords->setName("nrecords"); llvm::BasicBlock* loop_entry = llvm::BasicBlock::Create(context(), "entry", *fn); @@ -261,7 +261,7 @@ Status LLVMGenerator::CodeGenExprValue(DexPtr value_expr, FieldDescriptorPtr out builder.SetInsertPoint(loop_body); // define loop_var : start with 0, +1 after each iter - llvm::PHINode* loop_var = builder.CreatePHI(types_->i32_type(), 2, "loop_var"); + llvm::PHINode* loop_var = builder.CreatePHI(types_->i64_type(), 2, "loop_var"); // The visitor can add code to both the entry/loop blocks. Visitor visitor(this, *fn, loop_entry, arg_addrs, arg_local_bitmaps, arg_context_ptr, @@ -287,9 +287,9 @@ Status LLVMGenerator::CodeGenExprValue(DexPtr value_expr, FieldDescriptorPtr out ADD_TRACE("saving result " + output->Name() + " value %T", output_value->data()); // check loop_var - loop_var->addIncoming(types_->i32_constant(0), loop_entry); + loop_var->addIncoming(types_->i64_constant(0), loop_entry); llvm::Value* loop_update = - builder.CreateAdd(loop_var, types_->i32_constant(1), "loop_var+1"); + builder.CreateAdd(loop_var, types_->i64_constant(1), "loop_var+1"); loop_var->addIncoming(loop_update, loop_body_tail); llvm::Value* loop_var_check = @@ -412,10 +412,10 @@ llvm::Value* LLVMGenerator::AddFunctionCall(const std::string& full_name, } // Visitor for generating the code for a decomposed expression. -LLVMGenerator::Visitor::Visitor(LLVMGenerator *generator, llvm::Function *function, - llvm::BasicBlock *entry_block, llvm::Value *arg_addrs, - llvm::Value *arg_local_bitmaps, - llvm::Value *arg_context_ptr, llvm::Value *loop_var) +LLVMGenerator::Visitor::Visitor(LLVMGenerator* generator, llvm::Function* function, + llvm::BasicBlock* entry_block, llvm::Value* arg_addrs, + llvm::Value* arg_local_bitmaps, + llvm::Value* arg_context_ptr, llvm::Value* loop_var) : generator_(generator), function_(function), entry_block_(entry_block), @@ -458,7 +458,7 @@ void LLVMGenerator::Visitor::Visit(const VectorReadVarLenValueDex& dex) { // => offset_end = offsets[loop_var + 1] llvm::Value* loop_var_next = - builder.CreateAdd(loop_var_, generator_->types_->i32_constant(1), "loop_var+1"); + builder.CreateAdd(loop_var_, generator_->types_->i64_constant(1), "loop_var+1"); slot = builder.CreateGEP(offsets_slot_ref, loop_var_next); llvm::Value* offset_end = builder.CreateLoad(slot, "offset_end"); @@ -590,13 +590,13 @@ void LLVMGenerator::Visitor::Visit(const NonNullableFuncDex& dex) { dex.func_descriptor()->name()); LLVMTypes* types = generator_->types_.get(); - const NativeFunction *native_function = dex.native_function(); + const NativeFunction* native_function = dex.native_function(); // build the function params (ignore validity). auto params = BuildParams(dex.function_holder().get(), dex.args(), false, native_function->needs_context()); - llvm::Type *ret_type = types->IRType(native_function->signature().ret_type()->id()); + llvm::Type* ret_type = types->IRType(native_function->signature().ret_type()->id()); llvm::Value* value = generator_->AddFunctionCall(native_function->pc_name(), ret_type, params); @@ -607,14 +607,14 @@ void LLVMGenerator::Visitor::Visit(const NullableNeverFuncDex& dex) { ADD_VISITOR_TRACE("visit NullableNever base function " + dex.func_descriptor()->name()); LLVMTypes* types = generator_->types_.get(); - const NativeFunction *native_function = dex.native_function(); + const NativeFunction* native_function = dex.native_function(); // build function params along with validity. auto params = BuildParams(dex.function_holder().get(), dex.args(), true, native_function->needs_context()); - llvm::Type *ret_type = types->IRType(native_function->signature().ret_type()->id()); - llvm::Value *value = + llvm::Type* ret_type = types->IRType(native_function->signature().ret_type()->id()); + llvm::Value* value = generator_->AddFunctionCall(native_function->pc_name(), ret_type, params); result_.reset(new LValue(value)); } @@ -625,7 +625,7 @@ void LLVMGenerator::Visitor::Visit(const NullableInternalFuncDex& dex) { llvm::IRBuilder<>& builder = ir_builder(); LLVMTypes* types = generator_->types_.get(); - const NativeFunction *native_function = dex.native_function(); + const NativeFunction* native_function = dex.native_function(); // build function params along with validity. auto params = BuildParams(dex.function_holder().get(), dex.args(), true, @@ -636,8 +636,8 @@ void LLVMGenerator::Visitor::Visit(const NullableInternalFuncDex& dex) { new llvm::AllocaInst(types->i8_type(), 0, "result_valid", entry_block_); params.push_back(result_valid_ptr); - llvm::Type *ret_type = types->IRType(native_function->signature().ret_type()->id()); - llvm::Value *value = + llvm::Type* ret_type = types->IRType(native_function->signature().ret_type()->id()); + llvm::Value* value = generator_->AddFunctionCall(native_function->pc_name(), ret_type, params); // load the result validity and truncate to i1. @@ -872,11 +872,11 @@ LValuePtr LLVMGenerator::Visitor::BuildValueAndValidity(const ValueValidityPair& return std::make_shared<LValue>(value, length, validity); } -std::vector<llvm::Value *> LLVMGenerator::Visitor::BuildParams( - FunctionHolder *holder, const ValueValidityPairVector &args, bool with_validity, +std::vector<llvm::Value*> LLVMGenerator::Visitor::BuildParams( + FunctionHolder* holder, const ValueValidityPairVector& args, bool with_validity, bool with_context) { - LLVMTypes *types = generator_->types_.get(); - std::vector<llvm::Value *> params; + LLVMTypes* types = generator_->types_.get(); + std::vector<llvm::Value*> params; // if the function has holder, add the holder pointer first. if (holder != nullptr) { diff --git a/cpp/src/gandiva/llvm_generator.h b/cpp/src/gandiva/llvm_generator.h index c57bba4..547e0be 100644 --- a/cpp/src/gandiva/llvm_generator.h +++ b/cpp/src/gandiva/llvm_generator.h @@ -30,9 +30,9 @@ #include "gandiva/annotator.h" #include "gandiva/compiled_expr.h" #include "gandiva/configuration.h" -#include "gandiva/execution_context.h" #include "gandiva/dex_visitor.h" #include "gandiva/engine.h" +#include "gandiva/execution_context.h" #include "gandiva/function_registry.h" #include "gandiva/gandiva_aliases.h" #include "gandiva/llvm_types.h" @@ -74,24 +74,24 @@ class LLVMGenerator { /// Visitor to generate the code for a decomposed expression. class Visitor : public DexVisitor { public: - Visitor(LLVMGenerator *generator, llvm::Function *function, - llvm::BasicBlock *entry_block, llvm::Value *arg_addrs, - llvm::Value *arg_local_bitmaps, llvm::Value *arg_context_ptr, - llvm::Value *loop_var); - - void Visit(const VectorReadValidityDex &dex) override; - void Visit(const VectorReadFixedLenValueDex &dex) override; - void Visit(const VectorReadVarLenValueDex &dex) override; - void Visit(const LocalBitMapValidityDex &dex) override; - void Visit(const TrueDex &dex) override; - void Visit(const FalseDex &dex) override; - void Visit(const LiteralDex &dex) override; - void Visit(const NonNullableFuncDex &dex) override; - void Visit(const NullableNeverFuncDex &dex) override; - void Visit(const NullableInternalFuncDex &dex) override; - void Visit(const IfDex &dex) override; - void Visit(const BooleanAndDex &dex) override; - void Visit(const BooleanOrDex &dex) override; + Visitor(LLVMGenerator* generator, llvm::Function* function, + llvm::BasicBlock* entry_block, llvm::Value* arg_addrs, + llvm::Value* arg_local_bitmaps, llvm::Value* arg_context_ptr, + llvm::Value* loop_var); + + void Visit(const VectorReadValidityDex& dex) override; + void Visit(const VectorReadFixedLenValueDex& dex) override; + void Visit(const VectorReadVarLenValueDex& dex) override; + void Visit(const LocalBitMapValidityDex& dex) override; + void Visit(const TrueDex& dex) override; + void Visit(const FalseDex& dex) override; + void Visit(const LiteralDex& dex) override; + void Visit(const NonNullableFuncDex& dex) override; + void Visit(const NullableNeverFuncDex& dex) override; + void Visit(const NullableInternalFuncDex& dex) override; + void Visit(const IfDex& dex) override; + void Visit(const BooleanAndDex& dex) override; + void Visit(const BooleanOrDex& dex) override; LValuePtr result() { return result_; } @@ -109,9 +109,9 @@ class LLVMGenerator { LValuePtr BuildValueAndValidity(const ValueValidityPair& pair); // Generate code to build the params. - std::vector<llvm::Value *> BuildParams(FunctionHolder *holder, - const ValueValidityPairVector &args, - bool with_validity, bool with_context); + std::vector<llvm::Value*> BuildParams(FunctionHolder* holder, + const ValueValidityPairVector& args, + bool with_validity, bool with_context); // Switch to the entry_block and get reference of the validity/value/offsets buffer llvm::Value* GetBufferReference(int idx, BufferType buffer_type, FieldPtr field); @@ -124,12 +124,12 @@ class LLVMGenerator { LLVMGenerator* generator_; LValuePtr result_; - llvm::Function *function_; - llvm::BasicBlock *entry_block_; - llvm::Value *arg_addrs_; - llvm::Value *arg_local_bitmaps_; - llvm::Value *arg_context_ptr_; - llvm::Value *loop_var_; + llvm::Function* function_; + llvm::BasicBlock* entry_block_; + llvm::Value* arg_addrs_; + llvm::Value* arg_local_bitmaps_; + llvm::Value* arg_context_ptr_; + llvm::Value* loop_var_; }; // Generate the code for one expression, with the output of the expression going to diff --git a/cpp/src/gandiva/llvm_generator_test.cc b/cpp/src/gandiva/llvm_generator_test.cc index e50e8f8..ae83b02 100644 --- a/cpp/src/gandiva/llvm_generator_test.cc +++ b/cpp/src/gandiva/llvm_generator_test.cc @@ -112,7 +112,7 @@ TEST_F(TestLLVMGenerator, TestAdd) { reinterpret_cast<uint8_t*>(a1), reinterpret_cast<uint8_t*>(&in_bitmap), reinterpret_cast<uint8_t*>(out), reinterpret_cast<uint8_t*>(&out_bitmap), }; - eval_func(addrs, nullptr, 0, num_records); + eval_func(addrs, nullptr, 0 /* dummy context ptr */, num_records); uint32_t expected[] = {6, 8, 10, 12}; for (int i = 0; i < num_records; i++) { @@ -179,7 +179,7 @@ TEST_F(TestLLVMGenerator, TestNullInternal) { reinterpret_cast<uint8_t*>(&local_bitmap), }; - eval_func(addrs, local_bitmap_addrs, 0, num_records); + eval_func(addrs, local_bitmap_addrs, 0 /* dummy context ptr */, num_records); uint32_t expected_value[] = {0, 1, 0, 2}; bool expected_validity[] = {false, true, false, true}; diff --git a/cpp/src/gandiva/native_function.h b/cpp/src/gandiva/native_function.h index 744904f..e009410 100644 --- a/cpp/src/gandiva/native_function.h +++ b/cpp/src/gandiva/native_function.h @@ -46,9 +46,9 @@ class NativeFunction { bool needs_context() const { return needs_context_; } private: - NativeFunction(const std::string &base_name, const DataTypeVector ¶m_types, - DataTypePtr ret_type, const ResultNullableType &result_nullable_type, - const std::string &pc_name, bool needs_holder = false, + NativeFunction(const std::string& base_name, const DataTypeVector& param_types, + DataTypePtr ret_type, const ResultNullableType& result_nullable_type, + const std::string& pc_name, bool needs_holder = false, bool needs_context = false) : signature_(base_name, param_types, ret_type), needs_holder_(needs_holder), diff --git a/cpp/src/gandiva/node.h b/cpp/src/gandiva/node.h index fbb7495..5da7e9f 100644 --- a/cpp/src/gandiva/node.h +++ b/cpp/src/gandiva/node.h @@ -38,10 +38,10 @@ class Node { virtual ~Node() = default; - const DataTypePtr &return_type() const { return return_type_; } + const DataTypePtr& return_type() const { return return_type_; } /// Derived classes should simply invoke the Visit api of the visitor. - virtual Status Accept(NodeVisitor &visitor) const = 0; + virtual Status Accept(NodeVisitor& visitor) const = 0; virtual std::string ToString() const = 0; @@ -52,12 +52,12 @@ class Node { /// \brief Node in the expression tree, representing a literal. class LiteralNode : public Node { public: - LiteralNode(DataTypePtr type, const LiteralHolder &holder, bool is_null) + LiteralNode(DataTypePtr type, const LiteralHolder& holder, bool is_null) : Node(type), holder_(holder), is_null_(is_null) {} - Status Accept(NodeVisitor &visitor) const override { return visitor.Visit(*this); } + Status Accept(NodeVisitor& visitor) const override { return visitor.Visit(*this); } - const LiteralHolder &holder() const { return holder_; } + const LiteralHolder& holder() const { return holder_; } bool is_null() const { return is_null_; } @@ -96,9 +96,9 @@ class FieldNode : public Node { public: explicit FieldNode(FieldPtr field) : Node(field->type()), field_(field) {} - Status Accept(NodeVisitor &visitor) const override { return visitor.Visit(*this); } + Status Accept(NodeVisitor& visitor) const override { return visitor.Visit(*this); } - const FieldPtr &field() const { return field_; } + const FieldPtr& field() const { return field_; } std::string ToString() const override { return "(" + field()->type()->name() + ") " + field()->name(); @@ -111,12 +111,12 @@ class FieldNode : public Node { /// \brief Node in the expression tree, representing a function. class FunctionNode : public Node { public: - FunctionNode(const std::string &name, const NodeVector &children, DataTypePtr retType); + FunctionNode(const std::string& name, const NodeVector& children, DataTypePtr retType); - Status Accept(NodeVisitor &visitor) const override { return visitor.Visit(*this); } + Status Accept(NodeVisitor& visitor) const override { return visitor.Visit(*this); } - const FuncDescriptorPtr &descriptor() const { return descriptor_; } - const NodeVector &children() const { return children_; } + const FuncDescriptorPtr& descriptor() const { return descriptor_; } + const NodeVector& children() const { return children_; } std::string ToString() const override { std::stringstream ss; @@ -139,11 +139,11 @@ class FunctionNode : public Node { NodeVector children_; }; -inline FunctionNode::FunctionNode(const std::string &name, const NodeVector &children, +inline FunctionNode::FunctionNode(const std::string& name, const NodeVector& children, DataTypePtr return_type) : Node(return_type), children_(children) { DataTypeVector param_types; - for (auto &child : children) { + for (auto& child : children) { param_types.push_back(child->return_type()); } @@ -159,11 +159,11 @@ class IfNode : public Node { then_node_(then_node), else_node_(else_node) {} - Status Accept(NodeVisitor &visitor) const override { return visitor.Visit(*this); } + Status Accept(NodeVisitor& visitor) const override { return visitor.Visit(*this); } - const NodePtr &condition() const { return condition_; } - const NodePtr &then_node() const { return then_node_; } - const NodePtr &else_node() const { return else_node_; } + const NodePtr& condition() const { return condition_; } + const NodePtr& then_node() const { return then_node_; } + const NodePtr& else_node() const { return else_node_; } std::string ToString() const override { std::stringstream ss; @@ -184,19 +184,19 @@ class BooleanNode : public Node { public: enum ExprType : char { AND, OR }; - BooleanNode(ExprType expr_type, const NodeVector &children) + BooleanNode(ExprType expr_type, const NodeVector& children) : Node(arrow::boolean()), expr_type_(expr_type), children_(children) {} - Status Accept(NodeVisitor &visitor) const override { return visitor.Visit(*this); } + Status Accept(NodeVisitor& visitor) const override { return visitor.Visit(*this); } ExprType expr_type() const { return expr_type_; } - const NodeVector &children() const { return children_; } + const NodeVector& children() const { return children_; } std::string ToString() const override { std::stringstream ss; bool first = true; - for (auto &child : children_) { + for (auto& child : children_) { if (!first) { if (expr_type() == BooleanNode::AND) { ss << " && "; diff --git a/cpp/src/gandiva/precompiled/CMakeLists.txt b/cpp/src/gandiva/precompiled/CMakeLists.txt index 21621b4..aa93f5b 100644 --- a/cpp/src/gandiva/precompiled/CMakeLists.txt +++ b/cpp/src/gandiva/precompiled/CMakeLists.txt @@ -38,6 +38,7 @@ foreach(SRC_FILE ${PRECOMPILED_SRCS}) OUTPUT ${BC_FILE} COMMAND ${CLANG_EXECUTABLE} -D GDV_HELPERS -std=c++11 -emit-llvm -O2 -c ${ABSOLUTE_SRC} -o ${BC_FILE} + -I${CMAKE_SOURCE_DIR}/src DEPENDS ${SRC_FILE}) list(APPEND BC_FILES ${BC_FILE}) endforeach() diff --git a/cpp/src/gandiva/precompiled/arithmetic_ops.cc b/cpp/src/gandiva/precompiled/arithmetic_ops.cc index ae6a0d3..61a77b8 100644 --- a/cpp/src/gandiva/precompiled/arithmetic_ops.cc +++ b/cpp/src/gandiva/precompiled/arithmetic_ops.cc @@ -172,7 +172,7 @@ NUMERIC_BOOL_DATE_FUNCTION(IS_NOT_DISTINCT_FROM) return 0; \ } \ *out_valid = true; \ - return in1 / in2; \ + return static_cast<TYPE>(in1 / in2); \ } NUMERIC_FUNCTION(DIVIDE_NULL_INTERNAL) diff --git a/cpp/src/gandiva/precompiled/arithmetic_ops_test.cc b/cpp/src/gandiva/precompiled/arithmetic_ops_test.cc index d7fded8..0a56d2e 100644 --- a/cpp/src/gandiva/precompiled/arithmetic_ops_test.cc +++ b/cpp/src/gandiva/precompiled/arithmetic_ops_test.cc @@ -16,8 +16,8 @@ // under the License. #include <gtest/gtest.h> -#include "gandiva/precompiled/types.h" #include "../execution_context.h" +#include "gandiva/precompiled/types.h" namespace gandiva { @@ -38,14 +38,16 @@ TEST(TestArithmeticOps, TestMod) { EXPECT_EQ(mod_int64_int32(10, 0), 10); } TEST(TestArithmeticOps, TestDivide) { boolean is_valid; gandiva::helpers::ExecutionContext error_holder; - int64 out = divide_int64_int64(10, true, 0, true, (int64)&error_holder, &is_valid); + int64 out = divide_int64_int64(10, true, 0, true, + reinterpret_cast<int64>(&error_holder), &is_valid); EXPECT_EQ(out, 0); EXPECT_EQ(is_valid, false); EXPECT_EQ(error_holder.has_error(), true); EXPECT_EQ(error_holder.get_error(), "divide by zero error"); gandiva::helpers::ExecutionContext error_holder1; - out = divide_int64_int64(10, true, 2, true, (int64)&error_holder, &is_valid); + out = divide_int64_int64(10, true, 2, true, reinterpret_cast<int64>(&error_holder), + &is_valid); EXPECT_EQ(out, 5); EXPECT_EQ(is_valid, true); EXPECT_EQ(error_holder1.has_error(), false); diff --git a/cpp/src/gandiva/precompiled/bitmap.cc b/cpp/src/gandiva/precompiled/bitmap.cc index 651f2cb..f3be00e 100644 --- a/cpp/src/gandiva/precompiled/bitmap.cc +++ b/cpp/src/gandiva/precompiled/bitmap.cc @@ -30,18 +30,18 @@ extern "C" { #define POS_TO_BIT_INDEX(p) (p % 8) FORCE_INLINE -bool bitMapGetBit(const uint8_t* bmap, int position) { +bool bitMapGetBit(const uint8_t* bmap, int64_t position) { return arrow::BitUtil::GetBit(bmap, position); } FORCE_INLINE -void bitMapSetBit(uint8_t* bmap, int position, bool value) { +void bitMapSetBit(uint8_t* bmap, int64_t position, bool value) { arrow::BitUtil::SetBitTo(bmap, position, value); } // Clear the bit if value = false. Does nothing if value = true. FORCE_INLINE -void bitMapClearBitIfFalse(uint8_t* bmap, int position, bool value) { +void bitMapClearBitIfFalse(uint8_t* bmap, int64_t position, bool value) { if (!value) { arrow::BitUtil::ClearBit(bmap, position); } diff --git a/cpp/src/gandiva/precompiled/context_helper.cc b/cpp/src/gandiva/precompiled/context_helper.cc index 35dfdf7..60ab7d1 100644 --- a/cpp/src/gandiva/precompiled/context_helper.cc +++ b/cpp/src/gandiva/precompiled/context_helper.cc @@ -1,22 +1,25 @@ -// Copyright (C) 2017-2018 Dremio Corporation +// 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 // -// Licensed 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 // -// 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. +// 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. #ifndef GANDIVA_CONTEXT_HELPER_H #define GANDIVA_CONTEXT_HELPER_H -#include "../execution_context.h" -#include "types.h" +#include "gandiva/execution_context.h" +#include "gandiva/precompiled/types.h" void context_set_error_msg(int64_t context_ptr, char const* err_msg) { gandiva::helpers::ExecutionContext* execution_context_ptr = diff --git a/cpp/src/gandiva/precompiled/extended_math_ops.cc b/cpp/src/gandiva/precompiled/extended_math_ops.cc index 617819a..2872e93 100644 --- a/cpp/src/gandiva/precompiled/extended_math_ops.cc +++ b/cpp/src/gandiva/precompiled/extended_math_ops.cc @@ -1,16 +1,19 @@ -// Copyright (C) 2017-2018 Dremio Corporation +// 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 // -// Licensed 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 // -// 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. +// 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. extern "C" { @@ -30,41 +33,43 @@ extern "C" { INNER(float64, OUT_TYPE) // Cubic root -#define CBRT(IN_TYPE, OUT_TYPE) \ - FORCE_INLINE \ - OUT_TYPE cbrt_##IN_TYPE(IN_TYPE in) { return (cbrtl(in)); } +#define CBRT(IN_TYPE, OUT_TYPE) \ + FORCE_INLINE \ + OUT_TYPE cbrt_##IN_TYPE(IN_TYPE in) { \ + return static_cast<float64>((cbrtl(static_cast<float64>(in)))); \ + } ENUMERIC_TYPES_UNARY(CBRT, float64) // Exponent #define EXP(IN_TYPE, OUT_TYPE) \ FORCE_INLINE \ - OUT_TYPE exp_##IN_TYPE(IN_TYPE in) { return (expl(in)); } + OUT_TYPE exp_##IN_TYPE(IN_TYPE in) { return static_cast<float64>(expl(in)); } ENUMERIC_TYPES_UNARY(EXP, float64) // log #define LOG(IN_TYPE, OUT_TYPE) \ FORCE_INLINE \ - OUT_TYPE log_##IN_TYPE(IN_TYPE in) { return (logl(in)); } + OUT_TYPE log_##IN_TYPE(IN_TYPE in) { return static_cast<float64>(logl(in)); } ENUMERIC_TYPES_UNARY(LOG, float64) // log base 10 #define LOG10(IN_TYPE, OUT_TYPE) \ FORCE_INLINE \ - OUT_TYPE log10_##IN_TYPE(IN_TYPE in) { return (log10l(in)); } + OUT_TYPE log10_##IN_TYPE(IN_TYPE in) { return static_cast<float64>(log10l(in)); } ENUMERIC_TYPES_UNARY(LOG10, float64) FORCE_INLINE void set_error_for_logbase(int64_t execution_context, double base) { - char const *prefix = "divide by zero error with log of base"; - int size = strlen(prefix) + 64; - char *error = (char *)malloc(size); + char const* prefix = "divide by zero error with log of base"; + int size = static_cast<int>(strlen(prefix)) + 64; + char* error = reinterpret_cast<char*>(malloc(size)); snprintf(error, size, "%s %f", prefix, base); context_set_error_msg(execution_context, error); - free(error); + free(static_cast<char*>(error)); } // log with base @@ -72,18 +77,18 @@ void set_error_for_logbase(int64_t execution_context, double base) { FORCE_INLINE \ OUT_TYPE log_##IN_TYPE1##_##IN_TYPE2(IN_TYPE1 base, boolean is_base_valid, \ IN_TYPE2 value, boolean is_value_valid, \ - int64 context, boolean *out_valid) { \ + int64 context, boolean* out_valid) { \ *out_valid = false; \ if (!is_base_valid || !is_value_valid) { \ return 0; \ } \ - OUT_TYPE log_of_base = logl(base); \ + OUT_TYPE log_of_base = static_cast<float64>(logl(base)); \ if (log_of_base == 0) { \ - set_error_for_logbase(context, base); \ + set_error_for_logbase(context, static_cast<double>(base)); \ return 0; \ } \ *out_valid = true; \ - return (logl(value) / logl(base)); \ + return static_cast<float64>(logl(value) / logl(base)); \ } LOG_WITH_BASE(int32, int32, float64) @@ -97,7 +102,7 @@ LOG_WITH_BASE(float64, float64, float64) #define POWER(IN_TYPE1, IN_TYPE2, OUT_TYPE) \ FORCE_INLINE \ OUT_TYPE power_##IN_TYPE1##_##IN_TYPE2(IN_TYPE1 in1, IN_TYPE2 in2) { \ - return (powl(in1, in2)); \ + return static_cast<float64>(powl(in1, in2)); \ } POWER(float64, float64, float64) diff --git a/cpp/src/gandiva/precompiled/extended_math_ops_test.cc b/cpp/src/gandiva/precompiled/extended_math_ops_test.cc index cfee248..cb8e8ab 100644 --- a/cpp/src/gandiva/precompiled/extended_math_ops_test.cc +++ b/cpp/src/gandiva/precompiled/extended_math_ops_test.cc @@ -1,16 +1,19 @@ -// Copyright (C) 2017-2018 Dremio Corporation +// 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 // -// Licensed 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 // -// 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. +// 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 <gtest/gtest.h> #include "gandiva/execution_context.h" @@ -64,7 +67,8 @@ TEST(TestExtendedMathOps, TestPower) { TEST(TestArithmeticOps, TestLogWithBase) { boolean is_valid; gandiva::helpers::ExecutionContext error_holder; - float64 out = log_int32_int32(1, true, 10, true, (int64)&error_holder, &is_valid); + float64 out = log_int32_int32(1, true, 10, true, reinterpret_cast<int64>(&error_holder), + &is_valid); EXPECT_EQ(out, 0); EXPECT_EQ(is_valid, false); EXPECT_EQ(error_holder.has_error(), true); @@ -72,7 +76,8 @@ TEST(TestArithmeticOps, TestLogWithBase) { << error_holder.get_error(); gandiva::helpers::ExecutionContext error_holder1; - out = log_int32_int32(2, true, 64, true, (int64)&error_holder, &is_valid); + out = log_int32_int32(2, true, 64, true, reinterpret_cast<int64>(&error_holder), + &is_valid); EXPECT_EQ(out, 6); EXPECT_EQ(is_valid, true); EXPECT_EQ(error_holder1.has_error(), false); diff --git a/cpp/src/gandiva/precompiled/string_ops.cc b/cpp/src/gandiva/precompiled/string_ops.cc index 7fc0501..29e10ba 100644 --- a/cpp/src/gandiva/precompiled/string_ops.cc +++ b/cpp/src/gandiva/precompiled/string_ops.cc @@ -77,13 +77,13 @@ VAR_LEN_OP_TYPES(BINARY_RELATIONAL, greater_than_or_equal_to, >=) INNER(binary) FORCE_INLINE -bool starts_with_utf8_utf8(const char *data, int32 data_len, const char *prefix, +bool starts_with_utf8_utf8(const char* data, int32 data_len, const char* prefix, int32 prefix_len) { return ((data_len >= prefix_len) && (memcmp(data, prefix, prefix_len) == 0)); } FORCE_INLINE -bool ends_with_utf8_utf8(const char *data, int32 data_len, const char *suffix, +bool ends_with_utf8_utf8(const char* data, int32 data_len, const char* suffix, int32 suffix_len) { return ((data_len >= suffix_len) && (memcmp(data + data_len - suffix_len, suffix, suffix_len) == 0)); @@ -106,9 +106,9 @@ int32 utf8_char_length(char c) { FORCE_INLINE void set_error_for_invalid_utf(int64_t execution_context, char val) { - char const *fmt = "unexpected byte \\%02hhx encountered while decoding utf8 string"; - int size = strlen(fmt) + 64; - char *error = (char *)malloc(size); + char const* fmt = "unexpected byte \\%02hhx encountered while decoding utf8 string"; + int size = static_cast<int>(strlen(fmt)) + 64; + char* error = reinterpret_cast<char*>(malloc(size)); snprintf(error, size, fmt, (unsigned char)val); context_set_error_msg(execution_context, error); free(error); @@ -116,8 +116,8 @@ void set_error_for_invalid_utf(int64_t execution_context, char val) { // Count the number of utf8 characters FORCE_INLINE -int32 utf8_length(const char *data, int32 data_len, boolean is_valid, int64 context, - boolean *out_valid) { +int32 utf8_length(const char* data, int32 data_len, boolean is_valid, int64 context, + boolean* out_valid) { *out_valid = false; if (!is_valid) { return 0; @@ -140,7 +140,7 @@ int32 utf8_length(const char *data, int32 data_len, boolean is_valid, int64 cont #define UTF8_LENGTH_NULL_INTERNAL(NAME, TYPE) \ FORCE_INLINE \ int32 NAME##_##TYPE(TYPE in, int32 in_len, boolean is_valid, int64 context, \ - boolean *out_valid) { \ + boolean* out_valid) { \ return utf8_length(in, in_len, is_valid, context, out_valid); \ } diff --git a/cpp/src/gandiva/precompiled/string_ops_test.cc b/cpp/src/gandiva/precompiled/string_ops_test.cc index 64e3264..e69ebb6 100644 --- a/cpp/src/gandiva/precompiled/string_ops_test.cc +++ b/cpp/src/gandiva/precompiled/string_ops_test.cc @@ -60,17 +60,21 @@ TEST(TestStringOps, TestCharLength) { EXPECT_TRUE(valid); std::string a("âpple"); - EXPECT_EQ(utf8_length(a.data(), a.length(), true, 0, &valid), 5); + EXPECT_EQ(utf8_length(a.data(), static_cast<int>(a.length()), true, 0, &valid), 5); EXPECT_TRUE(valid); std::string b("मदन"); - EXPECT_EQ(utf8_length(b.data(), b.length(), true, 0, &valid), 3); + EXPECT_EQ(static_cast<int>( + utf8_length(b.data(), static_cast<int>(b.length()), true, 0, &valid)), + 3); EXPECT_TRUE(valid); // invalid utf8 gandiva::helpers::ExecutionContext ctx; std::string c("\xf8\x28"); - EXPECT_EQ(utf8_length(c.data(), c.length(), true, (int64)&ctx, &valid), 0); + EXPECT_EQ(utf8_length(c.data(), static_cast<int>(c.length()), true, + reinterpret_cast<int64>(&ctx), &valid), + 0); EXPECT_TRUE(ctx.get_error().find( "unexpected byte \\f8 encountered while decoding utf8 string") != std::string::npos) diff --git a/cpp/src/gandiva/precompiled/time.cc b/cpp/src/gandiva/precompiled/time.cc index 2ac2fd9..c87a8f2 100644 --- a/cpp/src/gandiva/precompiled/time.cc +++ b/cpp/src/gandiva/precompiled/time.cc @@ -453,7 +453,7 @@ date64 castDATE_int64(int64 in) { return in; } static int days_in_month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; -bool IsLastDayOfMonth(const EpochTimePoint &tp) { +bool IsLastDayOfMonth(const EpochTimePoint& tp) { if (tp.TmMon() != 1) { // not February. Dont worry about leap year return (tp.TmMday() == days_in_month[tp.TmMon()]); @@ -492,30 +492,33 @@ bool IsLastDayOfMonth(const EpochTimePoint &tp) { int monthsDiff = (endYear - startYear) * 12 + (endMonth - startMonth); \ if ((endTime.TmMday() == startTime.TmMday()) || \ (IsLastDayOfMonth(endTime) && IsLastDayOfMonth(startTime))) { \ - return (double)monthsDiff; \ + return static_cast<double>(monthsDiff); \ } \ - double diffDays = (double)(endTime.TmMday() - startTime.TmMday()) / (double)31; \ - double diffHours = \ - (double)(endTime.TmHour() - startTime.TmHour()) + \ - (double)(endTime.TmMin() - startTime.TmMin()) / (double)MINS_IN_HOUR + \ - (double)(endTime.TmSec() - startTime.TmSec()) / (double)SECONDS_IN_HOUR; \ - return (double)monthsDiff + diffDays + diffHours / (double)(HOURS_IN_DAY * 31); \ + double diffDays = static_cast<double>(endTime.TmMday() - startTime.TmMday()) / \ + static_cast<double>(31); \ + double diffHours = static_cast<double>(endTime.TmHour() - startTime.TmHour()) + \ + static_cast<double>(endTime.TmMin() - startTime.TmMin()) / \ + static_cast<double>(MINS_IN_HOUR) + \ + static_cast<double>(endTime.TmSec() - startTime.TmSec()) / \ + static_cast<double>(SECONDS_IN_HOUR); \ + return static_cast<double>(monthsDiff) + diffDays + \ + diffHours / static_cast<double>(HOURS_IN_DAY * 31); \ } DATE_TYPES(MONTHS_BETWEEN) FORCE_INLINE -void set_error_for_date(int32 length, const char *input, const char *msg, +void set_error_for_date(int32 length, const char* input, const char* msg, int64_t execution_context) { - int size = length + strlen(msg) + 1; - char *error = (char *)malloc(size); + int size = length + static_cast<int>(strlen(msg)) + 1; + char* error = reinterpret_cast<char*>(malloc(size)); snprintf(error, size, "%s%s", msg, input); context_set_error_msg(execution_context, error); free(error); } -date64 castDATE_utf8(const char *input, int32 length, boolean is_valid1, - int64_t execution_context, boolean *out_valid) { +date64 castDATE_utf8(const char* input, int32 length, boolean is_valid1, + int64_t execution_context, boolean* out_valid) { *out_valid = false; if (!is_valid1) { return 0; @@ -538,7 +541,7 @@ date64 castDATE_utf8(const char *input, int32 length, boolean is_valid1, // store the last value dateFields[dateIndex++] = value; } - const char *msg = "Not a valid date value "; + const char* msg = "Not a valid date value "; if (dateIndex != 3) { set_error_for_date(length, input, msg, execution_context); return 0; diff --git a/cpp/src/gandiva/precompiled/time_test.cc b/cpp/src/gandiva/precompiled/time_test.cc index e53f44f..56a66de 100644 --- a/cpp/src/gandiva/precompiled/time_test.cc +++ b/cpp/src/gandiva/precompiled/time_test.cc @@ -18,9 +18,9 @@ #include <time.h> #include <gtest/gtest.h> -#include "gandiva/precompiled/types.h" -#include "gandiva/precompiled/date.h" #include "../execution_context.h" +#include "gandiva/precompiled/date.h" +#include "gandiva/precompiled/types.h" namespace gandiva { @@ -31,55 +31,55 @@ timestamp StringToTimestamp(const char* buf) { } TEST(TestTime, TestCastDate) { - const char *date = "1967-12-1"; + const char* date = "1967-12-1"; helpers::ExecutionContext context; bool valid; int64_t cast_to_date = castDATE_utf8(date, 9, true, (int64_t)&context, &valid); EXPECT_EQ(cast_to_date, -65836800000); EXPECT_EQ(valid, true); - const char *date1 = "1972-12-1"; + const char* date1 = "1972-12-1"; cast_to_date = castDATE_utf8(date1, 9, true, (int64_t)&context, &valid); EXPECT_EQ(cast_to_date, 92016000000); EXPECT_EQ(valid, true); - const char *date2 = "1972222222"; + const char* date2 = "1972222222"; cast_to_date = castDATE_utf8(date2, 10, true, (int64_t)&context, &valid); EXPECT_EQ(cast_to_date, 0); EXPECT_EQ(context.get_error(), "Not a valid date value 1972222222"); EXPECT_EQ(valid, false); - const char *date3 = "blahblah"; + const char* date3 = "blahblah"; cast_to_date = castDATE_utf8(date3, 8, true, (int64_t)&context, &valid); EXPECT_EQ(cast_to_date, 0); EXPECT_EQ(valid, false); - const char *date4 = "1967-12-1bb"; + const char* date4 = "1967-12-1bb"; cast_to_date = castDATE_utf8(date4, 11, true, (int64_t)&context, &valid); EXPECT_EQ(cast_to_date, -65836800000); EXPECT_EQ(valid, true); - const char *date5 = "67-12-1"; + const char* date5 = "67-12-1"; cast_to_date = castDATE_utf8(date5, 7, true, (int64_t)&context, &valid); EXPECT_EQ(cast_to_date, 3089923200000); EXPECT_EQ(valid, true); - const char *date6 = "67-1-1"; + const char* date6 = "67-1-1"; cast_to_date = castDATE_utf8(date6, 7, true, (int64_t)&context, &valid); EXPECT_EQ(cast_to_date, 3061065600000); EXPECT_EQ(valid, true); - const char *date7 = "71-1-1"; + const char* date7 = "71-1-1"; cast_to_date = castDATE_utf8(date7, 7, true, (int64_t)&context, &valid); EXPECT_EQ(cast_to_date, 31536000000); EXPECT_EQ(valid, true); - const char *date8 = "71-45-1"; + const char* date8 = "71-45-1"; cast_to_date = castDATE_utf8(date8, 7, true, (int64_t)&context, &valid); EXPECT_EQ(cast_to_date, 0); EXPECT_EQ(valid, false); - const char *date9 = "71-12-XX"; + const char* date9 = "71-12-XX"; cast_to_date = castDATE_utf8(date9, 8, true, (int64_t)&context, &valid); EXPECT_EQ(cast_to_date, 0); EXPECT_EQ(valid, false); diff --git a/cpp/src/gandiva/precompiled/types.h b/cpp/src/gandiva/precompiled/types.h index de924fa..da62cc0 100644 --- a/cpp/src/gandiva/precompiled/types.h +++ b/cpp/src/gandiva/precompiled/types.h @@ -47,10 +47,10 @@ using binary = char*; extern "C" { -bool bitMapGetBit(const unsigned char* bmap, int position); -void bitMapSetBit(unsigned char* bmap, int position, bool value); -void bitMapClearBitIfFalse(unsigned char* bmap, int position, bool value); -void context_set_error_msg(int64_t context_ptr, const char *err_msg); +bool bitMapGetBit(const unsigned char* bmap, int64_t position); +void bitMapSetBit(unsigned char* bmap, int64_t position, bool value); +void bitMapClearBitIfFalse(unsigned char* bmap, int64_t position, bool value); +void context_set_error_msg(int64_t context_ptr, const char* err_msg); int64 extractMillennium_timestamp(timestamp millis); int64 extractCentury_timestamp(timestamp millis); @@ -123,7 +123,7 @@ int32 mem_compare(const char* left, int32 left_len, const char* right, int32 rig int32 mod_int64_int32(int64 left, int32 right); int64 divide_int64_int64(int64 in1, boolean is_valid1, int64 in2, boolean is_valid2, - int64 error_holder, bool *out_valid); + int64 error_holder, bool* out_valid); float64 cbrt_int32(int32); float64 cbrt_int64(int64); @@ -148,22 +148,22 @@ float64 log10_float64(float64); float64 power_float64_float64(float64, float64); float64 log_int32_int32(int32 base, boolean is_base_valid, int32 value, - boolean is_value_valid, int64 context, boolean *out_valid); + boolean is_value_valid, int64 context, boolean* out_valid); -bool starts_with_utf8_utf8(const char *data, int32 data_len, const char *prefix, +bool starts_with_utf8_utf8(const char* data, int32 data_len, const char* prefix, int32 prefix_len); -bool ends_with_utf8_utf8(const char *data, int32 data_len, const char *suffix, +bool ends_with_utf8_utf8(const char* data, int32 data_len, const char* suffix, int32 suffix_len); -bool starts_with_plus_one_utf8_utf8(const char *data, int32 data_len, const char *prefix, +bool starts_with_plus_one_utf8_utf8(const char* data, int32 data_len, const char* prefix, int32 prefix_len); -bool ends_with_plus_one_utf8_utf8(const char *data, int32 data_len, const char *suffix, +bool ends_with_plus_one_utf8_utf8(const char* data, int32 data_len, const char* suffix, int32 suffix_len); -int32 utf8_length(const char *data, int32 data_len, boolean is_valid, int64 context, - boolean *out_valid); +int32 utf8_length(const char* data, int32 data_len, boolean is_valid, int64 context, + boolean* out_valid); -date64 castDATE_utf8(const char *input, int32 length, boolean is_valid1, - int64_t execution_context, boolean *out_valid); +date64 castDATE_utf8(const char* input, int32 length, boolean is_valid1, + int64_t execution_context, boolean* out_valid); } // extern "C" diff --git a/cpp/src/gandiva/projector_cache_key.h b/cpp/src/gandiva/projector_cache_key.h index 260d6b8..72724db 100644 --- a/cpp/src/gandiva/projector_cache_key.h +++ b/cpp/src/gandiva/projector_cache_key.h @@ -18,11 +18,11 @@ #ifndef GANDIVA_PROJECTOR_CACHE_KEY_H #define GANDIVA_PROJECTOR_CACHE_KEY_H +#include <algorithm> #include <memory> #include <string> -#include <vector> -#include <algorithm> #include <thread> +#include <vector> #include "gandiva/arrow.h" #include "gandiva/projector.h" @@ -75,16 +75,13 @@ class ProjectorCacheKey { std::string ToString() const { std::stringstream ss; - ss << "Schema ["; - - // remove newlines from schema - auto schema_str = schema_->ToString(); - std::replace(schema_str.begin(), schema_str.end(), '\n', ','); - ss << schema_str << "] "; + // indent, window, indent_size, null_rep and skip new lines. + arrow::PrettyPrintOptions options{0, 10, 2, "null", true}; + PrettyPrint(*schema_.get(), options, &ss); ss << "Expressions: ["; bool first = true; - for (auto &expr : expressions_as_strings_) { + for (auto& expr : expressions_as_strings_) { if (first) { first = false; } else { @@ -98,7 +95,7 @@ class ProjectorCacheKey { } private: - void UpdateUniqifier(const std::string expr) { + void UpdateUniqifier(const std::string& expr) { if (uniqifier_ == 0) { // caching of expressions with re2 patterns causes lock contention. So, use // multiple instances to reduce contention. diff --git a/cpp/src/gandiva/selection_vector_impl.h b/cpp/src/gandiva/selection_vector_impl.h index 5e5d271..80d3521 100644 --- a/cpp/src/gandiva/selection_vector_impl.h +++ b/cpp/src/gandiva/selection_vector_impl.h @@ -42,7 +42,9 @@ class SelectionVectorImpl : public SelectionVector { uint GetIndex(int index) const override { return raw_data_[index]; } - void SetIndex(int index, uint value) override { raw_data_[index] = value; } + void SetIndex(int index, uint value) override { + raw_data_[index] = static_cast<C_TYPE>(value); + } ArrayPtr ToArray() const override; diff --git a/cpp/src/gandiva/symbols-helpers.map b/cpp/src/gandiva/symbols-helpers.map index 48eedd1..a223b8e 100644 --- a/cpp/src/gandiva/symbols-helpers.map +++ b/cpp/src/gandiva/symbols-helpers.map @@ -1,3 +1,19 @@ +# 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. { global: extern "C++" { gandiva*; like*;to_date*}; local: *; diff --git a/cpp/src/gandiva/tests/date_time_test.cc b/cpp/src/gandiva/tests/date_time_test.cc index edf2a1a..3914558 100644 --- a/cpp/src/gandiva/tests/date_time_test.cc +++ b/cpp/src/gandiva/tests/date_time_test.cc @@ -341,7 +341,8 @@ TEST_F(TestProjector, TestMonthsBetween) { std::cout << status.message(); ASSERT_TRUE(status.ok()); - struct tm y1970 = {0}; + struct tm y1970; + memset(&y1970, 0, sizeof(struct tm)); y1970.tm_year = 70; y1970.tm_mon = 0; y1970.tm_mday = 1; diff --git a/cpp/src/gandiva/tests/projector_test.cc b/cpp/src/gandiva/tests/projector_test.cc index f6feb9c..e97c3a4 100644 --- a/cpp/src/gandiva/tests/projector_test.cc +++ b/cpp/src/gandiva/tests/projector_test.cc @@ -128,7 +128,7 @@ TEST_F(TestProjector, TestProjectCacheFloat) { auto schema = arrow::schema({}); auto res = field("result", arrow::float32()); - float f0 = 12345678891.000000; + float f0 = static_cast<float>(12345678891.000000); float f1 = f0 - 1000; auto literal0 = TreeExprBuilder::MakeLiteral(f0); @@ -366,12 +366,12 @@ TEST_F(TestProjector, TestExtendedMath) { std::vector<double> logb_vals; std::vector<double> power_vals; for (int i = 0; i < num_records; i++) { - cbrt_vals.push_back(cbrtl(input0[i])); - exp_vals.push_back(expl(input0[i])); - log_vals.push_back(logl(input0[i])); - log10_vals.push_back(log10l(input0[i])); - logb_vals.push_back(logl(input1[i]) / logl(input0[i])); - power_vals.push_back(powl(input0[i], input1[i])); + cbrt_vals.push_back(static_cast<double>(cbrtl(input0[i]))); + exp_vals.push_back(static_cast<double>(expl(input0[i]))); + log_vals.push_back(static_cast<double>(logl(input0[i]))); + log10_vals.push_back(static_cast<double>(log10l(input0[i]))); + logb_vals.push_back(static_cast<double>(logl(input1[i]) / logl(input0[i]))); + power_vals.push_back(static_cast<double>(powl(input0[i], input1[i]))); } auto expected_cbrt = MakeArrowArray<arrow::DoubleType, double>(cbrt_vals, validity); auto expected_exp = MakeArrowArray<arrow::DoubleType, double>(exp_vals, validity); diff --git a/cpp/src/gandiva/to_date_holder.cc b/cpp/src/gandiva/to_date_holder.cc index 96fafd1..71ba996 100644 --- a/cpp/src/gandiva/to_date_holder.cc +++ b/cpp/src/gandiva/to_date_holder.cc @@ -1,24 +1,27 @@ -// Copyright (C) 2017-2018 Dremio Corporation +// 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 // -// Licensed 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 // -// 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. +// 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 <algorithm> #include <string> -#include "gandiva/precompiled/date.h" #include "gandiva/date_utils.h" #include "gandiva/execution_context.h" #include "gandiva/node.h" +#include "gandiva/precompiled/date.h" #include "gandiva/to_date_holder.h" namespace gandiva { @@ -27,13 +30,13 @@ namespace gandiva { namespace helpers { #endif -Status ToDateHolder::Make(const FunctionNode &node, - std::shared_ptr<ToDateHolder> *holder) { +Status ToDateHolder::Make(const FunctionNode& node, + std::shared_ptr<ToDateHolder>* holder) { if (node.children().size() != 3) { return Status::Invalid("'to_date' function requires three parameters"); } - auto literal_pattern = dynamic_cast<LiteralNode *>(node.children().at(1).get()); + auto literal_pattern = dynamic_cast<LiteralNode*>(node.children().at(1).get()); if (literal_pattern == nullptr) { return Status::Invalid( "'to_date' function requires a literal as the second parameter"); @@ -46,7 +49,7 @@ Status ToDateHolder::Make(const FunctionNode &node, } auto pattern = boost::get<std::string>(literal_pattern->holder()); - auto literal_suppress_errors = dynamic_cast<LiteralNode *>(node.children().at(2).get()); + auto literal_suppress_errors = dynamic_cast<LiteralNode*>(node.children().at(2).get()); if (literal_pattern == nullptr) { return Status::Invalid( "'to_date' function requires a int literal as the third parameter"); @@ -61,8 +64,8 @@ Status ToDateHolder::Make(const FunctionNode &node, return Make(pattern, suppress_errors, holder); } -Status ToDateHolder::Make(const std::string &sql_pattern, int32_t suppress_errors, - std::shared_ptr<ToDateHolder> *holder) { +Status ToDateHolder::Make(const std::string& sql_pattern, int32_t suppress_errors, + std::shared_ptr<ToDateHolder>* holder) { std::shared_ptr<std::string> transformed_pattern; Status status = DateUtils::ToInternalFormat(sql_pattern, &transformed_pattern); GANDIVA_RETURN_NOT_OK(status); @@ -72,10 +75,8 @@ Status ToDateHolder::Make(const std::string &sql_pattern, int32_t suppress_error return Status::OK(); } -int64_t ToDateHolder::operator()(const std::string &data, bool in_valid, - int64_t execution_context, bool *out_valid) { - using namespace date; - using namespace std::chrono; +int64_t ToDateHolder::operator()(const std::string& data, bool in_valid, + int64_t execution_context, bool* out_valid) { // Issues // 1. processes date that do not match the format. // 2. does not process time in format +08:00 (or) id. @@ -83,16 +84,16 @@ int64_t ToDateHolder::operator()(const std::string &data, bool in_valid, if (!in_valid) { return 0; } - struct tm result = {0}; - char *ret = strptime(data.c_str(), pattern_.c_str(), &result); + struct tm result = {}; + char* ret = strptime(data.c_str(), pattern_.c_str(), &result); if (ret == nullptr) { return_error(execution_context, data); return 0; } *out_valid = true; // ignore the time part - date::sys_seconds secs = - (sys_days{year{result.tm_year + 1900} / (result.tm_mon + 1) / result.tm_mday}); + date::sys_seconds secs = date::sys_days(date::year(result.tm_year + 1900) / + (result.tm_mon + 1) / result.tm_mday); int64_t seconds_since_epoch = secs.time_since_epoch().count(); if (seconds_since_epoch == 0) { return_error(execution_context, data); @@ -101,17 +102,17 @@ int64_t ToDateHolder::operator()(const std::string &data, bool in_valid, return seconds_since_epoch * 1000; } -void ToDateHolder::return_error(int64_t execution_context, const std::string &data) { +void ToDateHolder::return_error(int64_t execution_context, const std::string& data) { if (suppress_errors_ == 1) { return; } - ExecutionContext *execution_context_ptr = - reinterpret_cast<ExecutionContext *>(execution_context); + ExecutionContext* execution_context_ptr = + reinterpret_cast<ExecutionContext*>(execution_context); std::string err_msg = "Error parsing value " + data + " for given format."; (execution_context_ptr)->set_error_msg(err_msg.c_str()); } #ifdef GDV_HELPERS -} +} // namespace helpers #endif } // namespace gandiva diff --git a/cpp/src/gandiva/to_date_holder.h b/cpp/src/gandiva/to_date_holder.h index 2e68a80..d69fe12 100644 --- a/cpp/src/gandiva/to_date_holder.h +++ b/cpp/src/gandiva/to_date_holder.h @@ -1,20 +1,25 @@ -// Copyright (C) 2017-2018 Dremio Corporation +// 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 // -// Licensed 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 // -// 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. +// 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. #ifndef TO_DATE_HOLDER_H #define TO_DATE_HOLDER_H +#include <memory> +#include <string> #include <unordered_map> #include "gandiva/function_holder.h" @@ -32,20 +37,20 @@ class ToDateHolder : public FunctionHolder { public: ~ToDateHolder() override = default; - static Status Make(const FunctionNode &node, std::shared_ptr<ToDateHolder> *holder); + static Status Make(const FunctionNode& node, std::shared_ptr<ToDateHolder>* holder); - static Status Make(const std::string &sql_pattern, int32_t suppress_errors, - std::shared_ptr<ToDateHolder> *holder); + static Status Make(const std::string& sql_pattern, int32_t suppress_errors, + std::shared_ptr<ToDateHolder>* holder); /// Return true if the data matches the pattern. - int64_t operator()(const std::string &data, bool in_valid, int64_t execution_context, - bool *out_valid); + int64_t operator()(const std::string& data, bool in_valid, int64_t execution_context, + bool* out_valid); private: - ToDateHolder(const std::string &pattern, int32_t suppress_errors) + ToDateHolder(const std::string& pattern, int32_t suppress_errors) : pattern_(pattern), suppress_errors_(suppress_errors) {} - void return_error(int64_t execution_context, const std::string &data); + void return_error(int64_t execution_context, const std::string& data); std::string pattern_; // date format string @@ -53,7 +58,7 @@ class ToDateHolder : public FunctionHolder { }; #ifdef GDV_HELPERS -} +} // namespace helpers #endif } // namespace gandiva #endif // TO_DATE_HOLDER_H diff --git a/cpp/src/gandiva/to_date_holder_test.cc b/cpp/src/gandiva/to_date_holder_test.cc index 77761b4..f8ded27 100644 --- a/cpp/src/gandiva/to_date_holder_test.cc +++ b/cpp/src/gandiva/to_date_holder_test.cc @@ -1,23 +1,26 @@ -// Copyright (C) 2017-2018 Dremio Corporation +// 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 // -// Licensed 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 // -// 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. +// 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 <memory> #include <vector> -#include "precompiled/epoch_time_point.h" #include "gandiva/execution_context.h" #include "gandiva/to_date_holder.h" +#include "precompiled/epoch_time_point.h" #include <gtest/gtest.h> @@ -42,7 +45,7 @@ TEST_F(TestToDateHolder, TestSimpleDateTime) { auto status = ToDateHolder::Make("YYYY-MM-DD HH:MI:SS", 1, &to_date_holder); EXPECT_EQ(status.ok(), true) << status.message(); ExecutionContext execution_context; - auto &to_date = *to_date_holder; + auto& to_date = *to_date_holder; bool out_valid; int64_t millis_since_epoch = to_date("1986-12-01 01:01:01", true, (int64_t)&execution_context, &out_valid); @@ -67,7 +70,7 @@ TEST_F(TestToDateHolder, TestSimpleDate) { auto status = ToDateHolder::Make("YYYY-MM-DD", 1, &to_date_holder); EXPECT_EQ(status.ok(), true) << status.message(); ExecutionContext execution_context; - auto &to_date = *to_date_holder; + auto& to_date = *to_date_holder; bool out_valid; int64_t millis_since_epoch = to_date("1986-12-01", true, (int64_t)&execution_context, &out_valid); @@ -97,7 +100,7 @@ TEST_F(TestToDateHolder, TestSimpleDateTimeError) { auto status = ToDateHolder::Make("YYYY-MM-DD HH:MI:SS", 0, &to_date_holder); EXPECT_EQ(status.ok(), true) << status.message(); ExecutionContext execution_context; - auto &to_date = *to_date_holder; + auto& to_date = *to_date_holder; bool out_valid; int64_t millis_since_epoch = @@ -122,7 +125,7 @@ TEST_F(TestToDateHolder, TestSimpleDateTimeMakeError) { EXPECT_EQ(status.IsInvalid(), true) << status.message(); } -int main(int argc, char **argv) { +int main(int argc, char** argv) { ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/java/gandiva/src/test/java/org/apache/arrow/gandiva/evaluator/ProjectorTest.java b/java/gandiva/src/test/java/org/apache/arrow/gandiva/evaluator/ProjectorTest.java index 2c18b75..6ed3d56 100644 --- a/java/gandiva/src/test/java/org/apache/arrow/gandiva/evaluator/ProjectorTest.java +++ b/java/gandiva/src/test/java/org/apache/arrow/gandiva/evaluator/ProjectorTest.java @@ -872,7 +872,7 @@ public class ProjectorTest extends BaseEvaluatorTest { } @Test - public void testGDV117() throws GandivaException, Exception { /* + public void testTimeEquals() throws GandivaException, Exception { /* * when isnotnull(x) then x * else y */
