Skip to content

Commit

Permalink
revert
Browse files Browse the repository at this point in the history
  • Loading branch information
ljcui committed Dec 20, 2024
1 parent bebe7a7 commit 83cc4aa
Show file tree
Hide file tree
Showing 22 changed files with 72 additions and 623 deletions.
3 changes: 0 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,3 @@
[submodule "deps/tugraph-db-browser"]
path = deps/tugraph-db-browser
url = https://github.com/TuGraph-family/tugraph-db-browser.git
[submodule "deps/buildit"]
path = deps/buildit
url = "https://github.com/RTEnzyme/buildit.git"
9 changes: 0 additions & 9 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,6 @@ if (BUILD_PROCEDURE)
add_subdirectory(procedures)
endif (BUILD_PROCEDURE)



# buildit
# add_custom_target(buildit
# COMMAND ${CMAKE_COMMAND} -E chdir ${EXTERNAL_PROJECT_DIR} $(MAKE)
# COMMENT "Building external project"
# )
# add_dependencies(my_program build_external_project)

# unit_test
if (WITH_TESTS)
add_subdirectory(test)
Expand Down
1 change: 0 additions & 1 deletion deps/buildit
Submodule buildit deleted from 734725
32 changes: 0 additions & 32 deletions src/BuildCypherLib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,9 @@ find_package(PythonInterp 3)
find_package(PythonLibs ${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR} EXACT REQUIRED)
#antlr4-runtime
find_package(antlr4-runtime REQUIRED)
# find_package(LLVM REQUIRED CONFIG)
set(ANTRL4_LIBRARY antlr4-runtime.a)

set(TARGET_LGRAPH_CYPHER_LIB lgraph_cypher_lib)
set(EXTERNAL_PROJECT_DIR "${CMAKE_SOURCE_DIR}/deps/buildit")
add_custom_target(buildit
COMMAND ${CMAKE_COMMAND} -E chdir ${EXTERNAL_PROJECT_DIR} $(MAKE)
COMMENT "Building external project"
)


set(LGRAPH_CYPHER_SRC # find cypher/ -name "*.cpp" | sort
cypher/arithmetic/agg_funcs.cpp
Expand All @@ -24,10 +17,8 @@ set(LGRAPH_CYPHER_SRC # find cypher/ -name "*.cpp" | sort
cypher/execution_plan/execution_plan_v2.cpp
cypher/execution_plan/execution_plan_maker.cpp
cypher/execution_plan/pattern_graph_maker.cpp
cypher/execution_plan/ops/op_config.cpp
cypher/execution_plan/ops/op_aggregate.cpp
cypher/execution_plan/ops/op_all_node_scan.cpp
cypher/execution_plan/ops/op_all_node_scan_col.cpp
cypher/execution_plan/ops/op_apply.cpp
cypher/execution_plan/ops/op_argument.cpp
cypher/execution_plan/ops/op_cartesian_product.cpp
Expand All @@ -43,13 +34,10 @@ set(LGRAPH_CYPHER_SRC # find cypher/ -name "*.cpp" | sort
cypher/execution_plan/ops/op_immediate_argument.cpp
cypher/execution_plan/ops/op_inquery_call.cpp
cypher/execution_plan/ops/op_limit.cpp
cypher/execution_plan/ops/op_limit_col.cpp
cypher/execution_plan/ops/op_node_by_label_scan.cpp
cypher/execution_plan/ops/op_optional.cpp
cypher/execution_plan/ops/op_produce_results.cpp
cypher/execution_plan/ops/op_produce_results_col.cpp
cypher/execution_plan/ops/op_project.cpp
cypher/execution_plan/ops/op_project_col.cpp
cypher/execution_plan/ops/op_relationship_count.cpp
cypher/execution_plan/ops/op_remove.cpp
cypher/execution_plan/ops/op_set.cpp
Expand All @@ -67,13 +55,7 @@ set(LGRAPH_CYPHER_SRC # find cypher/ -name "*.cpp" | sort
cypher/execution_plan/ops/op_node_by_id_seek.cpp
cypher/execution_plan/ops/op_traversal.cpp
cypher/execution_plan/ops/op_gql_remove.cpp
cypher/execution_plan/plan_cache/plan_cache_param.cpp
cypher/execution_plan/plan_cache/plan_cache.cpp
cypher/execution_plan/scheduler.cpp
cypher/experimental/data_type/field_data.h
cypher/experimental/expressions/cexpr.cpp
cypher/experimental/expressions/kernal/binary.cpp
# cypher/experimental/jit/TuJIT.cpp
cypher/filter/filter.cpp
cypher/filter/iterator.cpp
cypher/graph/graph.cpp
Expand Down Expand Up @@ -106,24 +88,10 @@ target_include_directories(${TARGET_LGRAPH_CYPHER_LIB} PUBLIC
${ANTLR4_INCLUDE_DIR}
${CMAKE_CURRENT_LIST_DIR}/cypher)

include_directories(
${CMAKE_SOURCE_DIR}/deps/buildit/include
${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})

target_link_directories(${TARGET_LGRAPH_CYPHER_LIB} PUBLIC
${CMAKE_SOURCE_DIR}/deps/buildit/lib)

add_dependencies(${TARGET_LGRAPH_CYPHER_LIB} buildit)

target_link_libraries(${TARGET_LGRAPH_CYPHER_LIB} PUBLIC
${ANTRL4_LIBRARY}
geax_isogql
# ${CMAKE_SOURCE_DIR}/deps/buildit/build/libbuildit.a
lgraph)

target_link_libraries(${TARGET_LGRAPH_CYPHER_LIB} PRIVATE
lgraph_server_lib)

# llvm_map_components_to_libnames(llvm_libs Core Support)
# target_link_libraries(${TARGET_LGRAPH_CYPHER_LIB} PRIVATE ${llvm_libs})
40 changes: 15 additions & 25 deletions src/cypher/arithmetic/arithmetic_expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1554,20 +1554,13 @@ void ArithOperandNode::SetEntity(const std::string &alias, const std::string &pr
}

void ArithOperandNode::SetParameter(const std::string &param, const SymbolTable &sym_tab) {
if (std::isdigit(param[1])) {
// query plan parameter
type = AR_OPERAND_CONSTANT;
constant = sym_tab.param_tab_->at(param);
} else {
// named parameter
type = AR_OPERAND_PARAMETER;
variadic.alias = param;
auto it = sym_tab.symbols.find(param);
if (it == sym_tab.symbols.end()) {
throw lgraph::CypherException("Parameter not defined: " + param);
}
variadic.alias_idx = it->second.id;
type = AR_OPERAND_PARAMETER;
variadic.alias = param;
auto it = sym_tab.symbols.find(param);
if (it == sym_tab.symbols.end()) {
throw lgraph::CypherException("Parameter not defined: " + param);
}
variadic.alias_idx = it->second.id;
}

void ArithOperandNode::RealignAliasId(const SymbolTable &sym_tab) {
Expand All @@ -1577,20 +1570,17 @@ void ArithOperandNode::RealignAliasId(const SymbolTable &sym_tab) {
variadic.alias_idx = it->second.id;
}

cypher::FieldData GenerateCypherFieldData(const parser::Expression &expr,
const SymbolTable &sym_tab) {
if (expr.type == parser::Expression::PARAMETER) {
return cypher::FieldData(sym_tab.param_tab_->at(expr.String()));
} else if (expr.type != parser::Expression::LIST
&& expr.type != parser::Expression::MAP) {
cypher::FieldData GenerateCypherFieldData(const parser::Expression &expr) {
if (expr.type != parser::Expression::LIST && expr.type != parser::Expression::MAP) {
return cypher::FieldData(parser::MakeFieldData(expr));
} else if (expr.type == parser::Expression::LIST) {
}
if (expr.type == parser::Expression::LIST) {
std::vector<cypher::FieldData> list;
for (auto &e : expr.List()) list.emplace_back(GenerateCypherFieldData(e, sym_tab));
for (auto &e : expr.List()) list.emplace_back(GenerateCypherFieldData(e));
return cypher::FieldData(std::move(list));
} else {
std::unordered_map<std::string, cypher::FieldData> map;
for (auto &e : expr.Map()) map.emplace(e.first, GenerateCypherFieldData(e.second, sym_tab));
for (auto &e : expr.Map()) map.emplace(e.first, GenerateCypherFieldData(e.second));
return cypher::FieldData(std::move(map));
}
}
Expand Down Expand Up @@ -1633,13 +1623,13 @@ void ArithOperandNode::Set(const parser::Expression &expr, const SymbolTable &sy
{
/* e.g. [1,3,5,7], [1,3,5.55,'seven'] */
type = ArithOperandNode::AR_OPERAND_CONSTANT;
constant = GenerateCypherFieldData(expr, sym_tab);
constant = GenerateCypherFieldData(expr);
break;
}
case parser::Expression::MAP:
{
type = ArithOperandNode::AR_OPERAND_CONSTANT;
constant = GenerateCypherFieldData(expr, sym_tab);
constant = GenerateCypherFieldData(expr);
break;
}
default:
Expand Down Expand Up @@ -1789,7 +1779,7 @@ void ArithExprNode::Set(const parser::Expression &expr, const SymbolTable &sym_t
* [n.name, n.age] as op */
bool is_operand = true;
for (auto &e : expr.List()) {
if (!e.IsLiteral() && e.type != parser::Expression::PARAMETER) is_operand = false;
if (!e.IsLiteral()) is_operand = false;
if (e.type == parser::Expression::MAP) is_operand = true;
}
if (!is_operand) {
Expand Down
8 changes: 0 additions & 8 deletions src/cypher/arithmetic/arithmetic_expression.h
Original file line number Diff line number Diff line change
Expand Up @@ -752,19 +752,11 @@ struct ArithExprNode {

void SetOperand(ArithOperandNode::ArithOperandType operand_type,
const cypher::FieldData &data) {
// @todo(anyone) below assertion throws excpetion when set parameter operand.
CYPHER_THROW_ASSERT(operand_type == ArithOperandNode::AR_OPERAND_CONSTANT);
type = AR_EXP_OPERAND;
operand.SetConstant(data);
}

void SetOperandParameter(ArithOperandNode::ArithOperandType operand_type,
const std::string &param, const SymbolTable &sym_tab) {
CYPHER_THROW_ASSERT(operand_type == ArithOperandNode::AR_OPERAND_PARAMETER);
type = AR_EXP_OPERAND;
operand.SetParameter(param, sym_tab);
}

void SetOperandVariable(ArithOperandNode::ArithOperandType operand_type,
const bool &hasMapFieldName = false, const std::string &value_alias = "",
const std::string &map_field_name = "") {
Expand Down
7 changes: 2 additions & 5 deletions src/cypher/execution_plan/execution_plan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -603,11 +603,8 @@ void ExecutionPlan::_BuildExpandOps(const parser::QueryPart &part, PatternGraph
pattern_graph.symbol_table);
if (pf.type == Property::PARAMETER) {
// TODO(anyone) use record
// Fix bugs of parameterized execution:
// MATCH (rachel:Person {name: $name1})-[]->(family:Person)-[:ACTED_IN]->(film)
// <-[:ACTED_IN]-(richard:Person {name: $name2}) RETURN family.name;
ae2.SetOperandParameter(ArithOperandNode::AR_OPERAND_PARAMETER,
pf.value_alias, pattern_graph.symbol_table);
ae2.SetOperand(ArithOperandNode::AR_OPERAND_PARAMETER,
cypher::FieldData(lgraph::FieldData(pf.value_alias)));
} else if (pf.type == Property::VARIABLE) {
ae2.SetOperandVariable(ArithOperandNode::AR_OPERAND_VARIABLE,
pf.hasMapFieldName, pf.value_alias, pf.map_field_name);
Expand Down
47 changes: 7 additions & 40 deletions src/cypher/execution_plan/execution_plan_maker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

namespace cypher {

DEFINE_bool(is_columnar, false, "build plan in column manner");

// Locates all "taps" (entry points) of root.
static void _StreamTaps(OpBase* root, std::vector<OpBase*>& taps) {
if (!root->children.empty()) {
Expand Down Expand Up @@ -236,8 +234,6 @@ void ExecutionPlanMaker::_AddScanOp(const SymbolTable* sym_tab, Node* node,
if (!node->Label().empty()) {
/* labeled */
scan_op = new NodeByLabelScan(node, sym_tab);
} else if (FLAGS_is_columnar) {
scan_op = new AllNodeScanCol(node, sym_tab);
} else {
/* Node not labeled, no other option but a full scan. */
scan_op = new AllNodeScan(node, sym_tab);
Expand Down Expand Up @@ -1056,12 +1052,7 @@ std::any ExecutionPlanMaker::visit(geax::frontend::CompositeQueryStatement* node
if (!node->body().empty()) {
auto op_union = new Union();
op_union->AddChild(pattern_graph_root_[cur_pattern_graph_]);
OpBase* op_produce = nullptr;
if (FLAGS_is_columnar) {
op_produce = new ProduceResultsCol();
} else {
op_produce = new ProduceResults();
}
auto op_produce = new ProduceResults();
op_produce->AddChild(op_union);
pattern_graph_root_[cur_pattern_graph_] = op_produce;
for (auto statement : node->body()) {
Expand Down Expand Up @@ -1136,12 +1127,7 @@ std::any ExecutionPlanMaker::visit(geax::frontend::NamedProcedureCall* node) {
auto op = new OpGqlStandaloneCall(name, node->args(), node->yield(),
pattern_graphs_[cur_pattern_graph_].symbol_table);
expand_ops.emplace_back(op);
OpBase* produce = nullptr;
if (FLAGS_is_columnar) {
produce = new ProduceResultsCol();
} else {
produce = new ProduceResults();
}
auto produce = new ProduceResults();
expand_ops.emplace_back(produce);
std::reverse(expand_ops.begin(), expand_ops.end());
if (auto op = _SingleBranchConnect(expand_ops)) {
Expand Down Expand Up @@ -1246,20 +1232,11 @@ std::any ExecutionPlanMaker::visit(geax::frontend::PrimitiveResultStatement* nod
}
}
if (cur_pattern_graph_ == pattern_graph_size_ - 1) {
OpBase* result = nullptr;
if (FLAGS_is_columnar) {
result = new ProduceResultsCol();
} else {
result = new ProduceResults();
}
auto result = new ProduceResults();
ops.push_back(result);
}
if (node->limit().has_value()) {
if (FLAGS_is_columnar) {
ops.emplace_back(new LimitCol(std::get<0>(node->limit().value())));
} else {
ops.emplace_back(new Limit(std::get<0>(node->limit().value())));
}
ops.emplace_back(new Limit(std::get<0>(node->limit().value())));
}
if (node->offset().has_value()) {
ops.emplace_back(new Skip(std::get<0>(node->offset().value())));
Expand Down Expand Up @@ -1334,13 +1311,8 @@ std::any ExecutionPlanMaker::visit(geax::frontend::PrimitiveResultStatement* nod
if (node->distinct()) {
ops.emplace_back(new Distinct());
}
if (FLAGS_is_columnar) {
ops.emplace_back(
new ProjectCol(arith_items, &pattern_graphs_[cur_pattern_graph_].symbol_table));
} else {
ops.emplace_back(
new Project(arith_items, &pattern_graphs_[cur_pattern_graph_].symbol_table));
}
ops.emplace_back(
new Project(arith_items, &pattern_graphs_[cur_pattern_graph_].symbol_table));
}
if (auto op = _SingleBranchConnect(ops)) {
_UpdateStreamRoot(op, pattern_graph_root_[cur_pattern_graph_]);
Expand All @@ -1363,12 +1335,7 @@ std::any ExecutionPlanMaker::visit(geax::frontend::LinearDataModifyingStatement*
auto resultStatement = node->resultStatement().value();
ACCEPT_AND_CHECK_WITH_ERROR_MSG(resultStatement);
} else {
OpBase* result = nullptr;
if (FLAGS_is_columnar) {
result = new ProduceResultsCol();
} else {
result = new ProduceResults();
}
auto result = new ProduceResults();
_UpdateStreamRoot(result, pattern_graph_root_[cur_pattern_graph_]);
}
return geax::frontend::GEAXErrorCode::GEAX_SUCCEED;
Expand Down
3 changes: 0 additions & 3 deletions src/cypher/execution_plan/execution_plan_maker.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

#pragma once

#include <gflags/gflags.h>
#include <vector>
#include "geax-front-end/ast/AstNode.h"
#include "geax-front-end/common/ObjectAllocator.h"
Expand All @@ -23,8 +22,6 @@

namespace cypher {

DECLARE_bool(is_columnar);

class ExecutionPlanMaker : public geax::frontend::AstNodeVisitor {
public:
ExecutionPlanMaker(std::vector<PatternGraph>& pattern_graphs,
Expand Down
1 change: 0 additions & 1 deletion src/cypher/execution_plan/ops/op.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ struct OpBase {
enum StreamState { StreamUnInitialized, StreamConsuming, StreamDepleted } state;
/* Stream state. */ // TODO(anyone) remove
std::shared_ptr<Record> record; // Result of consume.
std::shared_ptr<DataChunk> columnar_;
OpStats stats; // Profiling statistics.
enum OpResult {
OP_DEPLETED = 1,
Expand Down
4 changes: 1 addition & 3 deletions src/cypher/execution_plan/ops/op_argument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ Argument::Argument(const SymbolTable *sym_tab)
: OpBase(OpType::ARGUMENT, "Argument"), sym_tab_(sym_tab) {
std::map<size_t, std::pair<std::string, SymbolNode::Type>> ordered_alias;
for (auto &a : sym_tab->symbols) {
// WITH [$1, $2, $3] AS coll RETURN size(coll)
// Should ignore the query params in symbole table
if (a.second.scope == SymbolNode::ARGUMENT && a.second.type != SymbolNode::PARAMETER) {
if (a.second.scope == SymbolNode::ARGUMENT) {
ordered_alias.emplace(a.second.id, std::make_pair(a.first, a.second.type));
}
}
Expand Down
4 changes: 0 additions & 4 deletions src/cypher/execution_plan/ops/ops.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@
#pragma once

#include "cypher/execution_plan/ops/op_all_node_scan.h"
#include "cypher/execution_plan/ops/op_all_node_scan_col.h"
#include "cypher/execution_plan/ops/op_node_by_label_scan.h"
#include "cypher/execution_plan/ops/op_node_index_seek.h"
#include "cypher/execution_plan/ops/op_produce_results.h"
#include "cypher/execution_plan/ops/op_produce_results_col.h"
#include "cypher/execution_plan/ops/op_filter.h"
#include "cypher/execution_plan/ops/op_expand_all.h"
#include "cypher/execution_plan/ops/op_create.h"
Expand All @@ -36,10 +34,8 @@
#include "cypher/execution_plan/ops/op_gql_inquery_call.h"
#include "cypher/execution_plan/ops/op_aggregate.h"
#include "cypher/execution_plan/ops/op_project.h"
#include "cypher/execution_plan/ops/op_project_col.h"
#include "cypher/execution_plan/ops/op_sort.h"
#include "cypher/execution_plan/ops/op_limit.h"
#include "cypher/execution_plan/ops/op_limit_col.h"
#include "cypher/execution_plan/ops/op_cartesian_product.h"
#include "cypher/execution_plan/ops/op_set.h"
#include "cypher/execution_plan/ops/op_gql_set.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,7 @@ class LocateNodeByIndexedProp : public OptPass {

if (in_filter->ae_left_.type == ArithExprNode::AR_EXP_OPERAND &&
in_filter->ae_left_.operand.type == ArithOperandNode::AR_OPERAND_VARIADIC &&
!in_filter->ae_left_.operand.variadic.entity_prop.empty() &&
in_filter->ae_right_.type == ArithExprNode::AR_EXP_OPERAND) {
!in_filter->ae_left_.operand.variadic.entity_prop.empty()) {
auto right_data = Entry(in_filter->ae_right_.operand.constant);
if (!right_data.IsArray()) CYPHER_TODO();
field = in_filter->ae_left_.operand.variadic.entity_prop;
Expand Down
Loading

0 comments on commit 83cc4aa

Please sign in to comment.