-
Notifications
You must be signed in to change notification settings - Fork 871
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
Can't TRAVERSE through LINKMAP #9099
Comments
Also, I checked a similar use case with a
CREATE CLASS DataValue;
CREATE PROPERTY DataValue.id String;
CREATE PROPERTY DataValue.children LINKLIST DataValue;
LET r1 = INSERT INTO DataValue SET id="r1", children={};
LET r2 = INSERT INTO DataValue SET id="r2", children={};
LET r1c1 = INSERT INTO DataValue SET id="r1c1", children={};
LET r1c2 = INSERT INTO DataValue SET id="r1c2", children={};
LET r1c2c1 = INSERT INTO DataValue SET id="r1c2c1", children={};
LET r1c2c2 = INSERT INTO DataValue SET id="r1c2c2", children={};
LET r2c1 = INSERT INTO DataValue SET id="r2c1", children={};
LET r2c2 = INSERT INTO DataValue SET id="r2c2", children={};
UPDATE DataValue SET children = [$r1c1[0], $r1c2[0]] WHERE id = "r1";
UPDATE DataValue SET children = [$r1c2c1[0], $r1c2c2[0]] WHERE id = "r1c2";
UPDATE DataValue SET children = [$r2c1[0], $r2c2[0]] WHERE id = "r2";
TRAVERSE children FROM (SELECT FROM DataValue WHERE id = "r1"); The traversal now seems to work as I would have expected: {
"result": [
{
"@type": "d",
"@rid": "#33:0",
"@version": 2,
"@class": "DataValue",
"children": [
"#35:0",
"#36:0"
],
"id": "r1",
"@fieldTypes": "children=z"
},
{
"@type": "d",
"@rid": "#36:0",
"@version": 2,
"@class": "DataValue",
"children": [
"#37:0",
"#38:0"
],
"id": "r1c2",
"@fieldTypes": "children=z"
},
{
"@type": "d",
"@rid": "#38:0",
"@version": 1,
"@class": "DataValue",
"children": [
],
"id": "r1c2c2",
"@fieldTypes": "children=z"
},
{
"@type": "d",
"@rid": "#37:0",
"@version": 1,
"@class": "DataValue",
"children": [
],
"id": "r1c2c1",
"@fieldTypes": "children=z"
},
{
"@type": "d",
"@rid": "#35:0",
"@version": 1,
"@class": "DataValue",
"children": [
],
"id": "r1c1",
"@fieldTypes": "children=z"
}
],
"notification": "Query executed in 0.026 sec. Returned 5 record(s)"
} |
Investigating more, it seems like the issue might be in the following class: Line 110 in 3ccd061
private void addNextEntryPoints(Object nextStep, int depth, List<OIdentifiable> path, List<OIdentifiable> stack,
OCommandContext ctx) {
if (nextStep instanceof OIdentifiable) {
addNextEntryPoint(((OIdentifiable) nextStep), depth, path, stack, ctx);
} else if (nextStep instanceof Iterable) {
addNextEntryPoints(((Iterable) nextStep).iterator(), depth, path, stack, ctx);
} else if (nextStep instanceof OResult) {
addNextEntryPoint(((OResult) nextStep), depth, path, stack, ctx);
}
} What gets passed in here is an instance of ORecordLazyMap. This is not an instance of OIdentifiable, Iterable, or OResult. In the case of children being a LINKLIST, then the argument passed in is an ORecordLazyList, which IS an instance of Iterable. So it seems that LINKLIST the elements are iterated over and addes as entry points. The LINKMAP is just being ignored. |
I created a PR for this which may fix the issue. |
A workaround right now for my particular use case seems to be to use the TRAVERSE children.values() FROM (SELECT FROM DataValue WHERE id = "r1"); |
Actually, oddly enough.. using I spent quite some time replicating this more accurately. I suspect this is a separate issue, so I will open one. In the mean time the workaround for me ultimately involved doing this: SELECT FROM (
TRAVERSE children, children.values()
FROM (SELECT FROM DataValue WHERE id = "root")
)
WHERE @class INSTANCEOF "DataValue"; |
Previously a LINKLIST would be TRAVERSED but not a LINK Map. See issue #9099.
@luigidellaquila I think this was released in 3.0.27. I am testing that out tomorrow. If it works as expected, we can close this! |
Hi @mmacfadden, Could you test the last release, can we close this ? Regards |
@tglman I will take a look in the next day or so and report back. |
OrientDB Version: 3.0.26
Java Version: OpenJDK 11
OS: Linux
Expected behavior
Ability to use TRAVERSE in the Document API through a LINKMAP.
Actual behavior
Only the initial entry point node is returned.
Steps to reproduce
TRAVERSE
Only the r1 element is returned.
Is it not possible to TRAVERSE through links in a LINKMAP? I have not gone back and verified, but I thought this was possible in a previous 3.0.X version.
The text was updated successfully, but these errors were encountered: