From couchdb-user-return-1896-apmail-incubator-couchdb-user-archive=incubator.apache.org@incubator.apache.org Sat Nov 15 01:42:11 2008 Return-Path: Delivered-To: apmail-incubator-couchdb-user-archive@locus.apache.org Received: (qmail 40696 invoked from network); 15 Nov 2008 01:42:11 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 15 Nov 2008 01:42:11 -0000 Received: (qmail 87188 invoked by uid 500); 15 Nov 2008 01:42:17 -0000 Delivered-To: apmail-incubator-couchdb-user-archive@incubator.apache.org Received: (qmail 87150 invoked by uid 500); 15 Nov 2008 01:42:17 -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 87139 invoked by uid 99); 15 Nov 2008 01:42:17 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 14 Nov 2008 17:42:17 -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.144 as permitted sender) Received: from [74.125.92.144] (HELO qw-out-1920.google.com) (74.125.92.144) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 15 Nov 2008 01:40:54 +0000 Received: by qw-out-1920.google.com with SMTP id 4so1097675qwk.54 for ; Fri, 14 Nov 2008 17:41:28 -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=20UD6IdoKimda+rK3Hp6udasneGu+DiyokcQzL4A59w=; b=Aj4pwYOKFJI5Oh7uK1n60BeGijp8Ij/keIIlz7U3DjhFFigmf2aIKOLO02k8eET6OZ Pi2QQ0cZKI+cU/hPNlFdeKe/ZEUxUC7pqe+OeZGO7nnO1OVpgKld9kyXLRWWzGILXpBq kOVxSIt0h8XSOkeB1cLNUQvubQ6UeE/7h34Tc= 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=ovwqtgX45UFbPfhq3E2KXnY7l+Pj8F7Zwp/gYM/HxeM5v+Dubqqc/OzZjJIE3Q9zSq 9EHZVwK0Qp1gCNVTFoZaUdChE3z25UmBQlGka3OxcrhF90zuJuEHvkXe6VaaH3CKb/t+ iORI21sgGasWG3/R8etZuU7TDQRBx8cQF1Hcs= Received: by 10.214.11.9 with SMTP id 9mr1618218qak.329.1226713287415; Fri, 14 Nov 2008 17:41:27 -0800 (PST) Received: by 10.214.215.21 with HTTP; Fri, 14 Nov 2008 17:41:27 -0800 (PST) Message-ID: Date: Fri, 14 Nov 2008 20:41:27 -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> <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 On Fri, Nov 14, 2008 at 8:37 PM, Paul Davis wrote: > I wrote a fuzz thing to go along with the diff testing. > > You can get it with: > > $ sudo easy_install jsontools > > # Examples > from StringIO import StringIO > import jsontools > stream = StringIO() > > //Fuzzy objects > fj = jsontools.FuzzyJson() > obj1 = fj.generate(1).next() > obj2 = fj.modify(obj1) > > //Diff the objects > jsontools.jsondiff(obj1, obj2, stream=stream) > > //Apply the diff > stream.seek(0) > result = jsontools.jsonapply(stream, obj1) > > //Compare them > assert jsontools.jsoncmp(result, obj2) == 2 > == True > Any comments? > > Paul > > On Thu, Nov 13, 2008 at 9:34 PM, Paul Davis wrote: >> 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 >>> >> >