Having just done a blog/wiki/forum prototype using Neo as the backend, I found that it was easier to use a series of traversals driven by domain-specific code than to write/model a single traverser. I also ended up placing the collection of node(s) in an intermediate/wrapper class that also tags the nodes with metadata (retrieved from their properties or properties of nodes they are related to) so that I can sort/filter the collection using the Comparer/Comparator interface(s).
The decision to do it the way we did could be borne more of ignorance of how to best write and utilize traversers, though. -----Original Message----- From: user-boun...@lists.neo4j.org [mailto:user-boun...@lists.neo4j.org] On Behalf Of Robert Hritz Sent: Monday, January 25, 2010 1:29 PM To: user@lists.neo4j.org Subject: [Neo] Traverser customization Hi, I am currently playing around with neo4j for one of my pet projects and it certainly looks like a interesting technology. I have a few questions regarding traversers though. Let's say I'm building a threaded discussion forum. Any node can be root of a tree of 'reaction' relations with other nodes. Now usually, I would want to display the reactions tree depth-first, with descending creation time (newest reactions first), and of course paged. For the depth-first part, we have the DepthFirstTraverser, which is fine. Descending creation time (of the node or relation, doesn't really matter) can be approximated by the 'natural ordering' mentioned in AbstractTraverser.addEndNodesToList(), we only have to reverse the order in which nodes are added to the positions list - I didn't try this yet but shouldn't be a big issue. Of course I could get all the relevant nodes and do the sorting later in the application instead of having to modify the AbstractTraverser but this looks to be far more effective. Now to paging: using StopEvaluator and ReturnableEvaluator, I can get the first N nodes, next N nodes etc.. But if the root node has 100k direct descendants in this relationship and I only want first X of them by the aforementioned ordering, the ReturnableEvaluator will still be called for all 100k traversal positions, which is not effective at all, because I already know that I do not want the last 100k-X, where X is not more than 100. I do understand that StopEvaluator and ReturnableEvaluator are fine for many cases like results filtering, but in the case I would need something like a HardStopEvaluator, which will stop the traverser from adding new positions and/or calling the evaluators after a node. Of course, I can modify the current traverser to fit my needs, but maybe I am missing something or there is a better, faster, more effective way to accomplish this task. Thank you very much for any input. Cheers, Robert Hritz _______________________________________________ Neo mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user _______________________________________________ Neo mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user