Short version: it looks as if HDF5 handles all the things we were
worried about its not handling.
On Tue, 2014-07-29 at 23:55 -0400, Bob Carpenter wrote:
> I'm at least glad to hear it's been stable since 2002.
The original hdf, aka hd4, was from 1988. However, it's explicitly
designed to permit new datatypes, either user or system in the future.
E.g., if future hardware has 512 byte floats that could be added.
>
> To enable binary data to work cross-platform, a format needs to
> specify endian-ness, and mismatched platforms need to swap
> bytes. That's how UTF-16 and UTF-32 encodings of Unicode
> are designed, for example.
Looking at the tutorials, esp
http://www.hdfgroup.org/HDF5/Tutor/rdwt.html which says
"The data in memory can have a datatype different from that of the file
and can also be of a different size (i.e., the data in memory is a
subset of the dataset elements, or vice versa)."
it seems things "just work":
1) client code doesn't need to swap bytes or check data type on disk;
2) client code can use platform native data types, which are stored with
full information about their endianness.
So if you read data on a platform with a different format from the one
it is written, the hdf library will know that from the info on disk and
adjust accordingly.
See also
http://www.hdfgroup.org/HDF5/Tutor/datatypes.html
>
> Transforming strings to numbers is very expensive. My
> thinking for the original design was that reading in data was
> unlikely to be a bottleneck for MCMC. It is turning out
> to be a bottleneck for optimization, though, which is much
> much faster than MCMC.
My distaste for storing large amounts of numeric data as text is
probably as much aesthetic as practical, though the sheer bulk of
putting numbers as text does seem a practical problem.
I wouldn't think an optimizer would go anywhere near the textual
representation of numbers.
>
> Not getting the row-major versus column-major working through
> all interfaces seems like a bug in the interface, or maybe I'm
> not understanding some underlying principles.
According to 7.3.2.5 in
http://www.hdfgroup.org/HDF5/doc/UG/12_Dataspaces.html
the on disk format is C-style, and calls from Fortran will silently
switch the order going out and reverse it going in. But the dump tool
will show the C format and so things will look strange if you wrote from
Fortran.
They do note that Fortran and C have different limits on how many
dimensions they can handle, and the HDF5 spec currently limits it to the
higher of these (32, for C).
> In any case, we
> probably don't need to worry about Fortran. But then R and
> C++ have different defaults (C++ arrays are row major, R's are
> column major). Mixing these up causes no end of trouble, as when
> BUGS adopted R's dump format, then put the arrays in opposite
> majority (row major vs. column major).
Even though R is implemented in C, it seems to follow Fortran
conventions for arrays. Julia has the same ordering as R. I suppose
that means they could still get mixed up, since the hdf library would
think you were using C but the data have Fortran ordering.
>
> - Bob
From
http://www.hdfgroup.org/HDF5/Tutor/crtfile.html
What is an HDF5 file?
An HDF5 file is a binary file containing scientific data and supporting
metadata.
That same page explains that the textual representation of data you saw
is what you get from h5dump (e.g., Fig 4.2).
Ross