Return-Path: Delivered-To: apmail-incubator-couchdb-user-archive@locus.apache.org Received: (qmail 82320 invoked from network); 5 Oct 2008 19:37:32 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 5 Oct 2008 19:37:32 -0000 Received: (qmail 63479 invoked by uid 500); 5 Oct 2008 19:37:30 -0000 Delivered-To: apmail-incubator-couchdb-user-archive@incubator.apache.org Received: (qmail 63445 invoked by uid 500); 5 Oct 2008 19:37:29 -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 63434 invoked by uid 99); 5 Oct 2008 19:37:29 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 05 Oct 2008 12:37:29 -0700 X-ASF-Spam-Status: No, hits=3.3 required=10.0 tests=DNS_FROM_SECURITYSAGE,HTML_MESSAGE,SPF_NEUTRAL X-Spam-Check-By: apache.org Received-SPF: neutral (athena.apache.org: local policy) Received: from [72.14.220.157] (HELO fg-out-1718.google.com) (72.14.220.157) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 05 Oct 2008 19:36:24 +0000 Received: by fg-out-1718.google.com with SMTP id l26so1708500fgb.26 for ; Sun, 05 Oct 2008 12:36:40 -0700 (PDT) Received: by 10.187.185.8 with SMTP id m8mr871119fap.93.1223235400022; Sun, 05 Oct 2008 12:36:40 -0700 (PDT) Received: by 10.187.179.6 with HTTP; Sun, 5 Oct 2008 12:36:39 -0700 (PDT) Message-ID: Date: Sun, 5 Oct 2008 20:36:39 +0100 From: "Nick Johnson" To: couchdb-user@incubator.apache.org Subject: Re: Sorting views with composite keys In-Reply-To: <60FF2718-50A6-4909-BEA2-B9B5E8F74533@apache.org> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_28866_29702321.1223235400008" References: <27d8d0930810051135j7f736c87g4b48bdbf3c86dedd@mail.gmail.com> <60FF2718-50A6-4909-BEA2-B9B5E8F74533@apache.org> X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_28866_29702321.1223235400008 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On Sun, Oct 5, 2008 at 8:21 PM, Jan Lehnardt wrote: > In my defense :) > > My suggestion was a 3 minute hack that was done without > much thinking. If we want to go that route, we'd need to > add more sorting handlers for other data types. this could > go into a view-JS standard library (like sum()). > > the use-case was just having the sorting by first and second key, > but only ever query on the first one. Well, potentially someone might limit based on the second key too, but I have no issue with preprocessing queries in the same manner. > > > I'm not claiming that this is a stellar idea, only one that might > be feasible for a specific use case. Indeed. I'm concerned about the overhead of converting a string into an array of integers, though. Instinct tells me it may be worse than taking the bitwise negation of the string and encoding that as a hex string, though. > > > Cheers > Jan > -- > > > On Oct 5, 2008, at 20:48 , Chris Anderson wrote: > > yeah you'd have to preprocess the keys with a similar function.. >> >> I think the use case is that you'd query based on the front key, and a >> count, so as to get, say the last 10 alphabetical tags for a given >> user. >> >> Come to think of it, I'm not sure what sense there is in doing this. >> Why not just use a regular collation, and if you have more per >> front-key than you can fit in ram, just page through the front key's >> second key in reverse... >> >> >> On Sun, Oct 5, 2008 at 11:35 AM, Ayende Rahien wrote: >> >>> How does querying those works?I mean, the keys wouldn't match, would >>> they? >>> >>> On Sun, Oct 5, 2008 at 8:26 PM, Chris Anderson >>> wrote: >>> >>> Jan posted this to the IRC channel. >>>> >>>> http://friendpaste.com/rc9CcxUW >>>> >>>> I supposed you'd have to write a reverse method for each JS primitive >>>> type, if you wanted to be completely flexible. >>>> >>>> >>>> On Sun, Oct 5, 2008 at 9:25 AM, Nick Johnson >>>> wrote: >>>> >>>>> How would I construct a view with two keys, a and b, sorted first by a >>>>> ascending, then by b descending? Composite keys are easy enough to >>>>> >>>> generate, >>>> >>>>> but the key [a,b] would only permit sorting both in ascending order (or >>>>> >>>> both >>>> >>>>> in descending order, if we scan in reverse). Can anyone suggest a way >>>>> of >>>>> modifying the keys to support heterogenous sort orders like this? My >>>>> best >>>>> idea so far is a monstrosity involving hex-encoded binary data. :) >>>>> >>>>> >>>> >>>> >>>> -- >>>> Chris Anderson >>>> http://jchris.mfdz.com >>>> >>>> >>> >> >> >> -- >> Chris Anderson >> http://jchris.mfdz.com >> >> > ------=_Part_28866_29702321.1223235400008--