What is the best way to represent an Edge Entity in a Java Object?

40 views
Skip to first unread message

Otávio Gonçalves de Santana

unread,
Jan 11, 2018, 3:40:10 PM1/11/18
to Gremlin-users


Hello, my name is Otávio Santana.
I'm working in a future JSR to NoSQL database. Basically, we gonna have one API for each database type, however, once there is Tinkerpop we'll keep this one on the Graph site. The idea is a wrap in the tinkerpop to represent Java Entities.
And now we have an issue and I would like to know what do you think?


The Currently model

/**
 * @param <IN>  the inbound Entity
 * @param <OUT> the outbound entity
 */
public interface EdgeEntity<OUT, IN> {

    /**
     * Gets the inbound entity
     *
     * @return the inbound entity
     */
    IN getInbound();

    /**
     * Gets the outbound entity
     *
     * @return the outbound entity
     */
    OUT getOutbound();
}

However, this current version does not support very well when there are more than one Edge types, e.g.: give this code:

        Person ada =...; 
        Technology java = ...;
        Technology cloud = ...;

       graph.edge(ada, "lives" "Sao Paulo");
       graph.edge(ada, "works", cloud);
       graph.edge(ada, "works", java);

01

EdgeEntity<Person,?> edges = graph.getTraversalEdge();
//that gonna return both: cities and technology edge

That makes me not full confidence in this current API.

The Options that I have in my mind:

what I thought:

1) Keep this existing API


2) Changes to add generics in the methods with throw class cast exception:

public interface EdgeEntity {

T <T> getInbound()throws ClassCastException;

T <T> getOutbound()throws ClassCastException;
}

3) Make the methods to return Object:

public interface EdgeEntity {

Object getInbound();

Object getOutbound();
}

4) another suggestion

To know more about Graph API: https://dzone.com/articles/have-a-fun-moment-with-graph-and-java

Stephen Mallette

unread,
Jan 16, 2018, 7:40:32 AM1/16/18
to Gremlin-users
I'm not sure I understand enough about your library to offer much good specific advice. I can only say that generally speaking it's probably fairly rare for a graph application of any reasonable complexity to have only one edge type, so i'm sure users will encounter the issue. I guess option 2 seems best for this type of framework. Given my understanding so far, getting type safety is part of the value of this type of project, so to return Object or use your current approach both seem as though they go against that basic goal.

--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/5c783859-b649-46f5-b744-ddabb50a68d7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Otávio Gonçalves de Santana

unread,
Jan 16, 2018, 8:12:21 AM1/16/18
to Gremlin-users
Thank you Stephen
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages