casacore
Loading...
Searching...
No Matches
PagedArray.h
Go to the documentation of this file.
1// # PagedArray.h: templated Lattice, paged from disk to memory on demand
2// # Copyright (C) 1994,1995,1996,1997,1998,1999,2000,2001,2002,2003
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: casa-feedback@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#ifndef LATTICES_PAGEDARRAY_H
27#define LATTICES_PAGEDARRAY_H
28
29// # Includes
30#include <casacore/casa/aips.h>
31#include <casacore/lattices/Lattices/Lattice.h>
32#include <casacore/lattices/Lattices/TiledShape.h>
33#include <casacore/tables/Tables/ArrayColumn.h>
34#include <casacore/tables/Tables/Table.h>
35#include <casacore/tables/DataMan/TiledStManAccessor.h>
36#include <casacore/casa/BasicSL/String.h>
37
38namespace casacore { // # NAMESPACE CASACORE - BEGIN
39
40// <summary>
41// A Lattice that is read from or written to disk.
42// </summary>
43
44// <use visibility=export>
45
46// <reviewed reviewer="Peter Barnes" date="1999/10/30" tests="tPagedArray.cc"
47// demos="dPagedArray.cc">
48// </reviewed>
49
50// <prerequisite>
51// <li> <linkto class="Lattice">Lattice</linkto>
52// <li> <linkto class="TiledShape">TiledShape</linkto>
53// </prerequisite>
54
55// <etymology>
56// "Demand paging" is a technique used to implement virtual memory in
57// computer operating systems. In this scheme, code or data are read from
58// disk to memory only as needed by a process, and are read in fixed-sized
59// chunks called "pages". PagedArrays are somewhat the same -- though
60// without the automatic features found in virtual memory demand paging.
61// However PagedArrays do allow the user to access chunks of the disk in a
62// flexible way, that can match the requirements of many algorithms.
63// </etymology>
64
65// <synopsis>
66// At the time of writing, typical scientific computers provide sufficient
67// memory for storing and manipulating 2-dimensional astronomical images,
68// which have average size of around 8 MBytes. Astronomy is increasingly
69// using three or higher dimensional arrays, which can be larger by one or
70// two orders of magnitude. PagedArrays provide a convenient way of
71// accessing these large arrays without requiring all the data to be read
72// into real or virtual memory.
73// <p>
74// When you construct a PagedArray you do not read any data into
75// memory. Instead a disk file (ie. a Table) is created, in a place you
76// specify, to hold the data. This means you need to have enough disk space
77// to hold the array. Constructing a PagedArray is equivalent to opening a
78// file.
79// <p>
80// Because the data is stored on disk it can be saved after the program,
81// function, or task that created the PagedArray has finished. This saved
82// array can then be read again at a later stage.
83// <p>
84// So there are two reasons for using a PagedArray:
85// <ol>
86// <li> To provide for arrays that are too large for the computer's memory.
87// <li> To provide a way of saving arrays to disk for later access.
88// </ol>
89//
90// To access the data in a PagedArray you can either:
91// <ol>
92// <li> Use a <linkto class=LatticeIterator>LatticeIterator</linkto>
93// <li> Use the getSlice and putSlice member functions
94// <li> Use the parenthesis operator or getAt and putAt functions
95// </ol>
96// These access methods are given in order of preference. Some examples of
97// these access methods are in the documentation for the
98// <linkto class=Lattice>Lattice</linkto> class as well as below.
99// <p>
100// In nearly all cases you access the PagedArray by reading a "slice" of the
101// PagedArray into a Casacore <linkto class=Array>Array</linkto>. Because the
102// slice is stored in memory it is important that the slice you read is not
103// too big compared to the physical memory on your computer. Otherwise your
104// computer will page excessively and performance will be poor.
105// <p>
106// To overcome this you may be tempted to access the PagedArray a pixel at a
107// time. This will use little memory but the overhead of accessing a large
108// data set by separately reading each pixel from disk will also lead to poor
109// performance.
110// <p>
111// In general the best way to access the data in PagedArrays is to use a
112// LatticeIterator with a cursor size that "fits" nicely into memory. Not
113// only do the LaticeIterator classes provide a relatively simple way to
114// read/write all the data but they optimally set up the cache that is
115// associated with each PagedArray.
116// <p>
117// If the LatticeIterator classes do not access the data the way you want
118// you can use the getSlice and putSlice member functions. These functions
119// do not set up the cache for you and improved performance may be obtained
120// by tweaking the cache using the setCacheSizeFromPath member frunction.
121//
122// <ANCHOR NAME="PagedArray:Advanced"><h3>More Details</h3></ANCHOR>
123// In order to utilise PagedArrays fully and understand many of the member
124// functions and data access methods in this class, you need to be familiar
125// with some of the concepts involved in the implementation of PagedArrays.
126// <p>
127// Each PagedArray is stored in one cell of a Table as an indirect Array
128// (see the documentation for the <linkto module="Tables">Tables</linkto>
129// module for more information). This means that multiple PagedArrays can be
130// stored in one Table. To specify which PagedArray you are referring to in
131// a given Table you need to specify the cell using its column name and row
132// number during construction. If a cell is not specified the default column
133// name (as given by the defaultColumnName function) and row number (as
134// given by the defaultRowNumber function) are used. This ability to store
135// multiple PagedArrays's is used in the PagedImage class where the image is
136// stored in one cell and a mask is optionally stored in a another column in
137// the same row.
138// <p>
139// There are currently a number of limitations when storing multiple
140// PagedArrays in the same Table.
141// <ul>
142// <li> All the PagedArrays in the same column MUST have the same number of
143// dimensions. The dimension used for any particular column is set when the
144// first PagedArray in that column is constructed. If you want to put a
145// say two-dimensional PagedArray into another row of a column that
146// already contains a four-dimensional PagedArray you need to add two
147// degenerate axes. In principle you could use the resize function, but see
148// below for why this is not recommended. It is better to just ensure that
149// all the PagedArrays have the same number of dimensions.
150// <li> All the cells in a column that contains PagedArrays must have their
151// shape defined. This becomes important if you are creating a PagedArray in
152// say row five of a Table that currently only has one row. The PagedArray
153// constructor will add another four rows to the Table, and put your
154// PagedArray (with the shape you specify) in row five. For the three
155// rows for which no shape was specified, the constructor will construct
156// PagedArrays with only one element (and of an appropriate
157// dimensionality). As you cannot resize these single element PagedArrays
158// without difficulty (see below), it is recommended that you add
159// PagedArrays to rows in your Table sequentially. It is necessary to have
160// the constructor define the shape of all cells in the Table as it is an
161// error to write a Table to disk with undefined cell shapes.
162// </ul>
163//
164// Each PagedArray is stored on disk using the tiled cell storage manager
165// (<linkto class=TiledCellStMan>TiledCellStMan</linkto>). This stores the
166// data in tiles which are regular subsections of the PagedArray. For
167// example a PagedArray of shape [1024,1024,4,128] may have a tile shape of
168// [32,16,4,16]. The data in each tile is stored as a unit on the disk. This
169// means that there is no preferred axis when accessing multi-dimensional
170// data.
171// <br>
172// The tile shape can be specified when constructing a new PagedArray but
173// not when reading an old one as it is intrinsic to the way the data is
174// stored on disk. It is NOT recommended that you specify the tile shape
175// unless you can control the lifetime of the PagedArray (this includes the
176// time it spends on disk), or can guarantee the access pattern. For example
177// if you know that a PagedArray of shape [512,512,4,32] will always be
178// sliced plane by plane you may prefer to specify a tile shape of
179// [512,64,1,1] rather than the default of [32,16,4,16].
180// <br>
181// Tiles can be cached by the tile storage manager so that it does not need
182// to read the data from disk every time you are accessing the a pixel in a
183// different tile. In order to cache the correct tiles you should tell the
184// storage manager what section of the PagedArray you will be
185// accessing. This is done using the setCacheSizeFromPath member
186// function. Alternatively you can set the size of the cache using the
187// setCacheSizeInTiles member function.
188// <br>
189// By default there is no limit on how much memory the tile cache can
190// consume. This can be changed using the setMaximumCacheSize member
191// function. The tiled storage manager always tries to cache enough tiles to
192// ensure that each tile is read from disk only once, so setting the maximum
193// cache size will trade off memory usage for disk I/O. Setting the cache
194// size is illustrated in example 5 below.
195// <br>
196// The showCacheStatistics member function is provided to allow you to
197// evaluate the performance of the tile cache.
198// </synopsis>
199
200// <example>
201// All the examples in this section are available in dPagedArray.cc
202//
203// <h4>Example 1:</h4>
204// Create a PagedArray of Floats of shape [1024,1024,4,256] in a file
205// called "myData_tmp.array" and initialize it to zero. This will create a
206// directory on disk called "myData_tmp.array" that contains files that
207// exceed 1024*1024*4*256*4 (= 4 GBytes) in size.
208// <srcblock>
209// const IPosition arrayShape(4,1024,1024,4,256);
210// const String filename("myData_tmp.array");
211// PagedArray<Float> diskArray(arrayShape, filename);
212// cout << "Created a PagedArray of shape " << diskArray.shape()
213// << " (" << diskArray.shape().product()/1024/1024*sizeof(Float)
214// << " MBytes)" << endl
215// << "in the table called " << diskArray.tableName() << endl;
216// diskArray.set(0.0f);
217// // Using the set function is an efficient way to initialize the PagedArray
218// // as it uses a PagedArrIter internally. Note that the set function is
219// // defined in the Lattice class that PagedArray is derived from.
220// </srcblock>
221//
222// <h4>Example 2:</h4>
223// Read the PagedArray produced in Example 1 and put a Gaussian profile into
224// each spectral channel.
225// <srcblock>
226// PagedArray<Float> diskArray("myData_tmp.array");
227// IPosition shape = diskArray.shape();
228// // Construct a Gaussian Profile to be 10 channels wide and centred on
229// // channel 16. Its height is 1.0.
230// Gaussian1D<Float> g(1.0f, 16.0f, 10.0f);
231// // Create a vector to cache a sampled version of this profile.
232// Vector<Float> profile(shape(3));
233// indgen(profile);
234// profile.apply(g);
235// // Now put this profile into every spectral channel in the paged array. This
236// // is best done using an iterator.
237// LatticeIterator<Float> iter(diskArray,
238// TiledLineStepper(shape, diskArray.tileShape(), 3));
239// for (iter.reset(); !iter.atEnd(); iter++) {
240// iter.woCursor() = profile;
241// }
242// </srcblock>
243//
244// <h4>Example 3:</h4>
245// Now multiply the I-polarization data by 10.0 in this PagedArray. The
246// I-polarization data occupies 1 GByte of RAM which is too big to read
247// into the memory of most computers. So an iterator is used to get suitable
248// sized chunks.
249// <srcblock>
250// Table t("myData_tmp.array", Table::Update);
251// PagedArray<Float> da(t);
252// const IPosition latticeShape = da.shape();
253// const nx = latticeShape(0);
254// const ny = latticeShape(1);
255// const npol = latticeShape(2);
256// const nchan = latticeShape(3);
257// IPosition cursorShape = da.niceCursorShape();
258// cursorShape(2) = 1;
259// LatticeStepper step(latticeShape, cursorShape);
260// step.subSection(IPosition(4,0), IPosition(4,nx-1,ny-1,0,nchan-1));
261// LatticeIterator<Float> iter(da, step);
262// for (iter.reset(); !iter.atEnd(); iter++) {
263// iter.rwCursor() *= 10.0f;
264// }
265// </srcblock>
266//
267// <h4>Example 4:</h4>
268// Use a direct call to getSlice to access a small central region of the
269// V-polarization in spectral channel 0 only. The region is small enough
270// to not warrant constructing iterators and setting up
271// LatticeNavigators. In this example the call to the getSlice function
272// is unnecessary but is done for illustration purposes anyway.
273// <srcblock>
274// SetupNewTable maskSetup("mask_tmp.array", TableDesc(), Table::New);
275// Table maskTable(maskSetup);
276// PagedArray<Bool> maskArray(IPosition(4,1024,1024,4,256), maskTable);
277// maskArray.set(False);
278// COWPtr<Array<Bool>> maskPtr;
279// maskArray.getSlice(maskPtr, IPosition(4,240,240,3,0),
280// IPosition(4,32,32,1,1), IPosition(4,1));
281// maskPtr.rwRef() = True;
282// maskArray.putSlice(*maskPtr, IPosition(4,240,240,3,1));
283// </srcblock>
284//
285// <h4>Example 5:</h4>
286// In this example the data in the PagedArray will be accessed a row at
287// a time while setting the cache size to different values. The comments
288// illustrate the results when running on an Ultra 1/140 with 64MBytes
289// of memory.
290// <srcblock>
291// PagedArray<Float> pa(IPosition(4,128,128,4,32));
292// const IPosition latticeShape = pa.shape();
293// cout << "The tile shape is:" << pa.tileShape() << endl;
294// // The tile shape is:[32, 16, 4, 16]
295//
296// // Setup to access the PagedArray a row at a time
297// const IPosition sliceShape(4,latticeShape(0), 1, 1, 1);
298// const IPosition stride(4,1);
299// Array<Float> row(sliceShape);
300// IPosition start(4, 0);
301//
302// // Set the cache size to enough pixels for one tile only. This uses
303// // 128kBytes of cache memory and takes 125 secs.
304// pa.setCacheSizeInTiles (1);
305// Timer clock;
306// for (start(3) = 0; start(3) < latticeShape(3); start(3)++) {
307// for (start(2) = 0; start(2) < latticeShape(2); start(2)++) {
308// for (start(1) = 0; start(1) < latticeShape(1); start(1)++) {
309// pa.getSlice(row, start, sliceShape, stride);
310// }
311// }
312// }
313// clock.show();
314// pa.showCacheStatistics(cout);
315// pa.clearCache();
316//
317// // Set the cache size to enough pixels for one row of tiles (ie. 4).
318// // This uses 512 kBytes of cache memory and takes 10 secs.
319// pa.setCacheSizeInTiles (4);
320// clock.mark();
321// for (start(3) = 0; start(3) < latticeShape(3); start(3)++) {
322// for (start(2) = 0; start(2) < latticeShape(2); start(2)++) {
323// for (start(1) = 0; start(1) < latticeShape(1); start(1)++) {
324// pa.getSlice(row, start, sliceShape, stride);
325// }
326// }
327// }
328// clock.show();
329// pa.showCacheStatistics(cout);
330// pa.clearCache();
331//
332// // Set the cache size to enough pixels for one plane of tiles
333// // (ie. 4*8). This uses 4 MBytes of cache memory and takes 2 secs.
334// pa.setCacheSizeInTiles (4*8);
335// clock.mark();
336// for (start(3) = 0; start(3) < latticeShape(3); start(3)++) {
337// for (start(2) = 0; start(2) < latticeShape(2); start(2)++) {
338// for (start(1) = 0; start(1) < latticeShape(1); start(1)++) {
339// pa.getSlice(row, start, sliceShape, stride);
340// }
341// }
342// }
343// clock.show();
344// pa.showCacheStatistics(cout);
345// pa.clearCache();
346// </srcblock>
347// </example>
348
349// <motivation>
350// Arrays of data are sometimes much too large to hold in random access memory.
351// PagedArrays, especially in combination with LatticeIterator,
352// provide convenient access to such large data sets.
353// </motivation>
354
355// <templating arg=T>
356// <li> Due to storage in Tables, the templated type must be able to be
357// stored in a Casacore Table. This restricts the template argument to all
358// the common types Bool, Float, Double, Complex, String etc.) More details
359// can be found in the RetypedArrayEngine class.
360// </templating>
361
362// <todo asof="1997/04/14">
363// <li> A better way of resizing PagedArrays
364// </todo>
365
366// <linkfrom anchor="PagedArray" classes="Lattice ArrayLattice">
367// <here>PagedArray</here> - a disk based Lattice.
368// </linkfrom>
369
370template <class T>
371class PagedArray : public Lattice<T> {
372 // # Make members of parent class known.
373 public:
374 using Lattice<T>::ndim;
375
376 public:
377 // The default constructor creates a PagedArray that is useless for just
378 // about everything, except that it can be assigned to with the assignment
379 // operator.
381
382 // Construct a new PagedArray with the specified shape. A new Table with
383 // the specified filename is constructed to hold the array. The Table will
384 // remain on disk after the PagedArray goes out of scope or is deleted.
385 PagedArray(const TiledShape& shape, const String& filename);
386
387 // Construct a new PagedArray with the specified shape. A scratch Table is
388 // created in the current working directory to hold the array. This Table
389 // will be deleted automatically when the PagedArray goes out of scope or
390 // is deleted.
391 explicit PagedArray(const TiledShape& shape);
392
393 // Construct a new PagedArray, with the specified shape, in the default
394 // row and column of the supplied Table.
396
397 // Construct a new PagedArray, with the specified shape, in the specified
398 // row and column of the supplied Table.
399 PagedArray(const TiledShape& shape, Table& file, const String& columnName, uInt rowNum);
400
401 // Reconstruct from a pre-existing PagedArray in the default row and
402 // column of the supplied Table with the supplied filename.
403 explicit PagedArray(const String& filename);
404
405 // Reconstruct from a pre-existing PagedArray in the default row and
406 // column of the supplied Table.
407 explicit PagedArray(Table& file);
408
409 // Reconstruct from a pre-existing PagedArray in the specified row and
410 // column of the supplied Table.
411 PagedArray(Table& file, const String& columnName, uInt rowNum);
412
413 // The copy constructor which uses reference semantics. Copying by value
414 // doesn't make sense, because it would require the creation of a
415 // temporary (but possibly huge) file on disk.
417
418 // The destructor flushes the PagedArrays contents to disk.
420
421 // The assignment operator with reference semantics. As with the copy
422 // constructor assigning by value does not make sense.
424
425 // Make a copy of the object (reference semantics).
426 virtual Lattice<T>* clone() const;
427
428 // A PagedArray is always persistent.
429 virtual Bool isPersistent() const;
430
431 // A PagedArray is always paged to disk.
432 virtual Bool isPaged() const;
433
434 // Is the PagedArray writable?
435 virtual Bool isWritable() const;
436
437 // Returns the shape of the PagedArray.
438 virtual IPosition shape() const;
439
440 // Return the current Table name. By default this includes the full path.
441 // The path preceeding the file name can be stripped off on request.
442 virtual String name(Bool stripPath = False) const;
443
444 // Functions to resize the PagedArray. The old contents are lost. Usage of
445 // this function is NOT currently recommended (see the <linkto
446 // class="PagedArray:Advanced">More Details</linkto> section above).
447 void resize(const TiledShape& newShape);
448
449 // Returns the current table name (ie. filename) of this PagedArray.
450 const String& tableName() const;
451
452 // Return the current table object.
453 // <group>
455 const Table& table() const;
456 // </group>
457
458 // Returns the current Table column name of this PagedArray.
459 const String& columnName() const;
460
461 // Returns the default TableColumn name for a PagedArray.
463
464 // Returns an accessor to the tiled storage manager.
466
467 // Returns the current row number of this PagedArray.
469
470 // Returns the default row number for a PagedArray.
471 static uInt defaultRow();
472
473 // Returns the current tile shape for this PagedArray.
475
476 // Returns the maximum recommended number of pixels for a cursor. This is
477 // the number of pixels in a tile.
478 virtual uInt advisedMaxPixels() const;
479
480 // Set the maximum allowed cache size for all Arrays in this column of the
481 // Table. The actual value used may be smaller. A value of zero means
482 // that there is no maximum.
483 virtual void setMaximumCacheSize(uInt howManyPixels);
484
485 // Return the maximum allowed cache size (in pixels) for all Arrays in
486 // this column of the Table. The actual cache size may be smaller. A
487 // value of zero means that no maximum is currently defined.
488 virtual uInt maximumCacheSize() const;
489
490 // Set the actual cache size for this Array to be big enough for the
491 // indicated number of tiles. This cache is not shared with PagedArrays
492 // in other rows and is always clipped to be less than the maximum value
493 // set using the setMaximumCacheSize member function.
494 // Tiles are cached using a first in first out algorithm.
495 virtual void setCacheSizeInTiles(uInt howManyTiles);
496
497 // Set the actual cache size for this Array to "fit" the indicated
498 // path. This cache is not shared with PagedArrays in other rows and is
499 // always less than the maximum value. The sliceShape is the cursor or
500 // slice that you will be requiring (with each call to
501 // {get,put}Slice). The windowStart and windowLength delimit the range of
502 // pixels that will ultimatly be accessed. The AxisPath is described in
503 // the documentation for the LatticeStepper class.
504 virtual void setCacheSizeFromPath(const IPosition& sliceShape, const IPosition& windowStart,
505 const IPosition& windowLength, const IPosition& axisPath);
506
507 // Clears and frees up the tile cache. The maximum allowed cache size is
508 // unchanged from when <src>setMaximumCacheSize</src> was last called.
509 virtual void clearCache();
510
511 // Generate a report on how the cache is doing. This is reset every
512 // time <src>clearCache</src> is called.
513 virtual void showCacheStatistics(std::ostream& os) const;
514
515 // Return the value of the single element located at the argument
516 // IPosition.
517 // Note that <src>Lattice::operator()</src> can also be used.
518 virtual T getAt(const IPosition& where) const;
519
520 // Put the value of a single element.
521 virtual void putAt(const T& value, const IPosition& where);
522
523 // A function which checks for internal consistency. Returns False if
524 // something nasty has happened to the PagedArray. In that case
525 // it also throws an exception.
526 virtual Bool ok() const;
527
528 // This function is used by the LatticeIterator class to generate an
529 // iterator of the correct type for a specified Lattice. Not recommended
530 // for general use.
531 virtual LatticeIterInterface<T>* makeIter(const LatticeNavigator& navigator, Bool useRef) const;
532
533 // Do the actual getting of an array of values.
534 virtual Bool doGetSlice(Array<T>& buffer, const Slicer& section);
535
536 // Do the actual getting of an array of values.
537 virtual void doPutSlice(const Array<T>& sourceBuffer, const IPosition& where,
538 const IPosition& stride);
539
540 // Get the best cursor shape.
541 virtual IPosition doNiceCursorShape(uInt maxPixels) const;
542
543 // Handle the (un)locking.
544 // <group>
545 virtual Bool lock(FileLocker::LockType, uInt nattempts);
546 virtual void unlock();
548 // </group>
549
550 // Resynchronize the PagedArray object with the lattice file.
551 // This function is only useful if no read-locking is used, ie.
552 // if the table lock option is UserNoReadLocking or AutoNoReadLocking.
553 // In that cases the table system does not acquire a read-lock, thus
554 // does not synchronize itself automatically.
555 virtual void resync();
556
557 // Flush the data (but do not unlock).
558 virtual void flush();
559
560 // Temporarily close the lattice.
561 // It will be reopened automatically on the next access.
562 virtual void tempClose();
563
564 // Explicitly reopen the temporarily closed lattice.
565 virtual void reopen();
566
567 private:
568 // Set the data in the TableInfo file
570 // make the ArrayColumn
572 // Make a Table to hold this PagedArray
573 void makeTable(const String& filename, Table::TableOption option);
574 // The default comment for PagedArray Colums
576 // Get the writable ArrayColumn object.
577 // It reopens the table for write if needed.
579 // Do the reopen of the table (if not open already).
580 // <group>
581 void doReopen() const;
582 void tempReopen() const;
583 // </group>
584
595};
596
597template <class T>
599 if (itsIsClosed) {
600 doReopen();
601 }
602 if (!itsWritable) {
603 itsTable.reopenRW();
605 }
606 return itsArray;
607}
608
609template <class T>
611 doReopen();
612 return itsTable;
613}
614template <class T>
615inline const Table& PagedArray<T>::table() const {
616 doReopen();
617 return itsTable;
618}
619
620template <class T>
621inline const String& PagedArray<T>::columnName() const {
622 return itsColumnName;
623}
624
625template <class T>
627 return "PagedArray";
628}
629
630template <class T>
632 return itsAccessor;
633}
634
635template <class T>
637 return itsRowNumber;
638}
639
640template <class T>
642 return 0;
643}
644
645template <class T>
647 if (itsIsClosed) {
648 tempReopen();
649 }
650}
651
652// # Declare extern templates for often used types.
653extern template class PagedArray<Float>;
654extern template class PagedArray<Complex>;
655
656} // namespace casacore
657
658#ifndef CASACORE_NO_AUTO_TEMPLATES
659#include <casacore/lattices/Lattices/PagedArray.tcc>
660#endif // # CASACORE_NO_AUTO_TEMPLATES
661#endif
LockType
Define the possible lock types.
Definition FileLocker.h:89
virtual uInt ndim() const
Return the number of axes in this Lattice.
Lattice()
Define default constructor to satisfy compiler.
Definition Lattice.h:390
void makeArray(const TiledShape &shape)
make the ArrayColumn
PagedArray(const String &filename)
Reconstruct from a pre-existing PagedArray in the default row and column of the supplied Table with t...
ArrayColumn< T > & getRWArray()
Get the writable ArrayColumn object.
Definition PagedArray.h:598
virtual T getAt(const IPosition &where) const
Return the value of the single element located at the argument IPosition.
virtual Bool lock(FileLocker::LockType, uInt nattempts)
Handle the (un)locking.
virtual void reopen()
Explicitly reopen the temporarily closed lattice.
void setTableType()
Set the data in the TableInfo file.
PagedArray()
The default constructor creates a PagedArray that is useless for just about everything,...
Table & table()
Return the current table object.
Definition PagedArray.h:610
virtual String name(Bool stripPath=False) const
Return the current Table name.
PagedArray< T > & operator=(const PagedArray< T > &other)
The assignment operator with reference semantics.
virtual Lattice< T > * clone() const
Make a copy of the object (reference semantics).
void tempReopen() const
virtual void putAt(const T &value, const IPosition &where)
Put the value of a single element.
virtual uInt advisedMaxPixels() const
Returns the maximum recommended number of pixels for a cursor.
~PagedArray()
The destructor flushes the PagedArrays contents to disk.
virtual void setCacheSizeInTiles(uInt howManyTiles)
Set the actual cache size for this Array to be big enough for the indicated number of tiles.
virtual IPosition shape() const
Returns the shape of the PagedArray.
static String defaultColumn()
Returns the default TableColumn name for a PagedArray.
Definition PagedArray.h:626
virtual void showCacheStatistics(std::ostream &os) const
Generate a report on how the cache is doing.
PagedArray(const TiledShape &shape)
Construct a new PagedArray with the specified shape.
void makeTable(const String &filename, Table::TableOption option)
Make a Table to hold this PagedArray.
virtual uInt maximumCacheSize() const
Return the maximum allowed cache size (in pixels) for all Arrays in this column of the Table.
ArrayColumn< T > itsArray
Definition PagedArray.h:593
virtual void setMaximumCacheSize(uInt howManyPixels)
Set the maximum allowed cache size for all Arrays in this column of the Table.
static uInt defaultRow()
Returns the default row number for a PagedArray.
Definition PagedArray.h:641
const String & columnName() const
Returns the current Table column name of this PagedArray.
Definition PagedArray.h:621
virtual LatticeIterInterface< T > * makeIter(const LatticeNavigator &navigator, Bool useRef) const
This function is used by the LatticeIterator class to generate an iterator of the correct type for a ...
virtual void doPutSlice(const Array< T > &sourceBuffer, const IPosition &where, const IPosition &stride)
Do the actual getting of an array of values.
uInt rowNumber() const
Returns the current row number of this PagedArray.
Definition PagedArray.h:636
PagedArray(const TiledShape &shape, Table &file)
Construct a new PagedArray, with the specified shape, in the default row and column of the supplied T...
virtual void setCacheSizeFromPath(const IPosition &sliceShape, const IPosition &windowStart, const IPosition &windowLength, const IPosition &axisPath)
Set the actual cache size for this Array to "fit" the indicated path.
void resize(const TiledShape &newShape)
Functions to resize the PagedArray.
PagedArray(Table &file)
Reconstruct from a pre-existing PagedArray in the default row and column of the supplied Table.
PagedArray(Table &file, const String &columnName, uInt rowNum)
Reconstruct from a pre-existing PagedArray in the specified row and column of the supplied Table.
const String & tableName() const
Returns the current table name (ie.
virtual void resync()
Resynchronize the PagedArray object with the lattice file.
PagedArray(const TiledShape &shape, const String &filename)
Construct a new PagedArray with the specified shape.
virtual Bool isWritable() const
Is the PagedArray writable?
virtual Bool isPersistent() const
A PagedArray is always persistent.
PagedArray(const PagedArray< T > &other)
The copy constructor which uses reference semantics.
virtual Bool ok() const
A function which checks for internal consistency.
virtual IPosition doNiceCursorShape(uInt maxPixels) const
Get the best cursor shape.
virtual Bool isPaged() const
A PagedArray is always paged to disk.
const ROTiledStManAccessor & accessor() const
Returns an accessor to the tiled storage manager.
Definition PagedArray.h:631
virtual Bool doGetSlice(Array< T > &buffer, const Slicer &section)
Do the actual getting of an array of values.
static String defaultComment()
The default comment for PagedArray Colums.
IPosition tileShape() const
Returns the current tile shape for this PagedArray.
virtual void clearCache()
Clears and frees up the tile cache.
virtual void flush()
Flush the data (but do not unlock).
virtual void unlock()
PagedArray(const TiledShape &shape, Table &file, const String &columnName, uInt rowNum)
Construct a new PagedArray, with the specified shape, in the specified row and column of the supplied...
void doReopen() const
Do the reopen of the table (if not open already).
Definition PagedArray.h:646
virtual Bool hasLock(FileLocker::LockType) const
virtual void tempClose()
Temporarily close the lattice.
ROTiledStManAccessor itsAccessor
Definition PagedArray.h:594
String: the storage and methods of handling collections of characters.
Definition String.h:355
TableOption
Define the possible options how a table can be opened.
Definition Table.h:168
For temporary backward namespace compatibility, use casa as alias for casacore.
Definition mainpage.dox:28
const Bool False
Definition aipstype.h:42
unsigned int uInt
Definition aipstype.h:49
bool Bool
Define the standard types used by Casacore.
Definition aipstype.h:40
const Bool True
Definition aipstype.h:41
NewDelAllocator< T > NewDelAllocator< T >::value
Definition Allocator.h:360