How to return a Vertex in the tinkerpop/gremlin format instead of the DSE graph format?

前端 未结 2 526
挽巷
挽巷 2021-01-27 00:34

I am trying to return a Vertex (in tinkerpop format) that it was just created with Gremlin:

DseCluster dseCluster = DseCluster.builder()
        .addContactPoint         


        
2条回答
  •  青春惊慌失措
    2021-01-27 01:12

    In Datastax 1.1 it seems that you can't cast to Vertex directly, there is no indication of this in the documentation.

    Instead you can access VertexProperty (org.apache.tinkerpop.gremlin.structure.VertexProperty) using .getProperties(String).

    GraphNode n = dseSession.executeGraph("g.V().hasLabel('test_vertex_meta_props')").one();
    Vertex vertex = n.asVertex();
    
    // there can be more than one VertexProperty with the key "meta_property"
    Iterator metaProps = vertex.getProperties("meta_property");
    
    VertexProperty metaProp1 = metaProps.next();
    // the value of the meta property
    int metaProp1Value = metaProp1.getValue().asInt();
    // the properties of the meta property itself
    Iterator simpleProps1 = metaProp1.getProperties();
    Property simpleProp11 = simpleProps1.next();
    double simplePropValue11 = simpleProp11.getValue().asDouble(); 
    Property simpleProp12 = simpleProps1.next();
    double simplePropValue12 = simpleProp12.getValue().asDouble(); 
    
    // **multi value** meta property.
    VertexProperty metaProp2 = metaProps.next();
    

    Via: Datastax Manual (1.1)

提交回复
热议问题