From 2e578d429c8c4d13fa3ba5f5259deb958fc67c1e Mon Sep 17 00:00:00 2001 From: lide-reed Date: Thu, 18 Apr 2019 20:32:35 +0800 Subject: [PATCH] Add missed license head and align code --- be/CMakeLists.txt | 2 +- be/src/exec/es_predicate.cpp | 16 +-- be/src/exec/es_predicate.h | 110 +++++++++--------- be/src/util/es_query_builder.cpp | 1 + be/src/util/es_query_builder.h | 3 + be/test/http/http_client_test.cpp | 1 - be/test/util/es_query_builder_test.cpp | 3 +- be/test/util/es_scan_reader_test.cpp | 1 + .../apache/doris/external/EsRestClient.java | 17 +++ 9 files changed, 86 insertions(+), 68 deletions(-) diff --git a/be/CMakeLists.txt b/be/CMakeLists.txt index 6a059259981a5e..fe4337ad8c7f45 100644 --- a/be/CMakeLists.txt +++ b/be/CMakeLists.txt @@ -284,7 +284,7 @@ set(CXX_GCC_FLAGS "-g -Wno-unused-local-typedefs") # Debug information is stored as dwarf2 to be as compatible as possible # -Werror: compile warnings should be errors when using the toolchain compiler. # Only enable for debug builds because this is what we test in pre-commit tests. -set(CXX_FLAGS_DEBUG "${CXX_GCC_FLAGS} -Werror -O0 -gdwarf-2") +set(CXX_FLAGS_DEBUG "${CXX_GCC_FLAGS} -Werror -ggdb") # For CMAKE_BUILD_TYPE=Release # -O3: Enable all compiler optimizations diff --git a/be/src/exec/es_predicate.cpp b/be/src/exec/es_predicate.cpp index c6bc1c1ecdfa02..17df4135825154 100644 --- a/be/src/exec/es_predicate.cpp +++ b/be/src/exec/es_predicate.cpp @@ -183,7 +183,7 @@ EsPredicate::~EsPredicate() { } bool EsPredicate::build_disjuncts_list() { - return build_disjuncts_list(_context->root(), _disjuncts); + return build_disjuncts_list(_context->root()); } // make sure to build by build_disjuncts_list @@ -216,7 +216,7 @@ static bool is_literal_node(const Expr* expr) { } } -bool EsPredicate::build_disjuncts_list(Expr* conjunct, vector& disjuncts) { +bool EsPredicate::build_disjuncts_list(Expr* conjunct) { if (TExprNodeType::BINARY_PRED == conjunct->node_type()) { if (conjunct->children().size() != 2) { VLOG(1) << "get disjuncts fail: number of childs is not 2"; @@ -258,7 +258,7 @@ bool EsPredicate::build_disjuncts_list(Expr* conjunct, vector& di op, literal); - disjuncts.push_back(predicate); + _disjuncts.push_back(predicate); return true; } @@ -281,7 +281,7 @@ bool EsPredicate::build_disjuncts_list(Expr* conjunct, vector& di return false; } } - disjuncts.push_back(predicate); + _disjuncts.push_back(predicate); return true; } @@ -324,7 +324,7 @@ bool EsPredicate::build_disjuncts_list(Expr* conjunct, vector& di slot_desc->type(), literal); - disjuncts.push_back(predicate); + _disjuncts.push_back(predicate); return true; } @@ -371,7 +371,7 @@ bool EsPredicate::build_disjuncts_list(Expr* conjunct, vector& di slot_desc->col_name(), slot_desc->type(), in_pred_values); - disjuncts.push_back(predicate); + _disjuncts.push_back(predicate); return true; } @@ -381,10 +381,10 @@ bool EsPredicate::build_disjuncts_list(Expr* conjunct, vector& di VLOG(1) << "get disjuncts fail: op is not COMPOUND_OR"; return false; } - if (!build_disjuncts_list(conjunct->get_child(0), disjuncts)) { + if (!build_disjuncts_list(conjunct->get_child(0))) { return false; } - if (!build_disjuncts_list(conjunct->get_child(1), disjuncts)) { + if (!build_disjuncts_list(conjunct->get_child(1))) { return false; } diff --git a/be/src/exec/es_predicate.h b/be/src/exec/es_predicate.h index 02d0383104fef3..cbb8f06ebee0d5 100644 --- a/be/src/exec/es_predicate.h +++ b/be/src/exec/es_predicate.h @@ -36,36 +36,36 @@ class ExprContext; class ExtBinaryPredicate; class ExtLiteral { - public: - ExtLiteral(PrimitiveType type, void *value) : - _type(type), - _value(value) { - _str = value_to_string(); - } - ~ExtLiteral(); - const std::string& to_string() const { - return _str; - } - - private: - int8_t get_byte(); - int16_t get_short(); - int32_t get_int(); - int64_t get_long(); - float get_float(); - double get_double(); - std::string get_string(); - std::string get_date_string(); - bool get_bool(); - std::string get_decimal_string(); - std::string get_decimalv2_string(); - std::string get_largeint_string(); - - std::string value_to_string(); - - PrimitiveType _type; - void* _value; - std::string _str; +public: + ExtLiteral(PrimitiveType type, void *value) : + _type(type), + _value(value) { + _str = value_to_string(); + } + ~ExtLiteral(); + const std::string& to_string() const { + return _str; + } + +private: + int8_t get_byte(); + int16_t get_short(); + int32_t get_int(); + int64_t get_long(); + float get_float(); + double get_double(); + std::string get_string(); + std::string get_date_string(); + bool get_bool(); + std::string get_decimal_string(); + std::string get_decimalv2_string(); + std::string get_largeint_string(); + + std::string value_to_string(); + + PrimitiveType _type; + void* _value; + std::string _str; }; struct ExtColumnDesc { @@ -169,34 +169,30 @@ struct ExtFunction : public ExtPredicate { }; class EsPredicate { +public: + EsPredicate(ExprContext* context, const TupleDescriptor* tuple_desc); + ~EsPredicate(); + const std::vector& get_predicate_list(); + bool build_disjuncts_list(); + // public for tests + EsPredicate(std::vector& all_predicates) { + _disjuncts = all_predicates; + }; + + Status get_es_query_status() { + return _es_query_status; + } + +private: + bool build_disjuncts_list(Expr* conjunct); + bool is_match_func(const Expr* conjunct); + const SlotDescriptor* get_slot_desc(SlotRef* slotRef); - public: - EsPredicate(ExprContext* context, const TupleDescriptor* tuple_desc); - ~EsPredicate(); - const std::vector& get_predicate_list(); - bool build_disjuncts_list(); - // public for tests - EsPredicate(std::vector& all_predicates) { - _disjuncts = all_predicates; - }; - - Status get_es_query_status() { - return _es_query_status; - } - - - private: - - bool build_disjuncts_list(Expr* conjunct, - std::vector& disjuncts); - bool is_match_func(const Expr* conjunct); - const SlotDescriptor* get_slot_desc(SlotRef* slotRef); - - ExprContext* _context; - int _disjuncts_num; - const TupleDescriptor* _tuple_desc; - std::vector _disjuncts; - Status _es_query_status; + ExprContext* _context; + int _disjuncts_num; + const TupleDescriptor* _tuple_desc; + std::vector _disjuncts; + Status _es_query_status; }; } diff --git a/be/src/util/es_query_builder.cpp b/be/src/util/es_query_builder.cpp index f17994a16af2fc..847395288ad9fa 100644 --- a/be/src/util/es_query_builder.cpp +++ b/be/src/util/es_query_builder.cpp @@ -14,6 +14,7 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. + #include "util/es_query_builder.h" #include diff --git a/be/src/util/es_query_builder.h b/be/src/util/es_query_builder.h index f5643db0040041..96310d7b4dae0c 100644 --- a/be/src/util/es_query_builder.h +++ b/be/src/util/es_query_builder.h @@ -14,9 +14,12 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. + #pragma once + #include #include + #include "rapidjson/document.h" #include "exec/es_predicate.h" #include "common/status.h" diff --git a/be/test/http/http_client_test.cpp b/be/test/http/http_client_test.cpp index c883e4c30374f8..e75a299142cf21 100644 --- a/be/test/http/http_client_test.cpp +++ b/be/test/http/http_client_test.cpp @@ -17,7 +17,6 @@ #include "http/http_client.h" - #include #include "boost/algorithm/string.hpp" diff --git a/be/test/util/es_query_builder_test.cpp b/be/test/util/es_query_builder_test.cpp index 3755defa995789..6f9f8691ac0d6d 100644 --- a/be/test/util/es_query_builder_test.cpp +++ b/be/test/util/es_query_builder_test.cpp @@ -26,6 +26,7 @@ #include "rapidjson/stringbuffer.h" #include "rapidjson/writer.h" #include "runtime/string_value.h" + namespace doris { class BooleanQueryBuilderTest : public testing::Test { @@ -33,6 +34,7 @@ class BooleanQueryBuilderTest : public testing::Test { BooleanQueryBuilderTest() { } virtual ~BooleanQueryBuilderTest() { } }; + TEST_F(BooleanQueryBuilderTest, term_query) { // content = "wyf" char str[] = "wyf"; @@ -431,7 +433,6 @@ TEST_F(BooleanQueryBuilderTest, validate_partial) { ASSERT_TRUE(result == expected1); } - } int main(int argc, char* argv[]) { diff --git a/be/test/util/es_scan_reader_test.cpp b/be/test/util/es_scan_reader_test.cpp index 06b194d13ca4d2..57b38aeb4ffcb2 100644 --- a/be/test/util/es_scan_reader_test.cpp +++ b/be/test/util/es_scan_reader_test.cpp @@ -14,6 +14,7 @@ // KIND, either express or implied. See the License for the // specific language governing permissions and limitations // under the License. + #include "util/es_scan_reader.h" #include "util/es_scroll_query.h" #include diff --git a/fe/src/main/java/org/apache/doris/external/EsRestClient.java b/fe/src/main/java/org/apache/doris/external/EsRestClient.java index 279e5c824e4a32..1159cadc646f30 100644 --- a/fe/src/main/java/org/apache/doris/external/EsRestClient.java +++ b/fe/src/main/java/org/apache/doris/external/EsRestClient.java @@ -1,3 +1,20 @@ +// 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. + package org.apache.doris.external; import okhttp3.Credentials;