//# TSMOption.h: Options for the Tiled Storage Manager Access //# Copyright (C) 2010 //# Associated Universities, Inc. Washington DC, USA. //# //# This library is free software; you can redistribute it and/or modify it //# under the terms of the GNU Library General Public License as published by //# the Free Software Foundation; either version 2 of the License, or (at your //# option) any later version. //# //# This library is distributed in the hope that it will be useful, but WITHOUT //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public //# License for more details. //# //# You should have receied a copy of the GNU Library General Public License //# along with this library; if not, write to the Free Software Foundation, //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA. //# //# Correspondence concerning AIPS++ should be addressed as follows: //# Internet email: aips2-request@nrao.edu. //# Postal address: AIPS++ Project Office //# National Radio Astronomy Observatory //# 520 Edgemont Road //# Charlottesville, VA 22903-2475 USA //# //# $Id$ #ifndef TABLES_TSMOPTION_H #define TABLES_TSMOPTION_H //# Includes #include namespace casacore { //# NAMESPACE CASACORE - BEGIN // // Options for the Tiled Storage Manager Access // // // // // //# Classes you should understand before using this one. //
  • TiledStMan // // // This class can be used to define how the Tiled Storage Manager accesses // its data. There are three ways: //
      //
    1. Using a cache of its own. The cache size is derived using the hinted // access pattern. The cache can be (too) large when using large tables // with bad access patterns. // A maximum cache size can be defined to overcome this problem, but // that may result in poor caching behaviour. // Until January 2010 this was the only way to access the data. //
    2. Use memory-mapped IO (mmap); the operating system take care of caching. // On 32-bit systems mmap cannot be used for larger tables due to the // 4 GB address space limit. // When creating or extending files, mmap can be disadvantageous because // extending the file requires remapping it. //
    3. Use buffered IO; the kernel's file cache should avoid unnecessary IO. // Its performance is less than mmap, but it works well on 32-bit systems. // The buffer size to be used can be defined. //
    // // The constructor of the class can be used to define the options or // to read options from the aipsrc file. //
      //
    • TSMOption::Cache // Use unbuffered file IO with internal TSM caching. This is the old // behaviour. // The maximum cache size can be given as a constructor argument. //
    • TSMOption::MMap // Use memory-mapped IO. //
    • TSMOption::Buffer // Use buffered file IO without. // The buffer size can be given as a constructor argument. //
    • TSMOption::Default // Use default. This is MMap for existing files on 64-bit systems, // otherwise Buffer. //
    • TSMOption::Aipsrc // Use the option as defined in the aipsrc file. //
    // The aipsrc variables are: //
      //
    • table.tsm.option gives the option as the case-insensitive // string value: //
        //
      • cache means TSMCache. //
      • mmap (or map) means TSMMap. //
      • mmapold (or mapold) means TSMMap for existing // tables and TSMDefault for new tables. //
      • buffer means TSMBuffer. //
      • default means TSMDefault. //
      // It defaults to value default. // Note that mmapold is almost the same as default. // Only on 32-bit systems it is different. //
    • table.tsm.maxcachesizemb gives the maximum cache size in // MibiByte for option TSMOption::Cache. A value -1 means // that the system determines the maximum. A value 0 means unlimited. // It defaults to -1. // Note it can always be overridden using class ROTiledStManAccessor. //
    • table.tsm.buffersize gives the buffer size for option // TSMOption::Buffer. A value <=0 means use the default 4096. // It defaults to 0. //
    //
    class TSMOption { public: // Define the possible options how the TiledStMan accesses its data. enum Option { // Use unbuffered file IO with internal TSM caching. Cache, // Use buffered file IO without internal TSM caching. Buffer, // Use memory-mapped IO. MMap, // Use default. Default, // Use as defined in the aipsrc file. Aipsrc }; // Create an option object. // The parameter values are described in the synopsis. // A size value -2 means reading that size from the aipsrc file. // The buffer size has to be given in bytes. // The maximum cache size has to be given in MibiBytes (1024*1024 bytes). TSMOption (Option option=Aipsrc, Int bufferSize=-2, Int maxCacheSizeMB=-2); // Fill the option in case Aipsrc or Default was given. // It is done as explained in the synopsis. void fillOption (Bool newFile); // Get the option. Option option() const { return itsOption; } // Get the buffer size. Int bufferSize() const { return itsBufferSize; } // Get the maximum cache size (in MibiByte). -1 means undefined. Int maxCacheSizeMB() const { return itsMaxCacheSize; } private: Option itsOption; Int itsBufferSize; Int itsMaxCacheSize; }; } //# NAMESPACE CASACORE - END #endif