From couchdb-user-return-1861-apmail-incubator-couchdb-user-archive=incubator.apache.org@incubator.apache.org Fri Nov 14 02:34:48 2008 Return-Path: Delivered-To: apmail-incubator-couchdb-user-archive@locus.apache.org Received: (qmail 98272 invoked from network); 14 Nov 2008 02:34:48 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 14 Nov 2008 02:34:48 -0000 Received: (qmail 59380 invoked by uid 500); 14 Nov 2008 02:34:54 -0000 Delivered-To: apmail-incubator-couchdb-user-archive@incubator.apache.org Received: (qmail 59349 invoked by uid 500); 14 Nov 2008 02:34:54 -0000 Mailing-List: contact couchdb-user-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: couchdb-user@incubator.apache.org Delivered-To: mailing list couchdb-user@incubator.apache.org Received: (qmail 59338 invoked by uid 99); 14 Nov 2008 02:34:54 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Nov 2008 18:34:54 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of paul.joseph.davis@gmail.com designates 74.125.92.146 as permitted sender) Received: from [74.125.92.146] (HELO qw-out-1920.google.com) (74.125.92.146) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 14 Nov 2008 02:33:31 +0000 Received: by qw-out-1920.google.com with SMTP id 4so828020qwk.54 for ; Thu, 13 Nov 2008 18:34:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=iBdavs26COfzTVP8kAq5GnXq5kSZYeRv41Hp/ERTj+c=; b=UWl9xUT595LS1Plq+IbBCRdwfpkAWS0P6XO/Z7tyuX5BOivPOrQD5NIzNz2Ril3zf2 wHVultTmeyBifluYrj/0GqZzef/qax7vaMLOfv0IE9n06TwsH3WOoi6wyvJNUqXW48CH hp+MHrc+qZyY37lFoYf1hxpJc7I3V67cgxQgE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=oVrz8dDvt+vWgZzgxSckVnPKoZqAlZaoUgKNvigMAysahKWA48CMJn1NERs4p/odZo 1att8JRGmItb5nb9u6xRi9K6tuzVZypVQwIsv/G0T64s6UBC/zp9gkkyBEx1mB/czhWi 7cITREUMPadofe90hdzc9eeewwcUXHbi9djro= Received: by 10.214.11.1 with SMTP id 1mr539491qak.199.1226630054139; Thu, 13 Nov 2008 18:34:14 -0800 (PST) Received: by 10.214.215.21 with HTTP; Thu, 13 Nov 2008 18:34:14 -0800 (PST) Message-ID: Date: Thu, 13 Nov 2008 21:34:14 -0500 From: "Paul Davis" To: couchdb-user@incubator.apache.org Subject: Re: Document Updates In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <403828.36717.qm@web52508.mail.re2.yahoo.com> <99294D7F-4D06-47F9-800B-DB9213D929F4@gmail.com> <20081113220313.GG15315@tumbolia.org> <20081113233718.GI15315@tumbolia.org> <0152683E-F379-46A2-B094-0315E17A407E@gmail.com> <4EB51263-640C-4530-9207-9DFCF076E7D9@gmail.com> <387E7267-6AC4-48FC-A680-65EA21992E9E@gmail.com> X-Virus-Checked: Checked by ClamAV on apache.org I don't think we need canonical JSON. The Spec definitely needs to be disambiguated though. As I see it there are two interpretations: 1. Order of fields matters which means repeated fields are ok 2. Order does not matter which means repeated fields are NOT ok It doesn't matter which is chosen, but one of them must be to make this work. Also, I got bored. So I implemented JSON diff in python for Case #2. http://www.davispj.com/svn/projects/json-diff/json-diff.py I gotta jet, but when I get home in a bit I'm gonna write a JSON fuzz library and then pound the diff thing with it. Not sure if it's obvious or not, but switching from case 2 to 1 is straightforward. Also, my current array diff implementation is kinda whack. And indels screw the rest of the diff, as in, its not so much a diff as a delete rest and add new. Getting this optimal is actually an N^2 runtime algorithm via dynamic programming (smith-waterman style) Also, do note that the erlang parser and python (and i assume ruby is in the python boat) have different behaviors in respect to the 2 cases. Erlang is Case 1, python is case 2. Paul On Thu, Nov 13, 2008 at 8:20 PM, Chris Anderson wrote: > On Thu, Nov 13, 2008 at 5:02 PM, ara.t.howard wrote: >> >> On Nov 13, 2008, at 5:49 PM, Antony Blakey wrote: >> >>> You could use the view mechanism, and attach a "language" attribute, and >>> have this be a general transformation interface, which would indeed be very >>> nice. For efficiency you would want to apply this over sets of documents, >>> and probably in a transactional context like bulk update does now. >>> >>> However... Damien wants something to use in replication, which would mean >>> that javascript would then become a required, rather than an optional part >>> of Couch, because replication would require it (unless you made the >>> replication diff generator pluggable ... but why go there?). The benefit of >>> the declarative diff format is that applying a diff can be done within >>> Couch. >> >> couldn't these queries run in the view server? in fact any mechanism which >> would allow the view server could accomplish this with a protocol between it >> and the db server. basically it's an addition to the map/reduce >> functionality which would alter documents on the fly. >> > > Antony's right the currently replication does not depend on the > availability of the view server. And I think it is smart to avoid that > dependence, when possible. > > Alas, my attempt to bypass all the craziness that is canonical JSON, > has come short of that. Oh wells... > > -- > Chris Anderson > http://jchris.mfdz.com >