Could not locate method: NeptuneGraphTraversal.values()

98 views
Skip to first unread message

Uche Ozoemena

unread,
Apr 29, 2022, 7:14:25 PM4/29/22
to Gremlin-users
I'm getting this error `Could not locate method: NeptuneGraphTraversal.values()` when running a query using gremlin for aws neptune. The specific query is this:
```javascript
import { process } from 'gremlin';

const { statics, t } = process;

    function getUsers() {
        return await this.query(g =>
            g
                .V()
                .match(
                    statics
                        .as('me')
                        .V(this.id)
                        // .has('user', t.id, this.id)
                        .fold()
                        .coalesce(
                            statics.unfold(),
                            statics.addV('user').property(t.id, this.id)
                        ),
                    statics.as('me').out('followed').out('followed').as('x'),
                    statics.as('x').not(statics.has(t.id, this.id)),
                    statics
                        .as('x')
                        .out('followed')
                        .has(t.id, this.id)
                        .count()
                        .is(0),
                    statics.as('x').in_('skip').has(t.id, this.id).count().is(0)
                )
                .select('x')
                .values(t.id)
                .dedup()
                .sample(3)
                .toList()
        );
    }
```

The error message suggests that neptune's `GraphTraversal` doesn't implement the [`values`](https://tinkerpop.apache.org/javadocs/current/core/org/apache/tinkerpop/gremlin/process/traversal/dsl/graph/GraphTraversal.html#values-java.lang.String...-) method, but I've reviewed the [implementation differences](https://docs.aws.amazon.com/neptune/latest/userguide/access-graph-gremlin-differences.html) and there's no mention of that. What could be the problem? What alternatives can I consider?

Stark Arya

unread,
Apr 30, 2022, 9:35:49 AM4/30/22
to Gremlin-users
You need to dedup x by values(t.id), as  select('x').dedup() is the same, so values(t.id) could de deleted.
Also you can use dedup().by(id) to modulator dedup.

As for the above error:
1. Though I have not used Neptune before, but as a general gremlin-server alibaba-gdb. values accept strings which is just property-key, not-including id or label,demo show as follows:

gremlin> g.V("p2164").valueMap()
==>[birthday:[484185600000],browserUsed:[Chrome],creationDate:[1268208971445],firstName:[Jie],gender:[male],lastName:[Chen],locationIP:[1.1.0.52],normalized_birthday:[19850506],p.id:[2164]]
gremlin> g.V("p2164").values("birthday")
==>484185600000
gremlin> g.V("p2164").values("~id")
gremlin> g.V("p2164").values(T.id)
Script6.groovy: 1: [Static type checking] - Cannot find matching method org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversal#values(org.apache.tinkerpop.gremlin.structure.T). Please check if the declared type is correct and if the method exists.
 @ line 1, column 1.
   g.V("p2164").values(T.id)


2.  Let go deeper to find why?

The kernel of values() step  in gremlin-core is here in Element.java:
/**
 * Get the values of properties as an {@link Iterator}.
*/
public default <V> Iterator<V> values(final String... propertyKeys) {
return IteratorUtils.map(this.<V>properties(propertyKeys), property -> property.value());
}

/**
* Get an {@link Iterator} of properties where the {@code propertyKeys} is meant to be a filter on the available
* keys. If no keys are provide then return all the properties.
*/
public <V> Iterator<? extends Property<V>> properties(final String... propertyKeys);


In TinkerGraph, the standard element include TinkerVertex and TinkerEdge, Let's takeTinkerVertex.java as example and go deeper: 
public <V> Iterator<VertexProperty<V>> properties(final String... propertyKeys) {
...
} else {
 return ((List)this.properties.entrySet().stream().filter((entry) -> {
 return ElementHelper.keyExists((String)entry.getKey(), propertyKeys);
 }).flatMap((entry) -> {
 return ((List)entry.getValue()).stream();
  }).collect(Collectors.toList())).iterator();
}
}

public static boolean keyExists(final String key, final String... providedKeys) {
 if (Graph.Hidden.isHidden(key)) return false;
}

isHidden means ~id, ~label  are not  property key.
Reply all
Reply to author
Forward
0 new messages