You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tinkerpop.apache.org by "stephen mallette (JIRA)" <ji...@apache.org> on 2015/07/30 20:04:04 UTC

[jira] [Updated] (TINKERPOP3-479) Consider Providing "getOrCreate" Functionality

     [ https://issues.apache.org/jira/browse/TINKERPOP3-479?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

stephen mallette updated TINKERPOP3-479:
----------------------------------------
    Fix Version/s: 3.1.0-incubating

I've already written two separate "getOrCreate" functions for two different situations using TP3.  Time to get this issue settled for 3.1.0. :)

I re-read our comments on this and the idea was to do something like {{Graph.ensure}}. As we got closer to GA, I thought that since we now do everything via {{GraphTraversal}} having a {{Graph}} API level method for this wasn't necessary.  However, some graphs might be able to take advantage of their internal {{upsert}} capabilities (orientdb has it, i believe).  

Aside from where the method goes my "getOrCreate" functions typically have this signature:

{code}
Vertex ensureV(String key,Object value, Object... keyValuesToInsert)
{code}

There was discussion of a need for returning "whether or not the Vertex was created on this call" - that had some value with locking in Titan - but perhaps it is more than we need for general support in TP3 right now?

> Consider Providing "getOrCreate" Functionality
> ----------------------------------------------
>
>                 Key: TINKERPOP3-479
>                 URL: https://issues.apache.org/jira/browse/TINKERPOP3-479
>             Project: TinkerPop 3
>          Issue Type: Improvement
>          Components: structure
>    Affects Versions: 3.0.0-incubating
>            Reporter: stephen mallette
>             Fix For: 3.1.0-incubating
>
>
> 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)