Re: [Neo4j] How to delete a node when it's already deleted ?
2010/12/7, Andres Taylor : > On Tue, Dec 7, 2010 at 1:54 PM, Mattias Persson > wrote: > > >> The (new) integrated index API cleans up deleted nodes/relationships that >> are left behind automatically and lazily (at least the lucene impl does) >> so >> no worries for the index part at least. >> > > Unless you are unlucky, and the index points to a node id that's been > reused. In which case you'll get false positives, and very hard to > find/reproduce bugs. I think a more general auto-index solution is needed. > Don't you agree? > Yes, you're right, there's always that risk. Auto-indexing requires a meta model, sort of... I think that's why there isn't a generic auto-indexer already. Sure, there is a meta-model component, but it hasn't received any love in a long time. > Andrés > ___ > Neo4j mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user > -- Mattias Persson, [matt...@neotechnology.com] Hacker, Neo Technology www.neotechnology.com ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
Re: [Neo4j] How to delete a node when it's already deleted ?
On Tue, Dec 7, 2010 at 1:54 PM, Mattias Persson wrote: > The (new) integrated index API cleans up deleted nodes/relationships that > are left behind automatically and lazily (at least the lucene impl does) so > no worries for the index part at least. > Unless you are unlucky, and the index points to a node id that's been reused. In which case you'll get false positives, and very hard to find/reproduce bugs. I think a more general auto-index solution is needed. Don't you agree? Andrés ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
Re: [Neo4j] How to delete a node when it's already deleted ?
I have the same requirements on a project I'm working on. What I did was use an abstract wrapper class for Node that helps with deletion. protected final Node underlyingNode; protected boolean isDeleted; public boolean isDeleted() { return isDeleted; } public void delete() { Iterable rels = this.underlyingNode.getRelationships(); for ( Relationship rel : rels) { rel.delete(); } this.underlyingNode.delete(); this.isDeleted = true; } I agree that it would be nice to have similar functionality right in the API, at least for the forced deletion operation. -Adam ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
Re: [Neo4j] How to delete a node when it's already deleted ?
On Tue, Dec 7, 2010 at 3:09 PM, Andreas Ronge wrote: > An Node#isDeleted() method would also be fine. The way I see it, there are two concerns here. The first is focused at the lower levels, where the WriteTransaction/LockReleaser discover an illegal operation - deletion of an already deleted primitive. This is a hard error and at their level it should throw an exception and of course set the tx to rollback only. This is mainly an engineering decision. The second is the user level where either the same logic should apply or a check should be made first to make sure things don't go downhill. Obviously the current approach is the former. Having just a isDeleted() method is kind of awkward because it would litter the code with if statements and things would be even worse with (checked) exceptions. Maybe stealing a bit off the id would be a better solution and have the NodeImpl/NodeProxy objects do the check internally. BTW, I think that from a user perspective with the current kernel such a wrapper object (with a boolean field possibly) would be the best approach, minimizing the bookkeeping in "business logic" code. What I find more interesting to discuss are the semantics of operations on primitives. At the moment there is no standard to adhere to and in that respect there is a decision to be made. What I mean is: what is the proper thing to do, conceptually, when doing basic primitive manipulations. Since there is an effort to standardize a graph traversal algebra, a similar thing should be done on a data definition level, with rationalization and detailed description of what is the Right Thing (TM) to do when, for instance, one deletes a Node from a graph, regardless of implementation. Obviously my thinking is influenced from the relational model, where there are hard constraints on different things - primary keys are an obvious example here. In that case, the proper thing to do was to make it propagate a hard error all the way up and all implementations do exactly that. In this way, behavior is standardized for all common operations. Should graph databases, beginning with Neo, undergo a similar process? Such an effort would give definite answers to most such problems, for example the "forced"/cascading deletion issue mentioned before. On the other hand, maybe I am overthinking this. cheers, CG ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
Re: [Neo4j] How to delete a node when it's already deleted ?
An Node#isDeleted() method would also be fine. On Tue, Dec 7, 2010 at 1:54 PM, Mattias Persson wrote: > 2010/12/7 Andreas Ronge > >> Hi >> >> I want to avoid keeping track if a node has been deleted or not. >> How can I implemented this ? >> >> I tried to simply catch the exception but then I can't commit the >> transaction. >> >> Node node = db.createNode() >> try { >> node.delete() >> node.delete() >> } catch { } >> tx.success >> tx.finish // BANG - org.neo4j.graphdb.TransactionFailureException: >> Unable to commit transaction >> >> The same applies for deleting relationships. >> > > Maybe it could be allowed to delete a node more than once in the same > transaction... I don't know what drawbacks that would have? > > >> >> Also, it would be great if there was a force parameter on the delete >> method. >> >> I would prefer a boolean if the delete was successful or not instead >> of an Exception >> (same for with node.getSingleRelationship() and maybe other methods) >> >> In saw on the list that other people also have requested a similar >> feature, Alexandru Popescu: >> >2. I was surprised to see a `Node`.delete() failing. The reason was it >> >had relationships. I think adding a method `Node`.delete(boolean >> >force) would >> >make code much easier. The method would automatically: >> > >> >- remove all relationships >> > > This one has been discussed since the dawn of time. It can potentially have > unexpected side effects on your graph by deleting relationships it maybe > wasn't aware of was connected to it. But if that's what (a lot of) people > want then I can't say it shouldn't be there. > > >> >- clean up indexes >> > >> > The (new) integrated index API cleans up deleted nodes/relationships that > are left behind automatically and lazily (at least the lucene impl does) so > no worries for the index part at least. It does so by just slipping in > delete commands for such stray entities into future write transactions. > >> >> /Andreas >> ___ >> Neo4j mailing list >> User@lists.neo4j.org >> https://lists.neo4j.org/mailman/listinfo/user >> > > > > -- > Mattias Persson, [matt...@neotechnology.com] > Hacker, Neo Technology > www.neotechnology.com > ___ > Neo4j mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user > ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
Re: [Neo4j] How to delete a node when it's already deleted ?
2010/12/7 Andreas Ronge > Hi > > I want to avoid keeping track if a node has been deleted or not. > How can I implemented this ? > > I tried to simply catch the exception but then I can't commit the > transaction. > > Node node = db.createNode() > try { >node.delete() >node.delete() > } catch { } > tx.success > tx.finish // BANG - org.neo4j.graphdb.TransactionFailureException: > Unable to commit transaction > > The same applies for deleting relationships. > Maybe it could be allowed to delete a node more than once in the same transaction... I don't know what drawbacks that would have? > > Also, it would be great if there was a force parameter on the delete > method. > > I would prefer a boolean if the delete was successful or not instead > of an Exception > (same for with node.getSingleRelationship() and maybe other methods) > > In saw on the list that other people also have requested a similar > feature, Alexandru Popescu: > >2. I was surprised to see a `Node`.delete() failing. The reason was it > >had relationships. I think adding a method `Node`.delete(boolean > >force) would > >make code much easier. The method would automatically: > > > >- remove all relationships > This one has been discussed since the dawn of time. It can potentially have unexpected side effects on your graph by deleting relationships it maybe wasn't aware of was connected to it. But if that's what (a lot of) people want then I can't say it shouldn't be there. > >- clean up indexes > > > The (new) integrated index API cleans up deleted nodes/relationships that are left behind automatically and lazily (at least the lucene impl does) so no worries for the index part at least. It does so by just slipping in delete commands for such stray entities into future write transactions. > > /Andreas > ___ > Neo4j mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user > -- Mattias Persson, [matt...@neotechnology.com] Hacker, Neo Technology www.neotechnology.com ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user
[Neo4j] How to delete a node when it's already deleted ?
Hi I want to avoid keeping track if a node has been deleted or not. How can I implemented this ? I tried to simply catch the exception but then I can't commit the transaction. Node node = db.createNode() try { node.delete() node.delete() } catch { } tx.success tx.finish // BANG - org.neo4j.graphdb.TransactionFailureException: Unable to commit transaction The same applies for deleting relationships. Also, it would be great if there was a force parameter on the delete method. I would prefer a boolean if the delete was successful or not instead of an Exception (same for with node.getSingleRelationship() and maybe other methods) In saw on the list that other people also have requested a similar feature, Alexandru Popescu: >2. I was surprised to see a `Node`.delete() failing. The reason was it >had relationships. I think adding a method `Node`.delete(boolean >force) would >make code much easier. The method would automatically: > >- remove all relationships >- clean up indexes > /Andreas ___ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user