Skip to content

adds global configuration key to register gremlin traversal sources#1239

Merged
lvca merged 6 commits intoArcadeData:mainfrom
erickj:traversal-supplier
Sep 14, 2023
Merged

adds global configuration key to register gremlin traversal sources#1239
lvca merged 6 commits intoArcadeData:mainfrom
erickj:traversal-supplier

Conversation

@erickj
Copy link
Contributor

@erickj erickj commented Sep 14, 2023

Allows customizing the gremlin script engines traversal sources. This allows clients of the database to register tinkerpop traversal DSLs or customize the traversal strategies.

Motivation

Using tinkerpop DSLs and customizing traversal strategies.

Related issues

A list of issues either fixed, containing architectural discussions, otherwise relevant
for this Pull Request.

Additional Notes

Anything else we should know when reviewing?

Checklist

  • I have run the build using mvn clean package command (some tests seem flaky, but unrelated)
  • [x ] My unit tests cover both failure and success scenarios

customizing the gremlin script engines traversal sources. This allows
clients of the database to register tinkerpop traversal DSLs or
customize the traversal strategies.
@erickj
Copy link
Contributor Author

erickj commented Sep 14, 2023

@lvca please let me know what you think.

I find tinker pop DSLs to be one of the most useful features of the framework. Additionally, it's nice to have the ability to customize the graph travresal strategies for various reasons.

validates GREMLIN_TRAVERSAL_BINDING entries conform to the expected
Map<String, TraversalSupplier> form.
Copy link
Contributor

@lvca lvca left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @erickj I think it's a cool feature to have integrated. Some questions in my review.

</annotationProcessorPath>
</annotationProcessorPaths>
<annotationProcessors>
<annotationProcessor>org.apache.tinkerpop.gremlin.process.traversal.dsl.GremlinDslProcessor</annotationProcessor>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does the annotation processor do? Does it browse all the jars in the classpath looking for an annotation?

Copy link
Contributor Author

@erickj erickj Sep 14, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it builds the SocialTraversalSource from the SocialTraversalDsl for the tests:

https://tinkerpop.apache.org/docs/current/reference/#gremlin-java-dsl

I'm not familiar very familiar with maven, but I added the tinkerpop-annotation artifact as a test-scoped dependency only. Will that be enough to not affect the release jar? Can I limit the annotationprocessor to just the test?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test only = good.

@lvca lvca self-assigned this Sep 14, 2023
@lvca lvca added the enhancement New feature or request label Sep 14, 2023
@lvca lvca added this to the 23.9.1 milestone Sep 14, 2023
@lvca lvca merged commit a547463 into ArcadeData:main Sep 14, 2023
@lvca
Copy link
Contributor

lvca commented Sep 14, 2023

Perfect now, merged. Thanks!

@erickj it would be awesome if you could add other developers to use the Gremlin DSL. Maybe a paragraph in our docs?
@gramian WDYT?

@erickj
Copy link
Contributor Author

erickj commented Sep 14, 2023

sg, I'll send a pull request on the docs repo in the next couple of days

@lvca
Copy link
Contributor

lvca commented Sep 14, 2023

Thanks

@erickj
Copy link
Contributor Author

erickj commented Sep 15, 2023

@lvca I'm sorry to create extra work on this, but unfortunately I think this needs to get rolled back in its current form and rethought. Currently it is entirely broken in the GremlinLangScriptEngine, which was overlooked in testing.

While working on writing up some documentation for this last night I was inspecting the Tinkerpop sources for the java GremlinLangScriptEngine, and came across a surprising & AFAICT undocumented check, which does not affect the groovy engine. The gremlin lang g4 grammar explicitly defines its TRAVERSAL_ROOT token as the literal 'g'. This is then validated in the GremlinLangeScriptEngine#eval and throws an error if the g graph is not bound.

I went back to verify this and tried adding another test to the GremlinTest make sure to set java as the GREMLIN_ENGINE, sure enough I get this parse error:

Caused by: javax.script.ScriptException: org.apache.tinkerpop.gremlin.language.grammar.GremlinParserException: Failed to interpret Gremlin query: Query parsing failed at line 1, character position at 0, error message : mismatched input 'friends' expecting {EmptyStringLiteral, 'g'}
	at org.apache.tinkerpop.gremlin.jsr223.GremlinLangScriptEngine.eval(GremlinLangScriptEngine.java:116)
	at java.scripting/javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:231)
	at com.arcadedb.gremlin.ArcadeGremlin.executeStatement(ArcadeGremlin.java:215)
	at com.arcadedb.gremlin.ArcadeGremlin.executeStatement(ArcadeGremlin.java:201)
	at com.arcadedb.gremlin.ArcadeGremlin.execute(ArcadeGremlin.java:67)

