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

Add support for multiple mutations #4210

Merged
merged 3 commits into from
Nov 27, 2019
Merged

Conversation

mangalaman93
Copy link
Contributor

@mangalaman93 mangalaman93 commented Oct 24, 2019

Now, the upsert can have multiple mutation block and if..else mutations are now possible.

This change is Reviewable

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

✅ A review job has been created and sent to the PullRequest network.


@mangalaman93 you can click here to see the review status or cancel the code review job.

Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

1 Message
It looks like the description for this pull request is either blank or very short. Adding a high-level summary will help our reviewers provide better feedback. Feel free to include questions for PullRequest reviewers and make specific feedback requests.

edgraph/server.go Outdated Show resolved Hide resolved
@mangalaman93 mangalaman93 force-pushed the aman/multiple_mutations branch from 4ce9e1e to cf43b07 Compare October 24, 2019 15:48
Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

⚠️ Warning

PullRequest detected a force-push on this branch. This may have caused some information to be lost, and additional time may be required to complete review of the code. Read More

@mangalaman93 mangalaman93 force-pushed the aman/multiple_mutations branch from cf43b07 to 8a08a1b Compare October 25, 2019 16:46
edgraph/server.go Outdated Show resolved Hide resolved
Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

The change looks good overall but does need some adjustments before getting it merged.


Reviewed with ❤️ by PullRequest

query/mutation.go Outdated Show resolved Hide resolved
edgraph/server.go Show resolved Hide resolved
edgraph/server.go Outdated Show resolved Hide resolved
go.mod Outdated Show resolved Hide resolved
edgraph/server.go Outdated Show resolved Hide resolved
edgraph/server.go Outdated Show resolved Hide resolved
query/mutation.go Outdated Show resolved Hide resolved
edgraph/server.go Outdated Show resolved Hide resolved
edgraph/server.go Outdated Show resolved Hide resolved
Copy link

@pullrequest pullrequest bot left a comment

Choose a reason for hiding this comment

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

✖️ This code review was cancelled. See Details

@mangalaman93 mangalaman93 force-pushed the aman/multiple_mutations branch 4 times, most recently from 72b1ecd to eb3e3a5 Compare November 5, 2019 17:03
@mangalaman93 mangalaman93 force-pushed the aman/multiple_mutations branch from e29d545 to 487ffff Compare November 6, 2019 17:05
@mangalaman93 mangalaman93 marked this pull request as ready for review November 7, 2019 15:23
@mangalaman93 mangalaman93 force-pushed the aman/multiple_mutations branch from c9a6ae1 to 24819a8 Compare November 7, 2019 15:44
Copy link
Contributor

@manishrjain manishrjain left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 13 files reviewed, 17 unresolved discussions (waiting on @danielmai, @mangalaman93, @manishrjain, @MichaelJCompton, @pawanrawal, and @pullrequest[bot])


