Skip to content

Commit

Permalink
Merge branch 'master' into indexBranch
Browse files Browse the repository at this point in the history
  • Loading branch information
ncbd authored Aug 29, 2024
2 parents f29ff79 + 4aff0f4 commit 0a727bb
Show file tree
Hide file tree
Showing 73 changed files with 2,776 additions and 3,057 deletions.
20 changes: 6 additions & 14 deletions ci/images/tugraph-compile-centos7-Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -358,20 +358,12 @@ RUN wget -O /tmp/openblas-faiss.tar.gz https://tugraph-web.oss-cn-beijing.aliyun
&& rm -rf /tmp/openblas-faiss /tmp/openblas-faiss.tar.gz && ldconfig

# install vsag
RUN wget -O /tmp/binutils-gcc-vsag.tar.gz https://tugraph-web.oss-cn-beijing.aliyuncs.com/tugraph/deps/binutils-gcc-vsag.tar.gz \
&& tar -xzvf /tmp/binutils-gcc-vsag.tar.gz -C /tmp && cd /tmp/gcc-14.2.0 \
&& yum install -y gmp-devel mpfr-devel libmpc-devel \
&& ./configure --disable-multilib --enable-languages=c,c++,fortran --prefix=/opt/gcc-14.2.0 \
&& make -j$(nproc) && make install && cd /tmp/binutils-2.43.1 \
&& ./configure --prefix=/usr/local/binutils-2.43.1 --with-sysroot=/opt/gcc-14.2.0 --libdir=/opt/gcc-14.2.0/lib64 --disable-multilib \
&& make -j$(nproc) && make install && cd /tmp/vsag && sh ./scripts/deps/install_deps_centos.sh \
&& PATH=/usr/local/binutils-2.43.1/bin:/opt/gcc-14.2.0/bin:$PATH \
LD_LIBRARY_PATH=/opt/gcc-14.2.0/lib64:/usr/lib64:$LD_LIBRARY_PATH \
LDFLAGS="-L/opt/gcc-14.2.0/lib64" \
LD=/opt/gcc-14.2.0/bin/ld \
make release && make install \
&& yum erase -y gmp-devel mpfr-devel libmpc-devel && yum clean all \
&& rm -rf /tmp/gcc-14.2.0 /tmp/binutils-2.43.1 /tmp/vsag /tmp/binutils-gcc-vsag.tar.gz /opt/gcc-14.2.0 /opt/intel /usr/local/binutils-2.43.1
RUN wget -O /tmp/vsag.tar.gz https://tugraph-web.oss-cn-beijing.aliyuncs.com/tugraph/deps/vsag.tar.gz \
&& tar -xzvf /tmp/vsag.tar.gz -C /tmp \
&& cd /tmp/vsag && sh ./scripts/deps/install_deps_centos.sh \
&& yum install -y libgfortran5.x86_64 && ln -s /usr/lib64/libgfortran.so.5.0.0 /usr/local/lib/libgfortran.so \
&& ldconfig && make release VSAG_CMAKE_ARGS="-S. -Bbuild -DDISABLE_SSE_FORCE=OFF -DDISABLE_AVX_FORCE=OFF -DDISABLE_AVX2_FORCE=OFF -DDISABLE_AVX512_FORCE=ON" \
&& make install && rm -rf /tmp/vsag /tmp/vsag.tar.gz /opt/intel

ENV JAVA_HOME=/usr/lib/jvm/java-11-openjdk \
LD_LIBRARY_PATH=/usr/local/lib64:/usr/local/lib:/usr/lib/jvm/java-11-openjdk/lib/server:$LD_LIBRARY_PATH \
Expand Down
1 change: 1 addition & 0 deletions deps/geax-front-end/include/geax-front-end/GEAXErrorCode.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ enum class GEAXErrorCode : uint32_t {
GEAX_SUCCEED = 0,
GEAX_ERROR = 1,
GEAX_OOPS = 4,
GEAX_OPTIMIZATION_PASS = 5,

GEAX_COMMON_INVALID_ARGUMENT = 30002,
GEAX_COMMON_NULLPTR = 30003,
Expand Down
13 changes: 13 additions & 0 deletions deps/geax-front-end/include/geax-front-end/ast/AstDumper.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,19 @@ class AstDumper : public AstNodeVisitor {
return GEAXErrorCode::GEAX_SUCCEED;
}

template <typename T1, typename T2, typename T3>
std::any visit(const std::tuple<T1, T2, T3>& t) {
INDET_GUARD();
VARIABLE_GUARD();
cur_var_ = "tuple<0>";
VISIT_AND_CHECK_WITH_MSG(std::get<0>(t));
cur_var_ = "tuple<1>";
VISIT_AND_CHECK_WITH_MSG(std::get<1>(t));
cur_var_ = "tuple<2>";
VISIT_AND_CHECK_WITH_MSG(std::get<2>(t));
return GEAXErrorCode::GEAX_SUCCEED;
}

template <typename T1, typename T2>
std::any visit(const std::variant<T1, T2>& t) {
INDET_GUARD();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class GraphPattern : public AstNode {

void setWhere(Expr* where) { where_ = where; }
const std::optional<Expr*>& where() const { return where_; }
void resetWhere() { where_.reset(); }

// NOTE(yaochi): this could be confict with system function yield()
void setYield(YieldField* yield) { yield_ = yield; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ class PrimitiveResultStatement : public AstNode {
void setDistinct(bool distinct) { isDistinct_ = distinct; }
bool distinct() const { return isDistinct_; }

void appendItem(std::string&& name, Expr* expr) { items_.emplace_back(std::move(name), expr); }
void setItems(std::vector<std::tuple<std::string, Expr*>>&& items) {
void appendItem(std::string&& name, Expr* expr) { items_.emplace_back(std::move(name), expr, false); }
void setItems(std::vector<std::tuple<std::string, Expr*, bool>>&& items) {
items_ = std::move(items);
}
const std::vector<std::tuple<std::string, Expr*>>& items() const { return items_; }
const std::vector<std::tuple<std::string, Expr*, bool>>& items() const { return items_; }
void appendGroupKey(Expr* groupKey) { groupKeys_.emplace_back(groupKey); }
void setGroupKeys(std::vector<Expr*>&& groupKeys) { groupKeys_ = std::move(groupKeys); }
const std::vector<Expr*>& groupKeys() const { return groupKeys_; }
Expand All @@ -64,7 +64,7 @@ class PrimitiveResultStatement : public AstNode {

private:
bool isDistinct_;
std::vector<std::tuple<std::string, Expr*>> items_;
std::vector<std::tuple<std::string, Expr*, bool>> items_;
std::vector<Expr*> groupKeys_;
std::vector<OrderByField*> orderBys_;
std::optional<IntParam> limit_;
Expand Down
3 changes: 3 additions & 0 deletions src/core/global_config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,5 +337,8 @@ fma_common::Configuration lgraph::GlobalConfig::InitConfig
argparser.Add(browser_options.retain_connection_credentials,
"browser.retain_connection_credentials", true)
.Comment("Config browser whether to store user credentials in local storage.");
argparser.Add(is_cypher_v2,
"is_cypher_v2", true)
.Comment("Config browser whether to store user credentials in local storage.");
return argparser;
}
3 changes: 2 additions & 1 deletion src/core/global_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,11 @@ struct BasicConfigs {
int ha_bootstrap_role = 0;
bool ha_is_witness = false; // node is witness or not
bool ha_enable_witness_to_leader = false; // enable witness to leader or not
std::string ha_first_snapshot_start_time = ""; // first snapshot start time
std::string ha_first_snapshot_start_time; // first snapshot start time
// whose format is "HH:MM:SS",
// and the default value is ""
// indicating a random time.
bool is_cypher_v2 = true;

// log
int verbose = 1;
Expand Down
1 change: 0 additions & 1 deletion src/core/vertex_index.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ class VertexIndexIterator : public ::lgraph::IteratorBase {

bool Goto(VertexId vid);


/**
* Gets the current key.
*
Expand Down
21 changes: 14 additions & 7 deletions src/cypher/arithmetic/ast_expr_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,10 @@ std::any cypher::AstExprEvaluator::visit(geax::frontend::AggFunc* node) {
// Evalute Mode
if (visit_mode_ == VisitMode::EVALUATE) {
if (agg_pos_ >= agg_ctxs_.size()) {
return Entry(cypher::FieldData(lgraph_api::FieldData(0)));
if (func_name == "count") {
return Entry(cypher::FieldData(lgraph_api::FieldData(0)));
}
return Entry(cypher::FieldData(lgraph_api::FieldData()));
}
return agg_ctxs_[agg_pos_++]->result;
} else if (visit_mode_ == VisitMode::AGGREGATE) {
Expand Down Expand Up @@ -362,7 +365,7 @@ std::any cypher::AstExprEvaluator::visit(geax::frontend::BAggFunc* node) {
// Evalute Mode
if (visit_mode_ == VisitMode::EVALUATE) {
if (agg_pos_ >= agg_ctxs_.size()) {
return Entry(cypher::FieldData(lgraph_api::FieldData(0)));
return Entry(cypher::FieldData(lgraph_api::FieldData()));
}
return agg_ctxs_[agg_pos_++]->result;
} else if (visit_mode_ == VisitMode::AGGREGATE) {
Expand Down Expand Up @@ -399,11 +402,13 @@ std::any cypher::AstExprEvaluator::visit(geax::frontend::MkList* node) {
std::vector<cypher::FieldData> list;
for (auto& e : elems) {
auto entry = std::any_cast<Entry>(e->accept(*this));
if (!entry.IsMap() && !entry.IsScalar()) NOT_SUPPORT_AND_THROW();
if (!entry.IsConstant()) NOT_SUPPORT_AND_THROW();
if (entry.IsScalar()) {
list.emplace_back(entry.constant.scalar);
} else {
list.emplace_back(*entry.constant.map);
} else if (entry.IsArray()) {
list.emplace_back(*entry.constant.array);
} else if (entry.IsMap()) {
list.emplace_back(*entry.constant.map);
}
}
return Entry(cypher::FieldData(list));
Expand All @@ -416,11 +421,13 @@ std::any cypher::AstExprEvaluator::visit(geax::frontend::MkMap* node) {
auto key = std::any_cast<Entry>(std::get<0>(pair)->accept(*this));
auto val = std::any_cast<Entry>(std::get<1>(pair)->accept(*this));
if (!key.IsString()) NOT_SUPPORT_AND_THROW();
if (!val.IsScalar() && !val.IsArray()) NOT_SUPPORT_AND_THROW();
if (!val.IsConstant()) NOT_SUPPORT_AND_THROW();
if (val.IsScalar()) {
map.emplace(key.constant.ToString(), val.constant.scalar);
} else {
} else if (val.IsArray()) {
map.emplace(key.constant.ToString(), *val.constant.array);
} else if (val.IsMap()) {
map.emplace(key.constant.ToString(), *val.constant.map);
}
}
return Entry(cypher::FieldData(map));
Expand Down
4 changes: 4 additions & 0 deletions src/cypher/arithmetic/ast_expr_evaluator.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ class AstExprEvaluator : public geax::frontend::AstExprNodeVisitorImpl {
}
}

geax::frontend::Expr* GetExpression() {
return expr_;
}

private:
std::any visit(geax::frontend::GetField* node) override;
std::any visit(geax::frontend::TupleGet* node) override;
Expand Down
36 changes: 36 additions & 0 deletions src/cypher/execution_plan/clause_read_only_decider.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#pragma once

#include "cypher/utils/ast_node_visitor_impl.h"
#include "procedure/procedure.h"

namespace cypher {

Expand All @@ -35,11 +36,46 @@ class ClauseReadOnlyDecider : public cypher::AstNodeVisitorImpl {
private:
std::any visit(geax::frontend::AmbientLinearQueryStatement* node) override {
read_only_ = true;
ACCEPT_AND_CHECK_WITH_ERROR_MSG(node->resultStatement());
for (auto query_statement : node->queryStatements()) {
ACCEPT_AND_CHECK_WITH_ERROR_MSG(query_statement);
}
return geax::frontend::GEAXErrorCode::GEAX_SUCCEED;
}

std::any visit(geax::frontend::LinearDataModifyingStatement* node) override {
read_only_ = false;
for (auto query_statement : node->queryStatements()) {
ACCEPT_AND_CHECK_WITH_ERROR_MSG(query_statement);
}
for (auto modify_statement : node->modifyStatements()) {
ACCEPT_AND_CHECK_WITH_ERROR_MSG(modify_statement);
}
if (node->resultStatement().has_value()) {
ACCEPT_AND_CHECK_WITH_ERROR_MSG(node->resultStatement().value());
}
return geax::frontend::GEAXErrorCode::GEAX_SUCCEED;
}

std::any visit(geax::frontend::NamedProcedureCall* node) override {
std::string func_name = std::get<std::string>(node->name());
if (func_name == "db.plugin.callPlugin") {
read_only_ = false;
} else {
auto pp = cypher::global_ptable.GetProcedure(func_name);
if (pp && !pp->read_only) read_only_ = false;
}
return geax::frontend::GEAXErrorCode::GEAX_SUCCEED;
}

std::any visit(geax::frontend::InQueryProcedureCall* node) override {
std::string func_name = std::get<std::string>(node->name());
if (func_name == "db.plugin.callPlugin") {
read_only_ = false;
} else {
auto pp = cypher::global_ptable.GetProcedure(func_name);
if (pp && !pp->read_only) read_only_ = false;
}
return geax::frontend::GEAXErrorCode::GEAX_SUCCEED;
}

Expand Down
2 changes: 1 addition & 1 deletion src/cypher/execution_plan/execution_plan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ static void BuildQueryGraph(const QueryPart &part, PatternGraph &graph) {
auto dst_nid = graph.AddNode("", dst_alias, Node::ARGUMENT);
graph.AddRelationship(std::set<std::string>{}, src_nid, dst_nid,
parser::LinkDirection::UNKNOWN, a.first,
Relationship::ARGUMENT, {});
Relationship::ARGUMENT, {}, {});
auto &src_node = graph.GetNode(src_nid);
auto &dst_node = graph.GetNode(dst_nid);
src_node.Visited() = true;
Expand Down
Loading

0 comments on commit 0a727bb

Please sign in to comment.