Revision: 21583
Author: gervandiepen
Date: Tue Mar 24 14:44:38 2015 UTC
Log: Added function to get the StorageOption
Added support for MultiHDF5
https://code.google.com/p/casacore/source/detail?r=21583
Modified:
/branches/nov14/tables/DataMan/DataManager.cc
/branches/nov14/tables/DataMan/DataManager.h
/branches/nov14/tables/DataMan/StArrayFile.cc
/branches/nov14/tables/DataMan/StArrayFile.h
/branches/nov14/tables/DataMan/TSMFile.cc
/branches/nov14/tables/DataMan/TSMFile.h
/branches/nov14/tables/Tables/BaseTable.cc
/branches/nov14/tables/Tables/BaseTable.h
/branches/nov14/tables/Tables/ColumnSet.cc
/branches/nov14/tables/Tables/ColumnSet.h
/branches/nov14/tables/Tables/ConcatTable.cc
/branches/nov14/tables/Tables/ConcatTable.h
/branches/nov14/tables/Tables/MemoryTable.cc
/branches/nov14/tables/Tables/MemoryTable.h
/branches/nov14/tables/Tables/NullTable.cc
/branches/nov14/tables/Tables/NullTable.h
/branches/nov14/tables/Tables/PlainTable.cc
/branches/nov14/tables/Tables/PlainTable.h
/branches/nov14/tables/Tables/RefTable.cc
/branches/nov14/tables/Tables/RefTable.h
/branches/nov14/tables/Tables/StorageOption.cc
/branches/nov14/tables/Tables/StorageOption.h
/branches/nov14/tables/Tables/Table.h
/branches/nov14/tables/apps/lsmf.cc
/branches/nov14/tables/apps/tomf.cc
=======================================
--- /branches/nov14/tables/DataMan/DataManager.cc Wed Dec 10 08:06:42 2014
UTC
+++ /branches/nov14/tables/DataMan/DataManager.cc Tue Mar 24 14:44:38 2015
UTC
@@ -119,7 +119,7 @@
tsmOption_p = tsmOption;
}
-void DataManager::setMultiFile (MultiFile* mfile)
+void DataManager::setMultiFile (MultiFileBase* mfile)
{
multiFile_p = mfile;
// Only caching can be used with a MultiFile.
=======================================
--- /branches/nov14/tables/DataMan/DataManager.h Wed Dec 10 08:06:42 2014
UTC
+++ /branches/nov14/tables/DataMan/DataManager.h Tue Mar 24 14:44:38 2015
UTC
@@ -47,7 +47,7 @@
class DataManagerColumn;
class SetupNewTable;
class Table;
-class MultiFile;
+class MultiFileBase;
class Record;
class IPosition;
class Slicer;
@@ -296,7 +296,7 @@
{ return tsmOption_p; }
// Get the MultiFile pointer (can be 0).
- MultiFile* multiFile()
+ MultiFileBase* multiFile()
{ return multiFile_p; }
// Compose a keyword name from the given keyword appended with the
@@ -388,7 +388,7 @@
// Tell the data manager that MultiFile can be used.
// Because MultiFile cannot be used with mmapped files, it sets
// the TSMOption accordingly.
- void setMultiFile (MultiFile* mfile);
+ void setMultiFile (MultiFileBase* mfile);
// Does the data manager support use of MultiFile?
// A derived class has to return True if it can use the MultiFile.
@@ -406,7 +406,7 @@
uInt seqnr_p; //# Unique nr of this st.man. in a
Table
Bool asBigEndian_p; //# store data in big or little endian
TSMOption tsmOption_p;
- MultiFile* multiFile_p; //# MultiFile to use; 0=no MultiFile
+ MultiFileBase* multiFile_p; //# MultiFile to use; 0=no MultiFile
Table* table_p; //# Table this data manager belongs to
mutable DataManager* clone_p; //# Pointer to clone (used by
SetupNewTab)
=======================================
--- /branches/nov14/tables/DataMan/StArrayFile.cc Wed Dec 10 08:06:42 2014
UTC
+++ /branches/nov14/tables/DataMan/StArrayFile.cc Tue Mar 24 14:44:38 2015
UTC
@@ -46,7 +46,7 @@
StManArrayFile::StManArrayFile (const String& fname, ByteIO::OpenOption
fop,
uInt version, Bool bigEndian,
- uInt bufferSize, MultiFile* mfile)
+ uInt bufferSize, MultiFileBase* mfile)
: leng_p (16),
version_p (version),
hasPut_p (False)
=======================================
--- /branches/nov14/tables/DataMan/StArrayFile.h Wed Dec 10 08:06:42 2014
UTC
+++ /branches/nov14/tables/DataMan/StArrayFile.h Tue Mar 24 14:44:38 2015
UTC
@@ -38,7 +38,7 @@
namespace casacore { //# NAMESPACE CASACORE - BEGIN
//# Forward Declarations
-class MultiFile;
+class MultiFileBase;
class IPosition;
@@ -139,7 +139,7 @@
StManArrayFile (const String& name, ByteIO::OpenOption,
uInt version=0, Bool bigEndian=True,
uInt bufferSize=0,
- MultiFile* mfile=0);
+ MultiFileBase* mfile=0);
// Close the possibly opened file.
~StManArrayFile();
=======================================
--- /branches/nov14/tables/DataMan/TSMFile.cc Wed Dec 10 08:06:42 2014 UTC
+++ /branches/nov14/tables/DataMan/TSMFile.cc Tue Mar 24 14:44:38 2015 UTC
@@ -38,7 +38,7 @@
namespace casacore { //# NAMESPACE CASACORE - BEGIN
TSMFile::TSMFile (const TiledStMan* stman, uInt fileSequenceNr,
- const TSMOption& tsmOpt, MultiFile* mfile)
+ const TSMOption& tsmOpt, MultiFileBase* mfile)
: fileSeqnr_p (fileSequenceNr),
file_p (0),
length_p (0)
@@ -56,7 +56,7 @@
}
TSMFile::TSMFile (const String& fileName, Bool writable,
- const TSMOption& tsmOpt, MultiFile* mfile)
+ const TSMOption& tsmOpt, MultiFileBase* mfile)
: fileSeqnr_p (0),
file_p (0),
length_p (0)
@@ -71,7 +71,7 @@
}
TSMFile::TSMFile (const TiledStMan* stman, AipsIO& ios, uInt seqnr,
- const TSMOption& tsmOpt, MultiFile* mfile)
+ const TSMOption& tsmOpt, MultiFileBase* mfile)
: file_p (0)
{
getObject (ios);
=======================================
--- /branches/nov14/tables/DataMan/TSMFile.h Wed Dec 10 08:06:42 2014 UTC
+++ /branches/nov14/tables/DataMan/TSMFile.h Tue Mar 24 14:44:38 2015 UTC
@@ -37,7 +37,7 @@
//# Forward Declarations
class TSMOption;
class TiledStMan;
-class MultiFile;
+class MultiFileBase;
class AipsIO;
// <summary>
@@ -84,18 +84,18 @@
// Create a TSMFile object (with corresponding file).
// The sequence number gets part of the file name.
TSMFile (const TiledStMan* stMan, uInt fileSequenceNr,
- const TSMOption&, MultiFile* mfile=0);
+ const TSMOption&, MultiFileBase* mfile=0);
// Create a TSMFile object for the given existing file.
TSMFile (const String& fileName, Bool writable, const TSMOption&,
- MultiFile* mfile=0);
+ MultiFileBase* mfile=0);
// Read the object back.
// The file is not opened until the first access,
// thus until the file descriptor is asked for the first time.
// It checks if the sequence number matches the expected one.
TSMFile (const TiledStMan* stMan, AipsIO& ios, uInt seqnr,
- const TSMOption&, MultiFile* mfile=0);
+ const TSMOption&, MultiFileBase* mfile=0);
// The destructor closes the file.
~TSMFile();
=======================================
--- /branches/nov14/tables/Tables/BaseTable.cc Wed Dec 10 08:06:42 2014 UTC
+++ /branches/nov14/tables/Tables/BaseTable.cc Tue Mar 24 14:44:38 2015 UTC
@@ -1016,6 +1016,12 @@
os << endl;
os << nrow() << " rows, " << tdesc.ncolumn() << " columns (using "
<< dminfo.nfields() << " data managers)" <<endl;
+ const StorageOption& stopt = storageOption();
+ if (stopt.option() == StorageOption::MultiFile) {
+ os << " Stored as MultiFile with blocksize " << stopt.blockSize() <<
endl;
+ } else if (stopt.option() == StorageOption::MultiHDF5) {
+ os << " Stored as MultiHDF5 with blocksize " << stopt.blockSize() <<
endl;
+ }
showStructureExtra (os);
uInt maxl = 0;
for (uInt i=0; i<tdesc.ncolumn(); ++i) {
=======================================
--- /branches/nov14/tables/Tables/BaseTable.h Wed Dec 10 08:06:42 2014 UTC
+++ /branches/nov14/tables/Tables/BaseTable.h Tue Mar 24 14:44:38 2015 UTC
@@ -33,6 +33,7 @@
#include <casacore/casa/aips.h>
#include <casacore/tables/Tables/TableInfo.h>
#include <casacore/tables/Tables/TableDesc.h>
+#include <casacore/tables/Tables/StorageOption.h>
#include <casacore/casa/Utilities/Compare.h>
#include <casacore/casa/Utilities/CountedPtr.h>
#include <casacore/casa/BasicSL/String.h>
@@ -121,6 +122,9 @@
// Is the table stored in big or little endian format?
virtual Bool asBigEndian() const = 0;
+ // Get the storage option used for the table.
+ virtual const StorageOption& storageOption() const = 0;
+
// Is the table in use (i.e. open) in another process?
// If <src>checkSubTables</src> is set, it is also checked if
// a subtable is used in another process.
=======================================
--- /branches/nov14/tables/Tables/ColumnSet.cc Tue Jan 6 07:56:10 2015 UTC
+++ /branches/nov14/tables/Tables/ColumnSet.cc Tue Mar 24 14:44:38 2015 UTC
@@ -36,6 +36,7 @@
#include <casacore/casa/Arrays/Vector.h>
#include <casacore/casa/Containers/Record.h>
#include <casacore/casa/IO/MultiFile.h>
+#include <casacore/casa/IO/MultiHDF5.h>
#include <casacore/casa/IO/MemoryIO.h>
#include <casacore/casa/Utilities/Assert.h>
#include <limits>
@@ -174,11 +175,12 @@
void ColumnSet::openMultiFile (uInt from, const Table& tab,
ByteIO::OpenOption opt)
{
- // Exit if MultiFile should not be used.
- if (storageOpt_p.option() != StorageOption::MultiFile) {
+ // Exit if MultiFile/HDF5 should not be used.
+ if (storageOpt_p.option() != StorageOption::MultiFile &&
+ storageOpt_p.option() != StorageOption::MultiHDF5) {
return;
}
- // See if any data manager can use MultiFile.
+ // See if any data manager can use MultiFile/HDF5.
Bool useMultiFile = False;
for (uInt i=from; i<blockDataMan_p.nelements(); i++) {
useMultiFile = useMultiFile ||
BLOCKDATAMANVAL(i)->hasMultiFileSupport();
@@ -187,8 +189,13 @@
if (useMultiFile) {
// Create the object if not created yet.
if (! multiFile_p) {
- multiFile_p = new MultiFile (tab.tableName() + "/table.mf",
- opt, storageOpt_p.blockSize());
+ if (storageOpt_p.option() == StorageOption::MultiFile) {
+ multiFile_p = new MultiFile (tab.tableName() + "/table.mf",
+ opt, storageOpt_p.blockSize());
+ } else {
+ multiFile_p = new MultiHDF5 (tab.tableName() + "/table.mfh5",
+ opt, storageOpt_p.blockSize());
+ }
}
// Pass it to the data managers.
for (uInt i=from; i<blockDataMan_p.nelements(); i++) {
@@ -765,7 +772,7 @@
//# Therefore a negative number is put as the version
//# (because nrrow_p is always positive).
// Still use version 2 if MultiFile is not used and #rows fit in a
uInt.
- if (storageOpt_p.option() == StorageOption::MultiFile ||
+ if (storageOpt_p.option() != StorageOption::SepFile ||
nrrow_p > Int64(std::numeric_limits<uInt>::max())) {
ios << Int(-3); // version (must be negative !!!)
ios << nrrow_p;
=======================================
--- /branches/nov14/tables/Tables/ColumnSet.h Wed Dec 10 08:06:42 2014 UTC
+++ /branches/nov14/tables/Tables/ColumnSet.h Tue Mar 24 14:44:38 2015 UTC
@@ -105,6 +105,10 @@
// Rename the necessary subtables in the column keywords.
void renameTables (const String& newName, const String& oldName);
+
+ // Get the storage option.
+ const StorageOption& storageOption() const
+ { return storageOpt_p; }
// Are subtables used in other processes.
Bool areTablesMultiUsed() const;
@@ -312,7 +316,7 @@
//# Declare the variables.
TableDesc* tdescPtr_p;
StorageOption storageOpt_p;
- MultiFile* multiFile_p;
+ MultiFileBase* multiFile_p;
Int64 nrrow_p; //# #rows
BaseTable* baseTablePtr_p;
TableLockData* lockPtr_p; //# lock object
=======================================
--- /branches/nov14/tables/Tables/ConcatTable.cc Wed Dec 10 08:06:42 2014
UTC
+++ /branches/nov14/tables/Tables/ConcatTable.cc Tue Mar 24 14:44:38 2015
UTC
@@ -170,6 +170,11 @@
{
return baseTabPtr_p[0]->asBigEndian();
}
+
+ const StorageOption& ConcatTable::storageOption() const
+ {
+ return baseTabPtr_p[0]->storageOption();
+ }
Bool ConcatTable::isMultiUsed (Bool) const
{
=======================================
--- /branches/nov14/tables/Tables/ConcatTable.h Wed Dec 10 08:06:42 2014 UTC
+++ /branches/nov14/tables/Tables/ConcatTable.h Tue Mar 24 14:44:38 2015 UTC
@@ -169,6 +169,10 @@
// It returns the endianness of the first underlying table.
virtual Bool asBigEndian() const;
+ // Get the storage option used for the table.
+ // It returns the storage option of the first underlying table.
+ virtual const StorageOption& storageOption() const;
+
// Is the table in use (i.e. open) in another process?
// It always returns False.
virtual Bool isMultiUsed (Bool checkSubTable) const;
=======================================
--- /branches/nov14/tables/Tables/MemoryTable.cc Wed Dec 10 08:06:42 2014
UTC
+++ /branches/nov14/tables/Tables/MemoryTable.cc Tue Mar 24 14:44:38 2015
UTC
@@ -104,6 +104,11 @@
{
return HostInfo::bigEndian();
}
+
+const StorageOption& MemoryTable::storageOption() const
+{
+ return colSetPtr_p->storageOption();
+}
Bool MemoryTable::isMultiUsed (Bool) const
{
=======================================
--- /branches/nov14/tables/Tables/MemoryTable.h Wed Dec 10 08:06:42 2014 UTC
+++ /branches/nov14/tables/Tables/MemoryTable.h Tue Mar 24 14:44:38 2015 UTC
@@ -98,6 +98,9 @@
// It returns the endian format of the machine.
virtual Bool asBigEndian() const;
+ // Get the storage option used for the table.
+ virtual const StorageOption& storageOption() const;
+
// Is the table in use (i.e. open) in another process?
// It always returns False.
virtual Bool isMultiUsed (Bool checkSubTable) const;
=======================================
--- /branches/nov14/tables/Tables/NullTable.cc Wed Dec 10 08:06:42 2014 UTC
+++ /branches/nov14/tables/Tables/NullTable.cc Tue Mar 24 14:44:38 2015 UTC
@@ -65,6 +65,12 @@
throwError ("isMultiUsed");
return False;
}
+
+const StorageOption& NullTable::storageOption() const
+{
+ throwError ("storageOption");
+ return storageOption(); // to satisfy compiler
+}
const TableLock& NullTable::lockOptions() const
{
=======================================
--- /branches/nov14/tables/Tables/NullTable.h Wed Dec 10 08:06:42 2014 UTC
+++ /branches/nov14/tables/Tables/NullTable.h Tue Mar 24 14:44:38 2015 UTC
@@ -79,6 +79,7 @@
// <group>
virtual void reopenRW();
virtual Bool asBigEndian() const;
+ virtual const StorageOption& storageOption() const;
virtual Bool isMultiUsed (Bool checkSubTable) const;
virtual const TableLock& lockOptions() const;
virtual void mergeLock (const TableLock& lockOptions);
=======================================
--- /branches/nov14/tables/Tables/PlainTable.cc Wed Dec 10 08:06:42 2014 UTC
+++ /branches/nov14/tables/Tables/PlainTable.cc Tue Mar 24 14:44:38 2015 UTC
@@ -343,6 +343,11 @@
{
return bigEndian_p;
}
+
+const StorageOption& PlainTable::storageOption() const
+{
+ return colSetPtr_p->storageOption();
+}
Bool PlainTable::isMultiUsed (Bool checkSubTables) const
{
=======================================
--- /branches/nov14/tables/Tables/PlainTable.h Wed Dec 10 08:06:42 2014 UTC
+++ /branches/nov14/tables/Tables/PlainTable.h Tue Mar 24 14:44:38 2015 UTC
@@ -121,6 +121,9 @@
// Is the table stored in big or little endian format?
virtual Bool asBigEndian() const;
+ // Get the storage option used for the table.
+ virtual const StorageOption& storageOption() const;
+
// Is the table in use (i.e. open) in another process?
// If <src>checkSubTables</src> is set, it is also checked if
// a subtable is used in another process.
=======================================
--- /branches/nov14/tables/Tables/RefTable.cc Wed Dec 10 08:06:42 2014 UTC
+++ /branches/nov14/tables/Tables/RefTable.cc Tue Mar 24 14:44:38 2015 UTC
@@ -211,6 +211,11 @@
{
return baseTabPtr_p->asBigEndian();
}
+
+const StorageOption& RefTable::storageOption() const
+{
+ return baseTabPtr_p->storageOption();
+}
Bool RefTable::isMultiUsed (Bool) const
{
=======================================
--- /branches/nov14/tables/Tables/RefTable.h Wed Dec 10 08:06:42 2014 UTC
+++ /branches/nov14/tables/Tables/RefTable.h Tue Mar 24 14:44:38 2015 UTC
@@ -159,6 +159,9 @@
// Is the table stored in big or little endian format?
virtual Bool asBigEndian() const;
+ // Get the storage option used for the table.
+ virtual const StorageOption& storageOption() const;
+
// Is the table in use (i.e. open) in another process?
// It always returns False.
virtual Bool isMultiUsed (Bool checkSubTable) const;
=======================================
--- /branches/nov14/tables/Tables/StorageOption.cc Wed Dec 10 08:06:42 2014
UTC
+++ /branches/nov14/tables/Tables/StorageOption.cc Tue Mar 24 14:44:38 2015
UTC
@@ -44,6 +44,8 @@
opt.downcase();
if (opt == "multifile") {
itsOption = StorageOption::MultiFile;
+ } else if (opt == "multihdf5") {
+ itsOption = StorageOption::MultiHDF5;
} else if (opt == "sepfile") {
itsOption = StorageOption::SepFile;
} else {
=======================================
--- /branches/nov14/tables/Tables/StorageOption.h Wed Dec 10 08:06:42 2014
UTC
+++ /branches/nov14/tables/Tables/StorageOption.h Tue Mar 24 14:44:38 2015
UTC
@@ -53,14 +53,17 @@
// for new file systems (like Lustre) requiring large block sizes.
// <br>The block size to be used in a MultiFile can be defined in
// this class. Default is 4 MByte.
+// <li> Using MultiHDF5 which behaves similar to MultiFile but uses an
+// HDF5 file instead of a regular file.
// </ol>
-// It is possible to specify the storage type and buffer size using aipsrc.
+// It is possible to specify the storage type and block size using aipsrc.
// The aipsrc variables are:
// <ul>
// <li> <src>tables.storage.type</src>. The (case-insensitive) value can
be
-// 'multifile'. Another value means the old way (separate files).
-// <li> <src>tables.storage.buffersize</src> gives the default buffer
size to be
-// used for the multifile option.
+// 'multifile' or 'multihdf5'.
+// Another value means the old way (separate files).
+// <li> <src>tables.storage.blocksize</src> gives the default blocksize
to be
+// used for the multifile and multihdf5 option.
// </ul>
// </synopsis>
@@ -70,8 +73,10 @@
public:
// Define the possible options how table files are organized.
enum Option {
- // Let storage managers use a combined multifile.
+ // Let storage managers use a combined MultiFile.
MultiFile,
+ // Let storage managers use a combined MultiHDF5.
+ MultiHDF5,
// Let storage managers use separate files.
SepFile,
// Use default (currently MultiFile).
=======================================
--- /branches/nov14/tables/Tables/Table.h Wed Dec 10 08:06:42 2014 UTC
+++ /branches/nov14/tables/Tables/Table.h Tue Mar 24 14:44:38 2015 UTC
@@ -416,6 +416,9 @@
// Get the endian format in which the table is stored.
Table::EndianFormat endianFormat() const;
+ // Get the storage option used for the table.
+ const StorageOption& storageOption() const;
+
// Is the table used (i.e. open) in this process.
static Bool isOpened (const String& tableName);
@@ -1087,6 +1090,8 @@
inline void Table::resync()
{ baseTabPtr_p->resync(); }
+inline const StorageOption& Table::storageOption() const
+ { return baseTabPtr_p->storageOption(); }
inline Bool Table::isMultiUsed(Bool checkSubTables) const
{ return baseTabPtr_p->isMultiUsed(checkSubTables); }
inline const TableLock& Table::lockOptions() const
=======================================
--- /branches/nov14/tables/apps/lsmf.cc Wed Dec 10 08:06:42 2014 UTC
+++ /branches/nov14/tables/apps/lsmf.cc Tue Mar 24 14:44:38 2015 UTC
@@ -26,6 +26,8 @@
//# $Id: showtable.cc 21480 2014-08-27 08:01:36Z gervandiepen $
#include <casacore/casa/IO/MultiFile.h>
+#include <casacore/casa/IO/MultiHDF5.h>
+#include <casacore/casa/HDF5/HDF5File.h>
#include <casacore/casa/BasicSL/STLIO.h>
#include <vector>
#include <stdexcept>
@@ -34,6 +36,28 @@
using namespace casacore;
using namespace std;
+void show (MultiFileBase& mfile, Bool showbl, const String& mftype)
+{
+ cout << endl;
+ cout << mftype << " = " << mfile.fileName() << endl;
+ cout << " blocksize = " << mfile.blockSize()
+ << " nfile = " << mfile.nfile()
+ << " nfreeblocks = " << mfile.freeBlocks().size() << endl;
+ if (showbl) {
+ cout << " freeblocks = " << mfile.freeBlocks() << endl;
+ }
+ for (uInt i=0; i<mfile.nfile(); ++i) {
+ const MultiFileInfo& info =
mfile.info()[i];
+ cout << ' ' <<
info.name
+ << " size=" << info.fsize
+ << " nblocks="
+ << (info.fsize+mfile.blockSize()-1) / mfile.blockSize()
+ << endl;
+ if (showbl) {
+ cout << ' ' << info.blockNrs << endl;
+ }
+ }
+}
int main (int argc, char* argv[])
{
@@ -58,24 +82,12 @@
if (iter->empty()) {
cerr << "*** Empty file name given" << endl;
} else {
- MultiFile mfile (*iter, ByteIO::Old);
- cout << endl;
- cout << "MultiFile = " << mfile.fileName() << endl;
- cout << " blocksize = " << mfile.blockSize()
- << " nfile = " << mfile.nfile()
- << " nfreeblocks = " << mfile.freeBlocks().size() << endl;
- if (showbl) {
- cout << " freeblocks = " << mfile.freeBlocks() << endl;
- }
- for (uInt i=0; i<mfile.nfile(); ++i) {
- const MultiFileInfo& info =
mfile.info()[i];
- cout << ' ' <<
info.name
- << " size=" << info.size
- << " nblocks=" << info.blockNrs.size()
- << endl;
- if (showbl) {
- cout << ' ' << info.blockNrs << endl;
- }
+ if (HDF5File::isHDF5(*iter)) {
+ MultiHDF5 mfile (*iter, ByteIO::Old);
+ show (mfile, showbl, "MultiHDF5");
+ } else {
+ MultiFile mfile (*iter, ByteIO::Old);
+ show (mfile, showbl, "MultiFile");
}
}
}
=======================================
--- /branches/nov14/tables/apps/tomf.cc Wed Dec 10 08:06:42 2014 UTC
+++ /branches/nov14/tables/apps/tomf.cc Tue Mar 24 14:44:38 2015 UTC
@@ -26,6 +26,8 @@
//# $Id: showtable.cc 21480 2014-08-27 08:01:36Z gervandiepen $
#include <casacore/casa/IO/MFFileIO.h>
+#include <casacore/casa/IO/MultiFile.h>
+#include <casacore/casa/IO/MultiHDF5.h>
#include <casacore/casa/IO/RegularFileIO.h>
#include <casacore/casa/IO/FiledesIO.h>
#include <casacore/casa/Containers/Block.h>
@@ -43,12 +45,15 @@
vector<String> fname;
String outName;
Int64 blockSize = 1048576;
+ Bool useHDF5 = False;
for (int argnr=1; argnr<argc; ++argnr) {
if (String(argv[argnr]) == "-b") {
argnr++;
if (argnr < argc) {
blockSize = atoi (argv[argnr]);
}
+ } else if (String(argv[argnr]) == "-h") {
+ useHDF5 = True;
} else if (argnr == argc-1) {
outName = argv[argnr];
} else {
@@ -56,12 +61,18 @@
}
}
if (fname.empty() || outName.empty()) {
- cerr << "Run as: tomf [-b blocksize] filename1 ... outname" <<
endl;
+ cerr << "Run as: tomf [-h] [-b blocksize] filename1 ... outname"
<< endl;
+ cerr << " -h create MultiFile as HDF5 instead of regular
file" << endl;
cerr << " -b blocksize in bytes; default 1048576" << endl;
return 0;
}
// Open each file and copy to the MultiFile.
- MultiFile mfile (outName, ByteIO::New, blockSize);
+ CountedPtr<MultiFileBase> mfile;
+ if (useHDF5) {
+ mfile = new MultiHDF5 (outName, ByteIO::New, blockSize);
+ } else {
+ mfile = new MultiFile (outName, ByteIO::New, blockSize);
+ }
Block<char> buffer (blockSize);
for (vector<String>::const_iterator iter=fname.begin();
iter!=fname.end(); ++iter) {
@@ -73,7 +84,7 @@
Int64 todo = file.length();
cout << " copying " << todo << " bytes of " << *iter
<< " ..." << endl;
- MFFileIO outfile (mfile, *iter, ByteIO::New);
+ MFFileIO outfile (*mfile, *iter, ByteIO::New);
while (todo > 0) {
Int64 sz = file.read (std::min(todo, blockSize),
buffer.storage());
outfile.write (sz, buffer.storage());