Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherry pick v3.0.0 (0117-0124) #3820

Merged
merged 16 commits into from
Jan 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Require an approved review in PRs including files with a designated code owner.
/conf/ @vesoft-inc/tech-committee-reviewers
/src/kvstore/raftex/ @critical27 @sherman-the-tank
/cmake/ @sherman-the-tank @yixinglu
*.thrift @vesoft-inc/tech-committee-reviewers
*.yy @CPWstatic
2 changes: 1 addition & 1 deletion cmake/ThriftGenerate.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ add_custom_command(
--gen "js:node:"
--gen "csharp"
--gen "java:hashcode"
--gen "go:thrift_import=github.com/facebook/fbthrift/thrift/lib/go/thrift,package_prefix=github.com/vesoft-inc/nebula-go/v2/,use_context"
--gen "go:thrift_import=github.com/facebook/fbthrift/thrift/lib/go/thrift,package_prefix=github.com/vesoft-inc/nebula-go/v3/,use_context"
-o "." "${file_path}/${file_name}.thrift"
COMMAND
mkdir -p "./gen-rust/${file_name}"
Expand Down
2 changes: 1 addition & 1 deletion src/codec/RowReaderV2.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class RowReaderV2 : public RowReader {
FRIEND_TEST(ScanEdgePropBench, ProcessEdgeProps);

public:
virtual ~RowReaderV2() = default;
~RowReaderV2() override = default;

Value getValueByName(const std::string& prop) const noexcept override;
Value getValueByIndex(const int64_t index) const noexcept override;
Expand Down
4 changes: 3 additions & 1 deletion src/common/base/SanitizerOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ const char* __asan_default_options() {
"fast_unwind_on_malloc=0 \n"
"detect_stack_use_after_return=1 \n"
"alloc_dealloc_mismatch=1 \n"
"new_delete_type_mismatch=1 \n"
// todo(doodle): Reopen when https://github.com/vesoft-inc/nebula/issues/3690
// addressed throughly
"new_delete_type_mismatch=0 \n"
"strict_init_order=1 \n"
"intercept_tls_get_addr=1 \n"
"symbolize_inline_frames=1 \n"
Expand Down
4 changes: 4 additions & 0 deletions src/common/expression/PropertyExpression.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ class LabelTagPropertyExpression final : public PropertyExpression {
return label_;
}

void setLabel(Expression* label) {
label_ = label;
}

private:
LabelTagPropertyExpression(ObjectPool* pool,
Expression* label = nullptr,
Expand Down
6 changes: 4 additions & 2 deletions src/graph/executor/admin/ShowHostsExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ folly::Future<Status> ShowHostsExecutor::showHosts() {
"Status",
"Leader count",
"Leader distribution",
"Partition distribution"});
"Partition distribution",
"Version"});

std::map<std::string, int64_t> leaderPartsCount;
std::map<std::string, int64_t> allPartsCount;
Expand Down Expand Up @@ -82,6 +83,7 @@ folly::Future<Status> ShowHostsExecutor::showHosts() {
r.emplace_back(leaderCount);
r.emplace_back(leaders.str());
r.emplace_back(parts.str());
r.emplace_back(host.version_ref().has_value() ? Value(*host.version_ref()) : Value());
v.emplace_back(std::move(r));
} // row loop
{
Expand Down Expand Up @@ -148,7 +150,7 @@ folly::Future<Status> ShowHostsExecutor::showHosts() {
LOG(ERROR) << resp.status();
return resp.status();
}
auto value = std::move(resp).value();
auto value = std::forward<decltype(resp)>(resp).value();
if (type == meta::cpp2::ListHostType::ALLOC) {
return finish(makeTraditionalResult(value));
}
Expand Down
1 change: 1 addition & 0 deletions src/graph/optimizer/OptGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ void OptGroup::addGroupNode(OptGroupNode *groupNode) {
DCHECK(groupNode != nullptr);
DCHECK(groupNode->group() == this);
groupNodes_.emplace_back(groupNode);
groupNode->node()->updateSymbols();
}

OptGroupNode *OptGroup::makeGroupNode(PlanNode *node) {
Expand Down
2 changes: 1 addition & 1 deletion src/graph/planner/match/MatchPlanner.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace graph {
class MatchPlanner final : public Planner {
public:
static std::unique_ptr<MatchPlanner> make() {
return std::unique_ptr<MatchPlanner>(new MatchPlanner());
return std::make_unique<MatchPlanner>();
}

static bool match(AstContext* astCtx);
Expand Down
9 changes: 9 additions & 0 deletions src/graph/planner/plan/PlanNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,15 @@ void PlanNode::releaseSymbols() {
}
}

void PlanNode::updateSymbols() {
auto symTbl = qctx_->symTable();
for (auto out : outputVars_) {
if (out != nullptr) {
symTbl->updateWrittenBy(out->name, out->name, this);
}
}
}

std::ostream& operator<<(std::ostream& os, PlanNode::Kind kind) {
os << PlanNode::toString(kind);
return os;
Expand Down
2 changes: 2 additions & 0 deletions src/graph/planner/plan/PlanNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,8 @@ class PlanNode {

void releaseSymbols();

void updateSymbols();

static const char* toString(Kind kind);
std::string toString() const;

Expand Down
2 changes: 1 addition & 1 deletion src/graph/service/GraphFlags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ DEFINE_bool(enable_optimizer, false, "Whether to enable optimizer");
DEFINE_uint32(ft_request_retry_times, 3, "Retry times if fulltext request failed");
DEFINE_bool(enable_client_white_list, true, "Turn on/off the client white list.");
DEFINE_string(client_white_list,
nebula::getOriginVersion() + ":2.5.0:2.5.1:2.6.0",
nebula::getOriginVersion() + ":3.0.0",
"A white list for different client versions, separate with colon.");

#endif
Expand Down
2 changes: 1 addition & 1 deletion src/graph/service/test/StandAloneTestGraphFlags.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@
DEFINE_uint32(ft_request_retry_times, 3, "Retry times if fulltext request failed");
DEFINE_bool(enable_client_white_list, true, "Turn on/off the client white list.");
DEFINE_string(client_white_list,
nebula::getOriginVersion() + ":2.5.0:2.5.1:2.6.0",
nebula::getOriginVersion() + ":3.0.0",
"A white list for different client versions, separate with colon.");
24 changes: 15 additions & 9 deletions src/graph/util/ExpressionUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,18 +126,24 @@ bool ExpressionUtils::isEvaluableExpr(const Expression *expr, const QueryContext
}

// rewrite Attribute to LabelTagProp
Expression *ExpressionUtils::rewriteAttr2LabelTagProp(const Expression *expr) {
Expression *ExpressionUtils::rewriteAttr2LabelTagProp(
const Expression *expr, const std::unordered_map<std::string, AliasType> &aliasTypeMap) {
ObjectPool *pool = expr->getObjPool();

auto matcher = [](const Expression *e) -> bool {
if (e->kind() == Expression::Kind::kAttribute) {
auto attrExpr = static_cast<const AttributeExpression *>(e);
if (attrExpr->left()->kind() == Expression::Kind::kLabelAttribute &&
attrExpr->right()->kind() == Expression::Kind::kConstant) {
return true;
}
auto matcher = [&aliasTypeMap](const Expression *e) -> bool {
if (e->kind() != Expression::Kind::kAttribute) {
return false;
}
return false;
auto attrExpr = static_cast<const AttributeExpression *>(e);
if (attrExpr->left()->kind() != Expression::Kind::kLabelAttribute) {
return false;
}
auto label = static_cast<const LabelAttributeExpression *>(attrExpr->left())->left()->name();
auto iter = aliasTypeMap.find(label);
if (iter == aliasTypeMap.end() || iter->second != AliasType::kNode) {
return false;
}
return true;
};

auto rewriter = [pool](const Expression *e) -> Expression * {
Expand Down
5 changes: 3 additions & 2 deletions src/graph/util/ExpressionUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
#include "common/expression/PropertyExpression.h"
#include "common/expression/TypeCastingExpression.h"
#include "common/expression/UnaryExpression.h"
#include "graph/context/ast/CypherAstContext.h"
#include "graph/visitor/EvaluableExprVisitor.h"
#include "graph/visitor/FindVisitor.h"
#include "graph/visitor/RewriteVisitor.h"

namespace nebula {
class ObjectPool;
namespace graph {

class ExpressionUtils {
public:
explicit ExpressionUtils(...) = delete;
Expand Down Expand Up @@ -55,7 +55,8 @@ class ExpressionUtils {

static bool isEvaluableExpr(const Expression* expr, const QueryContext* qctx = nullptr);

static Expression* rewriteAttr2LabelTagProp(const Expression* expr);
static Expression* rewriteAttr2LabelTagProp(
const Expression* expr, const std::unordered_map<std::string, AliasType>& aliasTypeMap);

static Expression* rewriteLabelAttr2TagProp(const Expression* expr);

Expand Down
4 changes: 4 additions & 0 deletions src/graph/validator/AdminJobValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ namespace nebula {
namespace graph {

Status AdminJobValidator::validateImpl() {
if (sentence_->getCmd() == meta::cpp2::AdminCmd::DATA_BALANCE ||
sentence_->getCmd() == meta::cpp2::AdminCmd::ZONE_BALANCE) {
return Status::SemanticError("Data balance not support");
}
if (sentence_->getOp() == meta::cpp2::AdminJobOp::ADD) {
auto cmd = sentence_->getCmd();
if (requireSpace()) {
Expand Down
11 changes: 7 additions & 4 deletions src/graph/validator/MatchValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,8 @@ Status MatchValidator::validateFilter(const Expression *filter,
auto transformRes = ExpressionUtils::filterTransform(filter);
NG_RETURN_IF_ERROR(transformRes);
// rewrite Attribute to LabelTagProperty
whereClauseCtx.filter = ExpressionUtils::rewriteAttr2LabelTagProp(transformRes.value());
whereClauseCtx.filter = ExpressionUtils::rewriteAttr2LabelTagProp(
transformRes.value(), whereClauseCtx.aliasesAvailable);

auto typeStatus = deduceExprType(whereClauseCtx.filter);
NG_RETURN_IF_ERROR(typeStatus);
Expand Down Expand Up @@ -383,7 +384,8 @@ Status MatchValidator::validateReturn(MatchReturn *ret,
ExpressionUtils::hasAny(column->expr(), {Expression::Kind::kAggregate})) {
retClauseCtx.yield->hasAgg_ = true;
}
column->setExpr(ExpressionUtils::rewriteAttr2LabelTagProp(column->expr()));
column->setExpr(ExpressionUtils::rewriteAttr2LabelTagProp(
column->expr(), retClauseCtx.yield->aliasesAvailable));
exprs.push_back(column->expr());
columns->addColumn(column->clone().release());
}
Expand Down Expand Up @@ -459,7 +461,8 @@ Status MatchValidator::validateWith(const WithClause *with,
}
if (with->returnItems()->columns()) {
for (auto *column : with->returnItems()->columns()->columns()) {
column->setExpr(ExpressionUtils::rewriteAttr2LabelTagProp(column->expr()));
column->setExpr(ExpressionUtils::rewriteAttr2LabelTagProp(
column->expr(), withClauseCtx.yield->aliasesAvailable));
columns->addColumn(column->clone().release());
}
}
Expand Down Expand Up @@ -819,7 +822,7 @@ Status MatchValidator::checkAlias(
auto name = static_cast<const VariablePropertyExpression *>(labelExpr)->prop();
auto res = getAliasType(aliasesAvailable, name);
NG_RETURN_IF_ERROR(res);
if (res.value() != AliasType::kNode) {
if (res.value() == AliasType::kEdge || res.value() == AliasType::kPath) {
return Status::SemanticError("The type of `%s' should be tag", name.c_str());
}
return Status::OK();
Expand Down
12 changes: 12 additions & 0 deletions src/graph/visitor/RewriteVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,18 @@ void RewriteVisitor::visit(PathBuildExpression *expr) {
}
}

void RewriteVisitor::visit(LabelTagPropertyExpression *expr) {
if (!care(expr->kind())) {
return;
}
auto label = expr->label();
if (matcher_(label)) {
expr->setLabel(rewriter_(label));
} else {
label->accept(this);
}
}

void RewriteVisitor::visit(AttributeExpression *expr) {
if (!care(expr->kind())) {
return;
Expand Down
2 changes: 1 addition & 1 deletion src/graph/visitor/RewriteVisitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ class RewriteVisitor final : public ExprVisitorImpl {
void visit(RelationalExpression*) override;
void visit(SubscriptExpression*) override;
void visit(PathBuildExpression*) override;
void visit(LabelTagPropertyExpression*) override;
void visit(SubscriptRangeExpression*) override;
void visit(ConstantExpression*) override {}
void visit(LabelExpression*) override {}
void visit(UUIDExpression*) override {}
void visit(LabelAttributeExpression*) override {}
void visit(LabelTagPropertyExpression*) override {}
void visit(VariableExpression*) override {}
void visit(VersionedVariableExpression*) override {}
void visit(TagPropertyExpression*) override {}
Expand Down
4 changes: 2 additions & 2 deletions src/interface/common.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace java com.vesoft.nebula
namespace go nebula
namespace js nebula
namespace csharp nebula
namespace py nebula2.common
namespace py nebula3.common

cpp_include "common/thrift/ThriftTypes.h"
cpp_include "common/datatypes/DateOps-inl.h"
Expand All @@ -34,7 +34,7 @@ cpp_include "common/datatypes/DurationOps-inl.h"
*
*/

const binary (cpp.type = "char const *") version = "2.6.0"
const binary (cpp.type = "char const *") version = "3.0.0"

typedef i64 (cpp.type = "nebula::ClusterID") ClusterID
typedef i32 (cpp.type = "nebula::GraphSpaceID") GraphSpaceID
Expand Down
2 changes: 1 addition & 1 deletion src/interface/graph.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace java com.vesoft.nebula.graph
namespace go nebula.graph
namespace js nebula.graph
namespace csharp nebula.graph
namespace py nebula2.graph
namespace py nebula3.graph

include "common.thrift"

Expand Down
2 changes: 1 addition & 1 deletion src/interface/meta.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace java com.vesoft.nebula.meta
namespace go nebula.meta
namespace js nebula.meta
namespace csharp nebula.meta
namespace py nebula2.meta
namespace py nebula3.meta

include "common.thrift"

Expand Down
2 changes: 1 addition & 1 deletion src/interface/storage.thrift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace java com.vesoft.nebula.storage
namespace go nebula.storage
namespace csharp nebula.storage
namespace js nebula.storage
namespace py nebula2.storage
namespace py nebula3.storage

include "common.thrift"
include "meta.thrift"
Expand Down
24 changes: 22 additions & 2 deletions src/kvstore/KVEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,18 @@ class KVEngine {
bool sync,
bool wait) = 0;

/**
* @brief Get the Snapshot from kv engine.
*
* @return const void* snapshot pointer.
*/
virtual const void* GetSnapshot() = 0;
/**
* @brief Release snapshot from kv engine.
*
* @param snapshot
*/
virtual void ReleaseSnapshot(const void* snapshot) = 0;
// Read a single key
virtual nebula::cpp2::ErrorCode get(const std::string& key, std::string* value) = 0;

Expand All @@ -62,9 +74,17 @@ class KVEngine {
const std::string& end,
std::unique_ptr<KVIterator>* iter) = 0;

// Get all results with 'prefix' str as prefix.
/**
* @brief Get all results with 'prefix' str as prefix.
*
* @param prefix Prefix string.
* @param snapshot Snapshot from kv engine. nullptr means no snapshot.
* @param iter Iterator for this prefix range.
* @return nebula::cpp2::ErrorCode
*/
virtual nebula::cpp2::ErrorCode prefix(const std::string& prefix,
std::unique_ptr<KVIterator>* iter) = 0;
std::unique_ptr<KVIterator>* iter,
const void* snapshot = nullptr) = 0;

// Get all results with 'prefix' str as prefix starting form 'start'
virtual nebula::cpp2::ErrorCode rangeWithPrefix(const std::string& start,
Expand Down
Loading