Skip to content
This repository has been archived by the owner on Dec 1, 2022. It is now read-only.

Commit

Permalink
Merge branch 'master' into feature/fetch-vertices-on-multi-tags
Browse files Browse the repository at this point in the history
  • Loading branch information
Shylock-Hg committed Oct 21, 2020
2 parents 0325872 + 782dc09 commit a622b32
Show file tree
Hide file tree
Showing 185 changed files with 6,492 additions and 2,008 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ build
_build
_build.log
_install
install
bin/
install_manifest.txt

Expand Down
1 change: 0 additions & 1 deletion .linters/cpp/checkKeyword.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@
'KW_BY',
'KW_IN',
'KW_NOT_IN',
'KW_NOT_CONTAINS',
'KW_DOWNLOAD',
'KW_GET',
'KW_OF',
Expand Down
7 changes: 5 additions & 2 deletions ci/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,10 @@ mkdir -p $BUILD_DIR

function get_py_client() {
git clone -b v2.0 https://github.com/vesoft-inc/nebula-python.git
cd nebula-python
pushd nebula-python
python3 setup.py install --user
popd
rm -rf nebula-python
}

function prepare() {
Expand Down Expand Up @@ -100,7 +102,8 @@ function run_test() {
$PROJ_DIR/tests/query/stateless/test_range.py \
$PROJ_DIR/tests/query/stateless/test_go.py \
$PROJ_DIR/tests/query/stateless/test_simple_query.py \
$PROJ_DIR/tests/query/stateless/test_keyword.py
$PROJ_DIR/tests/query/stateless/test_keyword.py \
$PROJ_DIR/tests/query/stateless/test_lookup.py
}

case "$1" in
Expand Down
1 change: 1 addition & 0 deletions conf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
install(
FILES
nebula-graphd.conf.default
nebula-graphd.conf.production
PERMISSIONS
OWNER_READ
GROUP_READ
Expand Down
15 changes: 14 additions & 1 deletion conf/nebula-graphd.conf.default
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
# Seconds before the idle connections are closed, 0 for never closed
--client_idle_timeout_secs=0
# Seconds before the idle sessions are expired, 0 for no expiration
--session_idle_timeout_secs=60000
--session_idle_timeout_secs=0
# The number of threads to accept incoming connections
--num_accept_threads=1
# The number of networking IO threads, 0 for # of CPU cores
Expand All @@ -52,3 +52,16 @@
--ws_http_port=13000
# HTTP2 service port
--ws_h2_port=13002

# The default charset when a space is created
--default_charset=utf8
# The defaule collate when a space is created
--default_collate=utf8_bin

########## authorization ##########
# Enable authorization
--enable_authorize=false

########## Authentication ##########
# User login authentication type, password for nebula authentication, ldap for ldap authentication, cloud for cloud authentication
--auth_type=password
11 changes: 10 additions & 1 deletion conf/nebula-graphd.conf.production
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,13 @@
# HTTP2 service port
--ws_h2_port=13002

--load_data_interval_secs=120
# Heartbeat interval of communication between meta client and graphd service
--heartbeat_interval_secs=10

########## authorization ##########
# Enable authorization
--enable_authorize=false

########## authentication ##########
# User login authentication type, password for nebula authentication, ldap for ldap authentication, cloud for cloud authentication
--auth_type=password
3 changes: 1 addition & 2 deletions resources/gflags.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
"wal_ttl",
"enable_reservoir_sampling",
"custom_filter_interval_secs",
"enable_multi_versions",
"enable_optimizer"
"enable_multi_versions"
],
"NESTED": [
"rocksdb_db_options",
Expand Down
3 changes: 2 additions & 1 deletion src/context/QueryContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ QueryContext::QueryContext() {
void QueryContext::init() {
objPool_ = std::make_unique<ObjectPool>();
ep_ = std::make_unique<ExecutionPlan>();
vctx_ = std::make_unique<ValidateContext>();
ectx_ = std::make_unique<ExecutionContext>();
idGen_ = std::make_unique<IdGenerator>(0);
symTable_ = std::make_unique<SymbolTable>(objPool_.get());
vctx_ = std::make_unique<ValidateContext>(std::make_unique<AnonVarGenerator>(symTable_.get()));
}

void QueryContext::addProfilingData(int64_t planNodeId, cpp2::ProfilingStats&& profilingStats) {
Expand Down
10 changes: 10 additions & 0 deletions src/context/QueryContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "service/RequestContext.h"
#include "util/IdGenerator.h"
#include "util/ObjectPool.h"
#include "context/Symbols.h"

namespace nebula {
namespace graph {
Expand Down Expand Up @@ -105,6 +106,10 @@ class QueryContext {
return sm_;
}

meta::IndexManager* indexMng() const {
return im_;
}

storage::GraphStorageClient* getStorageClient() const {
return storageClient_;
}
Expand Down Expand Up @@ -137,6 +142,10 @@ class QueryContext {

void fillPlanDescription();

SymbolTable* symTable() const {
return symTable_.get();
}

private:
void init();

Expand All @@ -157,6 +166,7 @@ class QueryContext {
// plan description for explain and profile query
std::unique_ptr<cpp2::PlanDescription> planDescription_;
std::unique_ptr<IdGenerator> idGen_;
std::unique_ptr<SymbolTable> symTable_;
};

} // namespace graph
Expand Down
3 changes: 2 additions & 1 deletion src/context/Result.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ namespace nebula {
namespace graph {

const Result& Result::EmptyResult() {
static Result kEmptyResult = ResultBuilder().iter(Iterator::Kind::kDefault).finish();
static Result kEmptyResult =
ResultBuilder().value(Value()).iter(Iterator::Kind::kDefault).finish();
return kEmptyResult;
}

Expand Down
123 changes: 123 additions & 0 deletions src/context/Symbols.h
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
16 changes: 7 additions & 9 deletions src/context/ValidateContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,22 @@
#ifndef CONTEXT_VALIDATECONTEXT_H_
#define CONTEXT_VALIDATECONTEXT_H_

#include "common/meta/SchemaManager.h"
#include "common/datatypes/Value.h"
#include "common/charset/Charset.h"
#include "common/datatypes/Value.h"
#include "common/meta/SchemaManager.h"
#include "context/Symbols.h"
#include "planner/ExecutionPlan.h"
#include "util/AnonVarGenerator.h"
#include "util/AnonColGenerator.h"
#include "service/Session.h"
#include "util/AnonColGenerator.h"
#include "util/AnonVarGenerator.h"

namespace nebula {
namespace graph {

using ColDef = std::pair<std::string, Value::Type>;
using ColsDef = std::vector<ColDef>;

class ValidateContext final {
public:
ValidateContext() {
anonVarGen_ = std::make_unique<AnonVarGenerator>();
explicit ValidateContext(std::unique_ptr<AnonVarGenerator> varGen) {
anonVarGen_ = std::move(varGen);
anonColGen_ = std::make_unique<AnonColGenerator>();
}

Expand Down
2 changes: 2 additions & 0 deletions src/executor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ nebula_add_library(
query/DataCollectExecutor.cpp
query/DataJoinExecutor.cpp
query/IndexScanExecutor.cpp
algo/ConjunctPathExecutor.cpp
algo/BFSShortestPathExecutor.cpp
admin/SwitchSpaceExecutor.cpp
admin/CreateUserExecutor.cpp
admin/DropUserExecutor.cpp
Expand Down
8 changes: 8 additions & 0 deletions src/executor/Executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
#include "executor/admin/SubmitJobExecutor.h"
#include "executor/admin/SwitchSpaceExecutor.h"
#include "executor/admin/UpdateUserExecutor.h"
#include "executor/algo/BFSShortestPathExecutor.h"
#include "executor/algo/ConjunctPathExecutor.h"
#include "executor/logic/LoopExecutor.h"
#include "executor/logic/PassThroughExecutor.h"
#include "executor/logic/SelectExecutor.h"
Expand Down Expand Up @@ -365,6 +367,12 @@ Executor *Executor::makeExecutor(QueryContext *qctx, const PlanNode *node) {
case PlanNode::Kind::kShowCollation: {
return pool->add(new ShowCollationExecutor(node, qctx));
}
case PlanNode::Kind::kBFSShortest: {
return pool->add(new BFSShortestPathExecutor(node, qctx));
}
case PlanNode::Kind::kConjunctPath: {
return pool->add(new ConjunctPathExecutor(node, qctx));
}
case PlanNode::Kind::kUnknown: {
break;
}
Expand Down
4 changes: 2 additions & 2 deletions src/executor/admin/BalanceExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ namespace graph {

class BalanceExecutor final : public Executor {
public:
BalanceExecutor(const PlanNode *node, QueryContext *ectx)
: Executor("BalanceExecutor", node, ectx) {}
BalanceExecutor(const PlanNode *node, QueryContext *qctx)
: Executor("BalanceExecutor", node, qctx) {}

folly::Future<Status> execute() override;

Expand Down
4 changes: 2 additions & 2 deletions src/executor/admin/BalanceLeadersExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ namespace graph {

class BalanceLeadersExecutor final : public Executor {
public:
BalanceLeadersExecutor(const PlanNode *node, QueryContext *ectx)
: Executor("BaanceLeadersExecutor", node, ectx) {}
BalanceLeadersExecutor(const PlanNode *node, QueryContext *qctx)
: Executor("BaanceLeadersExecutor", node, qctx) {}

folly::Future<Status> execute() override;

Expand Down
11 changes: 8 additions & 3 deletions src/executor/admin/ChangePasswordExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
* attached with Common Clause Condition 1.0, found in the LICENSES directory.
*/

#include "common/encryption/MD5Utils.h"

#include "context/QueryContext.h"
#include "executor/admin/ChangePasswordExecutor.h"
#include "planner/Admin.h"
#include "context/QueryContext.h"

namespace nebula {
namespace graph {
Expand All @@ -18,8 +20,11 @@ folly::Future<Status> ChangePasswordExecutor::execute() {

folly::Future<Status> ChangePasswordExecutor::changePassword() {
auto *cpNode = asNode<ChangePassword>(node());
return qctx()->getMetaClient()->changePassword(
*cpNode->username(), *cpNode->newPassword(), *cpNode->password())
return qctx()
->getMetaClient()
->changePassword(*cpNode->username(),
encryption::MD5Utils::md5Encode(*cpNode->newPassword()),
encryption::MD5Utils::md5Encode(*cpNode->password()))
.via(runner())
.then([this](StatusOr<bool> &&resp) {
SCOPED_TIMER(&execTime_);
Expand Down
Loading

0 comments on commit a622b32

Please sign in to comment.