Recursive apply-hops (not recurse)
Not plannedIt's not possible to have an apply-hops to hop to a rule where the same rule is used in an other apply hops. I have a case where I need to created a nested list structure based on hits from an apply-hops. The use case is Bouvet's org-map. Each department entity comes with the _id of it's parent, and Bouvet wants a nested structure where Bouvet ASA is at root level. Bouvet ASA has a list called "department", which contains it's three children, Bouvet AS, Bouvet AB and Olavstoppen. Each of these are dictionaries inside Bouvet ASA's department list and contain themselves lists of their sub-departments. On it goes until all the departments in Bouvet is gathered in a nested list hierarchical structure. The problem came up when we needed to construct this nested structure. Optimally, I'd like to start with an apply-hops where I start with Bouvet ASA and from there look for all departments which has Bouvet ASA as it's parent. The equality would look something like ["eq", "_S._id", "gd.parent.ID"]. Inside the rule for the apply-hops (let's call it "foo") I'd like to do an other call to "foo" where I repeat the process until all the apartments has been accounted for. Unfortunately I get a "maximum recursion depth exceeded" error as soon as I, inside "foo" call "foo" again with a new apply-hops. The config under shows an example of the problem.
{
"_id": "test-hops",
"type": "pipe",
"source": {
"type": "dataset",
"dataset": "DEBUG_ekstern-konsulent"
},
"transform": {
"type": "dtl",
"rules": {
"default": [
["copy", "_id"],
["merge",
["apply-hops", "foo", {
"datasets": ["global-case gc"],
"where": ["eq", "_S.$ids", "gc.$ids"]
}]
]
],
"foo": [
["merge",
["apply-hops", "foo", {
"datasets": ["global-case gc"],
"where": ["eq", "_S.$ids", "gc.$ids"]
}]
]
]
}
}
}
The same problem occurs when I use the recuse-tag. It doesn't seem like the max_depth tag works for these situations. I can understand why this functionality would be blocked due to memory issues, but it would be really nice if nice was a usable feature, maybe with a max_depth default or something to avoid endless loops?
-
Official comment
The problem is that the calls to "apply-hops" are recursive. This is not supported and we have no plans to support it. The problem is that we can't know at compile-time the depth of the query. Sesam does support recursion inside individual hops though, so maybe you can flatten the structure using such a hops instead?
Comment actions
Please sign in to leave a comment.
Comments
1 comment