This repository has been archived by the owner on Dec 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature/fetch-vertices-on-multi-tags
- Loading branch information
Showing
185 changed files
with
6,492 additions
and
2,008 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,7 @@ build | |
_build | ||
_build.log | ||
_install | ||
install | ||
bin/ | ||
install_manifest.txt | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -83,7 +83,6 @@ | |
'KW_BY', | ||
'KW_IN', | ||
'KW_NOT_IN', | ||
'KW_NOT_CONTAINS', | ||
'KW_DOWNLOAD', | ||
'KW_GET', | ||
'KW_OF', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
/* Copyright (c) 2020 vesoft inc. All rights reserved. | ||
* | ||
* This source code is licensed under Apache 2.0 License, | ||
* attached with Common Clause Condition 1.0, found in the LICENSES directory. | ||
*/ | ||
|
||
#ifndef CONTEXT_SYMBOLS_H_ | ||
#define CONTEXT_SYMBOLS_H_ | ||
|
||
#include "util/ObjectPool.h" | ||
|
||
namespace nebula { | ||
namespace graph { | ||
|
||
class PlanNode; | ||
|
||
struct ColDef { | ||
ColDef(std::string n, Value::Type t) { | ||
name = std::move(n); | ||
type = std::move(t); | ||
} | ||
|
||
bool operator==(const ColDef& rhs) const { | ||
return name == rhs.name && type == rhs.type; | ||
} | ||
|
||
std::string name; | ||
Value::Type type; | ||
}; | ||
|
||
using ColsDef = std::vector<ColDef>; | ||
|
||
struct Variable { | ||
explicit Variable(std::string n) : name(std::move(n)) {} | ||
|
||
std::string name; | ||
Value::Type type{Value::Type::DATASET}; | ||
// Valid if type is dataset. | ||
std::vector<std::string> colNames; | ||
|
||
std::unordered_set<PlanNode*> readBy; | ||
std::unordered_set<PlanNode*> writtenBy; | ||
}; | ||
|
||
class SymbolTable final { | ||
public: | ||
explicit SymbolTable(ObjectPool* objPool) { | ||
DCHECK(objPool != nullptr); | ||
objPool_ = objPool; | ||
} | ||
|
||
Variable* newVariable(std::string name) { | ||
VLOG(1) << "New variable for: " << name; | ||
auto* variable = objPool_->makeAndAdd<Variable>(name); | ||
addVar(std::move(name), variable); | ||
return variable; | ||
} | ||
|
||
void addVar(std::string varName, Variable* variable) { | ||
vars_.emplace(std::move(varName), variable); | ||
} | ||
|
||
bool readBy(const std::string& varName, PlanNode* node) { | ||
auto var = vars_.find(varName); | ||
if (var == vars_.end()) { | ||
return false; | ||
} | ||
var->second->readBy.emplace(node); | ||
return true; | ||
} | ||
|
||
bool writtenBy(const std::string& varName, PlanNode* node) { | ||
auto var = vars_.find(varName); | ||
if (var == vars_.end()) { | ||
return false; | ||
} | ||
var->second->writtenBy.emplace(node); | ||
return true; | ||
} | ||
|
||
bool deleteReadBy(const std::string& varName, PlanNode* node) { | ||
auto var = vars_.find(varName); | ||
if (var == vars_.end()) { | ||
return false; | ||
} | ||
var->second->readBy.erase(node); | ||
return true; | ||
} | ||
|
||
bool deleteWrittenBy(const std::string& varName, PlanNode* node) { | ||
auto var = vars_.find(varName); | ||
if (var == vars_.end()) { | ||
return false; | ||
} | ||
var->second->writtenBy.erase(node); | ||
return true; | ||
} | ||
|
||
bool updateReadBy(const std::string& oldVar, const std::string& newVar, PlanNode* node) { | ||
return deleteReadBy(oldVar, node) && readBy(newVar, node); | ||
} | ||
|
||
bool updateWrittenBy(const std::string& oldVar, const std::string& newVar, PlanNode* node) { | ||
return deleteWrittenBy(oldVar, node) && writtenBy(newVar, node); | ||
} | ||
|
||
Variable* getVar(const std::string& varName) { | ||
auto var = vars_.find(varName); | ||
if (var == vars_.end()) { | ||
return nullptr; | ||
} else { | ||
return var->second; | ||
} | ||
} | ||
|
||
private: | ||
ObjectPool* objPool_{nullptr}; | ||
// var name -> variable | ||
std::unordered_map<std::string, Variable*> vars_; | ||
}; | ||
} // namespace graph | ||
} // namespace nebula | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.