Mantid
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
Mantid::DataObjects::BoxControllerNeXusIO Class Reference

The class responsible for saving events into nexus file using generic box controller interface Expected to provide thread-safe file access. More...

#include <BoxControllerNeXusIO.h>

Inheritance diagram for Mantid::DataObjects::BoxControllerNeXusIO:
Mantid::API::IBoxControllerIO Mantid::Kernel::DiskBuffer

Public Types

enum class  EventDataVersion : size_t { EDVLean = 2 , EDVOriginal = 4 , EDVGoniometer = 5 }
 The version of the "event_data" Nexus dataset. More...
 
- Public Types inherited from Mantid::Kernel::DiskBuffer
using freeSpace_bySize_t = freeSpace_t::nth_index< 1 >::type
 A way to index the free space by their size. More...
 
using freeSpace_t = boost::multi_index::multi_index_container< FreeBlock, boost::multi_index::indexed_by< boost::multi_index::ordered_non_unique< ::boost::multi_index::const_mem_fun< FreeBlock, uint64_t, &FreeBlock::getFilePosition > >, boost::multi_index::ordered_non_unique< ::boost::multi_index::const_mem_fun< FreeBlock, uint64_t, &FreeBlock::getSize > > > >
 A map for the list of free space blocks in the file. More...
 

Public Member Functions

template<typename FloatOrDouble >
void adjustEventDataBlock (std::vector< FloatOrDouble > &Block, const std::string &accessMode) const
 Insert goniometer info in a block of event data, if necessary. More...
 
 BoxControllerNeXusIO (API::BoxController *const bc)
 Constructor. More...
 
void closeFile () override
 flush disk buffer data from memory and close underlying NeXus file More...
 
void copyFileTo (const std::string &destFilename) override
 Copy the file contents to a new location. More...
 
int64_t dataEventCount (void) const
 Number of data items in Nexus dataset "data_event" associated with the particular event data version. More...
 
void flushData () const override
 Clear NeXus internal cache. More...
 
size_t getDataChunk () const override
 Return the size of the NeXus data block used in NeXus data array. More...
 
