Revision: 21585
Author: gervandiepen
Date: Wed Mar 25 13:28:02 2015 UTC
Log: Fixed a problem with using HDF5
https://code.google.com/p/casacore/source/detail?r=21585
Modified:
/branches/nov14/casa/HDF5/HDF5File.cc
/branches/nov14/casa/HDF5/HDF5Group.cc
/branches/nov14/casa/IO/MultiFile.cc
/branches/nov14/casa/IO/MultiFile.h
/branches/nov14/casa/IO/MultiFileBase.cc
/branches/nov14/casa/IO/MultiFileBase.h
/branches/nov14/casa/IO/MultiHDF5.cc
/branches/nov14/casa/IO/MultiHDF5.h
/branches/nov14/lattices/LRegions/LCHDF5Mask.cc
/branches/nov14/tables/Tables/ColumnSet.cc
=======================================
--- /branches/nov14/casa/HDF5/HDF5File.cc Wed Dec 10 08:06:42 2014 UTC
+++ /branches/nov14/casa/HDF5/HDF5File.cc Wed Mar 25 13:28:02 2015 UTC
@@ -75,6 +75,10 @@
void HDF5File::close()
{
if (isValid()) {
+ // Do not check for errors.
+ // If the same file is opened twice, HDF5 will close the file on
+ // the first occasion and gives an error for the second close.
+ H5Fflush (getHid(), H5F_SCOPE_LOCAL);
H5Fclose (getHid());
clearHid();
}
=======================================
--- /branches/nov14/casa/HDF5/HDF5Group.cc Wed Dec 10 08:06:42 2014 UTC
+++ /branches/nov14/casa/HDF5/HDF5Group.cc Wed Mar 25 13:28:02 2015 UTC
@@ -43,7 +43,11 @@
H5P_DEFAULT, H5P_DEFAULT));
} else {
type = "open";
- setHid (H5Gopen2(parentHid, name.c_str(), H5P_DEFAULT));
+ // Note that testing if the link exists does not work for /.
+ if (name == "/" ||
+ H5Lexists (parentHid, name.c_str(), H5P_LINK_ACCESS_DEFAULT) ==
1) {
+ setHid (H5Gopen2(parentHid, name.c_str(), H5P_DEFAULT));
+ }
if (!isValid() && !mustExist) {
type = "open or create";
setHid (H5Gcreate2(parentHid, name.c_str(), H5P_DEFAULT,
@@ -97,8 +101,9 @@
void HDF5Group::remove (const HDF5Object& parentHid, const String& name)
{
- // The delete fails if the group does not exist, but that is no
problem.
- H5Ldelete (parentHid, name.c_str(), H5P_LINK_ACCESS_DEFAULT);
+ if (exists (parentHid, name)) {
+ H5Ldelete (parentHid, name.c_str(), H5P_LINK_ACCESS_DEFAULT);
+ }
}
#else
=======================================
--- /branches/nov14/casa/IO/MultiFile.cc Tue Mar 24 15:32:48 2015 UTC
+++ /branches/nov14/casa/IO/MultiFile.cc Wed Mar 25 13:28:02 2015 UTC
@@ -60,6 +60,11 @@
{
close();
}
+
+ void MultiFile::flushFile()
+ {
+ itsIO.flush();
+ }
void MultiFile::close()
{
=======================================
--- /branches/nov14/casa/IO/MultiFile.h Tue Mar 24 15:32:48 2015 UTC
+++ /branches/nov14/casa/IO/MultiFile.h Wed Mar 25 13:28:02 2015 UTC
@@ -57,6 +57,7 @@
// if a MultiFile has to be used and if so, the buffer size to use.
// It is also possible to specify that through aipsrc variables.
//
+
// A virtual file is spread over multiple (fixed size) data blocks in the
// MultiFile. A data block is never shared by multiple files.
// For each virtual file MultiFile keeps a MultiFileInfo object telling
@@ -129,6 +130,8 @@
virtual void doAddFile (MultiFileInfo&);
// Do the class-specific actions on deleting a file.
virtual void doDeleteFile (MultiFileInfo&);
+ // Flush the file itself.
+ virtual void flushFile();
// Flush and close the file.
virtual void close();
// Write the header info.
=======================================
--- /branches/nov14/casa/IO/MultiFileBase.cc Tue Mar 24 15:32:48 2015 UTC
+++ /branches/nov14/casa/IO/MultiFileBase.cc Wed Mar 25 13:28:02 2015 UTC
@@ -100,6 +100,7 @@
writeHeader();
itsChanged = False;
}
+ flushFile();
}
Int64 MultiFileBase::read (Int fileId, void* buf,
=======================================
--- /branches/nov14/casa/IO/MultiFileBase.h Tue Mar 24 15:32:48 2015 UTC
+++ /branches/nov14/casa/IO/MultiFileBase.h Wed Mar 25 13:28:02 2015 UTC
@@ -215,6 +215,8 @@
virtual void doAddFile (MultiFileInfo&) = 0;
// Do the class-specific actions on deleting a file.
virtual void doDeleteFile (MultiFileInfo&) = 0;
+ // Flush the file itself.
+ virtual void flushFile() = 0;
// Flush and close the file.
virtual void close() = 0;
// Write the header info.
=======================================
--- /branches/nov14/casa/IO/MultiHDF5.cc Tue Mar 24 15:32:48 2015 UTC
+++ /branches/nov14/casa/IO/MultiHDF5.cc Wed Mar 25 13:28:02 2015 UTC
@@ -51,16 +51,26 @@
{
close();
}
+
+ void MultiHDF5::flushFile()
+ {
+ itsFile.flush();
+ }
void MultiHDF5::close()
{
flush();
+ // Close all datasets and groups.
+ itsInfo.clear();
itsFile.close();
}
void MultiHDF5::reopenRW()
{
+ // Close all datasets and groups.
+ itsInfo.clear();
itsFile.reopenRW();
+ readHeader (True);
itsWritable = True;
}
=======================================
--- /branches/nov14/casa/IO/MultiHDF5.h Tue Mar 24 14:43:31 2015 UTC
+++ /branches/nov14/casa/IO/MultiHDF5.h Wed Mar 25 13:28:02 2015 UTC
@@ -127,6 +127,8 @@
virtual void doAddFile (MultiFileInfo&);
// Do the class-specific actions on deleting a file.
virtual void doDeleteFile (MultiFileInfo&);
+ // Flush the file itself.
+ virtual void flushFile();
// Flush and close the file.
virtual void close();
// Write the header info.
=======================================
--- /branches/nov14/lattices/LRegions/LCHDF5Mask.cc Wed Jan 28 10:01:12
2015 UTC
+++ /branches/nov14/lattices/LRegions/LCHDF5Mask.cc Wed Mar 25 13:28:02
2015 UTC
@@ -44,7 +44,7 @@
latticeShape.shape()-1, latticeShape.shape())
{
setBoundingBox (itsBox.boundingBox());
- itsMask = HDF5Lattice<Bool> (latticeShape, file, maskName, "Masks");
+ itsMask = HDF5Lattice<Bool> (latticeShape, file, maskName, "masks");
setMaskPtr (itsMask);
}
@@ -61,7 +61,7 @@
"shape of mask and box differ"));
}
setBoundingBox (itsBox.boundingBox());
- itsMask = HDF5Lattice<Bool> (box.latticeShape(), file,
maskName, "Masks");
+ itsMask = HDF5Lattice<Bool> (box.latticeShape(), file,
maskName, "masks");
setMaskPtr (itsMask);
}
@@ -176,7 +176,7 @@
const String& tableName)
{
HDF5Lattice<Bool> mask(rec.asString("filename"),
rec.asString("maskname"),
- "Masks");
+ "masks");
LCBox* boxPtr = (LCBox*)(LCRegion::fromRecord (rec.asRecord("box"),
tableName));
LCHDF5Mask* regPtr = new LCHDF5Mask (mask, *boxPtr);
=======================================
--- /branches/nov14/tables/Tables/ColumnSet.cc Tue Mar 24 14:44:38 2015 UTC
+++ /branches/nov14/tables/Tables/ColumnSet.cc Wed Mar 25 13:28:02 2015 UTC
@@ -816,6 +816,9 @@
}
memio.clear();
}
+ if (multiFile_p) {
+ multiFile_p->flush();
+ }
return written;
}