return NULL;
struct sort_bucket *out = (struct sort_bucket *) b->n.prev; // Such bucket is guaranteed to exist
- return (out->flags & SBF_FINAL) ? out : NULL;
+ if (!(out->flags & SBF_FINAL))
+ return NULL;
+ ASSERT(out->runs == 1);
+ return out;
}
static void
sorter_stop_timer(ctx, &ctx->total_pre_time);
SORT_XTRACE(((b->flags & SBF_SOURCE) ? 1 : 2), "Sorted in memory");
if (join)
- sbuck_drop(ins[0]);
+ {
+ ASSERT(join->runs == 2);
+ join->runs--;
+ sbuck_drop(ins[0]);
+ }
else
clist_insert_after(&ins[0]->n, list_pos);
sbuck_drop(b);
static uns
sorter_radix_bits(struct sort_context *ctx, struct sort_bucket *b)
{
- if (!b->hash_bits || !ctx->radix_split ||
+ if (!b->hash_bits || b->hash_bits < sorter_min_radix_bits ||
+ !ctx->radix_split ||
(b->flags & SBF_CUSTOM_PRESORT) ||
(sorter_debug & SORT_DEBUG_NO_RADIX))
return 0;
bin->size = ctx->in_size;
bin->hash_bits = ctx->hash_bits;
clist_add_tail(&ctx->bucket_list, &bin->n);
- SORT_XTRACE(2, "Input size: %s", F_BSIZE(bin));
+ SORT_XTRACE(2, "Input size: %s, %d hash bits", F_BSIZE(bin), bin->hash_bits);
// Create bucket for the output
struct sort_bucket *bout = sbuck_new(ctx);