Skip to content

Commit 6fd0cd8

Browse files
authored
Merge pull request #3279 from edhartnett/ejh_docs_0220
add doxygen documentation to libdap2 cache, cdf, dapattr, and dapcvt …
2 parents 0a0e664 + fc8fd1d commit 6fd0cd8

File tree

8 files changed

+523
-99
lines changed

8 files changed

+523
-99
lines changed

libdap2/cache.c

Lines changed: 54 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,15 @@ So this flag controls this. By default, it is on.
1616

1717
static int iscacheableconstraint(DCEconstraint* con);
1818

19-
/* Return 1 if we can reuse cached data to address
20-
the current get_vara request; return 0 otherwise.
21-
Target is in the constrained tree space.
22-
Currently, if the target matches a cache that is not
23-
a whole variable, then match is false.
19+
/**
20+
Test whether a variable's data can be satisfied from the cache.
21+
Searches the prefetch node first, then other cache nodes (LRU order).
22+
Only whole-variable cache nodes are considered for matching.
23+
Target must be in the constrained tree space.
24+
@param nccomm the common DAP state containing the cache
25+
@param target the CDFnode variable to look up in the cache
26+
@param cachenodep output pointer to the matching cache node, or unchanged if not found
27+
@return 1 if a usable cache node was found, 0 otherwise
2428
*/
2529
int
2630
iscached(NCDAPCOMMON* nccomm, CDFnode* target, NCcachenode** cachenodep)
@@ -87,11 +91,12 @@ else
8791
return found;
8892
}
8993

90-
/* Compute the set of prefetched data.
91-
Notes:
92-
1. All prefetches are whole variable fetches.
93-
2. If the data set is unconstrainable, we
94-
will prefetch the whole thing
94+
/**
95+
Fetch and cache the set of prefetchable variables.
96+
All prefetches are whole-variable fetches. If the dataset is
97+
unconstrainable, the entire dataset is prefetched.
98+
@param nccomm the common DAP state
99+
@return NC_NOERR on success, an NC error code on failure
95100
*/
96101
NCerror
97102
prefetchdata(NCDAPCOMMON* nccomm)
@@ -210,6 +215,18 @@ ncbytesfree(buf);
210215
return THROW(ncstat);
211216
}
212217

218+
/**
219+
Fetch data from the server and build a new cache node.
220+
Issues a constrained DATADDS fetch, restructures the resulting tree,
221+
and inserts the new node into the cache (evicting old entries as needed
222+
to stay within the cache size and count limits).
223+
@param nccomm the common DAP state
224+
@param constraint the DAP constraint to use for the fetch; ownership is transferred
225+
@param varlist the list of CDFnode variables covered by this cache node
226+
@param cachep output pointer to the newly created cache node
227+
@param flags cache control flags (e.g., NCF_PREFETCH)
228+
@return NC_NOERR on success, an NC error code on failure
229+
*/
213230
NCerror
214231
buildcachenode(NCDAPCOMMON* nccomm,
215232
DCEconstraint* constraint,
@@ -319,13 +336,23 @@ fprintf(stderr,"buildcachenode: %s\n",dumpcachenode(cachenode));
319336
return THROW(ncstat);
320337
}
321338

339+
/**
340+
Allocate and zero-initialize a new NCcachenode.
341+
@return pointer to the new NCcachenode, or NULL on allocation failure
342+
*/
322343
NCcachenode*
323344
createnccachenode(void)
324345
{
325346
NCcachenode* mem = (NCcachenode*)calloc(1,sizeof(NCcachenode));
326347
return mem;
327348
}
328349

350+
/**
351+
Free an NCcachenode and all resources it owns.
352+
Releases the OC data content, constraint, datadds tree, and variable list.
353+
@param nccomm the common DAP state (used for the OC connection)
354+
@param node the cache node to free; no-op if NULL
355+
*/
329356
void
330357
freenccachenode(NCDAPCOMMON* nccomm, NCcachenode* node)
331358
{
@@ -342,6 +369,11 @@ fprintf(stderr,"freecachenode: %s\n",
342369

343370
}
344371

372+
/**
373+
Free an NCcache and all cache nodes it contains.
374+
@param nccomm the common DAP state (passed to freenccachenode)
375+
@param cache the cache to free; no-op if NULL
376+
*/
345377
void
346378
freenccache(NCDAPCOMMON* nccomm, NCcache* cache)
347379
{
@@ -355,6 +387,10 @@ freenccache(NCDAPCOMMON* nccomm, NCcache* cache)
355387
nullfree(cache);
356388
}
357389

390+
/**
391+
Allocate and initialize a new NCcache with default limits.
392+
@return pointer to the new NCcache, or NULL on allocation failure
393+
*/
358394
NCcache*
359395
createnccache(void)
360396
{
@@ -396,11 +432,14 @@ iscacheableconstraint(DCEconstraint* con)
396432
return 1;
397433
}
398434

399-
/*
400-
A variable is prefetchable if
401-
1. it is atomic
402-
2. it's size is sufficiently small
403-
3. it is not contained in sequence or a dimensioned structure.
435+
/**
436+
Mark variables in the unconstrained DDS as eligible for prefetching.
437+
A variable is prefetchable if:
438+
1. it is atomic,
439+
2. its total element count is within the smallsizelimit, and
440+
3. it is not contained in a sequence.
441+
@param nccomm the common DAP state
442+
@return NC_NOERR always
404443
*/
405444
NCerror
406445
markprefetch(NCDAPCOMMON* nccomm)

0 commit comments

Comments
 (0)