|
|||||||||||||
So, then I have dataframe containing 100 unique users names. I'm using Gremlin + Python to push data to graph. The data have label of 'user'. Logically after insertion is done, if I query g.V().hasLabel('user').count() on gremlin shell, I should get 100 (Same as rows in dataframe). But I get some other number. Why is that so? I tried setting cache=false in setting file but same issue. Set of codes: keyname = 'name' What should happen logicall in each iteration is that, First it should print "No element found for ID: somenumber". Then it should add to graph. Then it should print the vertex added. But, If a vertex was found, it prints Element Exists, and then in 2nd print statement, it prints Element Added. But for those elements which doesnt exist, i.e. 1st Print statement: No element found, then in those cases 2nd print statement should be vertex added just now. But it prints Exception, no element coult be added. It looks like some vertex are not getting added at all. But at same time arent also throwing an exception. This is strange behaviour. Anyone has any ideas why this is happening? Thanks |
--To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/cbaa4fa9-161c-4d2e-ba7d-d0be77139dde%40googlegroups.com.
You received this message because you are subscribed to a topic in the Google Groups "Gremlin-users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gremlin-users/JUDdpJmyEsE/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gremlin-users+unsubscribe@googlegroups.com.
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from gremlin_python.structure.graph import Graph
>>> from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
>>> graph = Graph()
>>> g = graph.traversal().withRemote(DriverRemoteConnection('ws://localhost:8182/gremlin','g'))
>>> g.V().count().next()
6L
>>> keyname = 'name'
>>> label = 'user'
>>> k = 0
>>> for _, keyvalue in [(0,'hiep'), (0,'hiep'), (1,'hoi'), (2,'hoera')]:
... if label == 'user':
... try:
... print("Element Exists: {}. ID {}".format(g.V().hasLabel(label).has(keyname+"_{}".format(k), keyvalue).next(), _))
... except:
... print("No element fount in graph. ID: ", _)
... ret = g.addV(label).property(keyname+"_{}".format(k), keyvalue).next()
... if label == 'user':
... try:
... print("Element Added: {}. ID {}".format(g.V().hasLabel(label).has(keyname+"_{}".format(k), keyvalue).next(), _))
... except:
... print("Exception! Element couldn't be added. No element fount in graph. ID: ", _)
...
('No element fount in graph. ID: ', 0)
Element Added: v[13]. ID 0
Element Exists: v[13]. ID 0
Element Added: v[13]. ID 0
('No element fount in graph. ID: ', 1)
Element Added: v[17]. ID 1
('No element fount in graph. ID: ', 2)
Element Added: v[19]. ID 2
>>>
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from gremlin_python.structure.graph import Graph
>>> from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
>>> graph = Graph()
>>> g = graph.traversal().withRemote(DriverRemoteConnection('ws://localhost:8182/gremlin','g'))
>>>
>>> g.V().count().next()
6L
>>> keyname = 'name'
>>> label = 'user'
>>> k = 0
>>> for _, keyvalue in [(0,'hiep'), (0,'hiep'), (1,'hoi'), (2,'hoera')]:
... if label == 'user':
... g.V().hasLabel(label).has(keyname+"_{}".format(k), keyvalue).toList()
... ret = g.addV(label).property(keyname+"_{}".format(k), keyvalue).next()
... if label == 'user':
... g.V().hasLabel(label).has(keyname+"_{}".format(k), keyvalue).toList()
...
[]
[v[13]]
[v[13]]
[v[13], v[15]]
[]
[v[17]]
[]
[v[19]]
>>>
To unsubscribe from this group and all its topics, send an email to gremlin-user...@googlegroups.com.
Python 2.7.12 (default, Nov 19 2016, 06:48:10)
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> from gremlin_python.structure.graph import Graph
>>> from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
>>> graph = Graph()
>>> g = graph.traversal().withRemote(DriverRemoteConnection('ws://localhost:8182/gremlin','g'))
>>>
>>>
>>> keyname = 'name'
>>> label = 'user'
>>> k = 0
>>> for _, keyvalue in [(0,'hiep'), (0,'hiep'), (1,'hoi'), (2,'hoera')]:
... if label == 'user':
... try:
... print("Element Exists: {}. ID {}".format(g.V().hasLabel(label).has(keyname+"_{}".format(k), keyvalue).toList(), _))
... except:
... print("No element fount in graph. ID: ", _)
... ret = g.addV(label).property(keyname+"_{}".format(k), keyvalue).next()
... if label == 'user':
... try:
... print("Element Added: {}. ID {}".format(g.V().hasLabel(label).has(keyname+"_{}".format(k), keyvalue).toList(), _))
... except:
... print("Exception! Element couldn't be added. No element fount in graph. ID: ", _)
...
Element Exists: []. ID 0
Element Added: [v[13]]. ID 0
Element Exists: [v[13]]. ID 0
Element Added: [v[13], v[15]]. ID 0
Element Exists: []. ID 1
Element Added: [v[17]]. ID 1
Element Exists: []. ID 2
Element Added: [v[19]]. ID 2
>>>