X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Fsorter%2Fsorter.h;h=971e6e67b91d9102d837f4aa06ff13afc70ab887;hb=1f1ccf1786a62973de953e3f5c43392ad485770d;hp=d17f4197d89177f22f4be41971ce3f215306323e;hpb=69808c861b8df0745bd0bc93793f558e0055da7e;p=libucw.git diff --git a/lib/sorter/sorter.h b/lib/sorter/sorter.h index d17f4197..971e6e67 100644 --- a/lib/sorter/sorter.h +++ b/lib/sorter/sorter.h @@ -131,6 +131,7 @@ typedef SORT_KEY P(key); #ifdef SORT_INT64 typedef u64 P(hash_t); #define SORT_INT SORT_INT64 +#define SORT_LONG_HASH #else typedef uns P(hash_t); #endif @@ -193,6 +194,11 @@ static inline void P(copy_merged)(P(key) **keys, struct fastbuf **data UNUSED, u } #endif +#if defined(SORT_HASH_BITS) || defined(SORT_INT) +#define SORT_INTERNAL_RADIX +#include "lib/sorter/s-radix.h" +#endif + #if defined(SORT_VAR_KEY) || defined(SORT_VAR_DATA) || defined(SORT_UNIFY_WORKSPACE) #include "lib/sorter/s-internal.h" #else @@ -200,10 +206,7 @@ static inline void P(copy_merged)(P(key) **keys, struct fastbuf **data UNUSED, u #endif #include "lib/sorter/s-twoway.h" - -#if defined(SORT_HASH_BITS) || defined(SORT_INT) -#include "lib/sorter/s-radix.h" -#endif +#include "lib/sorter/s-multiway.h" static struct fastbuf *P(sort)( #ifdef SORT_INPUT_FILE @@ -268,14 +271,12 @@ static struct fastbuf *P(sort)( ctx.internal_sort = P(internal); ctx.internal_estimate = P(internal_estimate); ctx.twoway_merge = P(twoway_merge); + ctx.multiway_merge = P(multiway_merge); sorter_run(&ctx); #ifdef SORT_OUTPUT_FILE - if (rename(ctx.out_fb->name, out) < 0) - die("Cannot rename %s to %s: %m", ctx.out_fb->name, out); - bconfig(ctx.out_fb, BCONFIG_IS_TEMP_FILE, 0); - bclose(ctx.out_fb); + bfix_tmp_file(ctx.out_fb, out); ctx.out_fb = NULL; #endif return ctx.out_fb; @@ -302,6 +303,8 @@ static struct fastbuf *P(sort)( #undef SORT_UNIQUE #undef SORT_ASSERT_UNIQUE #undef SORT_DELETE_INPUT +#undef SORT_INTERNAL_RADIX +#undef SORT_LONG_HASH #undef SWAP #undef LESS #undef P