dgraph/cmd/alpha/http.go, line 415 at r3 (raw file):

	mp := map[string]interface{}{}
	if len(resp.Json) != 0 {
		if err := json.Unmarshal(resp.Json, &mp); err != nil {

Avoid this. Find another way.

Query should contain: {"data": ..., "extensions": ...}

Perhaps find the first bracket, and inject the json from below into it. That'd be much faster.


edgraph/server.go, line 524 at r3 (raw file):

	req.Query = strings.TrimSpace(req.Query)
	isQuery := len(req.Query) != 0
	if !isQuery && !isMutation {

Might not need to check it up here.


edgraph/server.go, line 532 at r3 (raw file):

		req:      req,
		condVars: make([]string, len(req.Mutations)),
		uidRes:   make(map[string][]string),

Try to avoid these empty inits.


edgraph/server.go, line 535 at r3 (raw file):

		valRes:   make(map[string]map[uint64]types.Val),
		latency:  l,
		span:     span,

Don't really need this. ctx already has span.


edgraph/server.go, line 558 at r3 (raw file):

	resp = &api.Response{}
	if isQuery {

switch case for isQuery, isMutation, default


edgraph/server.go, line 632 at r3 (raw file):

// @if condition defined in Conditional Upsert.
func buildUpsertQuery(qc *queryContext) string {
	if len(qc.req.Query) == 0 {

check if len(qc.gmuList) == 0 or not here?

Copy link
Contributor Author

@mangalaman93 mangalaman93 left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 13 files reviewed, 17 unresolved discussions (waiting on @danielmai, @mangalaman93, @manishrjain, @MichaelJCompton, @pawanrawal, and @pullrequest[bot])


go.mod, line 3 at r2 (raw file):

Previously, pullrequest[bot] wrote…

Was the CI switched to using Go 1.13 already? If not, I recommend reverting the change to go.mod, go.sum and redo it with Go 1.12.

This is because Go 1.13 has a GOPROXY enabled by default. This can lead to errors if any of your dependencies have been re-tagged upstream then Go 1.12 will see the new tag whilst Go 1.13 remains seeing the old tag (the goproxy is immutable) leading to a mismatch of the dependency's hash.

Done.


dgraph/cmd/alpha/http.go, line 415 at r3 (raw file):

Previously, manishrjain (Manish R Jain) wrote…

Avoid this. Find another way.

Query should contain: {"data": ..., "extensions": ...}

Perhaps find the first bracket, and inject the json from below into it. That'd be much faster.

Done.


edgraph/server.go, line 524 at r3 (raw file):

Previously, manishrjain (Manish R Jain) wrote…

Might not need to check it up here.

I have to check it here, otherwise parsing fails


edgraph/server.go, line 532 at r3 (raw file):

Previously, manishrjain (Manish R Jain) wrote…

Try to avoid these empty inits.

Done.


edgraph/server.go, line 535 at r3 (raw file):

Previously, manishrjain (Manish R Jain) wrote…

Don't really need this. ctx already has span.

ctx does have the key but the key for storing the context is not exported from the trace package. The exported function (FromContext) is only defined for type *SpanContext which is not the case here.


edgraph/server.go, line 558 at r3 (raw file):

Previously, manishrjain (Manish R Jain) wrote…

switch case for isQuery, isMutation, default

We need to do both if it is an upsert. Not sure a switch statement will work.


edgraph/server.go, line 632 at r3 (raw file):

Previously, manishrjain (Manish R Jain) wrote…

check if len(qc.gmuList) == 0 or not here?

Done.

@mangalaman93 mangalaman93 force-pushed the aman/multiple_mutations branch from 6116fe6 to b168008 Compare November 13, 2019 09:22
@mangalaman93 mangalaman93 changed the base branch from master to aman/refactor November 13, 2019 09:22
@mangalaman93 mangalaman93 force-pushed the aman/multiple_mutations branch from b168008 to 96e1668 Compare November 13, 2019 12:04
Copy link
Contributor

@martinmr martinmr left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 3 of 12 files at r3, 4 of 5 files at r5.
Reviewable status: all files reviewed, 17 unresolved discussions (waiting on @danielmai, @mangalaman93, @manishrjain, @MichaelJCompton, @pawanrawal, and @pullrequest[bot])

@mangalaman93 mangalaman93 force-pushed the aman/multiple_mutations branch from 257d6aa to 633c252 Compare November 14, 2019 04:20
@mangalaman93 mangalaman93 force-pushed the aman/refactor branch 2 times, most recently from 68508ba to 8acc6bd Compare November 21, 2019 12:17
@mangalaman93 mangalaman93 force-pushed the aman/multiple_mutations branch from 633c252 to f5a805f Compare November 21, 2019 16:37
@mangalaman93 mangalaman93 changed the base branch from aman/refactor to master November 21, 2019 16:39
@mangalaman93 mangalaman93 force-pushed the aman/multiple_mutations branch from f5a805f to 8adf4d3 Compare November 22, 2019 08:27
Copy link
Contributor

@manishrjain manishrjain left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewed 2 of 12 files at r3, 1 of 5 files at r5, 3 of 4 files at r6.
Reviewable status: all files reviewed, 12 unresolved discussions (waiting on @danielmai, @mangalaman93, @manishrjain, @MichaelJCompton, @pawanrawal, and @pullrequest[bot])

@mangalaman93 mangalaman93 force-pushed the aman/multiple_mutations branch from 8adf4d3 to 64560e6 Compare November 26, 2019 10:43
Copy link
Contributor

@pawanrawal pawanrawal left a comment

Choose a reason for hiding this comment

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

:lgtm: apart from a small thing that I was not very sure of. Perhaps a comment would help.

Reviewed 3 of 12 files at r3, 1 of 5 files at r5, 3 of 4 files at r6.
Reviewable status: all files reviewed, 13 unresolved discussions (waiting on @danielmai, @mangalaman93, @manishrjain, @MichaelJCompton, and @pullrequest[bot])


dgraph/cmd/alpha/http.go, line 354 at r7 (raw file):

			return mu, nil
		}
		if mu, err := extractMutation(ms); err != nil {

So ms can have set, delete and cond as keys and can also have mutations as keys? I would think that we only allow mutations as the key. Is that to maintain backward compatibility?

Copy link
Contributor Author

@mangalaman93 mangalaman93 left a comment

Choose a reason for hiding this comment

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

Reviewable status: all files reviewed, 13 unresolved discussions (waiting on @danielmai, @mangalaman93, @manishrjain, @MichaelJCompton, @pawanrawal, and @pullrequest[bot])


dgraph/cmd/alpha/http.go, line 354 at r7 (raw file):

Previously, pawanrawal (Pawan Rawal) wrote…

So ms can have set, delete and cond as keys and can also have mutations as keys? I would think that we only allow mutations as the key. Is that to maintain backward compatibility?

yeah, pretty much. I'd add a comment in the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants