[ https://issues.apache.org/jira/browse/TINKERPOP-2681?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17485734#comment-17485734 ]
ASF GitHub Bot commented on TINKERPOP-2681: ------------------------------------------- spmallette commented on a change in pull request #1555: URL: https://github.com/apache/tinkerpop/pull/1555#discussion_r797529098 ########## File path: docs/src/upgrade/release-3.6.x.asciidoc ########## @@ -29,6 +29,71 @@ Please see the link:https://github.com/apache/tinkerpop/blob/3.6.0/CHANGELOG.asc === Upgrading for Users +==== mergeV() and mergeE() + +One of the most commonly used patterns in Gremlin is the use of `fold().coalesce(unfold(), ...)` to perform upsert-like +functionality. While this pattern is quite flexible, it can also be confusing to new users and for certain use cases +challenging to get the pattern correctly implemented. For providers, the pattern is difficult to properly optimize +because it can branch into complexity quite quickly making it hard to identify a section of Gremlin for an upsert and +therefore is not executed as efficiently as it might have been otherwise. + +The new `mergeV()` and `mergeE()` steps greatly simplify this pattern and as the pattern is condensed into a single +step it should be straightforward for providers to optimize as part of their implementations. The following example +demonstrates just how much easier implementing a basic upsert of a vertex has gotten: + +[source,text] +---- +// prior to 3.6.0, use fold().coalesce(unfold(), ...) +gremlin> g.V().has('person','name','vadas').has('age', 27). +......1> fold(). +......2> coalesce(unfold().property('age',30), +......3> addV('person').property('name','vadas').property('age',27)). Review comment: > I find the example here already quite advanced and not obvious to understand. well, i think that's somewhat indicative of why these steps needed to be added. i tried to pick an easy one already....you should see a "hard" one. 😄 that said, i've added a more simple example along the lines you described. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@tinkerpop.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org > Create merge() step to codify best practice for upsert pattern > -------------------------------------------------------------- > > Key: TINKERPOP-2681 > URL: https://issues.apache.org/jira/browse/TINKERPOP-2681 > Project: TinkerPop > Issue Type: Improvement > Components: language, process > Affects Versions: 3.5.1 > Reporter: Dave Bechberger > Assignee: Stephen Mallette > Priority: Major > > Create a step that codifies the best practice for the upsert functionality > into a single step to make it easier to use, more discoverable, and easier > for implementers to optimize. -- This message was sent by Atlassian Jira (v8.20.1#820001)