First, a quick heads up: in this post I am making a distinction between 2
similar terms: Iterator and Iterable.

http://docs.oracle.com/javase/7/docs/api/java/util/Iterator.html <- e.g.
Traversal
http://docs.oracle.com/javase/7/docs/api/java/lang/Iterable.html <- e.g.
Collection

One of the things that I found surprising about Gremlin Server is that when
the response is an Iterable type then the items contained by that Iterable
are returned instead of the Iterable itself. This means that it is
impossible to return a Collection from GremlinServer (without a hack).

For example, if I execute the following via Gremlin Server

'map = [:]; map['foo'] = 'bar'; map['yee'] = 'haw'; map'

...then the response will contain 2 map entry pairs, not the map itself.
The same goes for all Collection types.

This is also a case where the behavior between Gremlin Server and the
GremlinExecutor differs. Meaning, if the previous snippet is executed
directly against GremlinExecutor then the result is a map, not the map's
entries.

Just to be clear, I have no issue with how *Iterator* types are handled,
especially given the nature of how results are streamed from a Traversal.

I'm fishing for feedback here because I know that Rexster and Gremlin
Server have behaved this way for quite some time, and that's not a good
sign for my viewpoint. Nevertheless, I'm wondering if it would be useful to
offer a configuration where Gremlin Server would iterate Iterator types
only.

Thanks,
Bob

Reply via email to