? Syntax1.sps
? diffs
? libtool
? my_lazy.patch
? pspp.jnl
? src/language/stats/glm.c
? src/language/tests/check-model.c
? src/ui/gui/.libs
? src/ui/gui/libpsppire.la
? src/ui/gui/src_ui_gui_libpsppire_la-glade-register.lo
? tests/libpspp/abt-test
? tests/libpspp/bt-test
? tests/libpspp/heap-test
? tests/libpspp/range-map-test
? tests/libpspp/range-set-test
? tests/libpspp/sparse-array-test
? tests/libpspp/tower-test
Index: src/data/automake.mk
===================================================================
RCS file: /sources/pspp/pspp/src/data/automake.mk,v
retrieving revision 1.28
diff -b -w -U 3 -r1.28 automake.mk
--- src/data/automake.mk 13 Aug 2007 04:13:48 -0000 1.28
+++ src/data/automake.mk 15 Sep 2007 05:46:56 -0000
@@ -50,6 +50,8 @@
src/data/format.def \
src/data/identifier.c \
src/data/identifier.h \
+ src/data/lazy-casereader.c \
+ src/data/lazy-casereader.h \
src/data/missing-values.c \
src/data/missing-values.h \
src/data/make-file.c \
Index: src/data/casereader-provider.h
===================================================================
RCS file: /sources/pspp/pspp/src/data/casereader-provider.h,v
retrieving revision 1.4
diff -b -w -U 3 -r1.4 casereader-provider.h
--- src/data/casereader-provider.h 7 Jul 2007 06:14:07 -0000 1.4
+++ src/data/casereader-provider.h 15 Sep 2007 05:46:56 -0000
@@ -156,4 +156,18 @@
casereader_create_random (size_t value_cnt, casenumber case_cnt,
const struct casereader_random_class *, void *aux);
+/* A casereader. */
+struct casereader
+ {
+ unsigned long serial;
+ struct taint *taint; /* Corrupted? */
+ size_t value_cnt; /* Values per case. */
+ casenumber case_cnt; /* Number of cases,
+ CASENUMBER_MAX if unknown. */
+ const struct casereader_class *class; /* Class. */
+ void *aux; /* Auxiliary data for class. */
+ };
+
+
+
#endif /* data/casereader-provider.h */
Index: src/data/casereader.c
===================================================================
RCS file: /sources/pspp/pspp/src/data/casereader.c,v
retrieving revision 1.6
diff -b -w -U 3 -r1.6 casereader.c
--- src/data/casereader.c 13 Aug 2007 00:43:48 -0000 1.6
+++ src/data/casereader.c 15 Sep 2007 05:46:57 -0000
@@ -30,15 +30,12 @@
#include "xalloc.h"
-/* A casereader. */
-struct casereader
+static unsigned long next_serial = 0;
+
+unsigned long
+casereader_serial (const struct casereader *r)
{
- struct taint *taint; /* Corrupted? */
- size_t value_cnt; /* Values per case. */
- casenumber case_cnt; /* Number of cases,
- CASENUMBER_MAX if unknown. */
- const struct casereader_class *class; /* Class. */
- void *aux; /* Auxiliary data for class. */
+ return r->serial;
};
static void insert_shim (struct casereader *);
@@ -80,6 +77,8 @@
bool ok = true;
if (reader != NULL)
{
+ printf ("Destroying reader %ld\n", reader->serial);
+
reader->class->destroy (reader, reader->aux);
ok = taint_destroy (reader->taint);
free (reader);
@@ -309,6 +308,8 @@
reader->case_cnt = case_cnt;
reader->class = class;
reader->aux = aux;
+ reader->serial = next_serial++;
+ printf ("Created reader %ld\n", reader->serial);
return reader;
}
Index: src/data/casereader.h
===================================================================
RCS file: /sources/pspp/pspp/src/data/casereader.h,v
retrieving revision 1.5
diff -b -w -U 3 -r1.5 casereader.h
--- src/data/casereader.h 12 Sep 2007 13:43:50 -0000 1.5
+++ src/data/casereader.h 15 Sep 2007 05:46:57 -0000
@@ -59,6 +59,8 @@
struct casereader;
struct casewriter;
+unsigned long casereader_serial (const struct casereader *);
+
bool casereader_read (struct casereader *, struct ccase *);
bool casereader_destroy (struct casereader *);
Index: src/data/lazy-casereader.c
===================================================================
RCS file: src/data/lazy-casereader.c
diff -N src/data/lazy-casereader.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/data/lazy-casereader.c 15 Sep 2007 05:46:57 -0000
@@ -0,0 +1,153 @@
+/* PSPP - a program for statistical analysis.
+ Copyright (C) 2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see . */
+
+#include
+
+#include
+
+#include
+
+#include
+#include
+#include
+#include
+
+#include "xalloc.h"
+
+/* A lazy casereader's auxiliary data. */
+struct lazy_casereader
+ {
+ struct casereader parent;
+
+ /* Callback for instantiation. */
+ struct casereader *(*callback) (void *aux);
+ void *aux;
+
+ /* Each of these has an important role in its own right, but
+ they also serve as reference counts. A struct lazy_status
+ has two owners: lazy_casereader_create's client and
+ a casereader. It can only be destroyed when both of those
+ clients no longer need it, in other words, when both of
+ these members are true. */
+ bool instantiated; /* Called the callback? */
+ bool destroyed; /* lazy_status_destroy called? */
+ };
+
+static struct casereader_class lazy_casereader_class;
+
+/* Creates and returns a new lazy casereader that will
+ instantiate its underlying casereader, if necessary, by
+ calling CALLBACK, passing AUX as its argument. *LS is set to
+ a newly allocated struct lazy_status that may be passed to
+ lazy_status_destroy when the lazy casereader is no longer
+ needed.
+
+ VALUE_CNT must be the number of struct values per case read
+ from the casereader.
+
+ CASE_CNT is an upper limit on the number of cases that
+ casereader_read will return from the casereader in successive
+ calls. Ordinarily, this is the actual number of cases in the
+ data source or CASENUMBER_MAX if the number of cases cannot be
+ predicted in advance. */
+struct casereader *
+lazy_casereader_create (size_t value_cnt, casenumber case_cnt,
+ struct casereader *(*callback) (void *aux), void *aux)
+{
+ struct lazy_casereader *lcr = (struct lazy_casereader* )
+ casereader_create_sequential (NULL, value_cnt, case_cnt,
+ &lazy_casereader_class, NULL);
+
+ lcr = realloc (lcr, sizeof (struct lazy_casereader));
+
+ lcr->callback = callback;
+ lcr->aux = aux;
+ lcr->instantiated = false;
+ lcr->destroyed = false;
+
+ return (struct casereader *) lcr;
+}
+
+
+
+/* Instantiates lazy casereader READER, which is associated with
+ LS. */
+static void
+instantiate_lazy_casereader (struct casereader *reader)
+{
+ struct lazy_casereader *lcr = (struct lazy_casereader *) reader;
+ struct casereader *subreader;
+
+ /* Call the client-provided callback to obtain the real
+ casereader, then swap READER with that casereader. */
+ assert (!lcr->destroyed);
+ subreader = lcr->callback (lcr->aux);
+ lcr->parent = *subreader;
+
+ free (subreader);
+
+ lcr->instantiated = true;
+}
+
+static bool
+lazy_casereader_read (struct casereader *reader, void *ls UNUSED,
+ struct ccase *c)
+{
+ printf ("%s: %p\n", __FUNCTION__, reader);
+ instantiate_lazy_casereader (reader);
+ return casereader_read (reader, c);
+}
+
+static void
+lazy_casereader_do_destroy (struct casereader *reader, void *aux UNUSED)
+{
+ struct lazy_casereader *lcr = (struct lazy_casereader *) reader;
+ printf ("%s: %p\n", __FUNCTION__, reader);
+
+ if (!lcr->destroyed)
+ {
+ if ( lcr->instantiated )
+ casereader_destroy (reader);
+
+ lcr->destroyed = true;
+ }
+}
+
+
+static struct casereader *
+lazy_casereader_clone (struct casereader *reader, void *ls_ UNUSED)
+{
+ printf ("%s: %p\n", __FUNCTION__, reader);
+ instantiate_lazy_casereader (reader);
+ return casereader_clone (reader);
+}
+
+static bool
+lazy_casereader_peek (struct casereader *reader, void *ls_ UNUSED,
+ casenumber idx, struct ccase *c)
+{
+ printf ("%s: %p\n", __FUNCTION__, reader);
+ instantiate_lazy_casereader (reader);
+ return casereader_peek (reader, idx, c);
+}
+
+static struct casereader_class lazy_casereader_class =
+ {
+ lazy_casereader_read,
+ lazy_casereader_do_destroy,
+ lazy_casereader_clone,
+ lazy_casereader_peek,
+ };
Index: src/data/lazy-casereader.h
===================================================================
RCS file: src/data/lazy-casereader.h
diff -N src/data/lazy-casereader.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ src/data/lazy-casereader.h 15 Sep 2007 05:46:57 -0000
@@ -0,0 +1,38 @@
+/* PSPP - a program for statistical analysis.
+ Copyright (C) 2007 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see . */
+
+/* Lazy casereader.
+
+ A "lazy casereader" is a casereader that saves an underlying
+ casereader from the need to be instantiated in the case where
+ it is never used. If any casereader operation is ever
+ performed on a lazy casereader, it invokes a callback function
+ (provided by the lazy casereader's creator) to instantiate the
+ underlying reader. */
+
+#ifndef DATA_LAZY_CASEREADER_H
+#define DATA_LAZY_CASEREADER_H 1
+
+#include
+#include
+
+struct casereader *lazy_casereader_create (size_t value_cnt,
+ casenumber case_cnt,
+ struct casereader *(*) (void *aux),
+ void *aux);
+
+
+#endif /* data/lazy-casereader.h */
Index: src/ui/gui/helper.c
===================================================================
RCS file: /sources/pspp/pspp/src/ui/gui/helper.c,v
retrieving revision 1.27
diff -b -w -U 3 -r1.27 helper.c
--- src/ui/gui/helper.c 6 Sep 2007 07:43:02 -0000 1.27
+++ src/ui/gui/helper.c 15 Sep 2007 05:46:57 -0000
@@ -28,21 +28,26 @@
#include
#include
#include
+#include
#include
#include
#include
#include
+#include
#include
#include
+#include
#include
#include
#include "psppire-data-store.h"
#include