X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Fsorter%2Fs-fixint.h;h=d901a064d34d4881a8393835b90e652b81f37335;hb=c0544008a494710146ac6cf88b61b5fd2d46f51b;hp=67fd17d06a7568dcbf85d5bcdffc8a81d861f114;hpb=ff6fce257ce09477b27d9cd9e624ce0692e536b1;p=libucw.git diff --git a/lib/sorter/s-fixint.h b/lib/sorter/s-fixint.h index 67fd17d0..d901a064 100644 --- a/lib/sorter/s-fixint.h +++ b/lib/sorter/s-fixint.h @@ -11,10 +11,14 @@ #define ASORT_PREFIX(x) SORT_PREFIX(array_##x) #define ASORT_KEY_TYPE P(key) -#define ASORT_ELT(i) ary[i] #define ASORT_LT(x,y) (P(compare)(&(x), &(y)) < 0) -#define ASORT_EXTRA_ARGS , P(key) *ary -#include "lib/arraysort.h" +#ifdef SORT_INTERNAL_RADIX +# define ASORT_HASH(x) P(hash)(&(x)) +# ifdef SORT_LONG_HASH +# define ASORT_LONG_HASH +# endif +#endif +#include "lib/sorter/array.h" /* * This is a more efficient implementation of the internal sorter, @@ -31,7 +35,7 @@ static size_t P(internal_workspace)(void) #ifdef SORT_UNIFY workspace = sizeof(P(key) *); #endif -#if 0 // FIXME: Workspace for radix-sort if needed +#ifdef SORT_INTERNAL_RADIX workspace = MAX(workspace, sizeof(P(key))); #endif return workspace; @@ -54,7 +58,7 @@ static int P(internal)(struct sort_context *ctx, struct sort_bucket *bin, struct P(key) *buf = ctx->big_buf; uns maxkeys = P(internal_num_keys)(ctx); - SORT_XTRACE(4, "s-fixint: Reading (maxkeys=%u)", maxkeys); + SORT_XTRACE(4, "s-fixint: Reading (maxkeys=%u, hash_bits=%d)", maxkeys, bin->hash_bits); uns n = 0; while (n < maxkeys && P(read_key)(in, &buf[n])) n++; @@ -68,7 +72,13 @@ static int P(internal)(struct sort_context *ctx, struct sort_bucket *bin, struct stk_fsize(n * P(internal_workspace)())); timestamp_t timer; init_timer(&timer); - P(array_sort)(n, buf); + buf = P(array_sort)(buf, n, +#ifdef SORT_INTERNAL_RADIX + workspace, bin->hash_bits +#else + NULL, 0 +#endif + ); ctx->total_int_time += get_timer(&timer); SORT_XTRACE(4, "s-fixint: Writing");