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