mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-11-27 07:30:33 +08:00
74b40fd788
Re: https://github.com/zarr-developers/zarr-python/pull/716 The Zarr version 2 spec has been extended to include the ability to choose the dimension separator in chunk name keys. The legal separators has been extended from {'.'} to {'.' '/'}. So now it is possible to use a key like "0/1/2/0" for chunk names. This PR implements this for NCZarr. The V2 spec now says that this separator can be set on a per-variable basis. For now, I have chosen to allow this be set only globally by adding a key named "ZARR.DIMENSION_SEPARATOR=<char>" in the .daprc/.dodsrc/ncrc file. Currently, the only legal separator characters are '.' (the default) and '/'. On writing, this key will only be written if its value is different than the default. This change caused problems because supporting a separator of '/' is difficult to parse when keys/paths use '/' as the path separator. A test case was added for this. Additionally, make nczarr be enabled default by default. This required some additional changes so that if zip and/or AWS S3 sdk are unavailable, then they are disabled for NCZarr. In addition the following unrelated changes were made. 1. Tested that pure-zarr mode could read an nczarr formatted store. 1. The .rc file handling now merges all known .rc files (.ncrc,.daprc, and .dodsrc) in that order and using those in HOME first, then in current directory. For duplicate entries, the later ones override the earlier ones. This change is to remove some of the conflicts inherent in the current .rc file load process. A set of test cases was also added. 1. Re-order tests in configure.ac and CMakeLists.txt so that if libcurl is not found then the other options that depend upon it properly are disabled. 1. I decided that xarray support should be enabled by default for pure zarr. In order to allow disabling, I added a new mode flag "noxarray". 1. Certain test in nczarr_test depend on use of .dodsrc. In order for these to work when testing in parallel, some inter-test dependencies needed to be added. 1. Improved authorization testing to use changes in thredds.ucar.edu
52 lines
1.9 KiB
C
52 lines
1.9 KiB
C
/*********************************************************************
|
|
* Copyright 2018, UCAR/Unidata
|
|
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
|
*********************************************************************/
|
|
|
|
#ifndef ZCACHE_H
|
|
#define ZCACHE_H
|
|
|
|
/* This holds all the fields
|
|
to support either impl of cache
|
|
*/
|
|
|
|
struct NCxcache;
|
|
|
|
typedef struct NCZCacheEntry {
|
|
struct List {void* next; void* prev; void* unused;} list;
|
|
int modified;
|
|
size64_t indices[NC_MAX_VAR_DIMS];
|
|
struct ChunkKey {
|
|
char* varkey; /* key to the containing variable */
|
|
char* chunkkey; /* name of the chunk */
|
|
} key;
|
|
size64_t hashkey;
|
|
void* data;
|
|
} NCZCacheEntry;
|
|
|
|
typedef struct NCZChunkCache {
|
|
const NC_VAR_INFO_T* var; /* backlink */
|
|
size64_t ndims; /* true ndims == var->ndims + scalar */
|
|
size64_t chunksize;
|
|
void* fillchunk; /* enough fillvalues to fill a chunk */
|
|
size_t maxentries; /* Max number of entries allowed */
|
|
NClist* mru; /* all cache entries in mru order */
|
|
struct NCxcache* xcache;
|
|
char dimension_separator;
|
|
} NCZChunkCache;
|
|
|
|
/**************************************************/
|
|
|
|
extern int NCZ_set_var_chunk_cache(int ncid, int varid, size_t size, size_t nelems, float preemption);
|
|
extern int NCZ_adjust_var_cache(NC_GRP_INFO_T *grp, NC_VAR_INFO_T *var);
|
|
extern int NCZ_create_chunk_cache(NC_VAR_INFO_T* var, size64_t, char dimsep, NCZChunkCache** cachep);
|
|
extern void NCZ_free_chunk_cache(NCZChunkCache* cache);
|
|
extern int NCZ_read_cache_chunk(NCZChunkCache* cache, const size64_t* indices, void** datap);
|
|
extern int NCZ_flush_chunk_cache(NCZChunkCache* cache);
|
|
extern size64_t NCZ_cache_entrysize(NCZChunkCache* cache);
|
|
extern NCZCacheEntry* NCZ_cache_entry(NCZChunkCache* cache, const size64_t* indices);
|
|
extern size64_t NCZ_cache_size(NCZChunkCache* cache);
|
|
extern int NCZ_buildchunkpath(NCZChunkCache* cache, const size64_t* chunkindices, struct ChunkKey* key);
|
|
|
|
#endif /*ZCACHE_H*/
|