Hi Jer, there is one more operation that is necessary to support and which introduces the need for the previous pointer: Delete. Deletion requires resetting pointers so the consistency of the chain is maintained.
Now, you're going to think that to delete you must already have retrieved the relationship, which means you can simply keep in memory the previous relationship while traversing and if the current is deleted, simply retrieve the previous and patch the chain. That would work beautifully. But. There is always a but. That's not the only delete operation supported. You can also retrieve a relationship by id. And delete that. You can see where this is going. If you retrieve a relationship by id and delete it, you of course still need to patch the chain. To do that, you need to know the previous relationship so you can reset its next pointer. You could do that by reading the start and end nodes, traverse their chains until you reach the relationship-to-delete, keep in memory the last accessed relationship and delete like described above. Or you can store the previous pointer in the record. O(N) vs O(1) Disk is cheap. That's all there is to it, really. To compare, you can look at the code for the structure and management of DynamicRecord (for example, DynamicStringStore). There we never delete by id, only by traversal. And in that case, the list is singly linked, exactly for the reasons you described. Hope it makes sense, CG -- You received this message because you are subscribed to the Google Groups "Neo4j" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
