last_item = item;
uns count = last_item - item_array;
- SORT_XTRACE(3, "s-internal: Sorting %d items", count);
+ SORT_XTRACE(3, "s-internal: Sorting %u items", count);
P(array_sort)(count, item_array);
SORT_XTRACE(3, "s-internal: Writing");
#endif
}
#ifdef SORT_UNIFY
- SORT_XTRACE(3, "Merging reduced %d records", merged);
+ SORT_XTRACE(3, "Merging reduced %u records", merged);
#endif
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);
+}