Git Product home page Git Product logo

Comments (9)

freemo avatar freemo commented on June 15, 2024

You can already do this via the @Adjaency or @Incidence annotation. Is there any reason this isnt sufficient?

from ferma.

sebeard avatar sebeard commented on June 15, 2024

Maybe I'm misusing or misunderstanding their usages. I do already use both these annotations.

From the example documentation;

public abstract class Person extends AbstractVertexFrame {
  @Property("name")
  public abstract String getName();

  @Property("name")
  public abstract void setName(String name);

  @Adjacency(label = "knows")
  public abstract List<Person> getKnowsPeople();

  @Incidence(label = "knows")
  public abstract List<Knows> getKnows();

  @Incidence(label = "knows")
  public abstract Knows addKnows(Person friend);

}

I understand that;

  • @Adjacency is a link to a node 'close by' - i.e there is an edge from Person to another Person. Adjacency describes a means of traversing from Vertex to Vertex. Using the method getKnowsPeople() I can get a list of all the People this instance of Person knows.
  • The @Incidence annotation is about the edges themselves. getKnows() returns all Knows edge instances coming out of this Vertex (or Person instance), while addKnows creates a link between this instance of Person and their friend (returning the edge itself).
  • The label value on both annotations, I believe is used under the covers to label the edge and the edge only.

From what I've seen in debug (and I probably haven't delved deep enough) Vertices can also have labels, and Ferma uses the simple class name as the label of the vertex.

What I'm suggesting is that any class annotated with @GraphElement could use an optional label attached to it as the label rather than the class name, Ferma can still fall back to using the class name if the label value is not supplied. Think of it a little like Spring's @Component/@Service annotation where you can specify a value which "may indicate a suggestion for a logical component name, to be turned into a Spring bean in case of an autodetected component."

This isn't that important - it's more of a convenience value so I can represent a data model without exposing my class hierarchy or structure, and describe the graph exactly as designed.

from ferma.

freemo avatar freemo commented on June 15, 2024

@sebeard so depends what you mean by "label". In graph databases, and more specifically tinkerpop, only edges have labels. Verticies do have IDs but they have to be unique so don't really serve a similar purpose. You could create an arbitrary property called "label" and use that in a similar way that edges have label, but that isnt a concept built into gremlin or tinkerpop in any way.

The class name isnt currently used as a "label" but it is used to define the type that backs a class. It is effectively used to figure out which concrete class is used to instantiate an instance of the vertex. Edges have the same property with the same purpose. It is separate from a label though and serves a different function.

Is your intention just to define a different "type" name in the graph, something that replaces the class name? It wouldnt be a label and currently you'd have to do that by writing a custom type resolver. But that is something that could, in theory, be defined in the GraphElement annotation, but it wouldnt be a label regardless and behave very differently than an edge label might.

from ferma.

sebeard avatar sebeard commented on June 15, 2024

@freemo Thanks for the great explanation. I think I started to grasp that having delved a bit deeper.

My intention was to effectively label the vertices similar to the edges. I think this is leftover understanding from when I was trying out the Gremlin-OGM project before noticing yours. OGM didn't quite cut it in terms of resolving to different type hierarchies.

One question though - I'm seeing in the tinkerpop documentation http://tinkerpop.apache.org/docs/3.3.0/reference/#label-step - (and specifically recipes - http://tinkerpop.apache.org/docs/current/recipes/#duplicate-edge) references to a hasLabel traversal which seems to refer to a label on a vertex. Could you explain that to me?

from ferma.

freemo avatar freemo commented on June 15, 2024

@sebeard so they are basically reusing the word "label" here to mean something entirely different from an edge label. When you do a Gremlin pipeline you can label any one step (effectively the group of vertex and edges represented by that step) with a specific label and then reference that label again later. for example when you see commands like as("a") at the link you sent me it creates the label "a" and assigned it to all the vertex and edges at that step. They are then later recalled when filtering with commands like by("a") and can be excluded or included in that particular step. None of that has anything to do with any label encoded into the graph itself however.

from ferma.

freemo avatar freemo commented on June 15, 2024

@sebeard Do we want to close this ticket, or are you requesting a feature whereby the type encoded into the graph can be customized?

from ferma.

sebeard avatar sebeard commented on June 15, 2024

@freemo Great thanks!! I think this can be closed. Thanks for aiding my understanding.

from ferma.

hatemalimam avatar hatemalimam commented on June 15, 2024

I'm little confused here, shouldn't all the Vertex be created in the Graph database in their corresponding label (Class.getName() for example) ? meaning if I create a framed vertex like this:

User julia = fg.addFramedVertex(User.class); julia.setName("Julia");

I get this in Neo4j

screen shot 2018-01-16 at 17 09 58

the vertex in the screenshot should be labeled as user, any specific reason why I'm getting this ? or is it the default behaviour of ferma ?

Is there any way to create a vertex with a label like the default approach in gremlin ?

Vertex peter = graph.addVertex(T.label, "user")

Which results with this:

screen shot 2018-01-16 at 17 15 21

from ferma.

hatemalimam avatar hatemalimam commented on June 15, 2024

I managed to solve my issue with this:

User user = fg.addFramedVertex(User.DEFAULT_INITIALIZER, T.label, "user"); user.setName("Julia");

from ferma.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.