Return-Path: X-Original-To: apmail-couchdb-user-archive@www.apache.org Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A405B10FC1 for ; Tue, 8 Apr 2014 15:02:39 +0000 (UTC) Received: (qmail 48572 invoked by uid 500); 8 Apr 2014 15:02:37 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 48525 invoked by uid 500); 8 Apr 2014 15:02:35 -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 48515 invoked by uid 99); 8 Apr 2014 15:02:33 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Apr 2014 15:02:33 +0000 X-ASF-Spam-Status: No, hits=-0.0 required=5.0 tests=RCVD_IN_DNSWL_NONE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of jens@couchbase.com designates 199.193.200.196 as permitted sender) Received: from [199.193.200.196] (HELO hub029-VA-5.exch029.serverdata.net) (199.193.200.196) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 08 Apr 2014 15:02:28 +0000 Received: from [10.0.1.9] (173.228.7.198) by east.exch029.serverdata.net (10.216.105.43) with Microsoft SMTP Server (TLS) id 14.3.174.1; Tue, 8 Apr 2014 08:02:04 -0700 Content-Type: text/plain; charset="windows-1252" MIME-Version: 1.0 (Mac OS X Mail 7.3 \(1877.7\)) Subject: Re: Is the revision field deterministic? From: Jens Alfke In-Reply-To: Date: Tue, 8 Apr 2014 08:01:59 -0700 Content-Transfer-Encoding: quoted-printable Message-ID: References: <3C2D3019-2D5D-492A-8A50-D471010EB870@apache.org> To: X-Mailer: Apple Mail (2.1877.7) X-Virus-Checked: Checked by ClamAV on apache.org On Apr 8, 2014, at 7:31 AM, Daniel Gonzalez = wrote: > Ok, but does mean it is indeed related to the document content, so a > different content would produce a different revision number. Yes. It=92s an MD5 (?) digest computed from the document JSON. > And just curious: what does "the same content mean"? Is a different > re-ordering of the json fields still passing the comparisson check? I hope not[1], since the ordering of keys is undefined/insignificant in = JSON and randomized in many languages/libraries (ones that implement = objects/dictionaries/maps using hash tables.) In many languages simply = reading JSON into memory and then serializing again can re-order the = keys. Even if it doesn=92t (as in Erlang), it can change the escape = sequences used in strings, the number of decimal places used in = non-integers, the presence of whitespace, etc. Couchbase Lite computes rev IDs based on a canonical encoding[2] of the = JSON that will always generate the same result regardless of = serialization differences. It won=92t be the same result arrived at by = CouchDB, though. =97Jens [1] I say =93I hope not=94 because I don=92t actually know the = implementation of this in CouchDB. [2] = https://github.com/couchbase/couchbase-lite-ios/wiki/Signed-Documents#gene= rating-canonical-digests=