Worse yet, if I try to just rename the binding to g in the test I have realized that the entire Gremlin.g4 grammar seems to have no support for DSLs at all, as each traveral method is explicitly tokenized in the grammar.

I can't find any info on this issue in the tinkerpop issue tracker or mailing lists, so I'm asking on their answers server to see if there is more info.

I think in the meantime this can:

a.) be rolled back entirely
b.) only allowed for GroovScriptEngine

a.) is probably better IMO

@lvca
Copy link
Contributor

lvca commented Sep 15, 2023

@erickj no worries, glad you caught up before the release. Usually the Gremlin Discord channel is the best way to get help and they are super responsive. You could link this issue (they are familiar with ArcadeDB). For now maybe it's better to rollback waiting for a solution that works in both cases.

@erickj
Copy link
Contributor Author

erickj commented Sep 15, 2023

Just to wrap up on this, I've had a brief conversation w/ Stephen Mallette on the tinkerpop discord about this

https://discord.com/channels/838910279550238720/1152253500705755258

tldr; from his POV, there is no plan to support DSLs in the java interpreter at any point in the near future, and "the two ScriptEngine implementations are not meant to have complete feature parity. " Overall the expectation of DSL usage is to pre-translate the query to bytecode on a client endpoint via something like https://github.com/apache/tinkerpop/blob/master/gremlin-javascript/src/main/javascript/gremlin-javascript/lib/process/translator.js then send the bytecode over HTTP to the server endpoint (aside, personally, I've found this approach too heavyweight in the past as you need to carry around your DSL & Traversals in multiple languages and need a javascript interpreter & HTTP server somewhere in the chain)

In the end this will most likely only ever be supported by the groovy interpreter.

Overall it's a bit disappointing to hear. I'm not sure on your thoughts on the general usefulness of this, but I think for the direction of the arcade project it would be difficult for users to start to understand script engine specific features, and would be too leaky for any user who wasn't well versed in the issue.

@lvca lmkwyt

@lvca
Copy link
Contributor

lvca commented Sep 16, 2023

Thanks for the detailed explanation. So @erickj are you currently using it with the Groovy Gremlin engine? What's your experience with the DSL and ArcadeDB? When do you find useful and when does it work properly?

@erickj
Copy link
Contributor Author

erickj commented Sep 16, 2023

I had been using the DSL prior to switching to ArcadeDB against an embedded tinkergraph where I was evaluating queries against the groovy gremlin engine. When I began testing against arcadedb I had thought I was using the java script engine, however I believe I understand what happened now. The DSL execucution throws a ScriptException, which when the GREMLIN_ENGINE is set to 'auto' gets caught, logs an error at FINE, and falls back to gremlin groovy. Because I never run logs at trace levels this error was hidden.

When it works well is in the graph schema design phase, where I design the indexes and queries in unison so that basic queries use the correct indices. It is also to cut down on boilerplate in queries in general for common or complex (but regular) queries. Finally, it makes queries easier to write overall. Since graph design phase is effectively an encapsulation and representation of a particular domain, keeping the query nomenclature in that same domain is a much more natural way for users to think than trying to map your question back to tinkerpop traversal methods.

Using the DSL on the write side is less effective IMO as the DSL construction becomes more onerous, and I've found using the tinkerpop mutation APIs to be unnecessary when compared to the native Arcadedb mutation APIs. Also, the mutation APIs aren't adhoc like queries are.

I'm currently working on a prototype to try and support the DSL in the GremlinLangScriptEngine which I'll go back and discuss with the tinkerpop devs when/if it actually works.

mergify bot added a commit that referenced this pull request Feb 22, 2026
…js [skip ci]

