gdotv
gdotv
Explore posts from servers
ATApache TinkerPop
Created by gdotv on 1/20/2025 in #questions
Neptune, Gremlin Java & Bindings
i suspect it should be right, even if its admittedly backwards
25 replies
ATApache TinkerPop
Created by gdotv on 1/20/2025 in #questions
Neptune, Gremlin Java & Bindings
I just overwrote the javascript default type translator (instead of groovy) and overrided the method that converts from/to/with to from/to/with_
25 replies
ATApache TinkerPop
Created by gdotv on 1/20/2025 in #questions
Neptune, Gremlin Java & Bindings
I was looking for that in the docs! I tihnk it's close enough, I can actually manually handle these 3 scenarios I think. 4.x will be the proper way of doing this!
25 replies
ATApache TinkerPop
Created by gdotv on 1/20/2025 in #questions
Neptune, Gremlin Java & Bindings
The solution was to simply swap to using the Javascript binding/translator as the syntax is identical as far as i know to Java, without the issue of casts being added to binding values
25 replies
ATApache TinkerPop
Created by gdotv on 1/20/2025 in #questions
Neptune, Gremlin Java & Bindings
Just wanted to add a little PS on this as I've had more time to test it. It turns out using the GroovyTranslator for Bindings was not quite the right approach, as it produced script with explicit casts (e.g. (int) 5) which Neptune was understandably not happy about
25 replies
ATApache TinkerPop
Created by gdotv on 1/20/2025 in #questions
Neptune, Gremlin Java & Bindings
I'll mark this as resolved, as it stands TP has everything I needed to solve this specific problem
25 replies
ATApache TinkerPop
Created by gdotv on 1/20/2025 in #questions
Neptune, Gremlin Java & Bindings
honestly thought the implementation on my side went very easily - I'll likely be using more visitor patterns in the future for the G.V() backend. Right now a lot of the grammar stuff is happening on the frontend but I can picture situations where backend parsing could be interesting too
25 replies
ATApache TinkerPop
Created by gdotv on 1/20/2025 in #questions
Neptune, Gremlin Java & Bindings
(just putting the information out there for anyone else who might find this useful, however unlikely it is!)
25 replies
ATApache TinkerPop
Created by gdotv on 1/20/2025 in #questions
Neptune, Gremlin Java & Bindings
I'm assuming converting to a graphTraversal is the right approach here, as opposed to Bytecode. I've created a really simple visitor that extends the BaseGremlinVisitor and just extracts the terminalStep's text via
visitTraversalTerminalMethod
visitTraversalTerminalMethod
so that I can easily swap it in and out during the translation process
25 replies
ATApache TinkerPop
Created by gdotv on 1/20/2025 in #questions
Neptune, Gremlin Java & Bindings
So just to confirm, that worked. I do have a bit more work to do here as queries are submitted with terminal steps which won't translate to a graphTraversal but it's a good start, for reference, this is what I've got:
try {
GraphTraversalSource g = AnonymousTraversalSource.traversal()
.withEmbedded(EmptyGraph.instance());
ConcurrentBindings b = new ConcurrentBindings();
b.putIfAbsent("g", g);
parameters.keySet().forEach(k -> {
b.putIfAbsent(k, parameters.get(k));
});
// Cheating a bit here, TODO implement terminal step detection and extraction to allow parsing to graphtraversal
String queryNoTerminalStep = query.replaceFirst(".toList\\(\\)", "");
GremlinLangScriptEngine glse = new GremlinLangScriptEngine();
GraphTraversal traversal = (GraphTraversal) glse.eval(queryNoTerminalStep, b);
query = GroovyTranslator.of(databaseConfiguration.getGraphTraversalSourceName() != null ? databaseConfiguration.getGraphTraversalSourceName() : "g",
new BindingsToGroovyTypeTranslator(false)).translate(traversal).getScript() + ".toList()";
} catch (ScriptException e) {
// TODO might need to handle that somehow
e.printStackTrace();
}
try {
GraphTraversalSource g = AnonymousTraversalSource.traversal()
.withEmbedded(EmptyGraph.instance());
ConcurrentBindings b = new ConcurrentBindings();
b.putIfAbsent("g", g);
parameters.keySet().forEach(k -> {
b.putIfAbsent(k, parameters.get(k));
});
// Cheating a bit here, TODO implement terminal step detection and extraction to allow parsing to graphtraversal
String queryNoTerminalStep = query.replaceFirst(".toList\\(\\)", "");
GremlinLangScriptEngine glse = new GremlinLangScriptEngine();
GraphTraversal traversal = (GraphTraversal) glse.eval(queryNoTerminalStep, b);
query = GroovyTranslator.of(databaseConfiguration.getGraphTraversalSourceName() != null ? databaseConfiguration.getGraphTraversalSourceName() : "g",
new BindingsToGroovyTypeTranslator(false)).translate(traversal).getScript() + ".toList()";
} catch (ScriptException e) {
// TODO might need to handle that somehow
e.printStackTrace();
}
25 replies
ATApache TinkerPop
Created by gdotv on 1/20/2025 in #questions
Neptune, Gremlin Java & Bindings
I'll have a look, thanks! I was wondering if I could somehow use the Translator classes and either the Java or GroovyTranslator!
25 replies
ATApache TinkerPop
Created by gdotv on 1/20/2025 in #questions
Neptune, Gremlin Java & Bindings
I'm always going to be stuck having to support "old" and "new" versions of database engines, particularly with Neptune where I have quite a few users. I'm generally having to take lowest common denominator approaches that ensure support across the board. I think deriving the code in GremlinLang to achieve what I need just for Neptune will actually do the trick. Even if it's not standard the important part is it works and is secure - I usually have to do little tweaks here and there for different database providers based on their limitations so it's nothing new for me!
25 replies
ATApache TinkerPop
Created by gdotv on 1/20/2025 in #questions
Neptune, Gremlin Java & Bindings
I'll start off by testing that - im guessing the safest handling for me is to ensure that any string valued parameter is escaped with StringEscapeUtils.escapeJava which I'm seeing tinkerpop does behind the scenes
25 replies
ATApache TinkerPop
Created by gdotv on 1/20/2025 in #questions
Neptune, Gremlin Java & Bindings
That function might actually be all I need here - for Neptune specifically, when sending queries, I can preprocess the query by replacing what would be the bindings to their actual value and submit the query with peace of mind that the parameter values have been sanitized properly
25 replies
ATApache TinkerPop
Created by gdotv on 1/20/2025 in #questions
Neptune, Gremlin Java & Bindings
there's potentially going to be some challenges in adopting TP4.0 in G.V() though I haven't looked into it for a while. I am noticing (for the first time) https://github.com/apache/tinkerpop/blob/master/gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/process/traversal/GremlinLang.java#L220 which kinda looks like it would do the trick for me as I expect it would allow me to "string replace" parameter names with properly parsed and sanitized values for the corresponding parameters
25 replies
JJanusGraph
Created by rpuga on 1/6/2025 in #questions
Graph does not support the provided graph computer: SparkGraphComputer
Hey, glad to hear, thanks for confirming. I'm gonna keep a note of this for my own testing 😁. Let me know if you need another trial of G.V() (or your current one extended) if your trial ran out while you were figuring this out.
7 replies
JJanusGraph
Created by rpuga on 12/18/2024 in #questions
Running OLAP queries on Janusgraph outside the Gremlin Console (from Java and G.V())
Hopefully this provides more context - maybe folks on the JanusGraph team can provide some more information on how to expose a graph traversal source from a spark computed job
8 replies
JJanusGraph
Created by rpuga on 12/18/2024 in #questions
Running OLAP queries on Janusgraph outside the Gremlin Console (from Java and G.V())
Hey, good question! G.V() isn't designed to run against embedded graphs as it will attempt to connect to a graph database via the Gremlin driver. In your case I believe you would need to expose a graph traversal source to your in memory graph on your server. G.V() is kind of a console replacement and not at the same time as it only allows running scripts or queries against the server, and does not include the more advanced console plug ins such as hadoop
8 replies
ATApache TinkerPop
Created by gdotv on 10/17/2024 in #questions
Is there a way to specify a query execution timeout via the GremlinLangScriptEngine?
that makes perfect sense, I think for my use case it's acceptable to just not offer the ability to timeout queries for in-memory graphs
5 replies
ATApache TinkerPop
Created by Max on 9/28/2024 in #questions
Best practices for local development with Neptune.
There's https://docs.localstack.cloud/user-guide/aws/neptune/ if you're looking for a quick solution that emulates the Neptune querying API.
11 replies