Re: Which qsort is used - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Which qsort is used
Date
Msg-id 19345.1134699867@sss.pgh.pa.us
Whole thread Raw
In response to Re: Which qsort is used  ("Dann Corbit" <DCorbit@connx.com>)
List pgsql-hackers
"Dann Corbit" <DCorbit@connx.com> writes:
> Radix sort can also be made completely generic by using a callback
> function.
> The function gives back n-bits at a time, from the most significant bits
> to the least significant.

That's mighty handwavy --- it assumes that the datatype permits a simple
breakdown into small pieces that can be sorted lexicographically.  Seems
to me that's a much stronger requirement than assuming that you can tell
which of two whole values is smaller.  What's worse, it needs to be the
same number of pieces for every value, which makes it hard to deal with
variable-length data.

> So, for char string, and a radix of 256, you just return the first char,
> then the second char, etc. to get the classical radix sort.

Uh, no, you'd need to work right-to-left, after having padded all the
strings to the same length somehow.
        regards, tom lane


pgsql-hackers by date:

Previous
From: Christopher Kings-Lynne
Date:
Subject: Re: Improving planning of outer joins
Next
From: "Qingqing Zhou"
Date:
Subject: Re: Which qsort is used