Bumps [testcontainers](https://github.com/testcontainers/testcontainers-node) from 11.11.0 to 11.12.0.
Release notes

*Sourced from [testcontainers's releases](https://github.com/testcontainers/testcontainers-node/releases).*

> v11.12.0
> --------
>
> Changes
> -------
>
> 🚀 Features
> ----------
>
> * Add SSL support for postgres containers [`@​cristianrgreco`](https://github.com/cristianrgreco) ([#1224](https://redirect.github.com/testcontainers/testcontainers-node/issues/1224))
> * Add Azurite support for HTTPS/OAuth configuration [`@​cristianrgreco`](https://github.com/cristianrgreco) ([#1228](https://redirect.github.com/testcontainers/testcontainers-node/issues/1228))
> * Support preserving UID/GID when copying archives to containers [`@​cristianrgreco`](https://github.com/cristianrgreco) ([#1234](https://redirect.github.com/testcontainers/testcontainers-node/issues/1234))
> * Follow symlinks when copying files into containers [`@​cristianrgreco`](https://github.com/cristianrgreco) ([#1235](https://redirect.github.com/testcontainers/testcontainers-node/issues/1235))
> * Warn when compose wait strategy names don't match containers [`@​cristianrgreco`](https://github.com/cristianrgreco) ([#1232](https://redirect.github.com/testcontainers/testcontainers-node/issues/1232))
> * Add support for GenericContainer security options [`@​cristianrgreco`](https://github.com/cristianrgreco) ([#1226](https://redirect.github.com/testcontainers/testcontainers-node/issues/1226))
>
> 🐛 Bug Fixes
> -----------
>
> * Honor nested .dockerignore exclusions in Docker build context [`@​cristianrgreco`](https://github.com/cristianrgreco) ([#1229](https://redirect.github.com/testcontainers/testcontainers-node/issues/1229))
> * Fallback to new Reaper when reused Reaper is unreachable [`@​cristianrgreco`](https://github.com/cristianrgreco) ([#1233](https://redirect.github.com/testcontainers/testcontainers-node/issues/1233))
>
> 📖 Documentation
> ---------------
>
> * Add AGENTS.md: [#1225](https://redirect.github.com/testcontainers/testcontainers-node/issues/1225)
> * Update AGENTS.md: [#1236](https://redirect.github.com/testcontainers/testcontainers-node/issues/1236), [#1231](https://redirect.github.com/testcontainers/testcontainers-node/issues/1231), [#1227](https://redirect.github.com/testcontainers/testcontainers-node/issues/1227)
>
> 🧹 Maintenance
> -------------
>
> * Restore compose warning test compile after naming simplification [`@​cristianrgreco`](https://github.com/cristianrgreco) ([#1239](https://redirect.github.com/testcontainers/testcontainers-node/issues/1239))
> * Simplify Docker Compose naming to v2-only format [`@​cristianrgreco`](https://github.com/cristianrgreco) ([#1238](https://redirect.github.com/testcontainers/testcontainers-node/issues/1238))
> * Docker event stream test helper matches both `status` and `Action` fields [`@​cristianrgreco`](https://github.com/cristianrgreco) ([#1230](https://redirect.github.com/testcontainers/testcontainers-node/issues/1230))
>
> 📦 Dependency Updates
> --------------------
>
> * Bump dependencies: [#1222](https://redirect.github.com/testcontainers/testcontainers-node/issues/1222), [#1223](https://redirect.github.com/testcontainers/testcontainers-node/issues/1223), [#1220](https://redirect.github.com/testcontainers/testcontainers-node/issues/1220), [#1221](https://redirect.github.com/testcontainers/testcontainers-node/issues/1221), [#1212](https://redirect.github.com/testcontainers/testcontainers-node/issues/1212), [#1211](https://redirect.github.com/testcontainers/testcontainers-node/issues/1211), [#1208](https://redirect.github.com/testcontainers/testcontainers-node/issues/1208), [#1209](https://redirect.github.com/testcontainers/testcontainers-node/issues/1209)
> * Bump mkdocs-material: [#1205](https://redirect.github.com/testcontainers/testcontainers-node/issues/1205)


Commits

* [`0481c58`](testcontainers/testcontainers-node@0481c58) Add SSL support for postgres containers ([#1224](https://redirect.github.com/testcontainers/testcontainers-node/issues/1224))
* [`746f96e`](testcontainers/testcontainers-node@746f96e) Add Azurite support for HTTPS/OAuth configuration ([#1228](https://redirect.github.com/testcontainers/testcontainers-node/issues/1228))
* [`ecd83c8`](testcontainers/testcontainers-node@ecd83c8) Fix stale composeContainerName reference in compose warning test ([#1239](https://redirect.github.com/testcontainers/testcontainers-node/issues/1239))
* [`f1a9a0b`](testcontainers/testcontainers-node@f1a9a0b) Support preserving UID/GID when copying archives to containers ([#1234](https://redirect.github.com/testcontainers/testcontainers-node/issues/1234))
* [`6274827`](testcontainers/testcontainers-node@6274827) Follow symlinks when copying files into containers ([#1235](https://redirect.github.com/testcontainers/testcontainers-node/issues/1235))
* [`5dc5293`](testcontainers/testcontainers-node@5dc5293) Simplify Compose naming to v2-only conventions ([#1238](https://redirect.github.com/testcontainers/testcontainers-node/issues/1238))
* [`975665b`](testcontainers/testcontainers-node@975665b) Honor nested .dockerignore exclusions in Docker build context ([#1229](https://redirect.github.com/testcontainers/testcontainers-node/issues/1229))
* [`d75a4ac`](testcontainers/testcontainers-node@d75a4ac) Fallback to new Reaper when reused one is unreachable ([#1233](https://redirect.github.com/testcontainers/testcontainers-node/issues/1233))
* [`84d0908`](testcontainers/testcontainers-node@84d0908) Warn when compose wait strategy names don't match containers ([#1232](https://redirect.github.com/testcontainers/testcontainers-node/issues/1232))
* [`c608c47`](testcontainers/testcontainers-node@c608c47) Update AGENTS.md ([#1236](https://redirect.github.com/testcontainers/testcontainers-node/issues/1236))
* Additional commits viewable in [compare view](testcontainers/testcontainers-node@v11.11.0...v11.12.0)
  
[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility\_score?dependency-name=testcontainers&package-manager=npm\_and\_yarn&previous-version=11.11.0&new-version=11.12.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
Dependabot commands and options
  
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot show  ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
mergify bot added a commit that referenced this pull request Feb 22, 2026
…studio [skip ci]

[//]: # (dependabot-start)
⚠️ \*\*Dependabot is rebasing this PR\*\* ⚠️
Rebasing might not happen immediately, so don't worry if this takes some time.
Note: if you make any changes to this PR yourself, they will take precedence over the rebase.
---
[//]: # (dependabot-end)
Bumps [testcontainers](https://github.com/testcontainers/testcontainers-node) from 11.11.0 to 11.12.0.
Release notes

*Sourced from [testcontainers's releases](https://github.com/testcontainers/testcontainers-node/releases).*

> v11.12.0
> --------
>
> Changes
> -------
>
> 🚀 Features
> ----------
>
> * Add SSL support for postgres containers [`@​cristianrgreco`](https://github.com/cristianrgreco) ([#1224](https://redirect.github.com/testcontainers/testcontainers-node/issues/1224))
> * Add Azurite support for HTTPS/OAuth configuration [`@​cristianrgreco`](https://github.com/cristianrgreco) ([#1228](https://redirect.github.com/testcontainers/testcontainers-node/issues/1228))
> * Support preserving UID/GID when copying archives to containers [`@​cristianrgreco`](https://github.com/cristianrgreco) ([#1234](https://redirect.github.com/testcontainers/testcontainers-node/issues/1234))
> * Follow symlinks when copying files into containers [`@​cristianrgreco`](https://github.com/cristianrgreco) ([#1235](https://redirect.github.com/testcontainers/testcontainers-node/issues/1235))
> * Warn when compose wait strategy names don't match containers [`@​cristianrgreco`](https://github.com/cristianrgreco) ([#1232](https://redirect.github.com/testcontainers/testcontainers-node/issues/1232))
> * Add support for GenericContainer security options [`@​cristianrgreco`](https://github.com/cristianrgreco) ([#1226](https://redirect.github.com/testcontainers/testcontainers-node/issues/1226))
>
> 🐛 Bug Fixes
> -----------
>
> * Honor nested .dockerignore exclusions in Docker build context [`@​cristianrgreco`](https://github.com/cristianrgreco) ([#1229](https://redirect.github.com/testcontainers/testcontainers-node/issues/1229))
> * Fallback to new Reaper when reused Reaper is unreachable [`@​cristianrgreco`](https://github.com/cristianrgreco) ([#1233](https://redirect.github.com/testcontainers/testcontainers-node/issues/1233))
>
> 📖 Documentation
> ---------------
>
> * Add AGENTS.md: [#1225](https://redirect.github.com/testcontainers/testcontainers-node/issues/1225)
> * Update AGENTS.md: [#1236](https://redirect.github.com/testcontainers/testcontainers-node/issues/1236), [#1231](https://redirect.github.com/testcontainers/testcontainers-node/issues/1231), [#1227](https://redirect.github.com/testcontainers/testcontainers-node/issues/1227)
>
> 🧹 Maintenance
> -------------
>
> * Restore compose warning test compile after naming simplification [`@​cristianrgreco`](https://github.com/cristianrgreco) ([#1239](https://redirect.github.com/testcontainers/testcontainers-node/issues/1239))
> * Simplify Docker Compose naming to v2-only format [`@​cristianrgreco`](https://github.com/cristianrgreco) ([#1238](https://redirect.github.com/testcontainers/testcontainers-node/issues/1238))
> * Docker event stream test helper matches both `status` and `Action` fields [`@​cristianrgreco`](https://github.com/cristianrgreco) ([#1230](https://redirect.github.com/testcontainers/testcontainers-node/issues/1230))
>
> 📦 Dependency Updates
> --------------------
>
> * Bump dependencies: [#1222](https://redirect.github.com/testcontainers/testcontainers-node/issues/1222), [#1223](https://redirect.github.com/testcontainers/testcontainers-node/issues/1223), [#1220](https://redirect.github.com/testcontainers/testcontainers-node/issues/1220), [#1221](https://redirect.github.com/testcontainers/testcontainers-node/issues/1221), [#1212](https://redirect.github.com/testcontainers/testcontainers-node/issues/1212), [#1211](https://redirect.github.com/testcontainers/testcontainers-node/issues/1211), [#1208](https://redirect.github.com/testcontainers/testcontainers-node/issues/1208), [#1209](https://redirect.github.com/testcontainers/testcontainers-node/issues/1209)
> * Bump mkdocs-material: [#1205](https://redirect.github.com/testcontainers/testcontainers-node/issues/1205)


Commits

* [`0481c58`](testcontainers/testcontainers-node@0481c58) Add SSL support for postgres containers ([#1224](https://redirect.github.com/testcontainers/testcontainers-node/issues/1224))
* [`746f96e`](testcontainers/testcontainers-node@746f96e) Add Azurite support for HTTPS/OAuth configuration ([#1228](https://redirect.github.com/testcontainers/testcontainers-node/issues/1228))
* [`ecd83c8`](testcontainers/testcontainers-node@ecd83c8) Fix stale composeContainerName reference in compose warning test ([#1239](https://redirect.github.com/testcontainers/testcontainers-node/issues/1239))
* [`f1a9a0b`](testcontainers/testcontainers-node@f1a9a0b) Support preserving UID/GID when copying archives to containers ([#1234](https://redirect.github.com/testcontainers/testcontainers-node/issues/1234))
* [`6274827`](testcontainers/testcontainers-node@6274827) Follow symlinks when copying files into containers ([#1235](https://redirect.github.com/testcontainers/testcontainers-node/issues/1235))
* [`5dc5293`](testcontainers/testcontainers-node@5dc5293) Simplify Compose naming to v2-only conventions ([#1238](https://redirect.github.com/testcontainers/testcontainers-node/issues/1238))
* [`975665b`](testcontainers/testcontainers-node@975665b) Honor nested .dockerignore exclusions in Docker build context ([#1229](https://redirect.github.com/testcontainers/testcontainers-node/issues/1229))
* [`d75a4ac`](testcontainers/testcontainers-node@d75a4ac) Fallback to new Reaper when reused one is unreachable ([#1233](https://redirect.github.com/testcontainers/testcontainers-node/issues/1233))
* [`84d0908`](testcontainers/testcontainers-node@84d0908) Warn when compose wait strategy names don't match containers ([#1232](https://redirect.github.com/testcontainers/testcontainers-node/issues/1232))
* [`c608c47`](testcontainers/testcontainers-node@c608c47) Update AGENTS.md ([#1236](https://redirect.github.com/testcontainers/testcontainers-node/issues/1236))
* Additional commits viewable in [compare view](testcontainers/testcontainers-node@v11.11.0...v11.12.0)
  
[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility\_score?dependency-name=testcontainers&package-manager=npm\_and\_yarn&previous-version=11.11.0&new-version=11.12.0)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)
Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.
[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)
---
Dependabot commands and options
  
You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot show  ignore conditions` will show all of the ignore conditions of the specified dependency
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants