Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 88563 invoked from network); 29 Mar 2010 23:36:25 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 29 Mar 2010 23:36:25 -0000 Received: (qmail 56373 invoked by uid 500); 29 Mar 2010 23:36:24 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 56309 invoked by uid 500); 29 Mar 2010 23:36:24 -0000 Mailing-List: contact user-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user@couchdb.apache.org Delivered-To: mailing list user@couchdb.apache.org Received: (qmail 56301 invoked by uid 99); 29 Mar 2010 23:36:24 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 Mar 2010 23:36:24 +0000 X-ASF-Spam-Status: No, hits=4.4 required=10.0 tests=FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_PASS,T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of itaborai83@gmail.com designates 209.85.219.221 as permitted sender) Received: from [209.85.219.221] (HELO mail-ew0-f221.google.com) (209.85.219.221) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 29 Mar 2010 23:36:18 +0000 Received: by ewy21 with SMTP id 21so3199338ewy.25 for ; Mon, 29 Mar 2010 16:35:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:received:message-id:subject:from:to:content-type; bh=+YlopQ2j5jCjTadfZH4yjMEQxHKkckJzeoygurr51q8=; b=SjEg4s6K/aGhFwq2QeY7Vr8X5Px1cntGTejGzLE+QTAvgufa9AatJ1ieVAgKl8D7ja RZv5DaBksvLYSRI/dmJEWv9RIHls8nb2QiFiZz3aIPZAA8Na5z6/QzlJNTCSIXPRO1ih BpcXQmKx2rHFpMQKxRC1g0wpuabeepkA1C6vY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; b=LXtFH0yZLkdnLcpN3RJa4Y15GN4Hnb8saM3v2YwInN0ywQsjszf23urJIjzdGprRxA 8wWe46tmiyRYz0bydRdjgFHRm8P1+Ajhuy0c0iGtSyuvAz0TGdzcM7zQOlDh9PU/QgQy bKaoRNSv1ZXEsTtfQLzmsXg+V2atvZLfRjBr0= MIME-Version: 1.0 Received: by 10.213.13.7 with HTTP; Mon, 29 Mar 2010 16:35:56 -0700 (PDT) In-Reply-To: References: <91076E76-9FAB-4590-82E2-9B14563882F0@gmail.com> Date: Mon, 29 Mar 2010 20:35:56 -0300 Received: by 10.213.65.76 with SMTP id h12mr768883ebi.70.1269905756940; Mon, 29 Mar 2010 16:35:56 -0700 (PDT) Message-ID: Subject: Re: Validate uniqueness field From: =?ISO-8859-1?Q?Daniel_Itabora=ED?= To: user@couchdb.apache.org Content-Type: multipart/alternative; boundary=00c09f8a55608a69770482f8f988 --00c09f8a55608a69770482f8f988 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Thanks. I'm such a noobie! Daniel On Mon, Mar 29, 2010 at 7:39 PM, Patrick Barnes wrote: > To nitpick slightly - you won't get a value of zero, you'll just find tha= t > there is no entry for the given key. ;-) > > -Patrick > > On 30/03/2010 3:06 AM, "Daniel Itabora=ED" wrote: > > Distributed uniqueness is a hard problem, but since you intend to use it > only on a single node, perhaps you should create a view for each set of > fields that you intend to be unique in your documents.You would emit the > unique combination of values as the key and the document id as the value. > For the reduce function, you should just count the number of documents th= at > hold that particular key. > > Prior to each PUT or POST on a document, you should query the view to mak= e > sure that no other document has used that specific combination of values > (the reduced value should be 0). Also, after each PUT or POST, you=B4d ha= ve > to > query it again to see if the uniqueness still holds (the reduced value > should be 1). > > If the probability of two or more writers issuing operations that might > violate the uniqueness constraint is low enough, you might be able to get > away with it. This, of course, has a race condition (aside from also bein= g > slow, ugly and discouraged). You would have to periodically handle > uniqueness violations either automatically or manually. > > I think you should ask yourself first what=B4s the worst that could happe= n > when a violation of a uniqueness constraint happens. Sometimes you can ju= st > work around it. > > > regards, > Daniel Itabora=ED > > > On Sun, Mar 28, 2010 at 12:41 AM, faust 1111 wrote: > > > Why too documents? > > Bu... > --00c09f8a55608a69770482f8f988--