mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-12-27 08:49:16 +08:00
eb3d9eb0c9
Primary changes: * Add an improved cache system to speed up performance. * Fix NCZarr to properly handle scalar variables. Misc. Related Changes: * Added unit tests for extendible hash and for the generic cache. * Add config parameter to set size of the NCZarr cache. * Add initial performance tests but leave them unused. * Add CRC64 support. * Move location of ncdumpchunks utility from /ncgen to /ncdump. * Refactor auth support. Misc. Unrelated Changes: * More cleanup of the S3 support * Add support for S3 authentication in .rc files: HTTP.S3.ACCESSID and HTTP.S3.SECRETKEY. * Remove the hashkey from the struct OBJHDR since it is never used.
69 lines
1.9 KiB
C
69 lines
1.9 KiB
C
/*
|
|
Copyright (c) 1998-2018 University Corporation for Atmospheric Research/Unidata
|
|
See COPYRIGHT for license information.
|
|
*/
|
|
|
|
#ifndef NCXCACHE_H
|
|
#define NCXCACHE_H
|
|
|
|
#include "nclist.h"
|
|
#include "ncexhash.h" /* Also includes name map and id map */
|
|
|
|
/* Define the implementation.
|
|
if defined, then the user's object
|
|
is assumed to hold the double linked list node,
|
|
otherwise, it is created here.
|
|
*/
|
|
#define NCXUSER
|
|
|
|
/*
|
|
This cache data structure is an ordered list of objects. It is
|
|
used to create an LRU cache of arbitrary objects.
|
|
*/
|
|
|
|
/* Doubly linked list element */
|
|
typedef struct NCxnode {
|
|
struct NCxnode* next;
|
|
struct NCxnode* prev;
|
|
void* content; /* associated data of some kind may be unused*/
|
|
} NCxnode;
|
|
|
|
typedef struct NCxcache {
|
|
NCxnode lru;
|
|
NCexhashmap* map;
|
|
} NCxcache;
|
|
|
|
/* Locate object by hashkey */
|
|
EXTERNL int ncxcachelookup(NCxcache* cache, ncexhashkey_t hkey, void** objp);
|
|
|
|
/* Insert object into the cache >*/
|
|
EXTERNL int ncxcacheinsert(NCxcache* cache, ncexhashkey_t hkey, void* obj);
|
|
|
|
/* Bring to front of the LRU queue */
|
|
EXTERNL int ncxcachetouch(NCxcache* cache, ncexhashkey_t hkey);
|
|
|
|
/* "Remove" object from the cache; return object */
|
|
EXTERNL int ncxcacheremove(NCxcache* cache, ncexhashkey_t hkey, void** obj);
|
|
|
|
/* Free cache. */
|
|
EXTERNL void ncxcachefree(NCxcache* cache);
|
|
|
|
/* Create a cache: size == 0 => use defaults */
|
|
EXTERNL int ncxcachenew(size_t initsize, NCxcache**) ;
|
|
|
|
/* Macro function */
|
|
|
|
/* Get the number of entries in an NCxcache */
|
|
#define ncxcachecount(cache) (cache == NULL ? 0 : ncexhashcount((cache)->map))
|
|
|
|
EXTERNL void* ncxcachefirst(NCxcache* cache);
|
|
EXTERNL void* ncxcachelast(NCxcache* cache);
|
|
|
|
/* Return the hash key for specified key; takes key+size; an alias for the one in ncexhash */
|
|
EXTERNL ncexhashkey_t ncxcachekey(const void* key, size_t size);
|
|
|
|
/* Debugging */
|
|
EXTERNL void ncxcacheprint(NCxcache* cache);
|
|
|
|
#endif /*NCXCACHE_H*/
|