Return-Path: Delivered-To: apmail-couchdb-user-archive@www.apache.org Received: (qmail 4694 invoked from network); 31 Mar 2009 23:03:58 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 31 Mar 2009 23:03:58 -0000 Received: (qmail 953 invoked by uid 500); 31 Mar 2009 23:03:57 -0000 Delivered-To: apmail-couchdb-user-archive@couchdb.apache.org Received: (qmail 869 invoked by uid 500); 31 Mar 2009 23:03:57 -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 856 invoked by uid 99); 31 Mar 2009 23:03:57 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 31 Mar 2009 23:03:57 +0000 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.44.28 as permitted sender) Received: from [74.125.44.28] (HELO yx-out-2324.google.com) (74.125.44.28) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 31 Mar 2009 23:03:50 +0000 Received: by yx-out-2324.google.com with SMTP id 8so1697306yxb.5 for ; Tue, 31 Mar 2009 16:03:29 -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:message-id:subject:from:to:content-type :content-transfer-encoding; bh=Pc9UBGpJaFgShYr8d2jjKA2E38THV6ryTWFy6fk/KUs=; b=KsICyeVwx6WQZAGepvabkWMm8KhHvN91rJPpDlX1w4xfsl03XvhdAFOP0SeMF6t0YW G1YNxc+TrNIExX+rTqT/iZgYOC1CqoiXYNzLu1PvAGemNT9xin9G87zuX+AQzdqJaBOc v7/OmGKHRuAZbp7nZsn8dkCdWN9GWs5zrfmW8= 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:content-transfer-encoding; b=FYTXqn+Pna24s99j2B9ivEVRdB4aNDRkLWTFw0ERlvgVK7rnSFIbCHE/XXj+UL7mhQ vlVG2g7PIuKKbloBoPIsUipFAdd1R7wFUpuQ+QjRrDh6zTu9RE1n8SWI+T0D6JWIhD9a nL4tbbGILsgqwLi3+3NyXoFMkN61ixvca3bQM= MIME-Version: 1.0 Received: by 10.100.226.16 with SMTP id y16mr754645ang.129.1238540609825; Tue, 31 Mar 2009 16:03:29 -0700 (PDT) In-Reply-To: <7db9abd30903311550y38c53915h961be45ee762af29@mail.gmail.com> References: <7db9abd30903311550y38c53915h961be45ee762af29@mail.gmail.com> Date: Tue, 31 Mar 2009 19:03:29 -0400 Message-ID: Subject: Re: View collation From: Paul Davis To: user@couchdb.apache.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Checked: Checked by ClamAV on apache.org Kowsik, This is how JSON is sorted by type. For reference the current version looks like this: type_sort(V) when is_atom(V) -> 0; type_sort(V) when is_integer(V) -> 1; type_sort(V) when is_float(V) -> 1; type_sort(V) when is_binary(V) -> 2; type_sort(V) when is_list(V) -> 3; type_sort({V}) when is_list(V) -> 4; type_sort(V) when is_tuple(V) -> 5. This means, that all atoms (null, true, false) sort first, then integers, floats, binaries (strings), lists (arrays), and then {V} when is_list(V) (objects). I'm pretty sure that the last one with V when is_tuple(V) is for making sure couchdb internal structures get sorted last because I don't think its possible for an Erlang representation of JSON to get past the previous line. The {obj, _} code you see is the old version of {V} when is_list(V) because of the changes in the Erlang representation of JSON since 0.8. For reference, {obj, [{<<"key">>, 1}]} became {[{<<"key">>, 1}]} which represents {"key": 1} HTH, Paul Davis On Tue, Mar 31, 2009 at 6:50 PM, kowsik wrote: > I'm working on something that hopefully will help couch newbies. Will > share once it's ready. In the meantime I have a question on view > collation. Looking at couch_view.erl I see the following line: > > type_sort({obj, _}) -> 4; % must come before tuple test below > > OTOH, http://wiki.apache.org/couchdb/View_collation doesn't have a > corresponding entry for this. Since I can't grok erlang just yet, what > does this do? From the looks of it any key that matches this clause > sorts between an array and an object. But what does that key look > like? Some JSON examples will be appreciated. > > Thanks, > > K. >