В настоящее время я создаю трубу, как показано в строке 2 ниже.
Pipe pipe = Gremlin.compile("_().out('knows').name");
После того, как он был создан, я кэширую его, чтобы его можно было повторно использовать с разными графиками ниже.
Graph graph = TinkerGraphFactory.createTinkerGraph();
pipe.setStarts(new SingleIterator<Vertex>(graph.getVertex(1)));
for(Object name : pipe)
{
System.out.println((String) name);
}
Мне интересно, хорошо ли это? Я спрашиваю, потому что javadoc из AbstractPipe говорит
public void reset()
Description copied from interface: Pipe
A pipe may maintain state. Reset is used to remove state. The general use case for reset() is to reuse a pipe in another computation without having to create a new Pipe object. An implementation of this method should be recursive whereby the starts (if a Pipe) should have this method called on it.
Specified by:
reset in interface Pipe<S,E>