-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding update option to graph edit methods #45
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I recommend we live without this. I suspect updating brings a bunch of complexity that we're not thinking through, such as merging nested fields. In my experience so far, get + put is plenty fast.
|
||
def test_update(O): | ||
errors = [] | ||
#print O.query().addV("vertex1").property("field1", {"test" : 1, "value" : False}).render() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to commit commented code.
if elem.Update { | ||
o := server.engine.GetVertex(elem.Graph, id) | ||
if o != nil { | ||
for k, v := range o.Data.Fields { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's possible that o.Data
is nil, which would panic.
if o != nil { | ||
for k, v := range o.Data.Fields { | ||
if _, ok := elem.Vertex.Data.Fields[k]; !ok { | ||
elem.Vertex.Data.Fields[k] = v |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These wouldn't recursively update fields, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, merging only occurs at the top level.
Suggested behavior?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess that's ok. Please add some comments in the python library and proto description to describe that behavior.
url = self.url + "/" + self.name + "/vertex" | ||
if update: | ||
url += "?update=true" | ||
print url |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the debug line.
Also, why is this using a URL parameter? Shouldn't it be part of the request document?
response = urllib2.urlopen(request) | ||
result = response.read() | ||
return json.loads(result) | ||
|
||
def updateVertex(self, id, label, prop={}): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing corresponding updateEdge and addEdge(update=True)
Needs tests. |
@adamstruck refactor and resubmit? |
When this comes back up, it'll be easier to re-write at this point |
Now, when doing an AddVertex or AddEdge, there is a
update
option that will check to see if the gid exists, and merges fields from the data struct before replacing in the graph. Only fields not in the new message are merged in.