casacore
BucketMapped.h
Go to the documentation of this file.
1//# BucketMapped.h: File buckets by means of file mapping
2//# Copyright (C) 2009
3//# Associated Universities, Inc. Washington DC, USA.
4//#
5//# This library is free software; you can redistribute it and/or modify it
6//# under the terms of the GNU Library General Public License as published by
7//# the Free Software Foundation; either version 2 of the License, or (at your
8//# option) any later version.
9//#
10//# This library is distributed in the hope that it will be useful, but WITHOUT
11//# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12//# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
13//# License for more details.
14//#
15//# You should have received a copy of the GNU Library General Public License
16//# along with this library; if not, write to the Free Software Foundation,
17//# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
18//#
19//# Correspondence concerning AIPS++ should be addressed as follows:
20//# Internet email: aips2-request@nrao.edu.
21//# Postal address: AIPS++ Project Office
22//# National Radio Astronomy Observatory
23//# 520 Edgemont Road
24//# Charlottesville, VA 22903-2475 USA
25//#
26//# $Id$
27
28#ifndef CASA_BUCKETMAPPED_H
29#define CASA_BUCKETMAPPED_H
30
31//# Includes
32#include <casacore/casa/aips.h>
33#include <casacore/casa/IO/BucketBase.h>
34#include <casacore/casa/IO/MMapfdIO.h>
35
36
37namespace casacore { //# NAMESPACE CASACORE - BEGIN
38
39 // <summary>
40 // Use file mapping for buckets in a part of a file
41 // </summary>
42
43 // <use visibility=export>
44
45 // <reviewed reviewer="UNKNOWN" date="before2004/08/25" tests="" demos="">
46 // </reviewed>
47
48 // <prerequisite>
49 //# Classes you should understand before using this one.
50 // <li> <linkto class=BucketFile>BucketFile</linkto>
51 // </prerequisite>
52
53 // <etymology>
54 // BucketMapped uses memory-mapped files for bucket access.
55 // </etymology>
56
57 // <synopsis>
58 // BucketMapped is similar to class
59 // <linkto class=BucketCache>BucketCache</linkto> and is meant to be used by
60 // the storage managers of the Table System.
61 //
62 // It gives access to buckets in a file by means of memory-mapped files.
63 // However, its functionality is a subset of BucketCache and is only meant
64 // to be used by the Tiled Storage Managers. If The Standard and Incremental
65 // Storage Manager also want to use it, functions like <src>extend</src>
66 // needs to be added to this class. Also support for a free bucket list needs
67 // to be added.
68 // </synopsis>
69
70 // <motivation>
71 // Use of BucketCache is sub-optimal when having large buckets and more or
72 // less random IO. Memory-mapping behaves much better.
73 // </motivation>
74
75
77 {
78 public:
79 // Create the cache for (part of) a file.
80 // The file part mapped into memory starts at startOffset. Its length is
81 // bucketSize*nrOfBuckets bytes.
82 // If the file is smaller, the remainder is indicated as an extension
83 // similarly to the behaviour of function extend.
84 BucketMapped (BucketFile* file, Int64 startOffset, uInt bucketSize,
85 uInt nrOfBuckets);
86
87 // Unmap the file
89
90 // Get a readonly pointer to the given bucket in memory.
91 const char* getBucket (uInt bucketNr);
92
93 // Get a writable pointer to the given bucket in memory.
94 // It sets the hasWritten flag.
95 char* getrwBucket (uInt bucketNr)
96 {
98 return const_cast<char*>(getBucket(bucketNr));
99 }
100
101private:
102 // Copy constructor is not possible.
104
105 // Assignment is not possible.
107
108 // Flush the file.
109 virtual void doFlush();
110
111 // Do the actual resync-ing.
112 virtual void doResync();
113
114 // Extend the file with the given number of buckets.
115 virtual void doExtend (uInt nrBucket);
116
117 // Initialize the bucket buffer.
118 // The uninitialized buckets before this bucket are also initialized.
119 virtual void initializeBuckets (uInt bucketNr);
120 };
121
122
123} //# NAMESPACE CASACORE - END
124
125#endif
Bool itsHasWritten
Have data been written?
Definition: BucketBase.h:131
const char * getBucket(uInt bucketNr)
Get a readonly pointer to the given bucket in memory.
~BucketMapped()
Unmap the file.
BucketMapped & operator=(const BucketMapped &)
Assignment is not possible.
virtual void initializeBuckets(uInt bucketNr)
Initialize the bucket buffer.
virtual void doExtend(uInt nrBucket)
Extend the file with the given number of buckets.
BucketMapped(const BucketMapped &)
Copy constructor is not possible.
virtual void doResync()
Do the actual resync-ing.
virtual void doFlush()
Flush the file.
char * getrwBucket(uInt bucketNr)
Get a writable pointer to the given bucket in memory.
Definition: BucketMapped.h:95
BucketMapped(BucketFile *file, Int64 startOffset, uInt bucketSize, uInt nrOfBuckets)
Create the cache for (part of) a file.
this file contains all the compiler specific defines
Definition: mainpage.dox:28
unsigned int uInt
Definition: aipstype.h:51
long long Int64
Define the extra non-standard types used by Casacore (like proposed uSize, Size)
Definition: aipsxtype.h:38
const Bool True
Definition: aipstype.h:43