Skip to content

Commit

Permalink
refs #6449 Enabled most system tests for MDBoxSaveable
Browse files Browse the repository at this point in the history
fixed minor error related to this.
  • Loading branch information
abuts committed Apr 16, 2013
1 parent 6d35b14 commit 206b161
Show file tree
Hide file tree
Showing 10 changed files with 499 additions and 787 deletions.
20 changes: 1 addition & 19 deletions Code/Mantid/Framework/API/inc/MantidAPI/BoxController.h
Original file line number Diff line number Diff line change
Expand Up @@ -358,25 +358,7 @@ namespace API
void setFileBacked(IBoxControllerIO *newFileIO,const std::string &fileName="");

//-----------------------------------------------------------------------------------
/** Set the memory-caching parameters for a file-backed
* MDEventWorkspace.
*
* @param bytesPerEvent :: sizeof(MDLeanEvent) that is in the workspace
* @param writeBufferSize :: number of EVENTS to accumulate before performing a disk write.
*/
void setCacheParameters(uint64_t writeBufferSize)
{
if(m_fileIO)
{
// Save the values
m_fileIO->setWriteBufferSize(writeBufferSize);
// If all caches are 0, don't use the MRU at all
// m_useWriteBuffer = !(writeBufferSize==0);
// m_fileIO->m_bytesPerEvent = bytesPerEvent;
}
}

//BoxCtrlChangesInterface *getChangesList(){return m_ChangesList;}
//BoxCtrlChangesInterface *getChangesList(){return m_ChangesList;}
//void setChangesList(BoxCtrlChangesInterface *pl){m_ChangesList=pl;}
//-----------------------------------------------------------------------------------
// increase the counter, calculatinb events at max;
Expand Down
1 change: 1 addition & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/IBoxControllerIO.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ namespace API
/** The header describes interface to IO Operations perfomed by the box controller
* May be replaced by a boost filestream in a future.
* It also currently assumes disk buffer usage.
* Disk buffer also assumes that actual IO operations performed by the class, inhereted from this one are thread-safe
*
* @date March 21, 2013
Expand Down
7 changes: 0 additions & 7 deletions Code/Mantid/Framework/Kernel/inc/MantidKernel/DiskBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,10 @@ namespace Kernel
{ m_fileLength = length; }

//-------------------------------------------------------------------------------------------
/** @return the file-access mutex */
Kernel::Mutex & getFileMutex()
{ return m_fileMutex; }


protected:
inline void writeOldObjects();

/// Mutex for accessing the file being buffered
Kernel::Mutex m_fileMutex;

// ----------------------- To-write buffer --------------------------------------
/// Do we use the write buffer? Always now
//bool m_useWriteBuffer;
Expand Down
6 changes: 4 additions & 2 deletions Code/Mantid/Framework/Kernel/inc/MantidKernel/Saveable.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@ namespace Kernel
when it decides it suitable, if the size of iSavable object in cache is unchanged from the previous
save/load operation */
bool m_dataChanged;
/// this
bool m_wasSaved;
// this tracks the history of operations, occuring over the data.
/// this boolean indicates if the data were saved on HDD and have physical representation on it (though this representation may be incorrect as data changed in memory)
mutable bool m_wasSaved;
/// this boolean indicates, if the data have its copy in memory
bool m_isLoaded;

/// the function saveAt has to be availible to DiskBuffer and nobody else. To highlight this we make it private
Expand Down
8 changes: 0 additions & 8 deletions Code/Mantid/Framework/Kernel/src/DiskBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,7 @@ namespace Kernel
fileIndexStart=this->allocate(NumObjEvents);
// Write to the disk; this will call the object specific save function;
// Prevent simultaneous file access (e.g. write while loading)
m_fileMutex.lock();
obj->saveAt(fileIndexStart,NumObjEvents);
m_fileMutex.unlock();
}
else
{
Expand All @@ -167,20 +165,16 @@ namespace Kernel
{
// Event list changed size. The MRU can tell us where it best fits now.
fileIndexStart= this->relocate(obj->getFilePosition(), NumFileEvents, NumObjEvents);
m_fileMutex.lock();
// Write to the disk; this will call the object specific save function;
obj->saveAt(fileIndexStart,NumObjEvents);
m_fileMutex.unlock();
}
else // despite object size have not been changed, it can be modified other way. In this case, the method which changed the data should set dataChanged ID
{
if(obj->isDataChanged())
{
fileIndexStart = obj->getFilePosition();
m_fileMutex.lock();
// Write to the disk; this will call the object specific save function;
obj->saveAt(fileIndexStart,NumObjEvents);
m_fileMutex.unlock();
// this is questionable operation, which adjust file size in case when the file postions were allocated externaly
if(fileIndexStart+NumObjEvents>m_fileLength)m_fileLength=fileIndexStart+NumObjEvents;
}
Expand Down Expand Up @@ -208,9 +202,7 @@ namespace Kernel
{
// NXS needs to flush the writes to file by closing and re-opening the data block.
// For speed, it is best to do this only once per write dump, using last object saved
m_fileMutex.lock();
obj->flushData();
m_fileMutex.unlock();
}

// Exchange with the new map you built out of the not-written blocks.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace MDEvents

//===============================================================================================
/** The class responsible for saving events into nexus file using generic box controller interface
* Expected to provide thread-safe file access.
@date March 15, 2013
Expand Down Expand Up @@ -77,44 +78,48 @@ namespace MDEvents
return m_BlockSize[1];
}
private:
/// full file name (with path) of the Nexis file responsible for the IO operations (as NeXus filename has very strange properties and often trunkated to 64 bytes)
/// Default size of the events block which can be written in the NeXus array at once identified by efficiency or some other external reasons
static enum {DATA_CHUNK=10000};

/// full file name (with path) of the Nexis file responsible for the IO operations (as NeXus filename has very strange properties and often truncated to 64 bytes)
std::string m_fileName;
// the file Handler responsible for Nexus IO operations;
/// the file Handler responsible for Nexus IO operations;
::NeXus::File * m_File;
/// identifier if the file open only for reading or is in read/write
bool m_ReadOnly;
/// The size of the events block which can be written in the neXus array at once (continious part of the data block)
size_t m_dataChunk;
/// shared pointer to the box controller, which is repsoponsible for this IO
API::BoxController_sptr m_bc;
//------
/// the start of the current data block to read from. It related to current physical representation of the data in NeXus file
std::vector<int64_t> m_BlockStart;
/// the vector, which describes the event specific data size, namely how many column an event is composed into and this class reads/writres
std::vector<int64_t> m_BlockSize;
/// lock Nexus file operations as Nexus is not thread safe
mutable Mantid::Kernel::Mutex m_fileMutex;

// Mainly static information which may be split into different IO classes selected through chein of responsibility.
/// number of bytes in the event coorinates (coord_t length). Set by setDataType but can be defined statically with coord_t
unsigned int m_CoordSize;

/// possible event types this class understands. The enum numbers have to correspond to the numbers of symbolic event types,
/// defined in EVENT_TYPES_SUPPORTED vector
static enum EventType
{
LeanEvent=0, //< the event consisting of signal error and event coordinate
FatEvent=1 //< the event havint the same as lean event plus RunID and detID
};

/// the type of event (currently MD event or MDLean event this class is deals with.
EventType m_EventType;

/// identifier if the file open only for reading or is in read/write
bool m_ReadOnly;

/// Default size of the events block which can be written in the NeXus array at once identified by efficiency or some other external reasons
static enum {DATA_CHUNK=10000};

/// lock Nexus file operations as Nexus is not thread safe
mutable Mantid::Kernel::Mutex m_fileMutex;
/// The version of the MDEvents data block
std::string m_EventsVersion;
/// the symblolic description of the event types currently supported by the class
std::vector<std::string> m_EventsTypesSupported;
/// data headers used for different events types
std::vector<std::string> m_EventsTypeHeaders;

/// The version of the MDEvents data block
std::string m_EventsVersion;
/// the name of the MD workspace group. Should be common with save/load, who uses this group to put other pieces of information about the workspace.
static std::string g_EventWSGroupName;
/// the name of the Nexus data group for saving the events
Expand All @@ -129,15 +134,12 @@ namespace MDEvents
void OpenAndCheckWSGroup();
void OpenAndCheckEventGroup();
void getDiskBufferFileData();
void checkWSDimesnions();
void prepareNxSToWrite_CurVersion();
void prepareNxSdata_CurVersion();

// get the event type from event name
static EventType TypeFromString(const std::vector<std::string> &typesSupported,const std::string typeName);

//
std::vector<int64_t> m_BlockStart;
/// the vector, which describes the event specific data size, which describes how many column an event is composed into and this class reads/writres
std::vector<int64_t> m_BlockSize;

};

Expand Down

0 comments on commit 206b161

Please sign in to comment.