]> mj.ucw.cz Git - libucw.git/blobdiff - lib/sorter/s-internal.h
Much better decisions on radix sorter parameters.
[libucw.git] / lib / sorter / s-internal.h
index a3c38128a850419e5625905294f1fa53345c524d..05fc7e982475495e2ba83f53a6b11eaa1ecb86ba 100644 (file)
@@ -137,3 +137,16 @@ static int P(internal)(struct sort_context *ctx, struct sort_bucket *bin, struct
 
   return ctx->more_keys;
 }
+
+static u64
+P(internal_estimate)(struct sort_context *ctx, struct sort_bucket *b UNUSED)
+{
+  uns avg;
+#ifdef SORT_VAR_KEY
+  avg = ALIGN_TO(sizeof(P(key))/4, CPU_STRUCT_ALIGN);  // Wild guess...
+#else
+  avg = ALIGN_TO(sizeof(P(key)), CPU_STRUCT_ALIGN);
+#endif
+  // We ignore the data part of records, it probably won't make the estimate much worse
+  return (ctx->big_buf_half_size / (avg + sizeof(P(internal_item_t))) * avg);
+}