-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
rewrite fetch prop on vertex: 1. support input/variable/multi-vertex-id/multi-tags. 2. keep order of input. #2222
Conversation
cfdf2b5
to
40934f6
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution. It is really a huge pr, i think we need some time to take care of it.
Great work! Excellent!
src/graph/FetchVerticesExecutor.cpp
Outdated
rsWriter = std::make_unique<RowSetWriter>(outputSchema); | ||
TagID tagId = std::move(tagIdStatus).value(); | ||
if (ds.find(tagId) != ds.end()) { | ||
auto vreader = ds[tagId].get(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use the iterator returned by 'find' directly to avoid looking up the hash map again.
@@ -279,7 +282,8 @@ bool MetaClient::loadSchemas(GraphSpaceID spaceId, | |||
SpaceEdgeTypeNameMap &edgeTypeNameMap, | |||
SpaceNewestTagVerMap &newestTagVerMap, | |||
SpaceNewestEdgeVerMap &newestEdgeVerMap, | |||
SpaceAllEdgeMap &allEdgeMap) { | |||
SpaceAllEdgeMap &allEdgeMap, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The better name are spaceAllEdges/spaceAllTags
@@ -921,6 +933,20 @@ StatusOr<std::vector<std::string>> MetaClient::getAllEdgeFromCache(const GraphSp | |||
return it->second; | |||
} | |||
|
|||
StatusOr<std::vector<std::string>> MetaClient::getAllTagFromCache(const GraphSpaceID& space) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The better name is getAllTagsFromCache.
PS. Maybe "getAllEdgeFromCache" should be getAllEdgesFromCache
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yelp
labels->addLabel(new std::string("*")); | ||
$$ = new FetchVerticesSentence(labels, $5, $6); | ||
} | ||
| KW_FETCH KW_PROP KW_ON MUL vid_ref_expression yield_clause { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to support multi props, maybe we need to support "KW_PROP" and "KW_PROPS" both.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just like value/values...
} | ||
{ | ||
GQLParser parser; | ||
std::string query = "FETCH PROP ON person, another 1, 2, 3"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to know what's the response looks like in this case. Person and Another maybe have different props. You join them on vid together?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we use the tag as Wide table, simply speaking: one tag hold one value. In this way, we can support large data adding and modify.
Person and Another tags join together, display default value if one of them is null.
src/parser/parser.yy
Outdated
| KW_FETCH KW_PROP KW_ON name_label edge_key_ref yield_clause { | ||
auto fetch = new FetchEdgesSentence($4, $5, $6); | ||
| KW_FETCH KW_PROP KW_ON fetch_labels edge_key_ref yield_clause { | ||
auto fetch = new FetchEdgesSentence($4->release(), $5, $6); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why call release here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will remove it.
resp_ = std::make_unique<cpp2::ExecutionResponse>(); | ||
auto colNames = outputs->getColNames(); | ||
resp_->set_column_names(std::move(colNames)); | ||
if (outputs->hasData()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it is the rightest sentence, you could avoid the interim result setting, it will introduce extra encode/decode.
You could take toThriftResponse as your reference inside GoExecutor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Emm... I simply copy the codes from FetchExecutor::finishExecution
. Maybe more attention will needed to fully understand.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine. Just leave it here.
src/graph/FetchVerticesExecutor.cpp
Outdated
auto schema = reader->getSchema().get(); | ||
Getters getters; | ||
getters.getVariableProp = [&] (const std::string &prop) -> OptVariantType { | ||
if (prop == "VertexID") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you define this behavior, please add notes about it in summary of this pr.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the previous codes, every record will be attached collumn "VertexID" at beggining. To be compatible with this behavior. I will comment on this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modify the codes to keep identical with previous codes.
if (dataMap.find(vid) == dataMap.end() && !expCtx_->hasInputProp()) { | ||
return Status::OK(); | ||
} | ||
auto& ds = dataMap[vid]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could use the iterator returned by find directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes
src/parser/Clauses.h
Outdated
|
||
std::string toString() const; | ||
|
||
std::string* release() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird about this method. Could you add some comments about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove it.
2c97e70
to
c35290c
Compare
c35290c
to
1516bad
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Impressive work!
src/graph/FetchVerticesExecutor.cpp
Outdated
colname_ = vexpr->prop(); | ||
bool existing = false; | ||
inputs_p_ = ectx()->variableHolder()->get(*varname, &existing); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inputs_p_
is not the code style of nebula repo.
auto fetch = new FetchEdgesSentence($4, $5, $6); | ||
$$ = fetch; | ||
} | ||
| KW_FETCH KW_PROP KW_ON name_label edge_key_ref yield_clause { | ||
| KW_FETCH KW_PROP KW_ON fetch_labels edge_key_ref yield_clause { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Emm, if don't implement it in this pr, please forbid this syntax at present.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the syntax has trouble to shift and reduce before edge_key and vids identifiers, I return the error msg in the executor.
f83c4eb
to
ef4f664
Compare
return Status::Error("tags shall never be empty"); | ||
} | ||
|
||
if (tagNames.size() == 1 && *tagNames[0] == "*") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we combine the logic about "*" and multi tags. It seems there are some duplicate codes here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sense.
resp_ = std::make_unique<cpp2::ExecutionResponse>(); | ||
auto colNames = outputs->getColNames(); | ||
resp_->set_column_names(std::move(colNames)); | ||
if (outputs->hasData()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine. Just leave it here.
{ | ||
cpp2::ExecutionResponse resp; | ||
auto &player = players_["Boris Diaw"]; | ||
auto *fmt = "GO FROM %ld over like YIELD like._dst as id" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to know, this case is really in usage?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heavily used. Mostly, we get a sub-graph, using filters or other restriction, and then fetch more information of the nodes.
$$ = new FetchVerticesSentence($4, $5, $6); | ||
} | ||
| KW_FETCH KW_PROP KW_ON MUL vid { | ||
$$ = new FetchVerticesSentence($5); | ||
| KW_FETCH KW_PROP KW_ON MUL vid_list yield_clause { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seem be conflict, if you fetch prop on * but specify the tag.prop when yield.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have many tags in use. it is redundant to write tag-name twice. In actually implement, if yield_clause specified, tag-names may only be used as verification.
if (col->expr()->isInputExpression()) { | ||
auto *inputExpr = dynamic_cast<InputPropertyExpression*>(col->expr()); | ||
auto *colName = inputExpr->prop(); | ||
if (*colName == "*") { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent. Could we combine the logic about "*" both in InputPropertyExpression and VariablePropertyExpression into one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
may have trouble due to
Expression *expr = new InputPropertyExpression(new std::string(prop));
Expression *expr = new VariablePropertyExpression(alias, new std::string(prop));
pd.owner = storage::cpp2::PropOwner::SOURCE; | ||
pd.name = prop; | ||
pd.id.set_tag_id(tagId); | ||
props_.emplace_back(std::move(pd)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where did your support allProps on one Tag. Such as tag1.*
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tag1.* can not pass syntax check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it compatible with the original behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the behavior is same.
ef4f664
to
cc34b01
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please address the inline comments.
If you don't want to fix them in this pr, please add one TODO comment.
BTW. Please check the failed UTs.
Thanks
cc34b01
to
44463e6
Compare
…id/multi-tags. 2. keep order of input.
7aa223e
to
e964bd9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Totally. the PR looks good to me.
Thanks for your contribution.
doc done |
…id/multi-tags. 2. keep order of input. (vesoft-inc#2222) Co-authored-by: trippli <[email protected]> Co-authored-by: dangleptr <[email protected]>
rewrite fetch prop on vertex.