dictionary: Introduce SPLIT_NONE for dictionaries without split variables.
authorBen Pfaff <blp@cs.stanford.edu>
Sat, 6 Aug 2022 17:55:12 +0000 (10:55 -0700)
committerBen Pfaff <blp@cs.stanford.edu>
Sun, 28 Aug 2022 21:22:19 +0000 (14:22 -0700)
This also implements dict_get_split_type(), which previously had a
prototype but no implementation.

src/data/dictionary.c
src/data/dictionary.h

index 5fae9cf07685e1e25d1df44d9780e2c9465dedf3..66cb956f1dc6d1dfa6284fe5bcc9d601e110d2b3 100644 (file)
@@ -259,7 +259,7 @@ dict_create (const char *encoding)
     .names_must_be_ids = true,
     .name_map = HMAP_INITIALIZER (d->name_map),
     .attributes = ATTRSET_INITIALIZER (d->attributes),
-    .split_type = SPLIT_LAYERED,
+    .split_type = SPLIT_NONE,
     .ref_cnt = 1,
   };
 
@@ -393,7 +393,7 @@ dict_set_split_vars__ (struct dictionary *d,
   assert (n == 0 || split != NULL);
 
   d->n_splits = n;
-  d->split_type = type;
+  d->split_type = type == SPLIT_NONE ? SPLIT_LAYERED : type;
   if (n > 0)
    {
     d->split = xnrealloc (d->split, n, sizeof *d->split) ;
@@ -413,6 +413,12 @@ dict_set_split_vars__ (struct dictionary *d,
     }
 }
 
+enum split_type
+dict_get_split_type (const struct dictionary *d)
+{
+  return d->split_type;
+}
+
 /* Sets N split vars SPLIT in dictionary D. */
 void
 dict_set_split_vars (struct dictionary *d,
@@ -425,7 +431,7 @@ dict_set_split_vars (struct dictionary *d,
 void
 dict_clear_split_vars (struct dictionary *d)
 {
-  dict_set_split_vars (d, NULL, 0, SPLIT_LAYERED);
+  dict_set_split_vars (d, NULL, 0, SPLIT_NONE);
 }
 \f
 
@@ -623,7 +629,7 @@ dict_clear__ (struct dictionary *d, bool skip_callbacks)
   invalidate_proto (d);
   hmap_clear (&d->name_map);
   d->next_value_idx = 0;
-  dict_set_split_vars__ (d, NULL, 0, SPLIT_LAYERED, skip_callbacks);
+  dict_set_split_vars__ (d, NULL, 0, SPLIT_NONE, skip_callbacks);
 
   if (skip_callbacks)
     {
index abc00062f198033f80555fe3fd0a229413af6a75..e9e203add068f1971cbd745fbd35f0c7ac1a8a8c 100644 (file)
@@ -125,9 +125,12 @@ void dict_compact_values (struct dictionary *);
 struct caseproto *dict_get_compacted_proto (const struct dictionary *,
                                             unsigned int exclude_classes);
 
-/* SPLIT FILE variables. */
+/* SPLIT FILE variables.
+
+   SPLIT_NONE is used if and only if there are no split file variables. */
 enum split_type
   {
+    SPLIT_NONE,                 /* No split file variables. */
     SPLIT_SEPARATE,             /* Produce separate output for each split. */
     SPLIT_LAYERED,              /* Output splits in same table.  */
   };