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

[doc] TTL cn #1934

Merged
merged 39 commits into from
Mar 17, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
4ea645e
Fix lambda captured by reference (#1681)
critical27 Jan 20, 2020
32eabfd
Merge branch 'master' of https://github.com/jude-zhu/nebula
jude-zhu Jan 21, 2020
5e802ac
Merge branch 'master' of https://github.com/jude-zhu/nebula
jude-zhu Feb 10, 2020
658a48e
Merge branch 'master' of https://github.com/jude-zhu/nebula
jude-zhu Feb 12, 2020
29bfbb2
Merge branch 'master' of https://github.com/jude-zhu/nebula
jude-zhu Feb 18, 2020
daa23e0
Merge branch 'master' of https://github.com/jude-zhu/nebula
jude-zhu Feb 26, 2020
fa83f27
Fix meta would crash when balance in multiple relica (#1826)
critical27 Feb 26, 2020
0f0b19c
support charset in schema (#1709)
panda-sheep Feb 26, 2020
f6407b2
Lookup benchmark (#1738)
bright-starry-sky Feb 26, 2020
3e6bd57
update readme link (#1815)
amber-moe Feb 26, 2020
453bf8f
update (#1809)
amber-moe Feb 26, 2020
ee97825
[doc] prerequisite added in quick start (#1808)
wilsonyou Feb 26, 2020
bd511e2
fix metrics-exposer comments and comment out (#1797)
amber-moe Feb 26, 2020
f3fa0a0
[doc]configure TTL (#1791)
amber-moe Feb 26, 2020
14f80c0
[doc]add lookup and update toc (#1778)
amber-moe Feb 26, 2020
53f6a32
Added sanitizer option for compile scripts. (#1819)
monadbobo Feb 26, 2020
ace9ab2
[doc] Group By statement updated (#1835)
wilsonyou Feb 27, 2020
ca6a864
Bidirectional traverse. (#1740)
CPWstatic Feb 28, 2020
e41d870
add charset doc (#1750)
amber-moe Feb 28, 2020
7d0568d
[doc]modify block cache (#1829)
amber-moe Feb 28, 2020
30f8a9e
default value supports expression (#1838)
amber-moe Feb 28, 2020
237dfb5
Fixed an error when using update sentence. (#1830)
monadbobo Mar 2, 2020
8a09218
[doc]add bidirect (#1752)
amber-moe Mar 2, 2020
d187735
Support delete vertices (#1317)
Mar 3, 2020
617ec4b
Check if inputs has duplicate column. (#1841)
CPWstatic Mar 3, 2020
2e9599e
support return partial result in get of kv interfaces (#1840)
critical27 Mar 3, 2020
8ecdcb3
Merge branch 'master' of https://github.com/vesoft-inc/nebula
jude-zhu Mar 4, 2020
9bb7a9d
Merge branch 'master' of https://github.com/jude-zhu/nebula
jude-zhu Mar 5, 2020
7c122ef
Merge branch 'master' of https://github.com/jude-zhu/nebula
jude-zhu Mar 17, 2020
2f79987
update ttl cn
jude-zhu Mar 17, 2020
cf91474
udpate
jude-zhu Mar 17, 2020
876b5e1
update
jude-zhu Mar 17, 2020
0dc0172
udpate
jude-zhu Mar 17, 2020
00456c8
update
jude-zhu Mar 17, 2020
1470953
update
jude-zhu Mar 17, 2020
9a809af
udpate
jude-zhu Mar 17, 2020
a413ff3
update
jude-zhu Mar 17, 2020
ae02f82
update
jude-zhu Mar 17, 2020
3fb4af7
Merge branch 'master' into ttl
dangleptr Mar 17, 2020
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
Prev Previous commit
Next Next commit
Bidirectional traverse. (#1740)
* Support bidirectional traverse.

* Add basic bidirectional traverse test.

* Fix ut.

* Add ut for multi edge traverse.

* Fix clang compile error.

* Address comment.

* Adddress @dangleptr's comment.

* Address comment.

Co-authored-by: laura-ding <48548375+laura-ding@users.noreply.github.com>
  • Loading branch information
2 people authored and jude-zhu committed Mar 4, 2020
commit ca6a8647b18f5162ec52cac051c298b61c4e297c
10 changes: 10 additions & 0 deletions src/common/filter/Expressions.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ class ExpressionContext final {
dstTagProps_.emplace(tag, prop);
}

std::unordered_map<std::string, EdgeType>& getEdgeMap() {
return edgeMap_;
}

std::unordered_map<std::string, TagID>& getTagMap() {
return tagMap_;
}
Expand Down Expand Up @@ -81,6 +85,7 @@ class ExpressionContext final {
return false;
}
edgeMap_.emplace(alias, edgeType);
edgeAlias_.emplace_back(alias);
return true;
}

Expand All @@ -94,6 +99,10 @@ class ExpressionContext final {
return true;
}

std::vector<std::string>& getEdgeAlias() {
return edgeAlias_;
}

using PropPair = std::pair<std::string, std::string>;

std::vector<PropPair> srcTagProps() const {
Expand Down Expand Up @@ -175,6 +184,7 @@ class ExpressionContext final {
// alias => edgeType
std::unordered_map<std::string, EdgeType> edgeMap_;
std::unordered_map<std::string, TagID> tagMap_;
std::vector<std::string> edgeAlias_;
bool overAll_{false};
GraphSpaceID space_;
nebula::storage::StorageClient *storageClient_{nullptr};
Expand Down
9 changes: 7 additions & 2 deletions src/dataman/RowReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,12 @@ class RowReader {
static StatusOr<VariantType> getDefaultProp(const meta::SchemaProviderIf* schema,
const std::string& prop) {
auto& vType = schema->getFieldType(prop);
return getDefaultProp(vType.type);
auto defaultVal = getDefaultProp(vType.type);
if (!defaultVal.ok()) {
LOG(ERROR) << "Get default value for `" << prop << "' failed: " << defaultVal.status();
}

return defaultVal;
}

static StatusOr<VariantType> getDefaultProp(const nebula::cpp2::SupportedType& type) {
Expand All @@ -114,7 +119,7 @@ class RowReader {
}
default:
auto msg = folly::sformat("Unknown type: {}", static_cast<int32_t>(type));
LOG(ERROR) << "Unknown type: " << msg;
LOG(ERROR) << msg;
return Status::Error(msg);
}
}
Expand Down
121 changes: 77 additions & 44 deletions src/graph/GoExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,12 @@ Status GoExecutor::prepareOverAll() {
}

auto v = edgeStatus.value();
if (isReversely()) {
v = -v;
auto status = addToEdgeTypes(v);
if (!status.ok()) {
return status;
}

edgeTypes_.push_back(v);

if (!expCtx_->addEdge(e, v)) {
if (!expCtx_->addEdge(e, std::abs(v))) {
return Status::Error(folly::sformat("edge alias({}) was dup", e));
}
}
Expand All @@ -251,7 +250,7 @@ Status GoExecutor::prepareOver() {
return Status::Error("Over clause shall never be null");
}

isReversely_ = clause->isReversely();
direction_ = clause->direction();

auto edges = clause->edges();
for (auto e : edges) {
Expand All @@ -267,17 +266,17 @@ Status GoExecutor::prepareOver() {
}

auto v = edgeStatus.value();
if (isReversely()) {
v = -v;
status = addToEdgeTypes(v);
if (!status.ok()) {
return status;
}
edgeTypes_.push_back(v);

if (e->alias() != nullptr) {
if (!expCtx_->addEdge(*e->alias(), v)) {
if (!expCtx_->addEdge(*e->alias(), std::abs(v))) {
return Status::Error(folly::sformat("edge alias({}) was dup", *e->alias()));
}
} else {
if (!expCtx_->addEdge(*e->edge(), v)) {
if (!expCtx_->addEdge(*e->edge(), std::abs(v))) {
return Status::Error(folly::sformat("edge alias({}) was dup", *e->edge()));
}
}
Expand All @@ -286,6 +285,29 @@ Status GoExecutor::prepareOver() {
return status;
}

Status GoExecutor::addToEdgeTypes(EdgeType type) {
switch (direction_) {
case OverClause::Direction::kForward: {
edgeTypes_.push_back(type);
break;
}
case OverClause::Direction::kBackward: {
type = -type;
edgeTypes_.push_back(type);
break;
}
case OverClause::Direction::kBidirect: {
edgeTypes_.push_back(type);
type = -type;
edgeTypes_.push_back(type);
break;
}
default: {
return Status::Error("Unkown direction type: %ld", static_cast<int64_t>(direction_));
}
}
return Status::OK();
}

Status GoExecutor::prepareWhere() {
auto *clause = sentence_->whereClause();
Expand Down Expand Up @@ -442,10 +464,13 @@ void GoExecutor::stepOut() {
}
auto returns = status.value();
std::string filterPushdown = "";
if (FLAGS_filter_pushdown && isFinalStep() && !isReversely()) {
if (FLAGS_filter_pushdown && isFinalStep()
&& direction_ == OverClause::Direction::kForward) {
// TODO: not support filter pushdown in reversely traversal now.
filterPushdown = whereWrapper_->filterPushdown_;
}
VLOG(1) << "edge type size: " << edgeTypes_.size()
<< " return cols: " << returns.size();
auto future = ectx()->getStorageClient()->getNeighbors(spaceId,
starts_,
edgeTypes_,
Expand Down Expand Up @@ -547,19 +572,6 @@ void GoExecutor::onVertexProps(RpcResponse &&rpcResp) {
UNUSED(rpcResp);
}

std::vector<std::string> GoExecutor::getEdgeNames() const {
std::vector<std::string> names;
auto spaceId = ectx()->rctx()->session()->space();
for (auto edgeType : edgeTypes_) {
auto status = ectx()->schemaManager()->toEdgeName(spaceId, std::abs(edgeType));
DCHECK(status.ok());
auto edgeName = status.value();
names.emplace_back(std::move(edgeName));
}

return names;
}

StatusOr<std::vector<VertexID>> GoExecutor::getDstIdsFromResp(RpcResponse &rpcResp) const {
std::unordered_set<VertexID> set;
for (auto &resp : rpcResp.responses()) {
Expand Down Expand Up @@ -587,13 +599,8 @@ void GoExecutor::finishExecution(RpcResponse &&rpcResp) {
// MayBe we can do better.
std::vector<std::unique_ptr<YieldColumn>> yc;
if (expCtx_->isOverAllEdge() && yields_.empty()) {
auto edgeNames = getEdgeNames();
if (edgeNames.empty()) {
doError(Status::Error("get edge name failed"));
return;
}
for (const auto &name : edgeNames) {
auto dummy = new std::string(name);
for (const auto &alias : expCtx_->getEdgeAlias()) {
auto dummy = new std::string(alias);
auto dummy_exp = new EdgeDstIdExpression(dummy);
auto ptr = std::make_unique<YieldColumn>(dummy_exp);
dummy_exp->setContext(expCtx_.get());
Expand Down Expand Up @@ -721,6 +728,7 @@ StatusOr<std::vector<storage::cpp2::PropDef>> GoExecutor::getStepOutProps() {
pd.name = _DST;
pd.id.set_edge_type(e);
props.emplace_back(std::move(pd));
VLOG(3) << "Need edge props: " << e << ", _dst";
}
auto spaceId = ectx()->rctx()->session()->space();
for (auto &tagProp : expCtx_->srcTagProps()) {
Expand All @@ -734,6 +742,7 @@ StatusOr<std::vector<storage::cpp2::PropDef>> GoExecutor::getStepOutProps() {
auto tagId = status.value();
pd.id.set_tag_id(tagId);
props.emplace_back(std::move(pd));
VLOG(3) << "Need tag src props: " << tagProp.first << ", " << tagProp.second;
}
for (auto &prop : expCtx_->aliasProps()) {
if (prop.second == _DST) {
Expand All @@ -749,7 +758,29 @@ StatusOr<std::vector<storage::cpp2::PropDef>> GoExecutor::getStepOutProps() {
return Status::Error("the edge was not found '%s'", prop.first.c_str());
}
pd.id.set_edge_type(edgeType);
props.emplace_back(std::move(pd));
switch (direction_) {
case OverClause::Direction::kForward: {
props.emplace_back(std::move(pd));
break;
}
case OverClause::Direction::kBackward: {
edgeType = -edgeType;
pd.id.set_edge_type(edgeType);
props.emplace_back(std::move(pd));
break;
}
case OverClause::Direction::kBidirect: {
props.emplace_back(pd);
edgeType = -edgeType;
pd.id.set_edge_type(edgeType);
props.emplace_back(std::move(pd));
break;
}
default:
return Status::Error(
"Unknown direction: %ld", static_cast<int64_t>(direction_));
}
VLOG(3) << "Need edge props: " << prop.first << ", " << prop.second;
}
return props;
}
Expand All @@ -770,6 +801,7 @@ StatusOr<std::vector<storage::cpp2::PropDef>> GoExecutor::getDstProps() {
auto tagId = status.value();
pd.id.set_tag_id(tagId);
props.emplace_back(std::move(pd));
VLOG(3) << "Need dst tag props: " << tagProp.first << ", " << tagProp.second;
}
return props;
}
Expand Down Expand Up @@ -976,9 +1008,7 @@ bool GoExecutor::processFinalResult(RpcResponse &rpcResp, Callback cb) const {
for (auto& edge : edata.edges) {
auto dstId = edge.get_dst();
Getters getters;
// In reverse mode, _dst will return the srcId.
getters.getEdgeDstId = [this,
&srcId,
&dstId,
&edgeType] (const std::string& edgeName)
-> OptVariantType {
Expand All @@ -990,13 +1020,12 @@ bool GoExecutor::processFinalResult(RpcResponse &rpcResp, Callback cb) const {
"Get edge type for `%s' failed in getters.",
edgeName.c_str());
}
if (type != edgeType) {
if (type != std::abs(edgeType)) {
return 0L;
}
}
return isReversely() ? srcId : dstId;
return dstId;
};
// In reverse mode, it is used to get the dst props.
getters.getSrcTagProp = [&spaceId,
&tagData,
&tagSchema,
Expand Down Expand Up @@ -1061,7 +1090,6 @@ bool GoExecutor::processFinalResult(RpcResponse &rpcResp, Callback cb) const {

// In reverse mode, we should handle _src
getters.getAliasProp = [&reader,
&dstId,
&srcId,
&edgeType,
&edgeSchema,
Expand All @@ -1074,16 +1102,21 @@ bool GoExecutor::processFinalResult(RpcResponse &rpcResp, Callback cb) const {
return Status::Error(
"Get edge type for `%s' failed in getters.", edgeName.c_str());
}
if (edgeType != type) {
auto sit = edgeSchema.find(type);
if (std::abs(edgeType) != type) {
auto sit = edgeSchema.find(
direction_ == OverClause::Direction::kBackward ? -type : type);
if (sit == edgeSchema.end()) {
LOG(ERROR) << "Can't find schema for " << edgeName;
return Status::Error("get schema failed");
std::string errMsg = folly::stringPrintf(
"Can't find shcema for %s when get default.",
edgeName.c_str());
LOG(ERROR) << errMsg;
return Status::Error(errMsg);
}
return RowReader::getDefaultProp(sit->second.get(), prop);
}

if (prop == _SRC) {
return isReversely() ? dstId : srcId;
return srcId;
}
DCHECK(reader != nullptr);
auto res = RowReader::getPropByName(reader.get(), prop);
Expand Down
8 changes: 3 additions & 5 deletions src/graph/GoExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ class GoExecutor final : public TraverseExecutor {

Status prepareOverAll();

Status addToEdgeTypes(EdgeType type);

/**
* To check if this is the final step.
*/
Expand All @@ -76,10 +78,6 @@ class GoExecutor final : public TraverseExecutor {
return upto_;
}

bool isReversely() const {
return isReversely_;
}

/**
* To obtain the source ids from various places,
* such as the literal id list, inputs from the pipeline or results of variable.
Expand Down Expand Up @@ -216,7 +214,7 @@ class GoExecutor final : public TraverseExecutor {
uint32_t steps_{1};
uint32_t curStep_{1};
bool upto_{false};
bool isReversely_{false};
OverClause::Direction direction_{OverClause::Direction::kForward};
std::vector<EdgeType> edgeTypes_;
std::string *varname_{nullptr};
std::string *colname_{nullptr};
Expand Down
Loading