Skip to content

Commit

Permalink
Merge branch 'master' into enhancement/remove-has-next
Browse files Browse the repository at this point in the history
  • Loading branch information
Shylock-Hg authored Dec 8, 2021
2 parents ca55560 + d6f83f3 commit e785688
Show file tree
Hide file tree
Showing 48 changed files with 627 additions and 198 deletions.
14 changes: 7 additions & 7 deletions .github/ISSUE_TEMPLATE/bug-report.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
---
name: Bug report
about: Help us to improve this project
name: Bug Report
about: I want to report a bug.
title: ''
labels: bug
labels: type/bug
assignees: ''

---

**Please check the FAQ documentation before raising an issue**

Please check the [FAQ](https://github.com/vesoft-inc/nebula/blob/master/docs/manual-EN/1.overview/2.quick-start/2.FAQ.md) documentation and old issues before raising an issue in case someone has asked the same question that you are asking.
<!-- Please check the [FAQ](https://docs.nebula-graph.com.cn/master/20.appendix/0.FAQ/) documentation and old issues before raising an issue in case someone has asked the same question that you are asking. -->

**Describe the bug (__required__)**

A clear and concise description of what the bug is.
<!-- A clear and concise description of what the bug is. -->

**Your Environments (__required__)**

Expand All @@ -32,8 +32,8 @@ Steps to reproduce the behavior:

**Expected behavior**

A clear and concise description of what you expected to happen.
<!-- A clear and concise description of what you expected to happen. -->

**Additional context**

Provide logs and configs, or any other context to trace the problem.
<!-- Provide logs and configs, or any other context to trace the problem. -->
10 changes: 5 additions & 5 deletions .github/ISSUE_TEMPLATE/enhancement.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
---
name: Enhancement
about: make the code neat or more efficient.
about: Suggest an enhancement to make the code neat or more efficient.
title: ''
labels: enhancement
labels: type/enhancement
assignees: ''
---

## Introduction
**Introduction**
<!-- concise introduction to problem, motivation, and overview of proposed solution -->

## Contents
**Contents**
<!-- Please describe the enhancement what you want in this section -->

## Related work
**Related work**
<!-- In this section you can add other related tasks to help assigner to complete the task more easily -->
14 changes: 7 additions & 7 deletions .github/ISSUE_TEMPLATE/feature_request.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
name: Feature Request
about: Suggest a feature for this project.
title: ''
labels: feature req
labels: type/feature req
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->

**Describe the solution you'd like**
A clear and concise description of what you want to happen.
<!-- A clear and concise description of what you want to happen. -->

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.
<!-- A clear and concise description of any alternative solutions or features you've considered. -->

**Additional context**
Add any other context or screenshots about the feature request here.
<!-- Add any other context or screenshots about the feature request here. -->
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE/question.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ about: I want to ask a question.
labels: question
---

## General Question
**General Question**

<!--
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/nightly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,10 @@ jobs:
-DENABLE_COVERAGE=on \
-B build
echo "::set-output name=j::8"
echo "::set-output name=t::6"
- name: Make
run: |
ccache -z
cmake --build build/ -j ${{ steps.cmake.outputs.j }} --target nebula-metad nebula-storaged nebula-graphd
cmake --build build/ -j ${{ steps.cmake.outputs.t }}
cmake --build build/ -j $(nproc)
ccache -s
- name: CTest
env:
Expand Down
6 changes: 1 addition & 5 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ jobs:
-DENABLE_TESTING=on \
-B build
echo "::set-output name=j::10"
echo "::set-output name=t::$(nproc)"
;;
ubuntu2004)
# build with Debug type
Expand All @@ -109,7 +108,6 @@ jobs:
-DENABLE_COVERAGE=on \
-B build
echo "::set-output name=j::10"
echo "::set-output name=t::6"
;;
esac
;;
Expand All @@ -123,14 +121,12 @@ jobs:
-DENABLE_TESTING=on \
-B build
echo "::set-output name=j::6"
echo "::set-output name=t::10"
;;
esac
- name: Make
run: |
ccache -z
cmake --build build/ -j $(nproc) --target nebula-metad nebula-storaged nebula-graphd
cmake --build build/ -j ${{ steps.cmake.outputs.t }}
cmake --build build/ -j $(nproc)
ccache -s
- name: CTest
env:
Expand Down
2 changes: 1 addition & 1 deletion src/clients/meta/MetaClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2394,7 +2394,6 @@ folly::Future<StatusOr<bool>> MetaClient::heartbeat() {
req.set_host(options_.localHost_);
req.set_role(options_.role_);
req.set_git_info_sha(options_.gitInfoSHA_);
req.set_version(getOriginVersion());
if (options_.role_ == cpp2::HostRole::STORAGE) {
if (options_.clusterId_.load() == 0) {
options_.clusterId_ = FileBasedClusterIdMan::getClusterIdFromFile(FLAGS_cluster_id_path);
Expand Down Expand Up @@ -3505,6 +3504,7 @@ bool MetaClient::checkIsPlanKilled(SessionID sessionId, ExecutionPlanID planId)

Status MetaClient::verifyVersion() {
auto req = cpp2::VerifyClientVersionReq();
req.set_host(options_.localHost_);
folly::Promise<StatusOr<cpp2::VerifyClientVersionResp>> promise;
auto future = promise.getFuture();
getResponse(
Expand Down
22 changes: 22 additions & 0 deletions src/common/utils/MetaKeyUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ namespace nebula {
static const std::unordered_map<std::string, std::pair<std::string, bool>> systemTableMaps = {
{"users", {"__users__", true}},
{"hosts", {"__hosts__", false}},
{"versions", {"__versions__", false}},
{"snapshots", {"__snapshots__", false}},
{"configs", {"__configs__", true}},
{"groups", {"__groups__", true}},
Expand Down Expand Up @@ -58,6 +59,7 @@ static const std::unordered_map<
static const std::string kSpacesTable = tableMaps.at("spaces").first; // NOLINT
static const std::string kPartsTable = tableMaps.at("parts").first; // NOLINT
static const std::string kHostsTable = systemTableMaps.at("hosts").first; // NOLINT
static const std::string kVersionsTable = systemTableMaps.at("versions").first; // NOLINT
static const std::string kTagsTable = tableMaps.at("tags").first; // NOLINT
static const std::string kEdgesTable = tableMaps.at("edges").first; // NOLINT
static const std::string kIndexesTable = tableMaps.at("indexes").first; // NOLINT
Expand Down Expand Up @@ -269,6 +271,26 @@ HostAddr MetaKeyUtils::parseHostKeyV2(folly::StringPiece key) {
return MetaKeyUtils::deserializeHostAddr(key);
}

std::string MetaKeyUtils::versionKey(const HostAddr& h) {
std::string key;
key.append(kVersionsTable.data(), kVersionsTable.size())
.append(MetaKeyUtils::serializeHostAddr(h));
return key;
}

std::string MetaKeyUtils::versionVal(const std::string& version) {
std::string val;
auto versionLen = version.size();
val.reserve(sizeof(int64_t) + versionLen);
val.append(reinterpret_cast<const char*>(&version), sizeof(int64_t)).append(version);
return val;
}

std::string MetaKeyUtils::parseVersion(folly::StringPiece val) {
auto len = *reinterpret_cast<const size_t*>(val.data());
return val.subpiece(sizeof(size_t), len).str();
}

std::string MetaKeyUtils::leaderKey(std::string addr, Port port) {
LOG(ERROR) << "deprecated function\n" << boost::stacktrace::stacktrace();
return leaderKeyV2(addr, port);
Expand Down
6 changes: 6 additions & 0 deletions src/common/utils/MetaKeyUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@ class MetaKeyUtils final {

static HostAddr parseHostKeyV2(folly::StringPiece key);

static std::string versionKey(const HostAddr& h);

static std::string versionVal(const std::string& version);

static std::string parseVersion(folly::StringPiece val);

static std::string leaderKey(std::string ip, Port port);

static std::string leaderKeyV2(std::string addr, Port port);
Expand Down
1 change: 1 addition & 0 deletions src/graph/optimizer/rule/CollapseProjectRule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "graph/optimizer/OptGroup.h"
#include "graph/planner/plan/PlanNode.h"
#include "graph/planner/plan/Query.h"
#include "graph/util/ExpressionUtils.h"

using nebula::graph::PlanNode;
using nebula::graph::QueryContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "graph/optimizer/OptimizerUtils.h"
#include "graph/planner/plan/PlanNode.h"
#include "graph/planner/plan/Scan.h"
#include "graph/util/ExpressionUtils.h"

using nebula::Expression;
using nebula::graph::EdgeIndexFullScan;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "graph/optimizer/rule/IndexScanRule.h"
#include "graph/planner/plan/PlanNode.h"
#include "graph/planner/plan/Scan.h"
#include "graph/util/ExpressionUtils.h"

using nebula::graph::Filter;
using nebula::graph::OptimizerUtils;
Expand Down
1 change: 1 addition & 0 deletions src/graph/optimizer/rule/PushLimitDownGetNeighborsRule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "graph/optimizer/OptGroup.h"
#include "graph/planner/plan/PlanNode.h"
#include "graph/planner/plan/Query.h"
#include "graph/util/ExpressionUtils.h"

using nebula::graph::GetNeighbors;
using nebula::graph::Limit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "graph/optimizer/OptGroup.h"
#include "graph/planner/plan/PlanNode.h"
#include "graph/planner/plan/Query.h"
#include "graph/util/ExpressionUtils.h"

using nebula::graph::GetNeighbors;
using nebula::graph::Limit;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "graph/optimizer/OptGroup.h"
#include "graph/planner/plan/PlanNode.h"
#include "graph/planner/plan/Query.h"
#include "graph/util/ExpressionUtils.h"

using nebula::graph::GetNeighbors;
using nebula::graph::PlanNode;
Expand Down
26 changes: 26 additions & 0 deletions src/graph/planner/plan/Query.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,19 @@
#include <folly/json.h>
#include <thrift/lib/cpp/util/EnumUtils.h>

#include "graph/util/ExpressionUtils.h"
#include "graph/util/ToJson.h"

using folly::stringPrintf;

namespace nebula {
namespace graph {

int64_t Explore::limit() const {
QueryExpressionContext ctx;
DCHECK(ExpressionUtils::isEvaluableExpr(limit_));
return DCHECK_NOTNULL(limit_)->eval(ctx).getInt();
}
std::unique_ptr<PlanNodeDescription> Explore::explain() const {
auto desc = SingleInputNode::explain();
addDescription("space", folly::to<std::string>(space_), desc.get());
Expand Down Expand Up @@ -318,6 +324,17 @@ void Sort::cloneMembers(const Sort& p) {
factors_ = std::move(factors);
}

// Get constant count value
int64_t Limit::count() const {
if (count_ == nullptr) {
return -1;
}
DCHECK(ExpressionUtils::isEvaluableExpr(count_));
QueryExpressionContext ctx;
auto s = count_->eval(ctx).getInt();
DCHECK_GE(s, 0);
return s;
}
std::unique_ptr<PlanNodeDescription> Limit::explain() const {
auto desc = SingleInputNode::explain();
addDescription("offset", folly::to<std::string>(offset_), desc.get());
Expand Down Expand Up @@ -364,6 +381,15 @@ void TopN::cloneMembers(const TopN& l) {
count_ = l.count_;
}

// Get constant count
int64_t Sample::count() const {
DCHECK(ExpressionUtils::isEvaluableExpr(count_));
QueryExpressionContext qec;
auto count = count_->eval(qec).getInt();
DCHECK_GE(count, 0);
return count;
}

std::unique_ptr<PlanNodeDescription> Sample::explain() const {
auto desc = SingleInputNode::explain();
addDescription("count", count_->toString(), desc.get());
Expand Down
26 changes: 3 additions & 23 deletions src/graph/planner/plan/Query.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ class Explore : public SingleInputNode {
bool dedup() const { return dedup_; }

// Get the constant limit value
int64_t limit() const {
QueryExpressionContext ctx;
DCHECK(ExpressionUtils::isEvaluableExpr(limit_));
return DCHECK_NOTNULL(limit_)->eval(ctx).getInt();
}
int64_t limit() const;

// Get the limit value in runtime
int64_t limit(QueryExpressionContext& ctx) const {
Expand Down Expand Up @@ -682,17 +678,7 @@ class Limit final : public SingleInputNode {
int64_t offset() const { return offset_; }

// Get constant count value
int64_t count() const {
if (count_ == nullptr) {
return -1;
}
DCHECK(ExpressionUtils::isEvaluableExpr(count_));
QueryExpressionContext ctx;
auto s = count_->eval(ctx).getInt();
DCHECK_GE(s, 0);
return s;
}

int64_t count() const;
// Get count in runtime
int64_t count(QueryExpressionContext& ctx) const {
if (count_ == nullptr) {
Expand Down Expand Up @@ -801,13 +787,7 @@ class Sample final : public SingleInputNode {
}

// Get constant count
int64_t count() const {
DCHECK(ExpressionUtils::isEvaluableExpr(count_));
QueryExpressionContext qec;
auto count = count_->eval(qec).getInt();
DCHECK_GE(count, 0);
return count;
}
int64_t count() const;

// Get Runtime count
int64_t count(QueryExpressionContext& qec) const {
Expand Down
1 change: 1 addition & 0 deletions src/graph/util/FTIndexUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include "graph/util/FTIndexUtils.h"

#include "common/expression/Expression.h"
#include "graph/util/ExpressionUtils.h"

DECLARE_uint32(ft_request_retry_times);

Expand Down
1 change: 0 additions & 1 deletion src/graph/util/FTIndexUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#include "clients/meta/MetaClient.h"
#include "common/base/StatusOr.h"
#include "common/plugin/fulltext/elasticsearch/ESGraphAdapter.h"
#include "graph/util/ExpressionUtils.h"
#include "graph/util/SchemaUtil.h"
#include "parser/MaintainSentences.h"

Expand Down
1 change: 1 addition & 0 deletions src/graph/validator/FindPathValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

#include "graph/planner/plan/Algo.h"
#include "graph/planner/plan/Logic.h"
#include "graph/util/ExpressionUtils.h"
#include "graph/util/ValidateUtil.h"

namespace nebula {
Expand Down
Loading

0 comments on commit e785688

Please sign in to comment.