1

I am trying to write a generic update query to edit titan vertices.

GraphTraversal<Vertex,Vertex> tempNode =  getVertexList(node.getKey(), g);
            if(tempNode.hasNext())
            {
                Vertex vertex = tempNode.next();

                final int length = node.getKey().getProperties().size() * 2 + 2;
                Object[] keyValue = new Object[length];

                int i = 0;
                for(Map.Entry<String, Object> entry: node.getKey().getProperties().entrySet())
                {
                    keyValue[i] = entry.getKey();
                    keyValue[i+1] = entry.getValue();
                    i += 2;
                }

                NodeStorage tempStorage = new NodeStorage(node.getValue().getId(), node.getKey().getProperties());
                for(Map.Entry<String, Object> entry: node.getValue().getProperties().entrySet())
                {
                    tempStorage.addProperty(entry.getKey(), entry.getValue());
                }

                vertex.property("hash", HashCreator.sha1FromNode(tempStorage), keyValue);
            }

in getVertexList I simply get the vertex by a certain key I defined. I then check if the list contains anything. I then want to change the properties of it and add a hash property.

I unfortunately didn't find out how I may edit the label string of the vertice. Is there a way?

raycons
  • 735
  • 12
  • 26
  • 2
    Nope you can't change vertex labels. I have asked this before: http://stackoverflow.com/a/34005118/1457059 – Filipe Teixeira Nov 09 '16 at 08:50
  • 1
    Possible duplicate of [Tinkerpop: Set Label After Creating Vertex](http://stackoverflow.com/questions/34004702/tinkerpop-set-label-after-creating-vertex) – stephen mallette Nov 10 '16 at 13:37
  • @stephenmallette Seems like it's impossible with TinkerPop 3 to change the vertex label and instead it's recommended a new vertex property gets used (In the following example, "type"). In that case, my query of `g.V().hasLabel(“XYZ”)` would then get changed to `g.V().has(“type”, “XYZ”)`. How this will impact on the performance? Would it become slower (performance intensive) compared to querying the vertices with a specific label? – Malgi Nov 04 '20 at 21:50
  • 1
    performance depends on the graph database you use. it will further depend on your schema and whether or not "type" uses an index and how selective that index is. – stephen mallette Nov 04 '20 at 22:26
  • @stephenmallette the database we use is Amazon Neptune. Do you mean there would be no performance degradation over running query `g.V().has(“type”, “XYZ”)` as opposed to `g.V().hasLabel(“XYZ”)` If we use proper indexing? – Malgi Nov 04 '20 at 22:32
  • 1
    in Neptune all field are automatically indexed so you don't have to specify it explicitly. Neptune also treats the `T.label` in much the same fashion as a property key when it comes to that index so I'd guess you would receive similar performance from either. – stephen mallette Nov 04 '20 at 23:02

0 Answers0