[
https://issues.apache.org/jira/browse/TINKERPOP3-479?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14388743#comment-14388743
]
Matt Frantz commented on TINKERPOP3-479:
----------------------------------------
I agree that returning the "created" flag can be important for certain use
cases. However, I wonder if the cost of supporting this return value might be
significant in some cases. Therefore, it might be important to allow the
caller to opt out, in case it doesn't affect the application logic.
For example, an application might want to ensure a vertex for subsequent
analysis. This vertex might be created at any time by any of several parallel
operations. None of the operations need to know if they are the ones who
created the vertex. However, in order to return the boolean, the system must
guarantee that only one of the operations receives the "true" result. That
sort of coordination might be expensive since it involves distributed state.
Would it be better to have both "ensureBlind" and "ensure" API's?
> Consider Providing "getOrCreate" Functionality
> ----------------------------------------------
>
> Key: TINKERPOP3-479
> URL: https://issues.apache.org/jira/browse/TINKERPOP3-479
> Project: TinkerPop 3
> Issue Type: Improvement
> Components: structure
> Reporter: stephen mallette
>
> One of the most commonly written functions used is good ol' "getOrCreate"
> where you want to get a {{Vertex}} if it exists or create it with supplied
> properties if it does not. We currently have a "helper" function for this on
> {{ElementHelper}}
> https://github.com/tinkerpop/tinkerpop3/blob/6d0f00865f673cb0739f6f310e1868425f732924/gremlin-core/src/main/java/com/tinkerpop/gremlin/structure/util/ElementHelper.java#L62
> but perhaps it is time to treat this issue as a first class citizen as part
> of the Graph API. I think that some vendors might actually be able to
> optimize this function as well.
> Another aspect of "getOrCreate" is "upsert" as well as options to ensure
> uniqueness. All of these things we've at some point or another built
> variations of outside of TinkerPop for applications, data loading, etc.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)