netcdf-c/plugins/h5misc.h
Dennis Heimbigner df3636b959 Mitigate S3 test interference + Unlimited Dimensions in NCZarr
This PR started as an attempt to add unlimited dimensions to NCZarr.
It did that, but this exposed significant problems with test interference.
So this PR is mostly about fixing -- well mitigating anyway -- test
interference.

The problem of test interference is now documented in the document docs/internal.md.
The solutions implemented here are also describe in that document.
The solution is somewhat fragile but multiple cleanup mechanisms
are provided. Note that this feature requires that the
AWS command line utility must be installed.

## Unlimited Dimensions.
The existing NCZarr extensions to Zarr are modified to support unlimited dimensions.
NCzarr extends the Zarr meta-data for the ".zgroup" object to include netcdf-4 model extensions. This information is stored in ".zgroup" as dictionary named "_nczarr_group".
Inside "_nczarr_group", there is a key named "dims" that stores information about netcdf-4 named dimensions. The value of "dims" is a dictionary whose keys are the named dimensions. The value associated with each dimension name has one of two forms
Form 1 is a special case of form 2, and is kept for backward compatibility. Whenever a new file is written, it uses format 1 if possible, otherwise format 2.
* Form 1: An integer representing the size of the dimension, which is used for simple named dimensions.
* Form 2: A dictionary with the following keys and values"
   - "size" with an integer value representing the (current) size of the dimension.
   - "unlimited" with a value of either "1" or "0" to indicate if this dimension is an unlimited dimension.

For Unlimited dimensions, the size is initially zero, and as variables extend the length of that dimension, the size value for the dimension increases.
That dimension size is shared by all arrays referencing that dimension, so if one array extends an unlimited dimension, it is implicitly extended for all other arrays that reference that dimension.
This is the standard semantics for unlimited dimensions.

Adding unlimited dimensions required a number of other changes to the NCZarr code-base. These included the following.
* Did a partial refactor of the slice handling code in zwalk.c to clean it up.
* Added a number of tests for unlimited dimensions derived from the same test in nc_test4.
* Added several NCZarr specific unlimited tests; more are needed.
* Add test of endianness.

## Misc. Other Changes
* Modify libdispatch/ncs3sdk_aws.cpp to optionally support use of the
   AWS Transfer Utility mechanism. This is controlled by the
   ```#define TRANSFER```` command in that file. It defaults to being disabled.
* Parameterize both the standard Unidata S3 bucket (S3TESTBUCKET) and the netcdf-c test data prefix (S3TESTSUBTREE).
* Fixed an obscure memory leak in ncdump.
* Removed some obsolete unit testing code and test cases.
* Uncovered a bug in the netcdf-c handling of big-endian floats and doubles. Have not fixed yet. See tst_h5_endians.c.
* Renamed some nczarr_tests testcases to avoid name conflicts with nc_test4.
* Modify the semantics of zmap\#ncsmap_write to only allow total rewrite of objects.
* Modify the semantics of zodom to properly handle stride > 1.
* Add a truncate operation to the libnczarr zmap code.
2023-09-26 16:56:48 -06:00

79 lines
2.0 KiB
C

#ifndef H5MISC_H
#define H5MISC_H
#ifdef _MSC_VER
#ifdef DLL_EXPORT /* define when building the library */
# define DECLSPEC __declspec(dllexport)
#else
# define DECLSPEC __declspec(dllimport)
#endif
#else
# define DECLSPEC extern
#endif
#include "netcdf_filter_build.h"
#include "netcdf_filter_hdf5_build.h"
/* use an integer greater than 256 to be id of the registered filter. */
#define H5Z_FILTER_TEST 32768
/* Define the test cases */
typedef enum H5testcase {
TC_NONE = 0,
TC_PARAMS = 1,
TC_ODDSIZE = 2,
TC_EXPANDED = 3,
} H5testcase;
/* Ensure consistency with test case */
/* All numeric types types */
struct All {
signed char tbyte;
unsigned char tubyte;
signed short tshort;
unsigned short tushort;
signed int tint;
unsigned int tuint;
float tfloat32;
signed long long tint64;
unsigned long long tuint64;
double tfloat64;
};
/* number of 32 bit unsigned value needed to hold fields of struct All */
#define NPARAMS (10 + 1/*int64*/ + 1/*uint64*/ + 1/*double*/ + 1/*test case number*/)
/* Test values */
static struct All spec = {
(char)-17, /* signed byte */
(unsigned char)23, /* unsigned byte */
(signed short)-25, /* signed short */
(unsigned short)27U, /* unsigned short */
77, /* signed int */
93U, /* unsigned int */
789.0f, /* float */
-9223372036854775807LL, /* signed int64 */
18446744073709551615ULL,/* unsigned int64 */
(double)12345678.12345678/* double */
};
/* declare the hdf5 interface */
DECLSPEC H5PL_type_t H5PLget_plugin_type(void);
DECLSPEC const void* H5PLget_plugin_info(void);
DECLSPEC const H5Z_class2_t H5Z_TEST[1];
#if 0
/* Declare filter specific functions */
DECLSPEC htri_t H5Z_test_can_apply(hid_t dcpl_id, hid_t type_id, hid_t space_id);
DECLSPEC size_t H5Z_filter_test(unsigned flags,size_t cd_nelmts,const unsigned cd_values[],
size_t nbytes,size_t *buf_size,void**buf);
#endif
DECLSPEC void NC_h5filterspec_fix8(void* mem0, int decode);
/* Shutup compiler */
void* NC_unused_h5misc() {return (void*)&spec;}
#endif /*H5MISC_H*/