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

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

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.

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])

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])

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