2010-06-03 21:24:43 +08:00
|
|
|
/*********************************************************************
|
2018-12-07 06:36:53 +08:00
|
|
|
* Copyright 2018, University Corporation for Atmospheric Research
|
2010-06-03 21:24:43 +08:00
|
|
|
* See netcdf/README file for copying and redistribution conditions.
|
2010-08-29 23:08:12 +08:00
|
|
|
* "$Id: nciter.c 400 2010-08-27 21:02:52Z russ $"
|
2010-06-03 21:24:43 +08:00
|
|
|
*********************************************************************/
|
|
|
|
|
|
|
|
#include "config.h" /* for USE_NETCDF4 macro */
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2011-09-22 07:10:03 +08:00
|
|
|
#include <netcdf.h>
|
2011-01-06 07:48:47 +08:00
|
|
|
#include "utils.h"
|
2010-06-03 21:24:43 +08:00
|
|
|
#include "nciter.h"
|
|
|
|
|
2010-10-05 01:24:21 +08:00
|
|
|
/* Initialize block iteration for variables, including those that
|
|
|
|
* won't fit in the copy buffer all at once. Returns error if
|
|
|
|
* variable is chunked but size of chunks is too big to fit in bufsize
|
|
|
|
* bytes. */
|
|
|
|
static int
|
|
|
|
nc_blkio_init(size_t bufsize, /* size in bytes of in-memory copy buffer */
|
|
|
|
size_t value_size, /* size in bytes of each variable element */
|
|
|
|
int rank, /* number of dimensions for variable */
|
|
|
|
int chunked, /* 1 if variable is chunked, 0 otherwise */
|
This PR adds EXPERIMENTAL support for accessing data in the
cloud using a variant of the Zarr protocol and storage
format. This enhancement is generically referred to as "NCZarr".
The data model supported by NCZarr is netcdf-4 minus the user-defined
types and the String type. In this sense it is similar to the CDF-5
data model.
More detailed information about enabling and using NCZarr is
described in the document NUG/nczarr.md and in a
[Unidata Developer's blog entry](https://www.unidata.ucar.edu/blogs/developer/en/entry/overview-of-zarr-support-in).
WARNING: this code has had limited testing, so do use this version
for production work. Also, performance improvements are ongoing.
Note especially the following platform matrix of successful tests:
Platform | Build System | S3 support
------------------------------------
Linux+gcc | Automake | yes
Linux+gcc | CMake | yes
Visual Studio | CMake | no
Additionally, and as a consequence of the addition of NCZarr,
major changes have been made to the Filter API. NOTE: NCZarr
does not yet support filters, but these changes are enablers for
that support in the future. Note that it is possible
(probable?) that there will be some accidental reversions if the
changes here did not correctly mimic the existing filter testing.
In any case, previously filter ids and parameters were of type
unsigned int. In order to support the more general zarr filter
model, this was all converted to char*. The old HDF5-specific,
unsigned int operations are still supported but they are
wrappers around the new, char* based nc_filterx_XXX functions.
This entailed at least the following changes:
1. Added the files libdispatch/dfilterx.c and include/ncfilter.h
2. Some filterx utilities have been moved to libdispatch/daux.c
3. A new entry, "filter_actions" was added to the NCDispatch table
and the version bumped.
4. An overly complex set of structs was created to support funnelling
all of the filterx operations thru a single dispatch
"filter_actions" entry.
5. Move common code to from libhdf5 to libsrc4 so that it is accessible
to nczarr.
Changes directly related to Zarr:
1. Modified CMakeList.txt and configure.ac to support both C and C++
-- this is in support of S3 support via the awd-sdk libraries.
2. Define a size64_t type to support nczarr.
3. More reworking of libdispatch/dinfermodel.c to
support zarr and to regularize the structure of the fragments
section of a URL.
Changes not directly related to Zarr:
1. Make client-side filter registration be conditional, with default off.
2. Hack include/nc4internal.h to make some flags added by Ed be unique:
e.g. NC_CREAT, NC_INDEF, etc.
3. cleanup include/nchttp.h and libdispatch/dhttp.c.
4. Misc. changes to support compiling under Visual Studio including:
* Better testing under windows for dirent.h and opendir and closedir.
5. Misc. changes to the oc2 code to support various libcurl CURLOPT flags
and to centralize error reporting.
6. By default, suppress the vlen tests that have unfixed memory leaks; add option to enable them.
7. Make part of the nc_test/test_byterange.sh test be contingent on remotetest.unidata.ucar.edu being accessible.
Changes Left TO-DO:
1. fix provenance code, it is too HDF5 specific.
2020-06-29 08:02:47 +08:00
|
|
|
nciter_t *iter) /* returned iteration state, don't mess with it */
|
|
|
|
{
|
2010-10-05 01:24:21 +08:00
|
|
|
int stat = NC_NOERR;
|
|
|
|
int i;
|
|
|
|
long long prod;
|
|
|
|
size_t *dims = iter->dimsizes;
|
|
|
|
|
|
|
|
iter->rank = rank;
|
|
|
|
iter->first = 1;
|
|
|
|
iter->more = 1;
|
|
|
|
iter->chunked = chunked;
|
|
|
|
prod = value_size;
|
|
|
|
if(iter->chunked == 0) { /* contiguous */
|
|
|
|
iter->right_dim = rank - 1;
|
|
|
|
for(i = rank; i > 0; i--) {
|
|
|
|
if(prod*dims[i-1] <= bufsize) {
|
|
|
|
prod *= dims[i-1];
|
|
|
|
iter->right_dim--;
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (i > 0) { /* variable won't fit in bufsize bytes */
|
|
|
|
iter->rows = bufsize/prod;
|
|
|
|
iter->numrows = dims[iter->right_dim] / iter->rows;
|
|
|
|
iter->leftover = dims[iter->right_dim] - iter->numrows * iter->rows;
|
|
|
|
iter->cur = 1;
|
|
|
|
iter->inc = iter->rows;
|
|
|
|
return stat;
|
|
|
|
}
|
|
|
|
/* else, variable will fit in bufsize bytes of memory. */
|
|
|
|
iter->right_dim = 0;
|
|
|
|
iter->rows = dims[0];
|
|
|
|
iter->inc = 0;
|
|
|
|
return stat;
|
2014-10-03 02:43:27 +08:00
|
|
|
}
|
2010-10-05 01:24:21 +08:00
|
|
|
/* else, handle chunked case */
|
|
|
|
for(i = 0; i < rank; i++) {
|
|
|
|
prod *= iter->chunksizes[i];
|
|
|
|
}
|
|
|
|
if(prod > bufsize) {
|
|
|
|
stat = NC_ENOMEM;
|
|
|
|
fprintf(stderr, "chunksize (= %ld) > copy_buffer size (= %ld)\n",
|
|
|
|
(long)prod, (long)bufsize);
|
|
|
|
}
|
|
|
|
return stat;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* From netCDF type in group igrp, get size in memory needed for each
|
|
|
|
* value. Wouldn't be needed if nc_inq_type() was a netCDF-3 function
|
|
|
|
* too. */
|
|
|
|
static int
|
This PR adds EXPERIMENTAL support for accessing data in the
cloud using a variant of the Zarr protocol and storage
format. This enhancement is generically referred to as "NCZarr".
The data model supported by NCZarr is netcdf-4 minus the user-defined
types and the String type. In this sense it is similar to the CDF-5
data model.
More detailed information about enabling and using NCZarr is
described in the document NUG/nczarr.md and in a
[Unidata Developer's blog entry](https://www.unidata.ucar.edu/blogs/developer/en/entry/overview-of-zarr-support-in).
WARNING: this code has had limited testing, so do use this version
for production work. Also, performance improvements are ongoing.
Note especially the following platform matrix of successful tests:
Platform | Build System | S3 support
------------------------------------
Linux+gcc | Automake | yes
Linux+gcc | CMake | yes
Visual Studio | CMake | no
Additionally, and as a consequence of the addition of NCZarr,
major changes have been made to the Filter API. NOTE: NCZarr
does not yet support filters, but these changes are enablers for
that support in the future. Note that it is possible
(probable?) that there will be some accidental reversions if the
changes here did not correctly mimic the existing filter testing.
In any case, previously filter ids and parameters were of type
unsigned int. In order to support the more general zarr filter
model, this was all converted to char*. The old HDF5-specific,
unsigned int operations are still supported but they are
wrappers around the new, char* based nc_filterx_XXX functions.
This entailed at least the following changes:
1. Added the files libdispatch/dfilterx.c and include/ncfilter.h
2. Some filterx utilities have been moved to libdispatch/daux.c
3. A new entry, "filter_actions" was added to the NCDispatch table
and the version bumped.
4. An overly complex set of structs was created to support funnelling
all of the filterx operations thru a single dispatch
"filter_actions" entry.
5. Move common code to from libhdf5 to libsrc4 so that it is accessible
to nczarr.
Changes directly related to Zarr:
1. Modified CMakeList.txt and configure.ac to support both C and C++
-- this is in support of S3 support via the awd-sdk libraries.
2. Define a size64_t type to support nczarr.
3. More reworking of libdispatch/dinfermodel.c to
support zarr and to regularize the structure of the fragments
section of a URL.
Changes not directly related to Zarr:
1. Make client-side filter registration be conditional, with default off.
2. Hack include/nc4internal.h to make some flags added by Ed be unique:
e.g. NC_CREAT, NC_INDEF, etc.
3. cleanup include/nchttp.h and libdispatch/dhttp.c.
4. Misc. changes to support compiling under Visual Studio including:
* Better testing under windows for dirent.h and opendir and closedir.
5. Misc. changes to the oc2 code to support various libcurl CURLOPT flags
and to centralize error reporting.
6. By default, suppress the vlen tests that have unfixed memory leaks; add option to enable them.
7. Make part of the nc_test/test_byterange.sh test be contingent on remotetest.unidata.ucar.edu being accessible.
Changes Left TO-DO:
1. fix provenance code, it is too HDF5 specific.
2020-06-29 08:02:47 +08:00
|
|
|
inq_value_size(int igrp, nc_type vartype, size_t *value_sizep)
|
|
|
|
{
|
2010-10-05 01:24:21 +08:00
|
|
|
int stat = NC_NOERR;
|
|
|
|
#ifdef USE_NETCDF4
|
2011-01-06 07:48:47 +08:00
|
|
|
NC_CHECK(nc_inq_type(igrp, vartype, NULL, value_sizep));
|
2010-10-05 01:24:21 +08:00
|
|
|
#else
|
|
|
|
switch(vartype) {
|
|
|
|
case NC_BYTE:
|
|
|
|
*value_sizep = sizeof(signed char);
|
|
|
|
break;
|
|
|
|
case NC_CHAR:
|
|
|
|
*value_sizep = sizeof(char);
|
|
|
|
break;
|
|
|
|
case NC_SHORT:
|
|
|
|
*value_sizep = sizeof(short);
|
|
|
|
break;
|
|
|
|
case NC_INT:
|
|
|
|
*value_sizep = sizeof(int);
|
|
|
|
break;
|
|
|
|
case NC_FLOAT:
|
|
|
|
*value_sizep = sizeof(float);
|
|
|
|
break;
|
|
|
|
case NC_DOUBLE:
|
|
|
|
*value_sizep = sizeof(double);
|
|
|
|
break;
|
|
|
|
default:
|
2011-01-06 07:48:47 +08:00
|
|
|
NC_CHECK(NC_EBADTYPE);
|
2010-10-05 01:24:21 +08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
#endif /* USE_NETCDF4 */
|
|
|
|
return stat;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Updates a vector of size_t, odometer style. Returns 0 if odometer
|
|
|
|
* overflowed, else 1.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
up_start(
|
|
|
|
int ndims, /* Number of dimensions */
|
|
|
|
const size_t *dims, /* The "odometer" limits for each dimension */
|
|
|
|
int incdim, /* the odmometer increment dimension */
|
|
|
|
size_t inc, /* the odometer increment for that dimension */
|
|
|
|
size_t* odom /* The "odometer" vector to be updated */
|
|
|
|
)
|
|
|
|
{
|
|
|
|
int id;
|
|
|
|
int ret = 1;
|
|
|
|
|
|
|
|
if(inc == 0) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
odom[incdim] += inc;
|
|
|
|
for (id = incdim; id > 0; id--) {
|
|
|
|
if(odom[id] >= dims[id]) {
|
|
|
|
odom[id-1]++;
|
|
|
|
odom[id] -= dims[id];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (odom[0] >= dims[0])
|
|
|
|
ret = 0;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Updates a vector of size_t, odometer style, for chunk access.
|
|
|
|
* Returns 0 if odometer overflowed, else 1.
|
|
|
|
*/
|
|
|
|
static int
|
|
|
|
up_start_by_chunks(
|
|
|
|
int ndims, /* Number of dimensions */
|
|
|
|
const size_t *dims, /* The "odometer" limits for each dimension */
|
|
|
|
const size_t *chunks, /* the odometer increments for each dimension */
|
|
|
|
size_t* odom /* The "odometer" vector to be updated */
|
|
|
|
)
|
|
|
|
{
|
|
|
|
int incdim = ndims - 1;
|
|
|
|
int id;
|
|
|
|
int ret = 1;
|
|
|
|
|
|
|
|
odom[incdim] += chunks[incdim];
|
|
|
|
for (id = incdim; id > 0; id--) {
|
|
|
|
if(odom[id] >= dims[id]) {
|
|
|
|
odom[id-1] += chunks[id-1];
|
|
|
|
/* odom[id] -= dims[id]; */
|
|
|
|
odom[id] = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (odom[0] >= dims[0])
|
|
|
|
ret = 0;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Begin public interfaces */
|
|
|
|
|
2010-06-03 21:24:43 +08:00
|
|
|
/* Initialize iteration for a variable. Just a wrapper for
|
|
|
|
* nc_blkio_init() that makes the netCDF calls needed to initialize
|
|
|
|
* lower-level iterator. */
|
|
|
|
int
|
|
|
|
nc_get_iter(int ncid,
|
|
|
|
int varid,
|
This PR adds EXPERIMENTAL support for accessing data in the
cloud using a variant of the Zarr protocol and storage
format. This enhancement is generically referred to as "NCZarr".
The data model supported by NCZarr is netcdf-4 minus the user-defined
types and the String type. In this sense it is similar to the CDF-5
data model.
More detailed information about enabling and using NCZarr is
described in the document NUG/nczarr.md and in a
[Unidata Developer's blog entry](https://www.unidata.ucar.edu/blogs/developer/en/entry/overview-of-zarr-support-in).
WARNING: this code has had limited testing, so do use this version
for production work. Also, performance improvements are ongoing.
Note especially the following platform matrix of successful tests:
Platform | Build System | S3 support
------------------------------------
Linux+gcc | Automake | yes
Linux+gcc | CMake | yes
Visual Studio | CMake | no
Additionally, and as a consequence of the addition of NCZarr,
major changes have been made to the Filter API. NOTE: NCZarr
does not yet support filters, but these changes are enablers for
that support in the future. Note that it is possible
(probable?) that there will be some accidental reversions if the
changes here did not correctly mimic the existing filter testing.
In any case, previously filter ids and parameters were of type
unsigned int. In order to support the more general zarr filter
model, this was all converted to char*. The old HDF5-specific,
unsigned int operations are still supported but they are
wrappers around the new, char* based nc_filterx_XXX functions.
This entailed at least the following changes:
1. Added the files libdispatch/dfilterx.c and include/ncfilter.h
2. Some filterx utilities have been moved to libdispatch/daux.c
3. A new entry, "filter_actions" was added to the NCDispatch table
and the version bumped.
4. An overly complex set of structs was created to support funnelling
all of the filterx operations thru a single dispatch
"filter_actions" entry.
5. Move common code to from libhdf5 to libsrc4 so that it is accessible
to nczarr.
Changes directly related to Zarr:
1. Modified CMakeList.txt and configure.ac to support both C and C++
-- this is in support of S3 support via the awd-sdk libraries.
2. Define a size64_t type to support nczarr.
3. More reworking of libdispatch/dinfermodel.c to
support zarr and to regularize the structure of the fragments
section of a URL.
Changes not directly related to Zarr:
1. Make client-side filter registration be conditional, with default off.
2. Hack include/nc4internal.h to make some flags added by Ed be unique:
e.g. NC_CREAT, NC_INDEF, etc.
3. cleanup include/nchttp.h and libdispatch/dhttp.c.
4. Misc. changes to support compiling under Visual Studio including:
* Better testing under windows for dirent.h and opendir and closedir.
5. Misc. changes to the oc2 code to support various libcurl CURLOPT flags
and to centralize error reporting.
6. By default, suppress the vlen tests that have unfixed memory leaks; add option to enable them.
7. Make part of the nc_test/test_byterange.sh test be contingent on remotetest.unidata.ucar.edu being accessible.
Changes Left TO-DO:
1. fix provenance code, it is too HDF5 specific.
2020-06-29 08:02:47 +08:00
|
|
|
size_t bufsize, /* size in bytes of memory buffer */
|
|
|
|
nciter_t **iterpp) /* returned opaque iteration state */
|
2010-06-03 21:24:43 +08:00
|
|
|
{
|
|
|
|
int stat = NC_NOERR;
|
2010-08-03 05:31:01 +08:00
|
|
|
nciter_t *iterp;
|
2010-06-03 21:24:43 +08:00
|
|
|
nc_type vartype;
|
2014-10-03 02:43:27 +08:00
|
|
|
size_t value_size = 0; /* size in bytes of each variable element */
|
2010-06-03 21:24:43 +08:00
|
|
|
int ndims; /* number of dimensions for variable */
|
2010-07-30 06:41:05 +08:00
|
|
|
int *dimids;
|
2010-06-03 21:24:43 +08:00
|
|
|
long long nvalues = 1;
|
|
|
|
int dim;
|
|
|
|
int chunked = 0;
|
|
|
|
|
2010-08-03 05:31:01 +08:00
|
|
|
/* Caller should free this by calling nc_free_iter(iterp) */
|
|
|
|
iterp = (nciter_t *) emalloc(sizeof(nciter_t));
|
2010-06-03 21:24:43 +08:00
|
|
|
memset((void*)iterp,0,sizeof(nciter_t)); /* make sure it is initialized */
|
|
|
|
|
2011-01-06 07:48:47 +08:00
|
|
|
NC_CHECK(nc_inq_varndims(ncid, varid, &ndims));
|
2014-10-03 02:43:27 +08:00
|
|
|
|
2013-04-24 05:50:07 +08:00
|
|
|
dimids = (int *) emalloc((ndims + 1) * sizeof(int));
|
2014-10-03 02:43:27 +08:00
|
|
|
|
2010-08-11 12:58:14 +08:00
|
|
|
iterp->dimsizes = (size_t *) emalloc((ndims + 1) * sizeof(size_t));
|
|
|
|
iterp->chunksizes = (size_t *) emalloc((ndims + 1) * sizeof(size_t));
|
2010-07-30 06:41:05 +08:00
|
|
|
|
2011-01-06 07:48:47 +08:00
|
|
|
NC_CHECK(nc_inq_vardimid (ncid, varid, dimids));
|
2010-06-03 21:24:43 +08:00
|
|
|
for(dim = 0; dim < ndims; dim++) {
|
|
|
|
size_t len;
|
2011-01-06 07:48:47 +08:00
|
|
|
NC_CHECK(nc_inq_dimlen(ncid, dimids[dim], &len));
|
2010-06-03 21:24:43 +08:00
|
|
|
nvalues *= len;
|
2010-08-03 05:31:01 +08:00
|
|
|
iterp->dimsizes[dim] = len;
|
2010-06-03 21:24:43 +08:00
|
|
|
}
|
2011-01-06 07:48:47 +08:00
|
|
|
NC_CHECK(nc_inq_vartype(ncid, varid, &vartype));
|
|
|
|
NC_CHECK(inq_value_size(ncid, vartype, &value_size));
|
2014-10-03 02:43:27 +08:00
|
|
|
#ifdef USE_NETCDF4
|
2010-06-03 21:24:43 +08:00
|
|
|
{
|
|
|
|
int contig = 1;
|
|
|
|
if(ndims > 0) {
|
2011-01-06 07:48:47 +08:00
|
|
|
NC_CHECK(nc_inq_var_chunking(ncid, varid, &contig, NULL));
|
2010-06-03 21:24:43 +08:00
|
|
|
}
|
|
|
|
if(contig == 0) { /* chunked */
|
2011-01-06 07:48:47 +08:00
|
|
|
NC_CHECK(nc_inq_var_chunking(ncid, varid, &contig, iterp->chunksizes));
|
2010-06-03 21:24:43 +08:00
|
|
|
chunked = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif /* USE_NETCDF4 */
|
2011-01-06 07:48:47 +08:00
|
|
|
NC_CHECK(nc_blkio_init(bufsize, value_size, ndims, chunked, iterp));
|
2010-06-03 21:24:43 +08:00
|
|
|
iterp->to_get = 0;
|
2010-07-30 06:41:05 +08:00
|
|
|
free(dimids);
|
2010-08-03 05:31:01 +08:00
|
|
|
*iterpp = iterp;
|
2010-06-03 21:24:43 +08:00
|
|
|
return stat;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Iterate on blocks for variables, by updating start and count vector
|
|
|
|
* for next vara call. Assumes nc_get_iter called first. Returns
|
|
|
|
* number of variable values to get, 0 if done, negative number if
|
2014-10-03 02:43:27 +08:00
|
|
|
* error, so use like this:
|
2010-06-03 21:24:43 +08:00
|
|
|
size_t to_get;
|
2014-10-03 02:43:27 +08:00
|
|
|
while((to_get = nc_next_iter(&iter, start, count)) > 0) {
|
|
|
|
... iteration ...
|
|
|
|
}
|
2010-06-03 21:24:43 +08:00
|
|
|
if(to_get < 0) { ... handle error ... }
|
|
|
|
*/
|
|
|
|
size_t
|
|
|
|
nc_next_iter(nciter_t *iter, /* returned opaque iteration state */
|
|
|
|
size_t *start, /* returned start vector for next vara call */
|
This PR adds EXPERIMENTAL support for accessing data in the
cloud using a variant of the Zarr protocol and storage
format. This enhancement is generically referred to as "NCZarr".
The data model supported by NCZarr is netcdf-4 minus the user-defined
types and the String type. In this sense it is similar to the CDF-5
data model.
More detailed information about enabling and using NCZarr is
described in the document NUG/nczarr.md and in a
[Unidata Developer's blog entry](https://www.unidata.ucar.edu/blogs/developer/en/entry/overview-of-zarr-support-in).
WARNING: this code has had limited testing, so do use this version
for production work. Also, performance improvements are ongoing.
Note especially the following platform matrix of successful tests:
Platform | Build System | S3 support
------------------------------------
Linux+gcc | Automake | yes
Linux+gcc | CMake | yes
Visual Studio | CMake | no
Additionally, and as a consequence of the addition of NCZarr,
major changes have been made to the Filter API. NOTE: NCZarr
does not yet support filters, but these changes are enablers for
that support in the future. Note that it is possible
(probable?) that there will be some accidental reversions if the
changes here did not correctly mimic the existing filter testing.
In any case, previously filter ids and parameters were of type
unsigned int. In order to support the more general zarr filter
model, this was all converted to char*. The old HDF5-specific,
unsigned int operations are still supported but they are
wrappers around the new, char* based nc_filterx_XXX functions.
This entailed at least the following changes:
1. Added the files libdispatch/dfilterx.c and include/ncfilter.h
2. Some filterx utilities have been moved to libdispatch/daux.c
3. A new entry, "filter_actions" was added to the NCDispatch table
and the version bumped.
4. An overly complex set of structs was created to support funnelling
all of the filterx operations thru a single dispatch
"filter_actions" entry.
5. Move common code to from libhdf5 to libsrc4 so that it is accessible
to nczarr.
Changes directly related to Zarr:
1. Modified CMakeList.txt and configure.ac to support both C and C++
-- this is in support of S3 support via the awd-sdk libraries.
2. Define a size64_t type to support nczarr.
3. More reworking of libdispatch/dinfermodel.c to
support zarr and to regularize the structure of the fragments
section of a URL.
Changes not directly related to Zarr:
1. Make client-side filter registration be conditional, with default off.
2. Hack include/nc4internal.h to make some flags added by Ed be unique:
e.g. NC_CREAT, NC_INDEF, etc.
3. cleanup include/nchttp.h and libdispatch/dhttp.c.
4. Misc. changes to support compiling under Visual Studio including:
* Better testing under windows for dirent.h and opendir and closedir.
5. Misc. changes to the oc2 code to support various libcurl CURLOPT flags
and to centralize error reporting.
6. By default, suppress the vlen tests that have unfixed memory leaks; add option to enable them.
7. Make part of the nc_test/test_byterange.sh test be contingent on remotetest.unidata.ucar.edu being accessible.
Changes Left TO-DO:
1. fix provenance code, it is too HDF5 specific.
2020-06-29 08:02:47 +08:00
|
|
|
size_t *count) /* returned count vector for next vara call */
|
|
|
|
{
|
2010-06-03 21:24:43 +08:00
|
|
|
int i;
|
|
|
|
/* Note: special case for chunked variables is just an
|
|
|
|
* optimization, the contiguous code below is OK even
|
|
|
|
* for chunked variables, but in general will do more I/O ... */
|
|
|
|
if(iter->first) {
|
|
|
|
if(!iter->chunked) { /* contiguous storage */
|
|
|
|
for(i = 0; i < iter->right_dim; i++) {
|
|
|
|
start[i] = 0;
|
|
|
|
count[i] = 1;
|
|
|
|
}
|
|
|
|
start[iter->right_dim] = 0;
|
|
|
|
count[iter->right_dim] = iter->rows;
|
|
|
|
for(i = iter->right_dim + 1; i < iter->rank; i++) {
|
|
|
|
start[i] = 0;
|
|
|
|
count[i] = iter->dimsizes[i];
|
|
|
|
}
|
|
|
|
} else { /* chunked storage */
|
|
|
|
for(i = 0; i < iter->rank; i++) {
|
|
|
|
start[i] = 0;
|
2012-01-19 05:20:11 +08:00
|
|
|
if(iter->chunksizes[i] <= iter->dimsizes[i])
|
|
|
|
count[i] = iter->chunksizes[i];
|
|
|
|
else /* can happen for variables with only unlimited dimensions */
|
|
|
|
count[i] = iter->dimsizes[i];
|
2010-06-03 21:24:43 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
iter->first = 0;
|
|
|
|
} else {
|
|
|
|
if(!iter->chunked) { /* contiguous storage */
|
2014-10-03 02:43:27 +08:00
|
|
|
iter->more = up_start(iter->rank, iter->dimsizes, iter->right_dim,
|
2010-06-03 21:24:43 +08:00
|
|
|
iter->inc, start);
|
|
|
|
/* iterate on pieces of variable */
|
|
|
|
if(iter->cur < iter->numrows) {
|
|
|
|
iter->inc = iter->rows;
|
|
|
|
count[iter->right_dim] = iter->rows;
|
|
|
|
iter->cur++;
|
|
|
|
} else {
|
|
|
|
if(iter->leftover > 0) {
|
|
|
|
count[iter->right_dim] = iter->leftover;
|
|
|
|
iter->inc = iter->leftover;
|
|
|
|
iter->cur = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else { /* chunked storage */
|
2014-10-03 02:43:27 +08:00
|
|
|
iter->more = up_start_by_chunks(iter->rank, iter->dimsizes,
|
2010-06-03 21:24:43 +08:00
|
|
|
iter->chunksizes, start);
|
|
|
|
/* adjust count to stay in range of dimsizes */
|
|
|
|
for(i = 0; i < iter->rank; i++) {
|
|
|
|
int leftover = iter->dimsizes[i] - start[i];
|
2012-01-31 06:10:23 +08:00
|
|
|
if(iter->chunksizes[i] <= iter->dimsizes[i])
|
|
|
|
count[i] = iter->chunksizes[i];
|
|
|
|
else /* can happen for variables with only unlimited dimensions */
|
|
|
|
count[i] = iter->dimsizes[i];
|
2014-10-03 02:43:27 +08:00
|
|
|
if(leftover < count[i])
|
2010-06-03 21:24:43 +08:00
|
|
|
count[i] = leftover;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
iter->to_get = 1;
|
|
|
|
for(i = 0; i < iter->rank; i++) {
|
|
|
|
iter->to_get *= count[i];
|
|
|
|
}
|
|
|
|
return iter->more == 0 ? 0 : iter->to_get ;
|
|
|
|
}
|
|
|
|
|
2010-08-03 05:31:01 +08:00
|
|
|
/* Free iterator and its internally allocated memory */
|
|
|
|
int
|
This PR adds EXPERIMENTAL support for accessing data in the
cloud using a variant of the Zarr protocol and storage
format. This enhancement is generically referred to as "NCZarr".
The data model supported by NCZarr is netcdf-4 minus the user-defined
types and the String type. In this sense it is similar to the CDF-5
data model.
More detailed information about enabling and using NCZarr is
described in the document NUG/nczarr.md and in a
[Unidata Developer's blog entry](https://www.unidata.ucar.edu/blogs/developer/en/entry/overview-of-zarr-support-in).
WARNING: this code has had limited testing, so do use this version
for production work. Also, performance improvements are ongoing.
Note especially the following platform matrix of successful tests:
Platform | Build System | S3 support
------------------------------------
Linux+gcc | Automake | yes
Linux+gcc | CMake | yes
Visual Studio | CMake | no
Additionally, and as a consequence of the addition of NCZarr,
major changes have been made to the Filter API. NOTE: NCZarr
does not yet support filters, but these changes are enablers for
that support in the future. Note that it is possible
(probable?) that there will be some accidental reversions if the
changes here did not correctly mimic the existing filter testing.
In any case, previously filter ids and parameters were of type
unsigned int. In order to support the more general zarr filter
model, this was all converted to char*. The old HDF5-specific,
unsigned int operations are still supported but they are
wrappers around the new, char* based nc_filterx_XXX functions.
This entailed at least the following changes:
1. Added the files libdispatch/dfilterx.c and include/ncfilter.h
2. Some filterx utilities have been moved to libdispatch/daux.c
3. A new entry, "filter_actions" was added to the NCDispatch table
and the version bumped.
4. An overly complex set of structs was created to support funnelling
all of the filterx operations thru a single dispatch
"filter_actions" entry.
5. Move common code to from libhdf5 to libsrc4 so that it is accessible
to nczarr.
Changes directly related to Zarr:
1. Modified CMakeList.txt and configure.ac to support both C and C++
-- this is in support of S3 support via the awd-sdk libraries.
2. Define a size64_t type to support nczarr.
3. More reworking of libdispatch/dinfermodel.c to
support zarr and to regularize the structure of the fragments
section of a URL.
Changes not directly related to Zarr:
1. Make client-side filter registration be conditional, with default off.
2. Hack include/nc4internal.h to make some flags added by Ed be unique:
e.g. NC_CREAT, NC_INDEF, etc.
3. cleanup include/nchttp.h and libdispatch/dhttp.c.
4. Misc. changes to support compiling under Visual Studio including:
* Better testing under windows for dirent.h and opendir and closedir.
5. Misc. changes to the oc2 code to support various libcurl CURLOPT flags
and to centralize error reporting.
6. By default, suppress the vlen tests that have unfixed memory leaks; add option to enable them.
7. Make part of the nc_test/test_byterange.sh test be contingent on remotetest.unidata.ucar.edu being accessible.
Changes Left TO-DO:
1. fix provenance code, it is too HDF5 specific.
2020-06-29 08:02:47 +08:00
|
|
|
nc_free_iter(nciter_t *iterp)
|
|
|
|
{
|
2010-08-03 05:31:01 +08:00
|
|
|
if(iterp->dimsizes)
|
|
|
|
free(iterp->dimsizes);
|
|
|
|
if(iterp->chunksizes)
|
|
|
|
free(iterp->chunksizes);
|
2012-08-01 06:17:42 +08:00
|
|
|
free(iterp);
|
2010-08-03 05:31:01 +08:00
|
|
|
return NC_NOERR;
|
|
|
|
}
|