[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Pspp-cvs] pspp/src/data ChangeLog dictionary.c dictionary...
From: |
Ben Pfaff |
Subject: |
[Pspp-cvs] pspp/src/data ChangeLog dictionary.c dictionary... |
Date: |
Sat, 06 May 2006 22:37:30 +0000 |
CVSROOT: /cvsroot/pspp
Module name: pspp
Branch:
Changes by: Ben Pfaff <address@hidden> 06/05/06 22:37:30
Modified files:
src/data : ChangeLog dictionary.c dictionary.h procedure.c
scratch-writer.c sys-file-writer.c
Log message:
Make dictionary compacting functions a little more general.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/data/ChangeLog.diff?tr1=1.37&tr2=1.38&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/data/dictionary.c.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/data/dictionary.h.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/data/procedure.c.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/data/scratch-writer.c.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/pspp/pspp/src/data/sys-file-writer.c.diff?tr1=1.8&tr2=1.9&r1=text&r2=text
Patches:
Index: pspp/src/data/ChangeLog
diff -u pspp/src/data/ChangeLog:1.37 pspp/src/data/ChangeLog:1.38
--- pspp/src/data/ChangeLog:1.37 Sat May 6 21:26:48 2006
+++ pspp/src/data/ChangeLog Sat May 6 22:37:30 2006
@@ -1,3 +1,19 @@
+Sat May 6 15:36:59 2006 Ben Pfaff <address@hidden>
+
+ Make dictionary compacting functions a little more general.
+
+ * sys-file-writer.c (sfm_open_writer): Use
+ dict_compacting_would_change().
+ (does_dict_need_translation) Removed.
+
+Sat May 6 15:35:42 2006 Ben Pfaff <address@hidden>
+
+ Make dictionary compacting functions a little more general.
+
+ * dictionary.c (dict_needs_compaction): Rename
+ dict_compacting_would_shrink(). Update all callers.
+ (dict_compacting_would_change) New function.
+
Sat May 6 14:25:49 2006 Ben Pfaff <address@hidden>
* sys-file-writer.c: (does_dict_need_translation) Fix bug:
Index: pspp/src/data/dictionary.c
diff -u pspp/src/data/dictionary.c:1.10 pspp/src/data/dictionary.c:1.11
--- pspp/src/data/dictionary.c:1.10 Thu May 4 06:19:02 2006
+++ pspp/src/data/dictionary.c Sat May 6 22:37:30 2006
@@ -855,19 +855,44 @@
}
/* Returns true if a case for dictionary D would be smaller after
- compaction, false otherwise. Compacting a case eliminates
+ compacting, false otherwise. Compacting a case eliminates
"holes" between values and after the last value. Holes are
created by deleting variables (or by scratch variables).
The return value may differ from whether compacting a case
- from dictionary D would *change* the case: compaction could
+ from dictionary D would *change* the case: compacting could
rearrange values even if it didn't reduce space
requirements. */
bool
-dict_needs_compaction (const struct dictionary *d)
+dict_compacting_would_shrink (const struct dictionary *d)
{
return dict_get_compacted_value_cnt (d) < dict_get_next_value_idx (d);
}
+
+/* Returns true if a case for dictionary D would be smaller after
+ compacting, false otherwise. Compacting a case eliminates
+ "holes" between values and after the last value. Holes are
+ created by deleting variables (or by scratch variables).
+
+ The return value may differ from whether compacting a case
+ from dictionary D would *shrink* the case: compacting could
+ rearrange values without reducing space requirements. */
+bool
+dict_compacting_would_change (const struct dictionary *d)
+{
+ size_t case_idx;
+ size_t i;
+
+ case_idx = 0;
+ for (i = 0; i < dict_get_var_cnt (d); i++)
+ {
+ struct variable *v = dict_get_var (d, i);
+ if (v->fv != case_idx)
+ return true;
+ case_idx += v->nv;
+ }
+ return false;
+}
/* How to copy a contiguous range of values between cases. */
struct copy_map
Index: pspp/src/data/dictionary.h
diff -u pspp/src/data/dictionary.h:1.2 pspp/src/data/dictionary.h:1.3
--- pspp/src/data/dictionary.h:1.2 Mon May 1 22:46:31 2006
+++ pspp/src/data/dictionary.h Sat May 6 22:37:30 2006
@@ -83,7 +83,8 @@
void dict_compact_values (struct dictionary *);
size_t dict_get_compacted_value_cnt (const struct dictionary *);
int *dict_get_compacted_idx_to_fv (const struct dictionary *);
-bool dict_needs_compaction (const struct dictionary *);
+bool dict_compacting_would_shrink (const struct dictionary *);
+bool dict_compacting_would_change (const struct dictionary *);
struct dict_compactor *dict_make_compactor (const struct dictionary *);
void dict_compactor_compact (const struct dict_compactor *,
Index: pspp/src/data/procedure.c
diff -u pspp/src/data/procedure.c:1.7 pspp/src/data/procedure.c:1.8
--- pspp/src/data/procedure.c:1.7 Sat May 6 20:39:47 2006
+++ pspp/src/data/procedure.c Sat May 6 22:37:30 2006
@@ -47,7 +47,7 @@
struct ccase trns_case; /* Case used for transformations. */
struct ccase sink_case; /* Case written to sink, if
- compaction is necessary. */
+ compacting is necessary. */
size_t cases_written; /* Cases output so far. */
};
@@ -281,8 +281,8 @@
if (permanent_dict == NULL)
permanent_dict = default_dict;
- /* Figure out compaction. */
- compactor = (dict_needs_compaction (permanent_dict)
+ /* Figure out whether to compact. */
+ compactor = (dict_compacting_would_shrink (permanent_dict)
? dict_make_compactor (permanent_dict)
: NULL);
@@ -411,7 +411,7 @@
/* Dictionary from before TEMPORARY becomes permanent. */
proc_cancel_temporary_transformations ();
- /* Finish compaction. */
+ /* Finish compacting. */
if (compactor != NULL)
{
dict_compactor_destroy (compactor);
Index: pspp/src/data/scratch-writer.c
diff -u pspp/src/data/scratch-writer.c:1.1 pspp/src/data/scratch-writer.c:1.2
--- pspp/src/data/scratch-writer.c:1.1 Sat Mar 4 01:11:57 2006
+++ pspp/src/data/scratch-writer.c Sat May 6 22:37:30 2006
@@ -61,7 +61,7 @@
/* Copy the dictionary and compact if needed. */
scratch_dict = dict_clone (dictionary);
- if (dict_needs_compaction (scratch_dict))
+ if (dict_compacting_would_shrink (scratch_dict))
{
compactor = dict_make_compactor (scratch_dict);
dict_compact_values (scratch_dict);
Index: pspp/src/data/sys-file-writer.c
diff -u pspp/src/data/sys-file-writer.c:1.8 pspp/src/data/sys-file-writer.c:1.9
--- pspp/src/data/sys-file-writer.c:1.8 Sat May 6 21:26:48 2006
+++ pspp/src/data/sys-file-writer.c Sat May 6 22:37:30 2006
@@ -103,7 +103,6 @@
const struct dictionary *dict);
static void write_documents (struct sfm_writer *, const struct dictionary *);
-static int does_dict_need_translation (const struct dictionary *);
static inline int
var_flt64_cnt (const struct variable *v)
@@ -194,7 +193,7 @@
w->fh = fh;
w->file = fdopen (fd, "w");
- w->needs_translation = does_dict_need_translation (d);
+ w->needs_translation = dict_compacting_would_change (d);
w->compress = opts.compress;
w->case_cnt = 0;
w->flt64_cnt = 0;
@@ -328,27 +327,6 @@
goto error;
}
-/* Returns zero if dictionary D's cases are ordered in the
- natural manner, with the first variable followed by the
- second, and so on,
- nonzero otherwise. */
-static int
-does_dict_need_translation (const struct dictionary *d)
-{
- size_t case_idx;
- size_t i;
-
- case_idx = 0;
- for (i = 0; i < dict_get_var_cnt (d); i++)
- {
- struct variable *v = dict_get_var (d, i);
- if (v->fv != case_idx)
- return 1;
- case_idx += v->nv;
- }
- return 0;
-}
-
/* Returns value of X truncated to two least-significant digits. */
static int
rerange (int x)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Pspp-cvs] pspp/src/data ChangeLog dictionary.c dictionary...,
Ben Pfaff <=