Skip to content
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

Closed
wants to merge 3 commits into from
Closed

Conversation

kellrott
Copy link
Member

@kellrott kellrott commented Feb 3, 2018

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.

Copy link

@buchanae buchanae left a 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()
Copy link

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 {
Copy link

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
Copy link

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?

Copy link
Member Author

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?

Copy link

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
Copy link

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={}):
Copy link

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)

@buchanae
Copy link

buchanae commented Feb 8, 2018

Needs tests.

@kellrott
Copy link
Member Author

@adamstruck refactor and resubmit?

@kellrott
Copy link
Member Author

When this comes back up, it'll be easier to re-write at this point

@kellrott kellrott closed this Jan 15, 2019
@kellrott kellrott deleted the vertex-update branch October 6, 2020 05:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants