PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ histogram_budget_clamps()

static void histogram_budget_clamps ( void  )
static

Definition at line 54 of file postgis/cunit/cu_tester.c.

55{
56 /* Zero or negative row counts disable histogram construction. */
57 CU_ASSERT_EQUAL(histogram_cell_budget(0.0, 2, 100), 0);
58 CU_ASSERT_EQUAL(histogram_cell_budget(-1.0, 4, 100), 0);
59
60 /* Degenerate dimensionality cannot allocate histogram space. */
61 CU_ASSERT_EQUAL(histogram_cell_budget(1000.0, 0, 100), 0);
62
63 /* Matches the classic pow(attstattarget, ndims) path. */
64 CU_ASSERT_EQUAL(histogram_cell_budget(1e6, 2, 100), 10000);
65 CU_ASSERT_EQUAL(histogram_cell_budget(1e6, 3, 50), 125000);
66
67 /* attstattarget^ndims exceeds ndims * 100000 and must be clamped. */
68 CU_ASSERT_EQUAL(histogram_cell_budget(1e6, 4, 50), 400000);
69
70 /* attstattarget<=0 is normalised to the smallest viable target. */
71 CU_ASSERT_EQUAL(histogram_cell_budget(1e6, 2, 0), 1);
72
73 /* Row clamp shrinks the grid for small relations. */
74 CU_ASSERT_EQUAL(histogram_cell_budget(1.0, 2, 100), 20);
75
76 /* Large tables now preserve the dimensional cap instead of overflowing. */
77 CU_ASSERT_EQUAL(histogram_cell_budget(1.5e8, 2, 100), 10000);
78
79 /* Regression for #5984: huge attstat targets stabilise instead of wrapping. */
80 CU_ASSERT_EQUAL(histogram_cell_budget(5e6, 2, 10000), 200000);
81
82 /* Trigger the INT_MAX guard once both other caps exceed it. */
83 CU_ASSERT_EQUAL(histogram_cell_budget((double)INT_MAX, 50000, INT_MAX), INT_MAX);
84}
static int histogram_cell_budget(double total_rows, int ndims, int attstattarget)

References histogram_cell_budget().

Referenced by main().

Here is the call graph for this function:
Here is the caller graph for this function: