X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Fsorter%2Fcommon.h;h=3097ea2de2cdf267a75f63ec13264d573ff18cc9;hb=332c927b8301d01c2c2d8f047a091a4396a6bc82;hp=99bc6a5f7e68497bfac047bdfddc010ecbcab6ef;hpb=6652d8d95e5f89eeb4c16163e708583e2f8f9799;p=libucw.git diff --git a/lib/sorter/common.h b/lib/sorter/common.h index 99bc6a5f..3097ea2d 100644 --- a/lib/sorter/common.h +++ b/lib/sorter/common.h @@ -18,12 +18,13 @@ extern uns sorter_debug; extern u64 sorter_bufsize; #define SORT_TRACE(x...) do { if (sorter_trace) log(L_DEBUG, x); } while(0) -#define SORT_XTRACE(x...) do { if (sorter_trace > 1) log(L_DEBUG, x); } while(0) +#define SORT_XTRACE(level, x...) do { if (sorter_trace >= level) log(L_DEBUG, x); } while(0) enum sort_debug { SORT_DEBUG_NO_PRESORT = 1, SORT_DEBUG_NO_JOIN = 2, SORT_DEBUG_KEEP_BUCKETS = 4, + SORT_DEBUG_NO_RADIX = 8, }; struct sort_bucket; @@ -32,6 +33,7 @@ struct sort_context { struct fastbuf *in_fb; struct fastbuf *out_fb; uns hash_bits; + u64 in_size; struct mempool *pool; clist bucket_list; @@ -45,10 +47,15 @@ struct sort_context { // Two-way split/merge: merge up to 2 source buckets to up to 2 destination buckets. // Bucket arrays are NULL-terminated. void (*twoway_merge)(struct sort_context *ctx, struct sort_bucket **ins, struct sort_bucket **outs); + // Radix split according to hash function + void (*radix_split)(struct sort_context *ctx, struct sort_bucket *in, struct sort_bucket **outs, uns bitpos, uns numbits); // State variables of internal_sort void *key_buf; int more_keys; + + // Timing + u64 start_time; }; void sorter_run(struct sort_context *ctx); @@ -91,5 +98,6 @@ sh_off_t sbuck_size(struct sort_bucket *b); struct fastbuf *sbuck_read(struct sort_bucket *b); struct fastbuf *sbuck_write(struct sort_bucket *b); void sbuck_swap_out(struct sort_bucket *b); +void format_size(byte *buf, u64 x); #endif