User Defined Steps for orientDB Handlers (Server Plugins)

OrientDB has Handlers (Server Plugins). Handlers allow writing custom functions. For example, there is a step union in Gremlin. In OrientDB, I can write my own function called customUnion using the handlers. Question: How can I call the custom function of OrientDB (or step of Gremlin) in the Gremlin console? Also, I am using the Gremlin Java API, so I need to call the custom function customUnion in Gremlin Java API. I have created the same question on OrientDB: https://github.com/orientechnologies/orientdb/issues/10003 It seems I need to configure the Gremlin server somehow to use my customUnion function(step), and then I can write my custom traversals in Java to use it in the Java API. However, I cannot find any tutorial for this in TinkerPop3 or orientDB
GitHub
Handlers (Server Plugins) and Gremlin · Issue #10003 · orientechnol...
Handler (Server Plugin) is the best solution for the feature, but it seems I cannot use my custom function (handler) in the Gremlin query. Is it really a limitation of Gremlin, or is there any way ...
2 Replies
spmallette
spmallette11mo ago
If i understand correctly, you have OrientDB running in Gremlin Server and you connect with the gremlin-driver (which you referred to as the Java API). Under this model, there is no way to call functions outside of those of the Gremlin language. When you use the "Java API" in this remote fashion you are sending Gremlin bytecode to the server and it can only encode Gremlin steps to that bytecode. In recent times we've added a call() step to Gremlin which would conceivably allow a graph like OrientDB to expose custom functions like those you are referring ot through it. So you could do something like g.V().call('customUnion') but I imagine OrientDB hasn't made use of that yet. The only way you could access these sorts of provider specific features would be by sending scripts instead of bytecode to the server. With scripts which are basically just Groovy code, anything you could do in Java would be possible from a remote context. As I write this I had an interesting thought actually. with lambdas enabled on the server you could probably do a poor-man's call() wity bytecode by doing something like:
g.V().flatMap{Lambda.function("customUnion(it)")}
g.V().flatMap{Lambda.function("customUnion(it)")}
I'm not sure how "customUnion" works so i've made up the argument in the example above but perhaps that could be a workaround for you. that Lambda forces the bytecode traversal to be executed as Groovy so you still get the benefit of using the "Java API" from the client-side (but not the server-side).
yasuro
yasuro11mo ago
Thanks a lot @spmallette. I got it. I will try 'g.V().call('customUnion')', but as you said, perhaps it is not supported in OrientDB yet. Other solutions look like a hack and so i don't want to use it. Do you mind if I post your answer on github in above issue? Or you can do it yourself. I just want to record you answer.
Want results from more Discord servers?
Add your server
More Posts
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 tHow can I write a project using an inject that doesn't exhaust itself?Take the following example query: g.inject("1", "2", "3").project("list").by(__.inject("b").fold()ReadOnlyStrategy for remote script execution to make a read only server instanceHi all, I am setting up a read only cluster of gremlin server, I have conifgured the initialization Pass label to coalesceWhen I want to pass a label to a `coalesce` step I get follwoing error: ``` "addE(occupied) failed Can I use a query to export data in the form of a query?In the SQL world you can use SQL Developer to generate INSERT statements from the results of a queryGremlin query to give response for 1 and 2 hops at same timeI have a graph setup with certain type of vertices like: inputFiles, outputFiles, convertors conveConnect and work with JGHi Guys. I'm looking for assistance with connecting to a JanusGraph database using Angular and TypeSAdd Multiple addV() by one IterateHello guys, I have crazy question which needs some experts to help me. I am using C# to add many nodMetricRegistry DocumentationIs there documentation anywhere on the metrics provided by the `MetricRegistry` and what their meaniHow do I enable Dynamic Graphs while using the default Docker image `janusgraph/janusgraph:latest`?With the following configuration settings and using the default `g` alias I can work with gremlin/Ja