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

rewrite fetch prop on vertex: 1. support input/variable/multi-vertex-id/multi-tags. 2. keep order of input. #2222

Merged
merged 3 commits into from
Jul 22, 2020

Conversation

xuguruogu
Copy link
Collaborator

@xuguruogu xuguruogu commented Jul 11, 2020

rewrite fetch prop on vertex.

  1. support multi vids for all case.
  2. support input/variable ref
  3. support multi tags. if yield is not specified, return as many as columns as posible as long as one of the vids has value.
  4. keep order of input.
  5. compatible with old tests.

Copy link
Contributor

@dangleptr dangleptr left a 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!

rsWriter = std::make_unique<RowSetWriter>(outputSchema);
TagID tagId = std::move(tagIdStatus).value();
if (ds.find(tagId) != ds.end()) {
auto vreader = ds[tagId].get();
Copy link
Contributor

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,
Copy link
Contributor

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) {
Copy link
Contributor

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

Copy link
Collaborator Author

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 {
Copy link
Contributor

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.

Copy link
Collaborator Author

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";
Copy link
Contributor

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?

Copy link
Collaborator Author

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.

| 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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why call release here?

Copy link
Collaborator Author

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()) {
Copy link
Contributor

@dangleptr dangleptr Jul 13, 2020

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.

Copy link
Collaborator Author

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.

Copy link
Contributor

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.

auto schema = reader->getSchema().get();
Getters getters;
getters.getVariableProp = [&] (const std::string &prop) -> OptVariantType {
if (prop == "VertexID") {
Copy link
Contributor

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator Author

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];
Copy link
Contributor

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes


std::string toString() const;

std::string* release() {
Copy link
Contributor

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove it.

@xuguruogu xuguruogu force-pushed the fetch-prop-on-vertex branch 2 times, most recently from 2c97e70 to c35290c Compare July 15, 2020 03:08
@jude-zhu jude-zhu requested a review from dangleptr July 15, 2020 03:50
@xuguruogu xuguruogu force-pushed the fetch-prop-on-vertex branch from c35290c to 1516bad Compare July 15, 2020 04:57
Copy link
Contributor

@CPWstatic CPWstatic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Impressive work!

colname_ = vexpr->prop();
bool existing = false;
inputs_p_ = ectx()->variableHolder()->get(*varname, &existing);
Copy link
Contributor

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 {
Copy link
Contributor

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.

Copy link
Collaborator Author

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.

@xuguruogu xuguruogu force-pushed the fetch-prop-on-vertex branch 2 times, most recently from f83c4eb to ef4f664 Compare July 15, 2020 16:40
return Status::Error("tags shall never be empty");
}

if (tagNames.size() == 1 && *tagNames[0] == "*") {
Copy link
Contributor

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.

Copy link
Collaborator Author

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()) {
Copy link
Contributor

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"
Copy link
Contributor

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?

Copy link
Collaborator Author

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 {
Copy link
Contributor

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.

Copy link
Collaborator Author

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 == "*") {
Copy link
Contributor

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?

Copy link
Collaborator Author

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));
Copy link
Contributor

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.*

Copy link
Collaborator Author

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.

Copy link
Contributor

@dangleptr dangleptr Jul 17, 2020

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the behavior is same.

@xuguruogu xuguruogu force-pushed the fetch-prop-on-vertex branch from ef4f664 to cc34b01 Compare July 17, 2020 14:16
@dangleptr dangleptr added the ready-for-testing PR: ready for the CI test label Jul 20, 2020
Copy link
Contributor

@dangleptr dangleptr left a 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

@xuguruogu xuguruogu force-pushed the fetch-prop-on-vertex branch from cc34b01 to 44463e6 Compare July 20, 2020 04:53
@xuguruogu xuguruogu force-pushed the fetch-prop-on-vertex branch from 7aa223e to e964bd9 Compare July 20, 2020 05:05
@jude-zhu jude-zhu requested a review from dangleptr July 21, 2020 08:00
Copy link
Contributor

@dangleptr dangleptr left a 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.

@dangleptr dangleptr merged commit 6cc9818 into vesoft-inc:master Jul 22, 2020
@xuguruogu xuguruogu deleted the fetch-prop-on-vertex branch July 22, 2020 05:28
@amber-moe amber-moe added the doc affected PR: improvements or additions to documentation label Jul 24, 2020
@amber-moe
Copy link
Contributor

doc done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc affected PR: improvements or additions to documentation ready-for-testing PR: ready for the CI test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants