Did you know ... | Search Documentation: |
Pack dynworks -- prolog/dynarray_persistence.pl |
This module provides persistence for dynarray objects, using the Berkeley DB
utility package. Please, refer to bdb_wrapper.pl
for details on the SWI-Prolog
interface to Berkeley DB.
Additionally, persisting and restoring from `.csv` files is also implemented.
Please, refer to the csv_wrapper.pl
for details.
The following considerations apply for CSV operations:
1. the dynarray involved must be 2-dimensional, and will be handled as having rows (dimension 1) and columns (dimension 2); 2. the stream involved must be of type 'text', and will be read or written from its current position; 3. persisting to, or restoring from, the given stream will be attempted, depending on whether or not the dynarray exists; 4. input and output are performed through the Prolog platform's built-in CSV library; 5. when persisting, the atoms associated with the dynarray's columns, if they exist, will be used as field names in the CSV file's header record; 6. when persisting, the data registered as labels, apart from the column names, will not be included; 7. when persisting, missing cells will be recorded on the CSV file as empty fields (containing the null char '\000\'); 8. when restoring, an attempt will be made to extract field names from the CSV file's first record and use them as labels; if not possible, the record will be treated as regular data.
[<dims-ranges>],<Nb>, [<key-label-1>,<value-label-1>],...,[<key-label-Nb>,<value-label-Nb>], [<pos-value-1>,<value-1>],...,[<pos-value-Nv>,<value-Nv>]
The serialized list will thus contain Np + Nv + 2
elements:
<dims-ranges> - the dimensions ranges used for the dynarray creation
<num-labels> - the total number of key-value label pairs
<key-label-j> - the key in the key-value label pair j
<value-label-j> - the value in the key-value label pair j
<pos-value-j> - the linear position of value j
within the dynarray
<value-j> - the value j
within the dynarray