zendorphins
zendorphins
ATApache TinkerPop
Created by zendorphins on 7/20/2023 in #questions
Modify traversal from outside the function that builds the traversal (Java)
Hi peeps, more of an OOP oriented question this time around. I'll start off by explaining what I'm trying to do first. In my app I have a bunch of tables that can have different types of filters applied to them. To make my life easier on the backend I've made an abstract Filter class which is extended by all the different types of filters, and the model mapper knows which subclass I want from a field sent in the request. A good way to apply the filtering to the traversal would be to have a dsl step that takes the list of filters, checks which instanceof each filter is and does it's stuff accordingly. I wanted to know if there would be any way to keep the logic in the filter classes, overriding the method in each subclass. Perhaps something like generating the steps in the filter and adding them to the admin traversal in the dsl, I'm not sure.
9 replies
ATApache TinkerPop
Created by zendorphins on 4/3/2023 in #questions
Translating bytecode into JupyterLabs compatible script.
I've found that the gremlin syntax in jupyter is different from every other language, including python. For now i've resorted to copying the java PythonTranslator into a new class and modifying the code to suit the differences. Does a better way exist?
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
Did a little bit of debugging and it seems that the issue has to do with a cast to Tree before calling the isLeaf() method inside getLeafTrees(). As far as my testing goes it seems to happen when a child of the root is a leaf. Here's an example dataset and the tree query: Data:
g.addV('node::Dev').as('1').
property(single, 'data', 22).addV('node::Dev').
as('2').
property(single, 'data', 16).addV('root::Dev').
as('3').
property(single, 'data', 9).addV('node::Dev').
as('4').
property(single, 'data', 5).addV('node::Dev').
as('5').
property(single, 'data', 2).addV('node::Dev').
as('6').
property(single, 'data', 11).addV('node::Dev').
as('7').
property(single, 'data', 15).addV('node::Dev').
as('8').
property(single, 'data', 10).addV('node::Dev').
as('9').
property(single, 'data', 1).addV('node::Dev').
as('10').
addE('left').from('1').to('2').addE('left').
from('3').to('4').addE('right').from('3').
to('6').addE('right').from('3').to('10').
addE('left').from('4').to('5').addE('left').
from('5').to('9').addE('left').from('6').
to('8').addE('right').from('6').to('7').
addE('right').from('7').to('1')
g.addV('node::Dev').as('1').
property(single, 'data', 22).addV('node::Dev').
as('2').
property(single, 'data', 16).addV('root::Dev').
as('3').
property(single, 'data', 9).addV('node::Dev').
as('4').
property(single, 'data', 5).addV('node::Dev').
as('5').
property(single, 'data', 2).addV('node::Dev').
as('6').
property(single, 'data', 11).addV('node::Dev').
as('7').
property(single, 'data', 15).addV('node::Dev').
as('8').
property(single, 'data', 10).addV('node::Dev').
as('9').
property(single, 'data', 1).addV('node::Dev').
as('10').
addE('left').from('1').to('2').addE('left').
from('3').to('4').addE('right').from('3').
to('6').addE('right').from('3').to('10').
addE('left').from('4').to('5').addE('left').
from('5').to('9').addE('left').from('6').
to('8').addE('right').from('6').to('7').
addE('right').from('7').to('1')
Query: g.V().hasLabel("Dev").hasLabel("root").emit().until(out().count().is(0)).repeat(out()).tree().by(elementMap()).next() The edge lables are inconsequential, i just modified a binary tree. The elementMap inside the by is also there for debug purposes.
20 replies