Reputation: 760
I tried following query with Gremlin and Tinkerpop
gremlin> graph = TinkerGraph.open()
==>tinkergraph[vertices:0 edges:0]
gremlin> g = traversal().withEmbedded(graph)
==>graphtraversalsource[tinkergraph[vertices:0 edges:0], standard]
gremlin> v = g.addV().property('name','marko').property('name','marko a. rodriguez').next()
==>v[0]
gremlin> g.V(v).properties('name').count()
==>2
gremlin>
When I run same with Gremlin-Python and Janusgraph,recieves following.
>>> v = g.addV().property('name','marko').property('name','marko a. rodriguez').next()
>>> g.V(v).properties('name').count().next()
1
My question is, why I am receiving different result. In the first case the output is 2, but in second case the output is 1.
I have tried to run the following queries too to explore more, and find the following result.
With Gremlin and TinkerpopGraph
gremlin> g.V(v).values('name')
==>marko
==>marko a. rodriguez
gremlin>
With Gremlin-Python and JanusGraph
>>> g.V(v).values('name').next()
'marko a. rodriguez'
When I tried the following with gremlin and Janusgraph, it works
gremlin> v = g.addV().property(list,'p_name','marko').property(list,'p_name','marko a. rodriguez').next()
==>v[12344]
gremlin> g.V(v).properties('p_name').count()
==>0
But running the same results in gremlin-python gives me error.
>>> v = g.addV().property(list,'p_name','marko').property(list,'p_name','marko a. rodriguez').next()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/sumit/.local/lib/python3.9/site-packages/gremlin_python/process/traversal.py", line 88, in next
return self.__next__()
File "/home/sumit/.local/lib/python3.9/site-packages/gremlin_python/process/traversal.py", line 47, in __next__
self.traversal_strategies.apply_strategies(self)
File "/home/sumit/.local/lib/python3.9/site-packages/gremlin_python/process/traversal.py", line 548, in apply_strategies
traversal_strategy.apply(traversal)
File "/home/sumit/.local/lib/python3.9/site-packages/gremlin_python/driver/remote_connection.py", line 63, in apply
remote_traversal = self.remote_connection.submit(traversal.bytecode)
File "/home/sumit/.local/lib/python3.9/site-packages/gremlin_python/driver/driver_remote_connection.py", line 60, in submit
results = result_set.all().result()
File "/usr/lib/python3.9/concurrent/futures/_base.py", line 440, in result
return self.__get_result()
File "/usr/lib/python3.9/concurrent/futures/_base.py", line 389, in __get_result
raise self._exception
File "/home/sumit/.local/lib/python3.9/site-packages/gremlin_python/driver/resultset.py", line 90, in cb
f.result()
File "/usr/lib/python3.9/concurrent/futures/_base.py", line 433, in result
return self.__get_result()
File "/usr/lib/python3.9/concurrent/futures/_base.py", line 389, in __get_result
raise self._exception
File "/usr/lib/python3.9/concurrent/futures/thread.py", line 52, in run
result = self.fn(*self.args, **self.kwargs)
File "/home/sumit/.local/lib/python3.9/site-packages/gremlin_python/driver/connection.py", line 83, in _receive
status_code = self._protocol.data_received(data, self._results)
File "/home/sumit/.local/lib/python3.9/site-packages/gremlin_python/driver/protocol.py", line 131, in data_received
raise GremlinServerError(message['status'])
gremlin_python.driver.protocol.GremlinServerError: 599: null: .property(ArrayList, String, String)
599: null: .property(ArrayList, String, String)
Upvotes: 1
Views: 142
Reputation: 14371
I believe what you are seeing is a special case condition with TinkerGraph where if you create two properties with the same key while creating the vertex as well, list cardinality is assumed. If you were to perform the same property additions on a vertex that already exists, single cardinality would be assumed and one would replace the other. For example:
gremlin> g.addV('xyz')
==>v[3]
gremlin>
g.V().hasLabel('xyz').property('name','me').property('name','me2').valueMap()
==>[name:[me2]]
As to your Python error, list
is a Python reserved word. Try using Cardinality.list
In general if your intent is to create a List or Set, be explicit with the cardinality value to ensure you get the expected results.
Upvotes: 1