2 * UCW Library -- Universal Sorter: Radix-Split Module
4 * (c) 2007 Martin Mares <mj@ucw.cz>
6 * This software may be freely distributed and used according to the terms
7 * of the GNU Lesser General Public License.
12 static void P(radix_split)(struct sort_context *ctx UNUSED, struct sort_bucket *bin, struct sort_bucket **bouts, uns bitpos, uns numbits)
14 uns nbucks = 1 << numbits;
15 uns mask = nbucks - 1;
16 struct fastbuf *in = sbuck_read(bin);
19 struct fastbuf *outs[nbucks];
20 bzero(outs, sizeof(outs));
22 while (P(read_key)(in, &k))
24 P(hash_t) h = P(hash)(&k);
25 uns i = (h >> bitpos) & mask;
26 if (unlikely(!outs[i]))
27 outs[i] = sbuck_write(bouts[i]);
28 P(copy_data)(&k, in, outs[i]);