const struct variable *clabels_example;
struct hmap clabels_values_map;
- union value *clabels_values;
+ struct ctables_value **clabels_values;
size_t n_clabels_values;
enum pivot_axis_type slabels_axis;
const struct ctables_categories *c = t->categories[var_get_dict_index (var)];
for (size_t i = 0; i < t->n_clabels_values; i++)
{
- const union value *value = &t->clabels_values[i];
- const struct ctables_category *cat = ctables_categories_match (c, value, var);
- if (!cat)
- {
- pivot_category_create_leaf (d->root, pivot_value_new_integer (value->f)); /* XXX */
- continue;
- }
+ const struct ctables_value *value = t->clabels_values[i];
+ const struct ctables_category *cat = ctables_categories_match (c, &value->value, var);
+ assert (cat != NULL);
pivot_category_create_leaf (d->root, ctables_category_create_label (
- cat, t->clabels_example, value));
+ cat, t->clabels_example, &value->value));
}
}
const struct variable *var = clabels_nest->vars[clabels_nest->n - 1];
const union value *value = &cell->axes[t->clabels_from_axis].cvs[clabels_nest->n - 1].value;
const struct ctables_value *ctv = ctables_value_find (t, value, var_get_width (var));
-
- printf ("leaf=%d\n", ctv ? ctv->leaf : 0);
- dindexes[n_dindexes++] = ctv ? ctv->leaf : 0; /* XXX */
- //dindexes[n_dindexes++] = 0;
+ assert (ctv != NULL);
+ dindexes[n_dindexes++] = ctv->leaf;
}
for (enum pivot_axis_type a = 0; a < PIVOT_N_AXES; a++)
for (size_t i = 0; i < stack->n; i++)
{
const struct ctables_nest *nest = &stack->nests[i];
- const struct variable *v = nest->vars[nest->n - 1];
- int width = var_get_width (v);
- const union value *value = case_data (c, v);
+ const struct variable *var = nest->vars[nest->n - 1];
+ int width = var_get_width (var);
+ const union value *value = case_data (c, var);
+
+ if (var_is_numeric (var) && value->f == SYSMIS)
+ continue;
+
+ if (!ctables_categories_match (t->categories [var_get_dict_index (var)],
+ value, var))
+ continue;
+
unsigned int hash = value_hash (value, width, 0);
struct ctables_value *clv = ctables_value_find__ (t, value, width, hash);
static int
compare_clabels_values_3way (const void *a_, const void *b_, const void *width_)
{
- const union value *a = a_;
- const union value *b = b_;
+ const struct ctables_value *const *ap = a_;
+ const struct ctables_value *const *bp = b_;
+ const struct ctables_value *a = *ap;
+ const struct ctables_value *b = *bp;
const int *width = width_;
- return value_compare_3way (a, b, *width);
+ return value_compare_3way (&a->value, &b->value, *width);
}
static void
struct ctables_value *clv;
size_t i = 0;
HMAP_FOR_EACH (clv, struct ctables_value, node, &t->clabels_values_map)
- {
- clv->leaf = i;
- t->clabels_values[i] = clv->value;
- i++;
- }
+ t->clabels_values[i++] = clv;
t->n_clabels_values = n;
assert (i == n);
sort (t->clabels_values, n, sizeof *t->clabels_values,
compare_clabels_values_3way, &width);
+
+ for (size_t i = 0; i < n; i++)
+ t->clabels_values[i]->leaf = i;
}
static bool