Skip to content

Commit

Permalink
fix #23: remove chinese characters in code comment (#402)
Browse files Browse the repository at this point in the history
* update copyright to 2024

* add deps

* clean chinese characters in code comments

* fix comments
  • Loading branch information
qishipengqsp authored Jan 31, 2024
1 parent a5c2290 commit 4a7f4b3
Show file tree
Hide file tree
Showing 20 changed files with 85 additions and 90 deletions.
5 changes: 2 additions & 3 deletions src/client/python/TuGraphClient/TuGraphClient.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

# TODO: implement load balancing
class AsyncTuGraphClient:
# 默认的客户端使用异步方式访问
# client accesses server asynchronously by default

def __init__(self, start_host_port, username, password, graph='default', use_https=False, load_balance=False,
retry=3, retry_interval_s=1):
Expand Down Expand Up @@ -319,8 +319,7 @@ async def get_server_info(self):


class TuGraphClient(AsyncTuGraphClient):
# 还是暴露之前的TuGraphClient
# 将之前暴露的8个接口重新封装成可以直接同步方式调用
# reserve legacy TuGraphClient for eight synchronous interface

def list_graphs(self):
return self._sync(partial(AsyncTuGraphClient.list_graphs, self))
Expand Down
2 changes: 1 addition & 1 deletion src/cypher/arithmetic/arithmetic_expression.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1273,7 +1273,7 @@ Entry ArithOpNode::Evaluate(RTContext *ctx, const Record &record) const {
/* if !func, custom function */
std::string input, output;
std::string name = func_name.substr(std::string(CUSTOM_FUNCTION_PREFIX).size());
// 将children都分别进行evaluate操作,并且添加到input进行输出
// evaluate every child and add to input for output
for (int i = 1; i < (int)children.size(); i++) {
auto v = children[i].Evaluate(ctx, record);
input.append(v.ToString());
Expand Down
34 changes: 17 additions & 17 deletions src/cypher/execution_plan/execution_plan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ void ExecutionPlan::_AddScanOp(const parser::QueryPart &part, const SymbolTable
}
}
if (!has_arg) {
// 符号表中没有type为argument的
// no argument type in symbol table
if (pf.type == Property::VALUE || pf.type == Property::PARAMETER) {
/* use index when possible. weak index lookup if label absent */
scan_op = new NodeIndexSeek(node, sym_tab);
Expand All @@ -348,7 +348,7 @@ void ExecutionPlan::_AddScanOp(const parser::QueryPart &part, const SymbolTable
}
ops.emplace_back(scan_op);
} else {
// 符号表有type为argument的
// argument type exists in symbol table
if (it->second.scope == SymbolNode::ARGUMENT) {
if (skip_arg_op) return;
scan_op = new Argument(sym_tab);
Expand Down Expand Up @@ -551,7 +551,7 @@ void ExecutionPlan::_BuildExpandOps(const parser::QueryPart &part, PatternGraph
auto &relp = pattern_graph.GetRelationship(std::get<1>(step));
auto &neighbor = pattern_graph.GetNode(std::get<2>(step));
if (relp.Empty() && neighbor.Empty()) {
// 邻居节点和关系都为空,证明是悬挂点 hanging为true
// neighbor and relationship are both empty, it's a hanging node
/* Node doesn't have any incoming nor outgoing edges,
* this is an hanging node "()", create a scan operation. */
CYPHER_THROW_ASSERT(stream.size() == 1);
Expand All @@ -565,10 +565,10 @@ void ExecutionPlan::_BuildExpandOps(const parser::QueryPart &part, PatternGraph
it->second.scope == SymbolNode::ARGUMENT) {
// the previous argument op added
skip_hanging_argument_op =
true; // 避免MATCH (a),(b) WITH a, b a,b会导致生成多个argument
true; // avoid `MATCH (a),(b) WITH a, b a,b` generates multiple arguments
}
} else if (relp.VarLen()) {
// 邻居不为空,进行expand
// expand when neighbor is not null
OpBase *expand_op = new VarLenExpand(&pattern_graph, &start, &neighbor, &relp);
expand_ops.emplace_back(expand_op);
} else {
Expand Down Expand Up @@ -606,7 +606,7 @@ void ExecutionPlan::_BuildExpandOps(const parser::QueryPart &part, PatternGraph
/* Locates expand all operations which do not have a child operation,
* And adds a scan operation as a new child. */
if (!hanging) {
// 如果不是悬挂点,就补一个scanop
// add a scan op when it is not a hanging node
CYPHER_THROW_ASSERT(!stream.empty());
std::vector<OpBase *> scan_ops;
auto &start_node = pattern_graph.GetNode(std::get<0>(stream[0]));
Expand All @@ -633,8 +633,9 @@ void ExecutionPlan::_BuildExpandOps(const parser::QueryPart &part, PatternGraph
}
} // end for streams
if (!traversal_root) {
// 如果traversal_root为空,则判断stream里面是否是悬挂点,且为argument,如果是这种情况_AddScanOp就会跳过,不产生任何op
// 1. 判断符号表中是否有argument
// judge if nodes in stream are dangling and of type ARGUMENT when traversal_root is null
// _AddScanOp will be skipped in this case. No op will be generated
// 1. judge if ARGUMENT type exists in symbol table
bool has_arg = false;
for (auto &a : pattern_graph.symbol_table.symbols) {
if (a.second.scope == SymbolNode::ARGUMENT) {
Expand All @@ -643,23 +644,22 @@ void ExecutionPlan::_BuildExpandOps(const parser::QueryPart &part, PatternGraph
}
}
if (!has_arg) CYPHER_TODO();
// 2. 判断是否都是悬挂点
// 所有stream都是悬挂点
// 2. judge if all nodes are dangiling
// all streams are dangling nodes
for (auto &stream : expand_streams) {
if (stream.size() != 1 ||
!pattern_graph.GetRelationship(std::get<1>(stream[0])).Empty()) {
CYPHER_TODO();
}
}
// 没有argument 或 整个流不是悬挂点,就抛出异常
// 符合条件的话,就在这里追加一个argument
// throw exception when argument or the stream is not dangling node
// add one more argument when condition is true
traversal_root = new Argument(&pattern_graph.symbol_table);
}
/* 调整树结构,使得笛卡尔积下的argument放到scan下
* 删掉笛卡尔积,即children[1]作为根节点
* 并且更改scan为dynamic
* 目前只处理CARTESIAN_PRODUCT下只有两个孩子的情况
* 例如:
/* Restructure the tree to move the argument down
* 1. remove cartesian product and emplace children[1] as the root
* 2. update the scan op to the dynamic one
* Only works when there are only two children of CARTESIAN_PRODUCT. E.g,
* before:
* Cartesian Product
Argument [c,f]
Expand Down
4 changes: 2 additions & 2 deletions src/cypher/execution_plan/execution_plan_maker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ void ExecutionPlanMaker::_AddScanOp(const SymbolTable* sym_tab, Node* node,
}
}
if (!has_arg) {
// 符号表中没有type为argument的
// no argument type in symbol table
if (pf.type == Property::VALUE || pf.type == Property::PARAMETER) {
/* use index when possible. weak index lookup if label absent */
scan_op = new NodeIndexSeek(node, sym_tab);
Expand All @@ -217,7 +217,7 @@ void ExecutionPlanMaker::_AddScanOp(const SymbolTable* sym_tab, Node* node,
}
ops.emplace_back(scan_op);
} else {
// 符号表有type为argument的
// has argument type in symbol table
if (it->second.scope == SymbolNode::ARGUMENT) {
if (skip_arg_op) return;
} else if (pf.type == Property::VALUE || pf.type == Property::PARAMETER) {
Expand Down
2 changes: 1 addition & 1 deletion src/cypher/execution_plan/ops/op.h
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ struct OpBase {

bool IsDynamicScan() const {
return type == OpType::NODE_INDEX_SEEK_DYNAMIC || type == OpType::ALL_NODE_SCAN_DYNAMIC ||
type == OpType::NODE_BY_LABEL_SCAN_DYNAMIC; // 新增
type == OpType::NODE_BY_LABEL_SCAN_DYNAMIC;
}

bool IsStreamRoot() const {
Expand Down
2 changes: 1 addition & 1 deletion src/cypher/execution_plan/ops/op_all_node_scan_dynamic.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class AllNodeScanDynamic : public OpBase {
auto child = children[0];
if (child->type != OpType::ARGUMENT) CYPHER_TODO();
if (!consuming_) {
// 第一次进来需要child->Consume
// call child->Consume first time
if (child->Consume(ctx) != OP_OK) {
return OP_DEPLETED;
}
Expand Down
4 changes: 2 additions & 2 deletions src/cypher/execution_plan/ops/op_apply.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,14 @@ class Apply : public OpBase {
if (state == StreamDepleted) return OP_DEPLETED;
if (state == StreamUnInitialized) {
if (PullFromLhs(ctx) != OP_OK) {
// Apply的计算,是这里是先计算lhs的
// starting with lhs first
state = StreamDepleted;
return OP_DEPLETED;
}
state = StreamConsuming;
}
auto res = rhs->Consume(ctx);
// 然后处理rhs
// then process rhs
while (res != OP_OK) {
if (PullFromLhs(ctx) != OP_OK) {
state = StreamDepleted;
Expand Down
6 changes: 2 additions & 4 deletions src/cypher/execution_plan/ops/op_filter.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,26 +69,24 @@ class OpFilter : public OpBase {
for (auto child : op->children) {
allModified = true;
if (child->type == cypher::OpType::ARGUMENT) {
// 判断ae_right的符号是否包含在argument中,全包含则containModifies为true
// containModifies is true when all ae_right symbols are included in arguments
for (auto alias : tif->RhsAlias()) {
if (std::find(child->modifies.begin(), child->modifies.end(), alias) ==
child->modifies.end()) {
allModified = false;
break;
}
}
// 如果ARGUMENT符合条件,则直接返回true,无需再找;否则,继续查找孩子的孩子
if (allModified == true) {
tif->SetProducerOp(child);
return true;
} else {
// 如果孩子树中找到了ARGUMENT,那么直接返回true,不继续迭代寻找
if (LocateAndSetProducer(child, tif) == true) {
return true;
}
}
} else {
// 如果孩子树中找到了ARGUMENT,那么直接返回true,不继续迭代寻找
// return true when ARGUMENT found in the child tree
if (LocateAndSetProducer(child, tif) == true) {
return true;
}
Expand Down
2 changes: 1 addition & 1 deletion src/cypher/execution_plan/ops/op_node_by_id_seek.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class NodeByIdSeek : public OpBase {
}

OpResult RealConsume(RTContext *ctx) override {
// 记得每次都要设为-1!!!!!
// remember set vid to -1 every time
node_->SetVid(-1);

if (!it_ || !it_->IsValid()) return OP_DEPLETED;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class NodeByLabelScanDynamic : public OpBase {
auto child = children[0];
if (child->type != OpType::ARGUMENT) CYPHER_TODO();
if (!consuming_) {
// 第一次进来需要child->Consume
// call child->Consume first time
if (child->Consume(ctx) != OP_OK) {
return OP_DEPLETED;
}
Expand Down
2 changes: 1 addition & 1 deletion src/cypher/execution_plan/ops/op_node_index_seek.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class NodeIndexSeek : public OpBase {
record->SetParameter(ctx->param_tab_);

auto &pf = node_->Prop();
field_ = pf.type != Property::NUL ? pf.field : field_; // 优先用prop形式指定的field
field_ = pf.type != Property::NUL ? pf.field : field_; // use pf.field if applicable
if (pf.type == Property::VALUE) {
target_values_.emplace_back(pf.value);
} else if (pf.type == Property::PARAMETER) {
Expand Down
2 changes: 1 addition & 1 deletion src/cypher/execution_plan/ops/op_traversal.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ class Traversal : public OpBase {
for (auto &num : map_.lock_table()) {
if (noneagg_property_.empty()) {
result_buffer_.emplace_back(lgraph::FieldData(num.second));
} else { // result_buffer_格式:[agg, key, agg, key, agg, key, ...]
} else { // result_buffer_ format:[agg, key, agg, key, agg, key, ...]
result_buffer_.emplace_back(lgraph::FieldData(num.second));
result_buffer_.emplace_back(num.first);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class LocateNodeByIndexedProp : public OptPass {
Node *node;
const SymbolTable *symtab;

// TODO(anyone) 2/9/22 gelincheng: 这里可以写的再优雅些嘛?
// TODO(anyone): rewrite this more elegantly
if (op_filter->children[0]->type == OpType::ALL_NODE_SCAN) {
node = dynamic_cast<AllNodeScan *>(op_filter->children[0])->GetNode();
symtab = dynamic_cast<AllNodeScan *>(op_filter->children[0])->sym_tab_;
Expand All @@ -71,9 +71,9 @@ class LocateNodeByIndexedProp : public OptPass {
symtab = dynamic_cast<NodeByLabelScan *>(op_filter->children[0])->sym_tab_;
}

// try to reuse NodeIndexSeek
// 这里修改了NodeIndexSeek的实现,使其支持静态多值
// 不选择直接构造一个unwind的原因:因为unwind需要增加一个符号,需要修改原先的symtab
// try to reuse NodeIndexSeek
// Here implemention of NodeIndexSeek is tweaked to support multiple static values
// Reason that not to build unwind:unwind needs one more symbol in symbol table
if (target_value_datas.empty()) target_value_datas.emplace_back(value);
auto op_node_index_seek = new NodeIndexSeek(node, symtab, field, target_value_datas);
op_node_index_seek->parent = op_post;
Expand All @@ -96,13 +96,13 @@ class LocateNodeByIndexedProp : public OptPass {
range_filter->GetCompareOp() == lgraph::LBR_EQ &&
range_filter->GetAeRight().operand.type == ArithOperandNode::AR_OPERAND_CONSTANT) {
if (field.empty()) {
// 右值可能会不是constant? 如果是para类型?需要处理嘛?
// right value may not be constant? need to process when it is para type.
field = range_filter->GetAeLeft().operand.variadic.entity_prop;
}
if (field != range_filter->GetAeLeft().operand.variadic.entity_prop) {
return false;
}
// 这里默认是scalar,数组情况后续处理
// assume the operand is scalar by default. Array will be supported later
value = range_filter->GetAeRight().operand.constant.scalar;
return true;
}
Expand Down Expand Up @@ -145,9 +145,9 @@ class LocateNodeByIndexedProp : public OptPass {
std::vector<lgraph::FieldData> &target_value_datas) {
/**
* @brief
* 检查Filter是不是符合属性值等值判断的filter
* Check if Filter is filters to filter prop values
*
* 2/8 适用情况: where n.prop = value || OR || IN
* where n.prop = value || OR || IN
*/

auto filter = op_filter->Filter();
Expand Down Expand Up @@ -182,7 +182,6 @@ class LocateNodeByIndexedProp : public OptPass {
}
if (!getValueFromRangeFilter(filter->Left(), field, value)) return false;
target_value_datas.emplace_back(value);
// 如果需要按照原来的输入顺序输出的话
std::reverse(target_value_datas.begin(), target_value_datas.end());
return true;
} else if (filter->Type() == lgraph::Filter::GEAX_EXPR_FILTER) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class LocateNodeByVid : public OptPass {
range_filter->GetAeLeft().op.func_name == "id" &&
range_filter->GetCompareOp() == lgraph::LBR_EQ) {
if (!range_filter->GetAeRight().operand.constant.IsInteger()) {
return -1; // TODO(anyone): 右值可能不是integer,这里用-1做flag合适嘛?
return -1; // TODO(anyone): return -1 is not ok when AeRight is not an integer.
}
return range_filter->GetAeRight().operand.constant.scalar.integer();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ class OptRewriteWithSchemaInference : public OptPass {
return true;
}

// match子句中的模式图可以分为多个极大连通子图,该函数提取每个极大连通子图的点和边,经过分析后加上标签信息
// pattern graph in match clause can be divided to multiple maximal connected subgraphs
// this function extracts V and E of each subgraphs and labels them after analysis
void _ExtractStreamAndAddLabels(OpBase *root, const lgraph::SchemaInfo *schema_info) {
CYPHER_THROW_ASSERT(root->type == OpType::EXPAND_ALL);
SchemaNodeMap schema_node_map;
Expand All @@ -103,7 +104,7 @@ class OptRewriteWithSchemaInference : public OptPass {
relp_map_value(start->ID(), neighbor->ID(), relp->Types(), relp->direction_);
schema_relp_map[relp->ID()] = relp_map_value;
} else if (op->type == OpType::VAR_LEN_EXPAND) {
// 含有可变长算子的情况暂不处理
// currently do not process when var len ops exist
return;
} else if ((op->IsScan() || op->IsDynamicScan()) && op->type != OpType::ARGUMENT) {
NodeID id;
Expand Down Expand Up @@ -140,12 +141,12 @@ class OptRewriteWithSchemaInference : public OptPass {
CYPHER_THROW_ASSERT(op->children.size() == 1);
op = op->children[0];
}
// 调用schema函数
// call schema function
rewrite::SchemaRewrite schema_rewrite;
std::vector<SchemaGraphMap> schema_graph_maps;
schema_graph_maps =
schema_rewrite.GetEffectivePath(*schema_info, &schema_node_map, &schema_relp_map);
// 目前只对一条可行路径的情况进行重写
// currently rewrite only when there is just one effective path
if (schema_graph_maps.size() != 1) {
return;
}
Expand Down Expand Up @@ -219,7 +220,7 @@ class OptRewriteWithSchemaInference : public OptPass {
}

void _RewriteWithSchemaInference(OpBase *root, const lgraph::SchemaInfo *schema_info) {
// 对单独的点和可变长不予优化
// do not optimize on single node and var len
if (root->type == OpType::EXPAND_ALL) {
_ExtractStreamAndAddLabels(root, schema_info);
} else {
Expand Down
Loading

0 comments on commit 4a7f4b3

Please sign in to comment.