28 #ifndef CASA_BUCKETCACHE_H
29 #define CASA_BUCKETCACHE_H
89 typedef char* (*BucketCacheToLocal) (
void* ownerObject,
const char* canonical);
90 typedef void (*BucketCacheFromLocal) (
void* ownerObject,
char* canonical,
92 typedef char* (*BucketCacheAddBuffer) (
void* ownerObject);
93 typedef void (*BucketCacheDeleteBuffer) (
void* ownerObject,
char* buffer);
229 BucketCacheToLocal readCallBack,
230 BucketCacheFromLocal writeCallBack,
231 BucketCacheAddBuffer addCallBack,
232 BucketCacheDeleteBuffer deleteCallBack);
BucketCacheDeleteBuffer its_DeleteCallBack
The delete callback function.
File object for BucketCache.
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
BucketFile * its_file
The file used.
void removeBucket()
Remove the current bucket; i.e.
Cache for buckets in a part of a file.
Int firstFreeBucket() const
Get the bucket number of the first free bucket.
BucketCacheFromLocal its_WriteCallBack
The write callback function.
void initializeBuckets(uInt bucketNr)
Initialize the bucket buffer.
Block< uInt > its_BucketNr
The buckets in the cache.
uInt its_NewNrOfBuckets
The new nr of buckets in the file (after extension).
void resync(uInt nrBucket, uInt nrOfFreeBucket, Int firstFreeBucket)
Resynchronize the object (after another process updated the file).
void readBucket(uInt slotNr)
Read a bucket.
void initStatistics()
(Re)initialize the cache statistics.
uInt addBucket(char *data)
Add a bucket to the file and make it the current one.
uInt its_ActualSlot
The cache slot actually used.
uInt cacheSize() const
Get the current cache size (in buckets).
uInt naccess_p
The statistics.
void extend(uInt nrBucket)
Extend the file with the given number of buckets.
void setDirty()
Set the dirty bit for the current bucket.
Block< Int > its_SlotNr
The slot numbers of the buckets in the cache (-1 = not in cache).
Bool flush(uInt fromSlot=0)
Flush the cache from the given slot on.
void resize(uInt cacheSize)
Resize the cache.
uInt its_LRUCounter
The Least Recently Used counter.
uInt its_NrOfFree
The number of free buckets.
BucketCache & operator=(const BucketCache &)
Assignment is not possible.
void getSlot(uInt bucketNr)
Get a cache slot for the bucket.
char * its_Buffer
The internal buffer.
uInt its_CurNrOfBuckets
The current nr of buckets in the file.
void setLRU()
Set the LRU information for the current slot.
LatticeExprNode length(const LatticeExprNode &expr, const LatticeExprNode &axis)
2-argument function to get the length of an axis.
BucketCache(BucketFile *file, Int64 startOffset, uInt bucketSize, uInt nrOfBuckets, uInt cacheSize, void *ownerObject, BucketCacheToLocal readCallBack, BucketCacheFromLocal writeCallBack, BucketCacheAddBuffer addCallBack, BucketCacheDeleteBuffer deleteCallBack)
Create the cache for (a part of) a file.
Int64 its_StartOffset
The starting offsets of the buckets in the file.
bool Bool
Define the standard types used by Casacore.
void writeBucket(uInt slotNr)
Write a bucket.
Block< uInt > its_Dirty
Determine if a block is dirty (i.e.
void * its_Owner
The owner object.
void showStatistics(ostream &os) const
Show the statistics.
Block< uInt > its_LRU
Determine when a block is used for the last time.
void checkOffset(uInt length, Int64 offset) const
Check if the offset of a non-cached part is correct.
uInt its_CacheSizeUsed
The nr of slots used in the cache.
BucketCacheAddBuffer its_InitCallBack
The add bucket callback function.
void put(const char *buf, uInt length, Int64 offset)
Put a part from the file outside the cached area.
uInt its_CacheSize
The size of the cache (i.e.
uInt nBucket() const
Get the current nr of buckets in the file.
uInt its_BucketSize
The bucket size.
void clear(uInt fromSlot=0, Bool doFlush=True)
Clear the cache from the given slot on.
BucketCacheToLocal its_ReadCallBack
The read callback function.
uInt nFreeBucket() const
Get the number of free buckets.
char * getBucket(uInt bucketNr)
Make another bucket current.
PtrBlock< char * > its_Cache
The cache itself.
Int its_FirstFree
The first free bucket (-1 = no free buckets).