[
https://issues.apache.org/jira/browse/TINKERPOP-2558?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18146918#comment-18146918
]
ASF GitHub Bot commented on TINKERPOP-2558:
-------------------------------------------
Cole-Greer commented on code in PR #3809:
URL: https://github.com/apache/tinkerpop/pull/3809#discussion_r4619062408
##########
gremlin-core/src/test/java/org/apache/tinkerpop/gremlin/language/translator/GremlinTranslatorTest.java:
##########
@@ -1577,6 +1665,250 @@ public static Collection<Object[]> data() {
"g.inject(new PrimitivePDT(\"Uint32\", \"42\"))",
"g.inject(new PrimitivePDT(\"Uint32\", \"42\"))",
"g.inject(PrimitivePDT('Uint32', '42'))"},
+ // a geometry literal passes through in gremlin-lang with
its keyword and arguments as written and
+ // its arguments separated by ", ", while the JVM
languages read the value back from its WKT and
+ // the non-JVM translators reject it
+ {"g.inject(Geometry(\"POINT(1 2)\"))",
+ null,
+ "g.inject(geometry0)",
Review Comment:
Nit: I think it's noteworthy that the anonymized translator reduces this to
`geometry0` instead of `point0`. I suppose both are valid, I think we could
preserve the narrower type in these cases though.
##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/language/grammar/GenericLiteralVisitor.java:
##########
@@ -588,6 +599,40 @@ public Object visitBinaryLiteral(final
GremlinParser.BinaryLiteralContext ctx) {
}
}
+ /**
+ * Parses a geometry literal into its value, for callers that hold a
context but no
+ * {@link Traversal}, such as the language translators.
+ */
+ public static Geometry parseGeometry(final
GremlinParser.GeometryLiteralContext ctx) {
+ return (Geometry) LITERAL_ONLY_VISITOR.visitGeometryLiteral(ctx);
+ }
Review Comment:
This method, along with `LITERAL_ONLY_VISITOR` is a break in precedent for
the parsers. As I understand it, it's purely meant to support the translators
parse literals, to then translate from a Java object instead of the raw
literals. I think this is a useful concept, but I don't like having it here, as
it leaves translator-only methods in the middle of our gremlin script parser.
It would be easy for people to accidentally misuse this method.
Could we drop this infrastructure from this class, and instead put something
like this into `TranslateVisitor`?
```
protected final GenericLiteralVisitor literalVisitor = new
GremlinAntlrToJava().genericVisitor;
```
The translators could then directly use
`literalVisitor..visitGeometryLiteral()` directly instead of going through this
`parseGeometry`.
##########
gremlin-language/src/main/antlr4/Gremlin.g4:
##########
@@ -1113,6 +1113,11 @@ traversalDT
| K_DAY | K_DT DOT K_DAY
;
+traversalModel
Review Comment:
Nit: I'm not sold on the name `traversalModel`, I keep thinking it has to do
with a `GraphTraversal`, but it's just about geospacial. How about `geoModel`
or `geospacialModel`?
##########
gremlin-core/src/main/java/org/apache/tinkerpop/gremlin/util/GeometryHelper.java:
##########
@@ -41,7 +41,7 @@ private GeometryHelper() {}
* @return the parsed geometry
* @since 4.0.0
*/
- public static Geometry Geometry(final String wktOrEwkt) {
+ public static Geometry geometry(final String wktOrEwkt) {
Review Comment:
Now that I'm seeing the grammar support for geometry coming together, I'm
not sure if there's much value in keeping this helper. It's notable that the
grammar, translators, and docs all seem to prefer direct use of
`Geometry.fromWKT()`, which also works natively in groovy. I think we could
simply leave groovy without this helper and accept Geometry construction as a
minor discrepancy between gremlin-lang and gremlin-groovy. We already have the
lower-case naming discrepancy anyways due to groovy's naming conflicts.
> GEO Spatial APIs
> ----------------
>
> Key: TINKERPOP-2558
> URL: https://issues.apache.org/jira/browse/TINKERPOP-2558
> Project: TinkerPop
> Issue Type: Improvement
> Components: process
> Affects Versions: 3.5.0
> Reporter: Jitesh
> Priority: Major
>
> Provide support for Geo based APIs (predicates, objects, etc)
>
>
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)