]> mj.ucw.cz Git - libucw.git/blobdiff - lib/sorter/govern.c
Fixed a typo.
[libucw.git] / lib / sorter / govern.c
index 9f525e60c67c22b695328d873ba43cf0fa711306..6b4dc696ca06de80d4bce4e3c6067f99133fa647 100644 (file)
@@ -62,7 +62,10 @@ sbuck_join_to(struct sort_bucket *b)
     return NULL;
 
   struct sort_bucket *out = (struct sort_bucket *) b->n.prev;  // Such bucket is guaranteed to exist
     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
 }
 
 static void
@@ -107,7 +110,11 @@ sorter_twoway(struct sort_context *ctx, struct sort_bucket *b)
          sorter_stop_timer(ctx, &ctx->total_pre_time);
          SORT_XTRACE(((b->flags & SBF_SOURCE) ? 1 : 2), "Sorted in memory");
          if (join)
          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);
          else
            clist_insert_after(&ins[0]->n, list_pos);
          sbuck_drop(b);
@@ -173,7 +180,8 @@ sorter_twoway(struct sort_context *ctx, struct sort_bucket *b)
 static uns
 sorter_radix_bits(struct sort_context *ctx, struct sort_bucket *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;
       (b->flags & SBF_CUSTOM_PRESORT) ||
       (sorter_debug & SORT_DEBUG_NO_RADIX))
     return 0;
@@ -243,7 +251,7 @@ sorter_run(struct sort_context *ctx)
   bin->size = ctx->in_size;
   bin->hash_bits = ctx->hash_bits;
   clist_add_tail(&ctx->bucket_list, &bin->n);
   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);
 
   // Create bucket for the output
   struct sort_bucket *bout = sbuck_new(ctx);