zendorphins
ATApache TinkerPop
•Created by zendorphins on 7/20/2023 in #questions
Modify traversal from outside the function that builds the traversal (Java)
Yep I was really missing the forest for the trees. Thanks for the response I should've thought about doing it this way, I was a bit thrown off by this stack overflow post. Thought I had to reassign the traversal after adding steps for some reason, which wouldn't have worked for passing by reference. Your implementation works great.
9 replies
ATApache TinkerPop
•Created by zendorphins on 7/20/2023 in #questions
Modify traversal from outside the function that builds the traversal (Java)
I'm a little bit in over my head right now, so if anyone has some documentation for how the dsl and admin traversal does it's magic I'd love to read it. This is the best I could come up with, which seems to not be the right way. While the steps do get added correctly to the main traversal, it seems like the bytecode does not.
9 replies
ATApache TinkerPop
•Created by zendorphins on 7/20/2023 in #questions
Modify traversal from outside the function that builds the traversal (Java)
This seems to be the way forward, but its giving me a class casting error and I can't find a way to turn it back into a GraphTraversal
9 replies
ATApache TinkerPop
•Created by zendorphins on 7/20/2023 in #questions
Modify traversal from outside the function that builds the traversal (Java)
I came up with this for now, though it would've been more flexible if I could have added the filter steps to the current traversal directly instead of giving an anonymous traversal to the filter() step
9 replies
ATApache TinkerPop
•Created by zendorphins on 7/20/2023 in #questions
Modify traversal from outside the function that builds the traversal (Java)
I was wandering if instead of checking what type the filter is, I could implement a method in each filter subclass that would return the steps I need and use that implementation directly in the dsl:
I know it's a pretty bad filtering method to only filter the final project step instead of filtering throughout the traversal, but the filters are the same for SQL queries and efficiency is not a priority currently.
Any suggestions for further reading regarding the implementation of optional filters on queries is definitely appreciated however.
9 replies
ATApache TinkerPop
•Created by zendorphins on 7/20/2023 in #questions
Modify traversal from outside the function that builds the traversal (Java)
I probably wasn't very clear in my intention, let me illustrate it with an example:
Let's say the abstract class is called Filter and I have 2 subclasses, RangeFilter and ExactFilter, that filter some column given by a range of values and an exact value respectively.
If I implement a dsl step like .applyFilters(List<Filter> filters) I believe I would require a for loop with a switch statement that checks what subclass the given Filter is, sort of like a visitor pattern, and return the steps i need for each filter implementation (
filter(__.select(filter.getKey()).is(P.eq(filter.getValue())))
for the exact filter for example):
9 replies
ATApache TinkerPop
•Created by zendorphins on 4/3/2023 in #questions
Translating bytecode into JupyterLabs compatible script.
"int":(int) 1 is also not usable it seems, along with VertexProperty.Cardinality.single
18 replies
ATApache TinkerPop
•Created by zendorphins on 4/3/2023 in #questions
Translating bytecode into JupyterLabs compatible script.
Seems like most of the map parenthesis need to be stripped and non-primitive typecasting like the bigDecimal one is somewhat wrong using new, although I have no clue about the type constraints on neptune or tinkerpop so I can't say that it is a problem
18 replies
ATApache TinkerPop
•Created by zendorphins on 4/3/2023 in #questions
Translating bytecode into JupyterLabs compatible script.
18 replies
ATApache TinkerPop
•Created by zendorphins on 4/3/2023 in #questions
Translating bytecode into JupyterLabs compatible script.
Not sure how good that custom translator is for all of the data types cause I haven't really used most of them but the query works in jupyter. I used logging to prevent any string escaping happening
18 replies
ATApache TinkerPop
•Created by zendorphins on 4/3/2023 in #questions
Translating bytecode into JupyterLabs compatible script.
Driver code:
18 replies
ATApache TinkerPop
•Created by zendorphins on 4/3/2023 in #questions
Translating bytecode into JupyterLabs compatible script.
Translator outputs:
18 replies
ATApache TinkerPop
•Created by zendorphins on 4/3/2023 in #questions
Translating bytecode into JupyterLabs compatible script.
Sure, i'll provide an example tomorrow
18 replies
ATApache TinkerPop
•Created by zendorphins on 4/3/2023 in #questions
Translating bytecode into JupyterLabs compatible script.
Yep i'm using the graph-notebook library as per neptune documentation, forgot to mention it. I'm trying to use a translator to get the query script out of an aws lambda (running with the java gremlin driver) in order to profile and sometimes debug them inside notebooks.
There's certain differences like maps being translated within {} instead of the needed [], the steps not having underscores or boolean values not being capitalised.
The groovy translator isn't a good fit either because of type casting and a lot of parentheses that it can't understand.
Fortunately the translator code is pretty easy to understand - thanks spmallette and Marko - so I made myself a custom one for the time being, although I feel like I'm missing something if i'm the first one to run into this problem.
I know there's a profile step but I don't think it accounts for neptune's optimisations, at least i haven't noticed it in the profiling section of neptune's docs, so i'm profiling queries in jupyter.
18 replies
ATApache TinkerPop
•Created by zendorphins on 3/20/2023 in #questions
Has anyone else encountered "NoSuchElementException" when calling getLeafTrees() on a tree object
Still working on getting some consistency with this error, it really threw me off that the last query suddenly started working the next day. I understood that getLeafTrees() is supposed to retrieve all child subtrees of the root, so if that's the case i wasn't misusing it. I suppose the method is basically those for loops i wrote with an isLeaf() check , but it's too low level for me to completely grasp and debug.
I guess for now this can be considered solved since i've found a work-around, hopefully i'll manage to get a consistent reproducible dataset.
20 replies
ATApache TinkerPop
•Created by zendorphins on 3/20/2023 in #questions
Has anyone else encountered "NoSuchElementException" when calling getLeafTrees() on a tree object
Yeah it's not the isLeaf() method itself, somehow when running getLeafTrees() there end up trees in there that have multiple roots. Maybe i misunderstood what a "leaf tree" is, can't blame myself too much for that since there's no doc. Also found this which seems pretty similar to my issue (https://github.com/JanusGraph/janusgraph/issues/1360)
Here's the code I now use to extract child trees from a root
20 replies
ATApache TinkerPop
•Created by zendorphins on 3/20/2023 in #questions
Has anyone else encountered "NoSuchElementException" when calling getLeafTrees() on a tree object
Unless I'm somehow ending up with malformed trees ofc, i'll have to do more debugging
20 replies
ATApache TinkerPop
•Created by zendorphins on 3/20/2023 in #questions
Has anyone else encountered "NoSuchElementException" when calling getLeafTrees() on a tree object
Perhaps i've misunderstood what a leaf is under this definition, but under the general tree leaf definition it looks a bit wrong
20 replies
ATApache TinkerPop
•Created by zendorphins on 3/20/2023 in #questions
Has anyone else encountered "NoSuchElementException" when calling getLeafTrees() on a tree object
Grasping at straws really, but it seems that the isLeaf() method is not being used correctly inside getLeafTrees() since it only checks the first branch for child nodes instead of checking all of them, thus providing a reason for the inconsistent errors (because the nodes aren't ordered in any way and get sent from the db in an arbitrary order)
20 replies
ATApache TinkerPop
•Created by zendorphins on 3/20/2023 in #questions
Has anyone else encountered "NoSuchElementException" when calling getLeafTrees() on a tree object
20 replies