Go to the documentation of this file.
28 #ifndef CASA_BUCKETCACHE_H
29 #define CASA_BUCKETCACHE_H
32 #include <casacore/casa/aips.h>
33 #include <casacore/casa/IO/BucketFile.h>
34 #include <casacore/casa/Containers/Block.h>
35 #include <casacore/casa/OS/CanonicalConversion.h>
38 #include <casacore/casa/iosfwd.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);
BucketCacheToLocal its_ReadCallBack
The read callback function.
void removeBucket()
Remove the current bucket; i.e.
void initializeBuckets(uInt bucketNr)
Initialize the bucket buffer.
void resync(uInt nrBucket, uInt nrOfFreeBucket, Int firstFreeBucket)
Resynchronize the object (after another process updated the file).
Block< uInt > its_BucketNr
The buckets in the cache.
BucketCacheDeleteBuffer its_DeleteCallBack
The delete callback function.
uInt its_BucketSize
The bucket size.
char * getBucket(uInt bucketNr)
Make another bucket current.
void initStatistics()
(Re)initialize the cache statistics.
BucketCacheFromLocal its_WriteCallBack
The write callback function.
void checkOffset(uInt length, Int64 offset) const
Check if the offset of a non-cached part is correct.
Int firstFreeBucket() const
Get the bucket number of the first free bucket.
void get(char *buf, uInt length, Int64 offset)
Get a part from the file outside the cached area.
void readBucket(uInt slotNr)
Read a bucket.
Cache for buckets in a part of a file.
void showStatistics(ostream &os) const
Show the statistics.
BucketFile * its_file
The file used.
void setDirty()
Set the dirty bit for the current bucket.
File object for BucketCache.
uInt cacheSize() const
Get the current cache size (in buckets).
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 its_LRUCounter
The Least Recently Used counter.
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.
uInt its_NewNrOfBuckets
The new nr of buckets in the file (after extension).
void setLRU()
Set the LRU information for the current slot.
void resize(uInt cacheSize)
Resize the cache.
void(* BucketCacheFromLocal)(void *ownerObject, char *canonical, const char *local)
void extend(uInt nrBucket)
Extend the file with the given number of buckets.
char * its_Buffer
The internal buffer.
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.
uInt its_NrOfFree
The number of free buckets.
BucketCache & operator=(const BucketCache &)
Assignment is not possible.
Define the type of the static read and write function.
uInt naccess_p
The statistics.
void getSlot(uInt bucketNr)
Get a cache slot for the bucket.
uInt its_CurNrOfBuckets
The current nr of buckets in the file.
Block< uInt > its_Dirty
Determine if a block is dirty (i.e.
this file contains all the compiler specific defines
LatticeExprNode length(const LatticeExprNode &expr, const LatticeExprNode &axis)
2-argument function to get the length of an axis.
void * its_Owner
The owner object.
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.
Int64 its_StartOffset
The starting offsets of the buckets in the file.
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
void writeBucket(uInt slotNr)
Write a bucket.
uInt nFreeBucket() const
Get the number of free buckets.
Int its_FirstFree
The first free bucket (-1 = no free buckets).
bool Bool
Define the standard types used by Casacore.
uInt nBucket() const
Get the current nr of buckets in the file.
Block< uInt > its_LRU
Determine when a block is used for the last time.
void(* BucketCacheDeleteBuffer)(void *ownerObject, char *buffer)
uInt its_CacheSize
The size of the cache (i.e.
PtrBlock< char * > its_Cache
The cache itself.
uInt its_CacheSizeUsed
The nr of slots used in the cache.
void clear(uInt fromSlot=0, Bool doFlush=True)
Clear the cache from the given slot on.