Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion be/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 8 additions & 8 deletions be/src/exec/es_predicate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -216,7 +216,7 @@ static bool is_literal_node(const Expr* expr) {
}
}

bool EsPredicate::build_disjuncts_list(Expr* conjunct, vector<ExtPredicate*>& 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";
Expand Down Expand Up @@ -258,7 +258,7 @@ bool EsPredicate::build_disjuncts_list(Expr* conjunct, vector<ExtPredicate*>& di
op,
literal);

disjuncts.push_back(predicate);
_disjuncts.push_back(predicate);
return true;
}

Expand All @@ -281,7 +281,7 @@ bool EsPredicate::build_disjuncts_list(Expr* conjunct, vector<ExtPredicate*>& di
return false;
}
}
disjuncts.push_back(predicate);
_disjuncts.push_back(predicate);

return true;
}
Expand Down Expand Up @@ -324,7 +324,7 @@ bool EsPredicate::build_disjuncts_list(Expr* conjunct, vector<ExtPredicate*>& di
slot_desc->type(),
literal);

disjuncts.push_back(predicate);
_disjuncts.push_back(predicate);
return true;
}

Expand Down Expand Up @@ -371,7 +371,7 @@ bool EsPredicate::build_disjuncts_list(Expr* conjunct, vector<ExtPredicate*>& di
slot_desc->col_name(),
slot_desc->type(),
in_pred_values);
disjuncts.push_back(predicate);
_disjuncts.push_back(predicate);

return true;
}
Expand All @@ -381,10 +381,10 @@ bool EsPredicate::build_disjuncts_list(Expr* conjunct, vector<ExtPredicate*>& 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;
}

Expand Down
110 changes: 53 additions & 57 deletions be/src/exec/es_predicate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -169,34 +169,30 @@ struct ExtFunction : public ExtPredicate {
};

class EsPredicate {
public:
EsPredicate(ExprContext* context, const TupleDescriptor* tuple_desc);
~EsPredicate();
const std::vector<ExtPredicate*>& get_predicate_list();
bool build_disjuncts_list();
// public for tests
EsPredicate(std::vector<ExtPredicate*>& 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<ExtPredicate*>& get_predicate_list();
bool build_disjuncts_list();
// public for tests
EsPredicate(std::vector<ExtPredicate*>& all_predicates) {
_disjuncts = all_predicates;
};

Status get_es_query_status() {
return _es_query_status;
}


private:

bool build_disjuncts_list(Expr* conjunct,
std::vector<ExtPredicate*>& 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<ExtPredicate*> _disjuncts;
Status _es_query_status;
ExprContext* _context;
int _disjuncts_num;
const TupleDescriptor* _tuple_desc;
std::vector<ExtPredicate*> _disjuncts;
Status _es_query_status;
};

}
Expand Down
1 change: 1 addition & 0 deletions be/src/util/es_query_builder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <boost/algorithm/string/replace.hpp>
Expand Down
3 changes: 3 additions & 0 deletions be/src/util/es_query_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<string>
#include<vector>

#include "rapidjson/document.h"
#include "exec/es_predicate.h"
#include "common/status.h"
Expand Down
1 change: 0 additions & 1 deletion be/test/http/http_client_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

#include "http/http_client.h"


#include <gtest/gtest.h>

#include "boost/algorithm/string.hpp"
Expand Down
3 changes: 2 additions & 1 deletion be/test/util/es_query_builder_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@
#include "rapidjson/stringbuffer.h"
#include "rapidjson/writer.h"
#include "runtime/string_value.h"

namespace doris {

class BooleanQueryBuilderTest : public testing::Test {
public:
BooleanQueryBuilderTest() { }
virtual ~BooleanQueryBuilderTest() { }
};

TEST_F(BooleanQueryBuilderTest, term_query) {
// content = "wyf"
char str[] = "wyf";
Expand Down Expand Up @@ -431,7 +433,6 @@ TEST_F(BooleanQueryBuilderTest, validate_partial) {
ASSERT_TRUE(result == expected1);
}


}

int main(int argc, char* argv[]) {
Expand Down
1 change: 1 addition & 0 deletions be/test/util/es_scan_reader_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 <gtest/gtest.h>
Expand Down
17 changes: 17 additions & 0 deletions fe/src/main/java/org/apache/doris/external/EsRestClient.java
Original file line number Diff line number Diff line change
@@ -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;
Expand Down