[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [patch #5690] Clean up case code

From: Ben Pfaff
Subject: Re: [patch #5690] Clean up case code
Date: Tue, 30 Jan 2007 06:34:09 -0800
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux)

John Darrington <address@hidden> writes:

> I can see two alternative ways to overcome this, but neither are
> particularly nice:
> 1. Copy the case locally, write to it, and replace it into the
>    flexifile. This wouldn't be very efficient if we're dealing with
>    very large cases.
> 2. Introduce some kind of special case for use in flexifiles which
>    allows writing.

3. Fix the flexifile implementation.  This is what I'm doing
   right now.  Progress is slow because I have little time, but
   it'll eventually be ready.

   The new flexifile has "get case" and "put case" operations for
   reading and writing arbitrary cases.

   Here's the current header file.  It uses a casereader instead
   of a casefile because casefiles have gone away in my source
   tree.  Currently I'm calling it a "datasheet" instead of a
   flexifile because that seems to be a better name given that my
   reworked source tree has no need for casefiles or multiple
   implementations of casefiles or casefile factories.  Trust me,
   it's an improvement.

   Maybe "datasheet" is too close to a name used in the GUI
   code.  In that case I'm open to other names; I could even go
   back to flexifile if you prefer.


#include <data/case.h>
#include <data/value.h>

struct casereader;

/* A datasheet is a 2-d array of data that may be stored in
   memory or on disk.  It efficiently supports data storage and
   retrieval, as well as adding, removing, and rearranging both
   rows and columns.  */

struct datasheet *datasheet_create (struct casereader *);
void datasheet_destroy (struct datasheet *);
struct casereader *datasheet_make_reader (struct datasheet *);

casenumber datasheet_get_case_count (const struct datasheet *);
size_t datasheet_get_value_count (const struct datasheet *);

/* Columns. */
void datasheet_insert_values (struct datasheet *,
                              const union value[], size_t cnt,
                              size_t before);
void datasheet_delete_values (struct datasheet *, size_t start, size_t cnt);
void datasheet_move_values (struct datasheet *,
                            size_t old_start, size_t new_start,
                            size_t cnt);
void datasheet_reorder_values (struct datasheet *,
                               size_t *ordering, size_t cnt);

/* Rows. */
bool datasheet_get_case (struct datasheet *, casenumber, struct ccase *);
bool datasheet_put_case (struct datasheet *, casenumber, struct ccase *);
void datasheet_insert_cases (struct datasheet *,
                             casenumber before, struct ccase *,
                             casenumber cnt);
void datasheet_delete_cases (struct datasheet *,
                             casenumber first, casenumber cnt);

#endif /* data/datasheet.h */

Ben Pfaff 

reply via email to

[Prev in Thread] Current Thread [Next in Thread]