Abstract interface definition for DAL
If a dataset is opened for modify or read, the DAL attempts to detect the format . The format may be determined with the ouputFileFormat() method. The output file format of newly created datasets may be specified by setting the SAS_FORMAT environment variable appropriately. The final argument, is currently only prototyped and should be ignored.
NB. This method must only be called by Meta Tasks.
NB. This method must only be called by Meta Tasks.
It is possible to have several ColumnData and CellData descriptors at the same time. However, the [from,range] range specifications (in the data() and cellData() and seek() methods) give rise to a slice (or subrabge) of the Column's data. The only restriction on slices is that they must not overlap with existing slices (although a subslice is an existing slive is allowed).
Moreover, but they all have to be deleted manually to avoid memory leaks. In particular, the following example is eroneous as it leads to a memory leak, since the pointer to the ColumnData object (as returned by the data() method) is lost:
int main() { DataSet * set = dataSetServer -> open( "test.dat", DataSetServer::Create ); Table * tab = set -> addTable( "tab1", 100 ); Column * col = tab -> addColumn( "col1", Column::Int32 ); int32 * data = col -> data() -> int32Data(); // Memory leak for( unsigned int i = 0; i < col -> elements() * col -> rows(); ++i ) data[i] = i; dataSetServer -> close( set ); }
The correct method is as follows:
int main() { DataSet * set = dataSetServer -> open( "test.dat", DataSetServer::Create ); Table * tab = set -> addTable( "tab1", 100 ); Column * col = tab -> addColumn( "col1", Column::Int32 ); ColumnData * coldat = col -> data(); int32 * data = int32Data(); for( unsigned int i = 0; i < col -> elements(); ++i ) data[i] = i; delete coldat; // Need to manually delete columnData objects to avoid memory leak dataSetServer -> close( set ); }The same is also true of the CellData object; it must be deleted after its final use, otherwise a memory leak is incurred.
Note that once the ColumnData object has been deleted, any corresponding pointers to the Column's data will be stale and can no longer be safely used.
The arguments are as follows:
Note that once the CellData object has been deleted, any corresponding pointers to the Column's data will be stale and can no longer be safely used.
The arguments are as follows:
It is possible to have several ArrayData descriptors at the same time. However, the [from,range] range specifications (in the data() and seek() methods) give rise to a slice (or subrabge) of the Column's data. The only restriction on slices is that they must not overlap with existing slices (although a subslice of an existing slice is allowed).
Moreover, they all have to be deleted manually after their last use to avoid memory leaks.
In particular, the following is considered eroneous as it leads to a memory leak, since the pointer to the ArrayData object (as returned by the data() method) is lost:
int main() { DataSet * set = dataSetServer -> open( "test.dat", DataSetServer::Create ); Array * arr = set -> addArray( "arr1", size ); int32 * data = arr -> data() -> int32Data(); // Memory leak for( unsigned int i = 0; i < arr -> elements(); ++i ) data[i] = i; dataSetServer -> close( set ); }
The correct method is as follows:
int main() { DataSet * set = dataSetServer -> open( "test.dat", DataSetServer::Create ); Array * arr = set -> addArray( "arr1", size ); ArrayData * arrdat = arr -> data(); int32 * data = arrdat() -> int32Data(); for( unsigned int i = 0; i < arr -> elements(); ++i ) data[i] = i; delete coldat; // Need to manually delete columnData objects to avoid memory leak. dataSetServer -> close( set ); }
XMM-Newton SOC -- 2023-04-16