Hi Bryce,
I really like what you are trying to achieve here. 
One question:
Instead of having NodeCollection, why not have GraphCollection<T extends 
PropertyContainer>. That way we can have collections of both Relationships and 
Nodes.
Niels

> Date: Fri, 16 Sep 2011 17:37:29 +1200
> From: [email protected]
> To: [email protected]
> Subject: [Neo4j] Neo4j graph collections introduction of NodeCollection       
> interface
> 
> Hi,
> 
> I had mentioned in a previous thread that I was working on introducing a
> NodeCollection interface to remove the dependency from IndexedRelationship
> to SortedTree.  I have an initial cut of this up now in my github repo:
> https://github.com/brycenz/graph-collections
> 
> It would be great to get community feedback on this as I think that having a
> well designed and common NodeCollection interface would help for multiple
> use cases, e.g. sortedTreeNodeCollection.addAll(linkedListNodeCollection)
> doing exactly what you think it would.
> 
> IndexedRelationship now takes a node to index relationships from, a
> relationship type, and a direction, as well as a NodeCollection at creation
> time.  As in the unit tests this then leads to:
> 
> Node indexedNode = graphDb().createNode();
> SortedTree st = new SortedTree( graphDb(), graphDb().createNode(), new
> IdComparator(), true, RelTypes.INDEXED_RELATIONSHIP.name() );
> 
> IndexedRelationship ir = new IndexedRelationship( indexedNode,
> RelTypes.INDEXED_RELATIONSHIP, Direction.OUTGOING, st );
> 
> To create the IndexedRelationship.  To later add nodes to the relationship
> you need to create an instance of IndexedRelationship without the
> NodeCollection:
> 
> IndexedRelationship ir = new IndexedRelationship( indexedNode,
> RelTypes.INDEXED_RELATIONSHIP, Direction.OUTGOING );
> 
> 
> What this means from a NodeCollection implementation point of view is that
> firstly it needs to use the NodeCollection.RelationshipType.VALUE
> relationship to connect from its internal data structure to the nodes being
> added to the collection, and it needs to be able to recreate itself from a
> base node that is passed into a constructor (that only takes the base node).
>  A node collection also needs to store its class name on the base node for
> later construction purposes, as well as any other data required to recreate
> the NodeCollection instance (in the case of SortedTree this is the
> comparator class, the tree name, and whether it is a unique index.
> 
> Niels, you may want to have a good look over SortedTree, I have made a few
> changes to it, mainly around introduction of a base node, and changing of
> the end value relationships.  This could be cleaned up better, but I wanted
> to start with minimal changes.
> 
> Both IndexedRelationship and IndexedRelationshipExpander have no
> dependencies on SortedTree now, and should work with any properly
> implemented NodeCollection.  I will be putting together a paged linked list
> NodeCollection next to try this.
> 
> Some future thoughts for NodeCollection, addition of as many of the
> java.util.Collection methods (e.g. addAll, removeAll, retainAll, contains,
> containsAll) as well as an abstract base NodeCollection to help provide
> non-optimised support for these methods.
> 
> Cheers
> Bryce
> _______________________________________________
> Neo4j mailing list
> [email protected]
> https://lists.neo4j.org/mailman/listinfo/user
                                          
_______________________________________________
Neo4j mailing list
[email protected]
https://lists.neo4j.org/mailman/listinfo/user

Reply via email to