void getDataType (size_t &CoordSize, std::string &typeName) const override
 As save/load operations use void data type, these function allow set up/get the type name provided for the IO operations and the size of the data type in bytes (e.g. More...
 
EventDataVersion getEventDataVersion () const
 
::NeXus::File * getFile ()
 
const std::string & getFileName () const override
 get the full file name of the file used for IO operations More...
 
int64_t getNDataColums () const
 
bool isOpened () const override
 
void loadBlock (std::vector< double > &, const uint64_t, const size_t) const override
 Load double data block from the opened NeXus file. More...
 
void loadBlock (std::vector< float > &, const uint64_t, const size_t) const override
 Load float data block from the opened NeXus file. More...
 
bool openFile (const std::string &fileName, const std::string &mode) override
 Open the file to use in IO operations with events. More...
 
void saveBlock (const std::vector< double > &, const uint64_t) const override
 Save double precision data block on specific position within properly opened NeXus data array. More...
 
void saveBlock (const std::vector< float > &, const uint64_t) const override
 Save float data block on specific position within properly opened NeXus data array. More...
 
void setDataType (const size_t blockSize, const std::string &typeName) override
 The optional method to set up the event type and the size of the event coordinate As save/load operations use void data type, these function allow set up/get the type name provided for the IO operations and the size of the data type in bytes (e.g. More...
 
void setEventDataVersion (const EventDataVersion &version)
 
void setEventDataVersion (const size_t &traitsCount)
 set the data version based on the number of attributes of the event, not counting its coordinates. More...
 
 ~BoxControllerNeXusIO () override
 
virtual void closeFile ()=0
 Close the file. More...
 
virtual void copyFileTo (const std::string &destFilename)=0
 Copy the file contents to a new location. More...
 
virtual void flushData () const =0
 flush the IO buffers More...
 
virtual size_t getDataChunk () const =0
 the method which returns the size of data block used in IO operations More...
 
virtual void getDataType (size_t &blockSize, std::string &typeName) const =0
 
virtual const std::string & getFileName () const =0
 
virtual bool isOpened () const =0
 
virtual void loadBlock (std::vector< double > &, const uint64_t, const size_t) const =0
 
virtual void loadBlock (std::vector< float > &, const uint64_t, const size_t) const =0
 load known size float data block from spefied file position More...
 
virtual bool openFile (const std::string &fileName, const std::string &mode)=0
 open file for i/o operations More...
 
virtual void saveBlock (const std::vector< double > &, const uint64_t) const =0
 Save a double data block in the specified file position. More...
 
virtual void saveBlock (const std::vector< float > &, const uint64_t) const =0
 Save a float data block in the specified file position. More...
 
virtual void setDataType (const size_t blockSize, const std::string &typeName)=0
 As save/load operations use void data type, these function allow set up/get the type name provided for the IO operations and the size of the data type in bytes (e.g. More...
 
- Public Member Functions inherited from Mantid::Kernel::DiskBuffer
uint64_t allocate (uint64_t const newSize)
 Allocate a block of the given size in a free spot in the file, or at the end of the file if there is no space. More...
 
void defragFreeBlocks ()
 Method that defrags free blocks by combining adjacent ones together NOTE: This is not necessary to run since the freeBlock() methods automatically defrags neighboring blocks. More...
 
 DiskBuffer ()
 Constructor. More...
 
 DiskBuffer (const DiskBuffer &)=delete
 
 DiskBuffer (uint64_t m_writeBufferSize)
 Constructor. More...
 
void flushCache ()
 Flush out all the data in the memory; and writes out everything in the to-write cache. More...
 
void freeBlock (uint64_t const pos, uint64_t const size)
 This method is called by this->relocate when object that has shrunk and so has left a bit of free space after itself on the file; or when an object gets moved to a new spot. More...
 
uint64_t getFileLength () const
 
freeSpace_tgetFreeSpaceMap ()
 
void getFreeSpaceVector (std::vector< uint64_t > &free) const
 Returns a vector with two entries per free block: position and size. More...
 
std::string getMemoryStr () const
 
uint64_t getWriteBufferSize () const
 
uint64_t getWriteBufferUsed () const
 
void objectDeleted (ISaveable *item)
 Call this method when an object that might be in the cache is getting deleted. More...
 
DiskBufferoperator= (const DiskBuffer &)=delete
 
uint64_t relocate (uint64_t const oldPos, uint64_t const oldSize, const uint64_t newSize)
 This method is called by an ISaveable object that has outgrown its space allocated on file and needs to relocate. More...
 
void setFileLength (const uint64_t length) const
 Set the length of the file that this MRU writes to. More...
 
void setFreeSpaceVector (std::vector< uint64_t > &free)
 Sets the free space map. More...
 
void setWriteBufferSize (uint64_t buffer)
 Set the size of the to-write buffer, in number of events. More...
 
void toWrite (ISaveable *item)
 Call this method when an object is ready to be written out to disk. More...
 
virtual ~DiskBuffer ()=default
 

Private Types

enum  { DATA_CHUNK = 10000 }
 Default size of the events block which can be written in the NeXus array at once identified by efficiency or some other external reasons. More...
 
enum  CoordConversion { noConversion , floatToDouble , doubleToFolat }
 the enum, which suggests the way (currently)two possible data types are converted to each other More...
 
enum  EventType { LeanEvent = 0 , FatEvent = 1 }
 possible event types this class understands. More...
 

Private Member Functions

void CreateEventGroup ()
 Create group responsible for keeping events and add necessary attributes to it. More...
 
void getDiskBufferFileData ()
 Load free space blocks from the data file or create the NeXus place to read/write them. More...
 
template<typename Type >
void loadGenericBlock (std::vector< Type > &Block, const uint64_t blockPosition, const size_t nPoints) const
 Load generic data block from the opened NeXus file. More...
 
void OpenAndCheckEventGroup ()
 Open existing Event group and check the attributes necessary for this algorithm to work. More...
 
void prepareNxSdata_CurVersion ()
 Open the NXS data blocks for loading/saving. More...
 
void prepareNxSToWrite_CurVersion ()
 Helper function which prepares NeXus event structure to accept events
More...
 
template<typename Type >
void saveGenericBlock (const std::vector< Type > &DataBlock, const uint64_t blockPosition) const
 Save generc data block on specific position within properly opened NeXus data array. More...
 

Static Private Member Functions

static EventType TypeFromString (const std::vector< std::string > &typesSupported, const std::string &typeName)
 get event type form its string representation More...
 

Private Attributes

API::BoxController *const m_bc
 shared pointer to the box controller, which is repsoponsible for this IO More...
 
std::vector< int64_t > m_BlockSize
 the vector, which describes the event specific data size, namely how many column an event is composed into and this class reads/writres More...
 
std::vector< int64_t > m_BlockStart
 the start of the current data block to read from. More...
 
unsigned int m_CoordSize
 number of bytes in the event coordinates (coord_t length). More...
 
size_t m_dataChunk
 The size of the events block which can be written in the neXus array at once (continuous part of the data block) More...
 
EventDataVersion m_EventDataVersion
 "data_event" dataset version in the current Nexus file More...
 
std::vector< std::string > m_EventsTypeHeaders
 data headers used for different events types More...
 
std::vector< std::string > m_EventsTypesSupported
 the symbolic description of the event types currently supported by the class More...
 
std::string m_EventsVersion
 The version of the md events data block. More...
 
enum Mantid::DataObjects::BoxControllerNeXusIO::EventType m_EventType
 
std::unique_ptr<::NeXus::File > m_File
 the file Handler responsible for Nexus IO operations; More...
 
std::mutex m_fileMutex
 lock Nexus file operations as Nexus is not thread safe More...
 
std::string m_fileName
 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) More...
 
enum Mantid::DataObjects::BoxControllerNeXusIO::CoordConversion m_ReadConversion
 
bool m_ReadOnly
 identifier if the file open only for reading or is in read/write More...
 

Static Private Attributes

static std::string g_DBDataName
 the group name to save disk buffer data More...
 
static std::string g_EventGroupName
 the name of the Nexus data group for saving the events More...
 

Additional Inherited Members

- Protected Member Functions inherited from Mantid::Kernel::DiskBuffer
void writeOldObjects ()
 Method to write out the old objects that have been stored in the "toWrite" buffer. More...
 
- Protected Attributes inherited from Mantid::Kernel::DiskBuffer
uint64_t m_fileLength
 Length of the file. This is where new blocks that don't fit get placed. More...
 
freeSpace_t m_free
 Map of the free blocks in the file. More...
 
freeSpace_bySize_tm_free_bySize
 Index into m_free, but indexed by block size. More...
 
std::mutex m_freeMutex
 Mutex for modifying the free space list. More...
 
std::mutex m_mutex
 Mutex for modifying the the toWrite buffer. More...
 
size_t m_nObjectsToWrite
 number of objects stored in to write buffer list More...
 
std::list< ISaveable * > m_toWriteBuffer
 A forward list for the buffer of "toWrite" objects. More...
 
size_t m_writeBufferSize
 Do we use the write buffer? Always now. More...
 
size_t m_writeBufferUsed
 Total amount of memory in the "toWrite" buffer. More...
 

Detailed Description

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

Definition at line 27 of file BoxControllerNeXusIO.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private

Default size of the events block which can be written in the NeXus array at once identified by efficiency or some other external reasons.

Enumerator
DATA_CHUNK 

Definition at line 113 of file BoxControllerNeXusIO.h.

◆ CoordConversion

the enum, which suggests the way (currently)two possible data types are converted to each other

Enumerator
noConversion 
floatToDouble 
doubleToFolat 

conversion btween fload/double requested by the client

Definition at line 181 of file BoxControllerNeXusIO.h.

◆ EventDataVersion

The version of the "event_data" Nexus dataset.

The "event_data" Nexus dataset may contain all or only a subset of the attributes of the current event object.

| class | attributes stored (besides coordinates)

MDLeanEvent | signal, error MDEvent | signal, error, run-index, detector-index MDEvent | signal, error, run-index, goniometer-index, detector-index

The number of attributes stored (neglecting coordinates) define the version

Enumerator
EDVLean 
EDVOriginal 
EDVGoniometer 

Definition at line 77 of file BoxControllerNeXusIO.h.

◆ EventType

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

Enumerator
LeanEvent 
FatEvent 

Definition at line 146 of file BoxControllerNeXusIO.h.

Constructor & Destructor Documentation

◆ BoxControllerNeXusIO()

Mantid::DataObjects::BoxControllerNeXusIO::BoxControllerNeXusIO ( API::BoxController *const  bc)

◆ ~BoxControllerNeXusIO()

Mantid::DataObjects::BoxControllerNeXusIO::~BoxControllerNeXusIO ( )
override

Definition at line 614 of file BoxControllerNeXusIO.cpp.

References closeFile().

Member Function Documentation

◆ adjustEventDataBlock()

template<typename FloatOrDouble >
template DLLExport void Mantid::DataObjects::BoxControllerNeXusIO::adjustEventDataBlock< double > ( std::vector< FloatOrDouble > &  Block,
const std::string &  accessMode 
) const

Insert goniometer info in a block of event data, if necessary.

The dataset "event_data" in old Nexus files lack goniometer info, thus it's necessary to insert the default goniometerIndex value into a data-block that has been read from the file before it's consumed by MDEvent::dataToEvents()

Parameters
Block: the storage vector containing the event data
accessMode: string specifying if we're reading from or writing to file. Valid values are "READ" and "WRITE"

Definition at line 418 of file BoxControllerNeXusIO.cpp.

References dataEventCount(), EDVGoniometer, EDVLean, EDVOriginal, and m_EventDataVersion.

Referenced by loadGenericBlock().

◆ closeFile()

void Mantid::DataObjects::BoxControllerNeXusIO::closeFile ( )
overridevirtual

flush disk buffer data from memory and close underlying NeXus file

Implements Mantid::API::IBoxControllerIO.

Definition at line 587 of file BoxControllerNeXusIO.cpp.

References Mantid::Kernel::DiskBuffer::flushCache(), g_DBDataName, Mantid::Kernel::DiskBuffer::getFreeSpaceVector(), m_File, m_fileMutex, and m_ReadOnly.

Referenced by copyFileTo(), and ~BoxControllerNeXusIO().

◆ copyFileTo()

void Mantid::DataObjects::BoxControllerNeXusIO::copyFileTo ( const std::string &  destFilename)
overridevirtual

Copy the file contents to a new location.

Copy the underlying file to the given destination.

If the file is opened and locked then it is closed, the copy made and the file is reopened again with the same mode

Parameters
destFilenameA filepath to copy the file to.

Implements Mantid::API::IBoxControllerIO.

Definition at line 174 of file BoxControllerNeXusIO.cpp.

References closeFile(), getFileName(), m_ReadOnly, and openFile().

◆ CreateEventGroup()

void Mantid::DataObjects::BoxControllerNeXusIO::CreateEventGroup ( )
private

Create group responsible for keeping events and add necessary attributes to it.

Definition at line 196 of file BoxControllerNeXusIO.cpp.

References g_EventGroupName, m_EventsVersion, m_File, m_fileName, and m_ReadOnly.

Referenced by openFile().

◆ dataEventCount()

int64_t Mantid::DataObjects::BoxControllerNeXusIO::dataEventCount ( void  ) const

Number of data items in Nexus dataset "data_event" associated with the particular event data version.

Definition at line 399 of file BoxControllerNeXusIO.cpp.

References EDVGoniometer, EDVLean, EDVOriginal, m_BlockSize, and m_EventDataVersion.

Referenced by adjustEventDataBlock(), and loadGenericBlock().

◆ flushData()

void Mantid::DataObjects::BoxControllerNeXusIO::flushData ( ) const
overridevirtual

Clear NeXus internal cache.

Implements Mantid::API::IBoxControllerIO.

Definition at line 582 of file BoxControllerNeXusIO.cpp.

References m_File, and m_fileMutex.

◆ getDataChunk()

size_t Mantid::DataObjects::BoxControllerNeXusIO::getDataChunk ( ) const
inlineoverridevirtual

Return the size of the NeXus data block used in NeXus data array.

Implements Mantid::API::IBoxControllerIO.

Definition at line 39 of file BoxControllerNeXusIO.h.

◆ getDataType()

void Mantid::DataObjects::BoxControllerNeXusIO::getDataType ( size_t &  CoordSize,
std::string &  typeName 
) const
overridevirtual

As save/load operations use void data type, these function allow set up/get the type name provided for the IO operations and the size of the data type in bytes (e.g.

the class dependent physical meaning of the blockSize and blockPosition used by save/load operations

Returns
CoordSize – size (in bytes) of the blockPosition and blockSize used in save/load operations
typeName – the name of the event used in the operations. The name itself defines the size and the format of the event

Implements Mantid::API::IBoxControllerIO.

Definition at line 105 of file BoxControllerNeXusIO.cpp.

References m_CoordSize, m_EventsTypesSupported, and m_EventType.

Referenced by setEventDataVersion().

◆ getDiskBufferFileData()

void Mantid::DataObjects::BoxControllerNeXusIO::getDiskBufferFileData ( )
private

Load free space blocks from the data file or create the NeXus place to read/write them.

Definition at line 296 of file BoxControllerNeXusIO.cpp.

References g_DBDataName, Mantid::Kernel::DiskBuffer::getFreeSpaceVector(), m_dataChunk, m_File, m_fileName, m_ReadOnly, and Mantid::Kernel::DiskBuffer::setFreeSpaceVector().

Referenced by openFile().

◆ getEventDataVersion()

EventDataVersion Mantid::DataObjects::BoxControllerNeXusIO::getEventDataVersion ( ) const
inline

Definition at line 79 of file BoxControllerNeXusIO.h.

◆ getFile()

::NeXus::File * Mantid::DataObjects::BoxControllerNeXusIO::getFile ( )
inline

Definition at line 62 of file BoxControllerNeXusIO.h.

◆ getFileName()

const std::string & Mantid::DataObjects::BoxControllerNeXusIO::getFileName ( ) const
inlineoverridevirtual

get the full file name of the file used for IO operations

Implements Mantid::API::IBoxControllerIO.

Definition at line 34 of file BoxControllerNeXusIO.h.

Referenced by copyFileTo().

◆ getNDataColums()

int64_t Mantid::DataObjects::BoxControllerNeXusIO::getNDataColums ( ) const
inline

Definition at line 60 of file BoxControllerNeXusIO.h.

◆ isOpened()

bool Mantid::DataObjects::BoxControllerNeXusIO::isOpened ( ) const
inlineoverridevirtual
Returns
true if the file to write events is opened and false otherwise

Implements Mantid::API::IBoxControllerIO.

Definition at line 32 of file BoxControllerNeXusIO.h.

◆ loadBlock() [1/2]

void Mantid::DataObjects::BoxControllerNeXusIO::loadBlock ( std::vector< double > &  Block,
const uint64_t  blockPosition,
const size_t  nPoints 
) const
overridevirtual

Load double data block from the opened NeXus file.

Parameters
Block– the storage vector to place data into
blockPosition– The starting place to read data from
nPoints– number of data points (events) to read
Returns
Block – resized block of data containing serialized events representation.

Implements Mantid::API::IBoxControllerIO.

Definition at line 563 of file BoxControllerNeXusIO.cpp.

References Mantid::DataObjects::convertFormats(), floatToDouble, loadGenericBlock(), m_fileName, m_ReadConversion, noConversion, and tmp.

◆ loadBlock() [2/2]

void Mantid::DataObjects::BoxControllerNeXusIO::loadBlock ( std::vector< float > &  Block,
const uint64_t  blockPosition,
const size_t  nPoints 
) const
overridevirtual

Load float data block from the opened NeXus file.

Parameters
Block– the storage vector to place data into
blockPosition– The starting place to read data from
nPoints– number of data points (events) to read
Returns
Block – resized block of data containing serialized events representation.

Implements Mantid::API::IBoxControllerIO.

Definition at line 540 of file BoxControllerNeXusIO.cpp.

References Mantid::DataObjects::convertFormats(), doubleToFolat, loadGenericBlock(), m_fileName, m_ReadConversion, noConversion, and tmp.

◆ loadGenericBlock()

template<typename Type >
void Mantid::DataObjects::BoxControllerNeXusIO::loadGenericBlock ( std::vector< Type > &  Block,
const uint64_t  blockPosition,
const size_t  nPoints 
) const
private

Load generic data block from the opened NeXus file.

Parameters
Block– the storage vector to place data into
blockPosition– The starting place to read data from
nPoints– number of data points (events) to read
Returns
Block – resized block of data containing serialized events representation.

Definition at line 505 of file BoxControllerNeXusIO.cpp.

References adjustEventDataBlock(), dataEventCount(), Mantid::Kernel::DiskBuffer::getFileLength(), m_BlockSize, m_File, m_fileMutex, and m_fileName.

Referenced by loadBlock().

◆ OpenAndCheckEventGroup()

void Mantid::DataObjects::BoxControllerNeXusIO::OpenAndCheckEventGroup ( )
private

Open existing Event group and check the attributes necessary for this algorithm to work.

Definition at line 211 of file BoxControllerNeXusIO.cpp.

References g_EventGroupName, m_EventsVersion, m_File, and m_fileName.

Referenced by openFile().

◆ openFile()

bool Mantid::DataObjects::BoxControllerNeXusIO::openFile ( const std::string &  fileName,
const std::string &  mode 
)
overridevirtual

Open the file to use in IO operations with events.

Parameters
fileName– the name of the file to open. Search for file performed within the Mantid search path.
mode– opening mode (read or read/write)

Implements Mantid::API::IBoxControllerIO.

Definition at line 118 of file BoxControllerNeXusIO.cpp.

References CreateEventGroup(), Mantid::DataObjects::MDBoxFlatTree::createOrOpenMDWSgroup(), g_EventGroupName, getDiskBufferFileData(), Mantid::API::BoxController::getNDims(), Mantid::Kernel::SingletonHolder< T >::Instance(), m_bc, m_EventsTypesSupported, m_EventType, m_File, m_fileMutex, m_fileName, m_ReadOnly, OpenAndCheckEventGroup(), prepareNxSdata_CurVersion(), and prepareNxSToWrite_CurVersion().

Referenced by copyFileTo().

◆ prepareNxSdata_CurVersion()

void Mantid::DataObjects::BoxControllerNeXusIO::prepareNxSdata_CurVersion ( )
private

Open the NXS data blocks for loading/saving.

The data should have been created before.

Definition at line 257 of file BoxControllerNeXusIO.cpp.

References doubleToFolat, floatToDouble, Mantid::API::BoxController::getNDims(), m_bc, m_CoordSize, m_File, m_fileName, m_ReadConversion, noConversion, setEventDataVersion(), and Mantid::Kernel::DiskBuffer::setFileLength().

Referenced by openFile(), and prepareNxSToWrite_CurVersion().

◆ prepareNxSToWrite_CurVersion()

void Mantid::DataObjects::BoxControllerNeXusIO::prepareNxSToWrite_CurVersion ( )
private

Helper function which prepares NeXus event structure to accept events

Definition at line 224 of file BoxControllerNeXusIO.cpp.

References m_BlockSize, m_CoordSize, m_dataChunk, m_EventsTypeHeaders, m_EventType, m_File, prepareNxSdata_CurVersion(), and Mantid::Kernel::DiskBuffer::setFileLength().

Referenced by openFile().

◆ saveBlock() [1/2]

void Mantid::DataObjects::BoxControllerNeXusIO::saveBlock ( const std::vector< double > &  DataBlock,
const uint64_t  blockPosition 
) const
overridevirtual

Save double precision data block on specific position within properly opened NeXus data array.

Parameters
DataBlock– the vector with data to write
blockPosition– The starting place to save data to

Implements Mantid::API::IBoxControllerIO.

Definition at line 361 of file BoxControllerNeXusIO.cpp.

References saveGenericBlock().

◆ saveBlock() [2/2]

void Mantid::DataObjects::BoxControllerNeXusIO::saveBlock ( const std::vector< float > &  DataBlock,
const uint64_t  blockPosition 
) const
overridevirtual

Save float data block on specific position within properly opened NeXus data array.

Parameters
DataBlock– the vector with data to write
blockPosition– The starting place to save data to

Implements Mantid::API::IBoxControllerIO.

Definition at line 354 of file BoxControllerNeXusIO.cpp.

References saveGenericBlock().

◆ saveGenericBlock()

template<typename Type >
void Mantid::DataObjects::BoxControllerNeXusIO::saveGenericBlock ( const std::vector< Type > &  DataBlock,
const uint64_t  blockPosition 
) const
private

Save generc data block on specific position within properly opened NeXus data array.

Parameters
DataBlock– the vector with data to write
blockPosition– The starting place to save data to

Definition at line 329 of file BoxControllerNeXusIO.cpp.

References Mantid::Kernel::DiskBuffer::getFileLength(), m_BlockSize, m_File, m_fileMutex, and Mantid::Kernel::DiskBuffer::setFileLength().

Referenced by saveBlock().

◆ setDataType()

void Mantid::DataObjects::BoxControllerNeXusIO::setDataType ( const size_t  blockSize,
const std::string &  typeName 
)
overridevirtual

The optional method to set up the event type and the size of the event coordinate As save/load operations use void data type, these function allow set up/get the type name provided for the IO operations and the size of the data type in bytes (e.g.

the class dependent physical meaning of the blockSize and blockPosition used by save/load operations

Parameters
blockSize– size (in bytes) of the blockPosition and blockSize used in save/load operations. 4 and 8 are supported only e.g. float and double
typeName– the name of the event used in the operations. The name itself defines the size and the format of the event The events described in the class header are supported only

Implements Mantid::API::IBoxControllerIO.

Definition at line 71 of file BoxControllerNeXusIO.cpp.

References EDVGoniometer, EDVLean, FatEvent, Mantid::API::BoxController::getNDims(), LeanEvent, m_bc, m_BlockSize, m_CoordSize, m_EventsTypesSupported, m_EventType, setEventDataVersion(), and TypeFromString().

◆ setEventDataVersion() [1/2]

void Mantid::DataObjects::BoxControllerNeXusIO::setEventDataVersion ( const EventDataVersion version)

◆ setEventDataVersion() [2/2]

void Mantid::DataObjects::BoxControllerNeXusIO::setEventDataVersion ( const size_t &  traitsCount)

set the data version based on the number of attributes of the event, not counting its coordinates.

Definition at line 384 of file BoxControllerNeXusIO.cpp.

References setEventDataVersion().

◆ TypeFromString()

BoxControllerNeXusIO::EventType Mantid::DataObjects::BoxControllerNeXusIO::TypeFromString ( const std::vector< std::string > &  typesSupported,
const std::string &  typeName 
)
staticprivate

get event type form its string representation

Definition at line 49 of file BoxControllerNeXusIO.cpp.

Referenced by setDataType().

Member Data Documentation

◆ g_DBDataName

std::string Mantid::DataObjects::BoxControllerNeXusIO::g_DBDataName
staticprivate

the group name to save disk buffer data

Definition at line 168 of file BoxControllerNeXusIO.h.

Referenced by closeFile(), and getDiskBufferFileData().

◆ g_EventGroupName

std::string Mantid::DataObjects::BoxControllerNeXusIO::g_EventGroupName
staticprivate

the name of the Nexus data group for saving the events

Definition at line 166 of file BoxControllerNeXusIO.h.

Referenced by CreateEventGroup(), OpenAndCheckEventGroup(), and openFile().

◆ m_bc

API::BoxController* const Mantid::DataObjects::BoxControllerNeXusIO::m_bc
private

shared pointer to the box controller, which is repsoponsible for this IO

Definition at line 127 of file BoxControllerNeXusIO.h.

Referenced by BoxControllerNeXusIO(), openFile(), prepareNxSdata_CurVersion(), and setDataType().

◆ m_BlockSize

std::vector<int64_t> Mantid::DataObjects::BoxControllerNeXusIO::m_BlockSize
private

the vector, which describes the event specific data size, namely how many column an event is composed into and this class reads/writres

Definition at line 134 of file BoxControllerNeXusIO.h.

Referenced by BoxControllerNeXusIO(), dataEventCount(), loadGenericBlock(), prepareNxSToWrite_CurVersion(), saveGenericBlock(), and setDataType().

◆ m_BlockStart

std::vector<int64_t> Mantid::DataObjects::BoxControllerNeXusIO::m_BlockStart
private

the start of the current data block to read from.

It related to current physical representation of the data in NeXus file

Definition at line 131 of file BoxControllerNeXusIO.h.

◆ m_CoordSize

unsigned int Mantid::DataObjects::BoxControllerNeXusIO::m_CoordSize
private

number of bytes in the event coordinates (coord_t length).

Set by setDataType but can be defined statically with coord_t

Definition at line 142 of file BoxControllerNeXusIO.h.

Referenced by getDataType(), prepareNxSdata_CurVersion(), prepareNxSToWrite_CurVersion(), and setDataType().

◆ m_dataChunk

size_t Mantid::DataObjects::BoxControllerNeXusIO::m_dataChunk
private

The size of the events block which can be written in the neXus array at once (continuous part of the data block)

Definition at line 125 of file BoxControllerNeXusIO.h.

Referenced by getDiskBufferFileData(), and prepareNxSToWrite_CurVersion().

◆ m_EventDataVersion

EventDataVersion Mantid::DataObjects::BoxControllerNeXusIO::m_EventDataVersion
private

"data_event" dataset version in the current Nexus file

Definition at line 157 of file BoxControllerNeXusIO.h.

Referenced by adjustEventDataBlock(), dataEventCount(), and setEventDataVersion().

◆ m_EventsTypeHeaders

std::vector<std::string> Mantid::DataObjects::BoxControllerNeXusIO::m_EventsTypeHeaders
private

data headers used for different events types

Definition at line 163 of file BoxControllerNeXusIO.h.

Referenced by BoxControllerNeXusIO(), and prepareNxSToWrite_CurVersion().

◆ m_EventsTypesSupported

std::vector<std::string> Mantid::DataObjects::BoxControllerNeXusIO::m_EventsTypesSupported
private

the symbolic description of the event types currently supported by the class

Definition at line 161 of file BoxControllerNeXusIO.h.

Referenced by BoxControllerNeXusIO(), getDataType(), openFile(), and setDataType().

◆ m_EventsVersion

std::string Mantid::DataObjects::BoxControllerNeXusIO::m_EventsVersion
private

The version of the md events data block.

Definition at line 154 of file BoxControllerNeXusIO.h.

Referenced by CreateEventGroup(), and OpenAndCheckEventGroup().

◆ m_EventType

enum Mantid::DataObjects::BoxControllerNeXusIO::EventType Mantid::DataObjects::BoxControllerNeXusIO::m_EventType
private

◆ m_File

std::unique_ptr<::NeXus::File> Mantid::DataObjects::BoxControllerNeXusIO::m_File
private

◆ m_fileMutex

std::mutex Mantid::DataObjects::BoxControllerNeXusIO::m_fileMutex
mutableprivate

lock Nexus file operations as Nexus is not thread safe

Definition at line 136 of file BoxControllerNeXusIO.h.

Referenced by closeFile(), flushData(), loadGenericBlock(), openFile(), and saveGenericBlock().

◆ m_fileName

std::string Mantid::DataObjects::BoxControllerNeXusIO::m_fileName
private

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)

Definition at line 118 of file BoxControllerNeXusIO.h.

Referenced by CreateEventGroup(), getDiskBufferFileData(), loadBlock(), loadGenericBlock(), OpenAndCheckEventGroup(), openFile(), and prepareNxSdata_CurVersion().

◆ m_ReadConversion

enum Mantid::DataObjects::BoxControllerNeXusIO::CoordConversion Mantid::DataObjects::BoxControllerNeXusIO::m_ReadConversion
private

◆ m_ReadOnly

bool Mantid::DataObjects::BoxControllerNeXusIO::m_ReadOnly
private

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

Definition at line 122 of file BoxControllerNeXusIO.h.

Referenced by closeFile(), copyFileTo(), CreateEventGroup(), getDiskBufferFileData(), and openFile().


The documentation for this class was generated from the following files: