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

cannot change edge's in/out with @rid #9071

Closed
tolgaulas opened this issue Nov 21, 2019 · 11 comments
Closed

cannot change edge's in/out with @rid #9071

tolgaulas opened this issue Nov 21, 2019 · 11 comments
Assignees

Comments

@tolgaulas
Copy link

OrientDB Version: 3.0.25

Java Version:

OS: Win 2019

Expected behavior

--before--
v1(#1:1) -out- edge1(#2:1) -in->v2(#1:2)
v1(#1:1) -out- edge2(#2:2) -in->v3(#1:3)

--op--
update edge #2:2 in=#1:2

--result--
v1(#1:1) -out- edge1(#2:1) -in->v2(#1:2)
v1(#1:1) -out- edge2(#2:2) -in->v2(#1:2)

Actual behavior

v1(#1:1) -out- edge1(#2:1) -in->v2(#1:2)
v1(#1:1) -out- edge2(#2:2) -in->v3(#1:3)

--op--
update edge #2:2 in=#1:2

--result--
v1(#1:1).out =[]
v2(#1:2).in =[#2:1,#2:2]
v3(#1:3).in=[]
edge2.in = #1:1
edge2.out = #1:2

Steps to reproduce

When I change an edge’s in/out property with @Rid (ie. update edge theEdge in=#12:12) the "out"ing vertex is loosing the link. And the simple traversing queries stop working.
Instead, one have to use the select notation instead of direct rid (i.e update edge theEdge in=(select from #12:12).

Yet, the "out"ing vertex still keeps an empty out_theEdge=[ ], which looks like having no impact in the internal engine, yet it’s disturbing.

@luigidellaquila luigidellaquila self-assigned this Nov 21, 2019
@luigidellaquila
Copy link
Member

Hi @tolgaulas

Thank you for reporting, I'll check it ASAP and let you know

Thanks

Luigi

@luigidellaquila
Copy link
Member

Hi @tolgaulas

I just tried it with the following

create vertex V set name ='a';  /* #9:0 */
create vertex V set name ='b'; /* #10:0 */
create vertex V set name ='c'; /* #11:0 */

create edge E from #9:0 to #10:0  /* #21:0 */

update edge #21:0 set in=#11:0

And it seems to work fine.
Any chance to have a reproducer?

Thanks

Luigi

@tolgaulas
Copy link
Author

Hi, can you run this and see select from V at the end in a blank DB please?


BEGIN;
LET a = DELETE VERTEX v1;
LET a = DELETE VERTEX v2;
LET a = DELETE VERTEX v3;
LET v1_r1 =INSERT INTO v1 set r=1;
LET v1_r2 =INSERT INTO v1 set r=2;

LET v2_r1 =INSERT INTO v2 set r=1;
LET v2_r2 =INSERT INTO v2 set r=2;

LET v3_r1 =INSERT INTO v3 set r=1;
LET v3_r2 =INSERT INTO v3 set r=2;

LET onetwo_oneone = CREATE EDGE one_two from $v1_r1 to $v2_r1;
LET onetwo_twotwo = CREATE EDGE one_two from $v1_r2 to $v2_r2;
LET onetwo_onetwo = CREATE EDGE one_two from $v1_r1 to $v2_r2;
LET onetwo_twoone = CREATE EDGE one_two from $v1_r2 to $v2_r1;

LET twothree_oneone = CREATE EDGE two_three from $v2_r1 to $v3_r1;
LET twothree_twotwo = CREATE EDGE two_three from $v2_r2 to $v3_r2;
LET twothree_onetwo = CREATE EDGE two_three from $v2_r1 to $v3_r2;
LET twothree_twoone = CREATE EDGE two_three from $v2_r2 to $v3_r1;

LET touchOne = update edge E set in=$v2_r1.@rid where @rid in (select unionall(inE()) from $v2_r2.@rid);

COMMIT RETRY 100;

RETURN;

@tolgaulas
Copy link
Author

I made it .toJson() and here is the result: Mind the #60:2.


{"@type":"d","@rid":"#47:2","@version":1,"@class":"v1","r":1,"out_one_two":["#85:2","#87:2"],"@fieldTypes":"out_one_two=g"}
--
{"@type":"d","@rid":"#48:2","@version":1,"@class":"v1","r":2,"out_one_two":["#86:2","#88:2"],"@fieldTypes":"out_one_two=g"}
{"@type":"d","@rid":"#59:2","@version":1,"@class":"v2","r":1,"in_one_two":["#85:2","#88:2","#86:2","#87:2"],"out_two_three":["#97:2","#99:2"],"@fieldTypes":"in_one_two=g,out_two_three=g"}
{"@type":"d","@rid":"#60:2","@version":1,"@class":"v2","r":2,"in_one_two":[],"out_two_three":["#98:2","#100:2"],"@fieldTypes":"in_one_two=g,out_two_three=g"}
{"@type":"d","@rid":"#71:2","@version":1,"@class":"v3","r":1,"in_two_three":["#97:2","#100:2"],"@fieldTypes":"in_two_three=g"}
{"@type":"d","@rid":"#72:2","@version":1,"@class":"v3","r":2,"in_two_three":["#98:2","#99:2"],"@fieldTypes":"in_two_three=g"}


@tolgaulas
Copy link
Author

And I guess, here may be problem:

select *.toJson() from V where in_one_two is not null

#60.2 should not be appeared here.

{"@type":"d","@rid":"#59:2","@version":1,"@class":"v2","r":1,"in_one_two":["#85:2","#88:2","#86:2","#87:2"],"out_two_three":["#97:2","#99:2"],"@fieldTypes":"in_one_two=g,out_two_three=g"}
--
{"@type":"d","@rid":"#60:2","@version":1,"@class":"v2","r":2,"in_one_two":[],"out_two_three":["#98:2","#100:2"],"@fieldTypes":"in_one_two=g,out_two_three=g"}


@luigidellaquila
Copy link
Member

Hi @tolgaulas

Thank you very much.
Ok, so the problem is in a batch script, let me check it, I'll let you know ASAP

Thanks

Luigi

@tolgaulas
Copy link
Author

Not necesarely in batch, here is the before state, the select op and the after state. See #62:2

== BEFORE== 
@version | *.toJson()
-- | --
0 | {"@type":"d","@rid":"#49:1","@version":1,"@class":"v1","r":1,"out_one_two":["#89:2","#91:2"],"@fieldTypes":"out_one_two=g"}
0 | {"@type":"d","@rid":"#50:1","@version":1,"@class":"v1","r":2,"out_one_two":["#90:2","#92:2"],"@fieldTypes":"out_one_two=g"}
0 | {"@type":"d","@rid":"#61:2","@version":1,"@class":"v2","r":1,"in_one_two":["#89:2","#92:2"],"out_two_three":["#101:2","#103:2"],"@fieldTypes":"in_one_two=g,out_two_three=g"}
0 | {"@type":"d","@rid":"#62:2","@version":1,"@class":"v2","r":2,"in_one_two":["#90:2","#91:2"],"out_two_three":["#102:2","#104:2"],"@fieldTypes":"in_one_two=g,out_two_three=g"}
0 | {"@type":"d","@rid":"#73:2","@version":1,"@class":"v3","r":1,"in_two_three":["#101:2","#104:2"],"@fieldTypes":"in_two_three=g"}
0 | {"@type":"d","@rid":"#74:2","@version":1,"@class":"v3","r":2,"in_two_three":["#102:2","#103:2"],"@fieldTypes":"in_two_three=g"}

==OPERATION==
update edge E set in=#61:2 where @rid in (select unionall(inE()) from #62:2);

==RESULT === 

0 | {"@type":"d","@rid":"#49:1","@version":1,"@class":"v1","r":1,"out_one_two":["#89:2","#91:2"],"@fieldTypes":"out_one_two=g"}
-- | --
0 | {"@type":"d","@rid":"#50:1","@version":1,"@class":"v1","r":2,"out_one_two":["#90:2","#92:2"],"@fieldTypes":"out_one_two=g"}
0 | {"@type":"d","@rid":"#61:2","@version":3,"@class":"v2","in_one_two":["#89:2","#92:2","#90:2","#91:2"],"r":1,"out_two_three":["#101:2","#103:2"],"@fieldTypes":"in_one_two=g,out_two_three=g"}
0 | {"@type":"d","@rid":"#62:2","@version":3,"@class":"v2","in_one_two":[],"r":2,"out_two_three":["#102:2","#104:2"],"@fieldTypes":"in_one_two=g,out_two_three=g"}
0 | {"@type":"d","@rid":"#73:2","@version":1,"@class":"v3","r":1,"in_two_three":["#101:2","#104:2"],"@fieldTypes":"in_two_three=g"}
0 | {"@type":"d","@rid":"#74:2","@version":1,"@class":"v3","r":2,"in_two_three":["#102:2","#103:2"],"@fieldTypes":"in_two_three=g"}

@luigidellaquila
Copy link
Member

Hi @tolgaulas

I just tried your script and I see a consistent graph at the end...

Screen Shot 2019-11-28 at 11 44 42

This is the expected behaviour, the update of out and in attributes of an edge also updates the linked vertices to maintain the graph consistent. Am I missing something?

Thanks

Luigi

@tolgaulas
Copy link
Author

Hi @luigidellaquila , the screenshot is correct. The empty array in #58:0's in_one_two may cause problem with "is null" filter operations, doesn't it? If we set the new in with (select from #rid) notation the empty array does not show hence is null fillter operations looks like running fine.

@luigidellaquila
Copy link
Member

Hi @tolgaulas

The empty array won't cause any problems, in general I'd suggest to use graph operators to check if edges exist, (eg. out().size() > 0) and avoid null checks on out_* and in_* attributes

Thanks

Luigi

@tolgaulas
Copy link
Author

tolgaulas commented Nov 28, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants