Or you can use the write locks on nodes to enforce just that. Just grab a write lock prior to reading/writing to it (writing will grab a write lock automatically of course). There's no exposed way of grabbing write locks manually, but removing a non-existent property is a temporary solution. It even solves the indexing problem if you do the index checks/inserts after you've grabbed a write lock on a certain node/relationship that will act as the synchronizer (that way it'll would also work in HA).
2011/6/10 <yougotroo...@gmail.com> > Right, I can leverage that. I could have a ConncurrentSkipListSet<Long> or > something with the nodes unique Id in it. If I add() the nodes unique Id to > the Set and it returns true, I know I can safely add children. If it > returns false then I know another thread beat me to it, and I can requeue > the thread > > On , Rick Bullotta <rick.bullo...@thingworx.com> wrote: > > Not sure it applies, but also remember that the node id itself is > > essentially a "unique key" across the entire set of nodes. > > > > > > > -----Original Message----- > > > From: user-boun...@lists.neo4j.org [mailto:user-boun...@lists.neo4j.org] > > On Behalf Of yougotroo...@gmail.com > > > Sent: Friday, June 10, 2011 3:10 PM > > > To: Neo4j user discussions > > > Subject: Re: [Neo4j] unique indexes > > > > > The only way I know of is to synchronize writes to the DB. This shouldn't > > > be a problem for me actually, even with a cluster, since what I really > > need > > > is for each node with a particular relationship to have a unique "name" > > > property, like how good parents would ensure their children all have > > unique > > > names. I could use terracottta and a concurrent data structure to ensure > > > there is only one thread writing to a particular node at any given time, > > > then I'd be guaranteed that checking for existence would work. > > > > > -Matt > > > > > > > On , Michael Hunger michael.hun...@neotechnology.com> wrote: > > > > Another idea is a merge after the fact, so either in a nightly batch or > > > > during a get operation duplicates are discovered they are merged. > > > > > > > > > > Cheers > > > > > > > > > > Michael > > > > > > > > > > Am 10.06.2011 um 18:55 schrieb Rick Bullotta: > > > > > > > > > > > Good point. Same would apply to relationship-based indexing, I > > suppose. > > > > In our use case, all of the entities that must be unique are maintained > > > > in a domain model that is managed by an in-memory hash, so we can > > enforce > > > > it prior to persistence. > > > > > > > > > > > > > > I suppose that one brute force way would be to synchronize/pipeline > > > > writes that required a unique index so that the situation of > uncommitted > > > > changes on another transaction could not occur. > > > > > > > > > > > > > > -----Original Message----- > > > > > > > From: user-boun...@lists.neo4j.org > > > > [mailto:user-boun...@lists.neo4j.org] On Behalf Of Alexander Smirnov > > > > > > > Sent: Friday, June 10, 2011 12:48 PM > > > > > > > To: Neo4j user discussions > > > > > > > Subject: Re: [Neo4j] unique indexes > > > > > > > > > > > > > > Check befor update could not help there, because Neo4j does not show > > > > > > > uncommited changes to other transactions, so it's possible to store > > > > > > > the same value in concurrent transactions. > > > > > > > I also tried to figure out how to avoid duplicated values in > database. > > > > > > > Seems that it needed some locks on database objects. > > > > > > > Can someone provide an example how to lock database objects properly > ? > > > > > > > > > > > > > > On Fri, Jun 10, 2011 at 8:01 AM, Rick Bullotta > > > > > > > rick.bullo...@thingworx.com> wrote: > > > > > > >> If you need to, you could check the existence of a match prior to > > > > every attempted add/insert/update. > > > > > > >> > > > > > > >> -----Original Message----- > > > > > > >> From: user-boun...@lists.neo4j.org > > > > [mailto:user-boun...@lists.neo4j.org] On Behalf Of Matt C > > > > > > >> Sent: Friday, June 10, 2011 10:25 AM > > > > > > >> To: Neo4j user discussions > > > > > > >> Subject: Re: [Neo4j] unique indexes > > > > > > >> > > > > > > >> An index that would enforce every value added to it be unique. I > > don't > > > > even > > > > > > >> see support for that in Lucene, so, nevermind. Just something I'm > > used > > > > to > > > > > > >> SQL handling for me. > > > > > > >> > > > > > > >> On Fri, Jun 10, 2011 at 1:05 AM, Peter Neubauer > > > > >> peter.neuba...@neotechnology.com> wrote: > > > > > > >> > > > > > > >>> Matt, > > > > > > >>> what do you mean by unique indexes? > > > > > > >>> > > > > > > >>> Cheers, > > > > > > >>> > > > > > > >>> /peter neubauer > > > > > > >>> > > > > > > >>> GTalk: neubauer.peter > > > > > > >>> Skype peter.neubauer > > > > > > >>> Phone +46 704 106975 > > > > > > >>> LinkedIn http://www.linkedin.com/in/neubauer > > > > > > >>> Twitter http://twitter.com/peterneubauer > > > > > > >>> > > > > > > >>> http://www.neo4j.org - Your high performance graph database. > > > > > > >>> http://startupbootcamp.org/ - Ă–resund - Innovation happens HERE. > > > > > > >>> http://www.thoughtmade.com - Scandinavia's coolest Bring-a-Thing > > > > party. > > > > > > >>> > > > > > > >>> > > > > > > >>> > > > > > > >>> On Fri, Jun 10, 2011 at 7:30 AM, Matt C yougotroo...@gmail.com> > > wrote: > > > > > > >>>> Sorry if this is covered somewhere, I couldn't find it in the > > docs. I > > > > > > >>> was > > > > > > >>>> wondering if its possible to create unique indexes with the > > > > > > >>>> LuceneIndexProvider? > > > > > > >>>> > > > > > > >>>> -Matt > > > > > > >>>> _______________________________________________ > > > > > > >>>> 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 > > > > > > >>> > > > > > > >> _______________________________________________ > > > > > > >> 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 > > > > > > >> > > > > > > > > > > > > > > > > > > > > > > > > > > > > -- > > > > > > > _________________ > > > > > > > entia non sunt multiplicanda praeter necessitatem, > > > > > > > (entities should not be multiplied beyond necessity.) > > > > > > > _______________________________________________ > > > > > > > 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 > > > > > > > > > > _______________________________________________ > > > > > > 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 > > > _______________________________________________ > > > 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 > -- 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