SDDSlib
|
This file contains the implementation of the SDDS output routines. More...
#include "SDDS.h"
#include "SDDS_internal.h"
#include "mdb.h"
#include <ctype.h>
#include <unistd.h>
Go to the source code of this file.
Functions | |
int32_t | SDDS_DisconnectFile (SDDS_DATASET *SDDS_dataset) |
Disconnects the SDDS dataset from its associated file. | |
int32_t | SDDS_ReconnectFile (SDDS_DATASET *SDDS_dataset) |
Reconnects the SDDS dataset to its previously associated file. | |
long | SDDS_DisconnectInputFile (SDDS_DATASET *SDDS_dataset) |
Disconnects the input file from the SDDS dataset. | |
int32_t | SDDS_ReconnectInputFile (SDDS_DATASET *SDDS_dataset, long position) |
Reconnects the input file for the SDDS dataset at a specified position. | |
int32_t | SDDS_InitializeAppend (SDDS_DATASET *SDDS_dataset, const char *filename) |
Initializes the SDDS dataset for appending data by adding a new page to an existing file. | |
int32_t | SDDS_InitializeAppendToPage (SDDS_DATASET *SDDS_dataset, const char *filename, int64_t updateInterval, int64_t *rowsPresentReturn) |
Initializes the SDDS dataset for appending data to the last page of an existing file. | |
int32_t | SDDS_InitializeOutput (SDDS_DATASET *SDDS_dataset, int32_t data_mode, int32_t lines_per_row, const char *description, const char *contents, const char *filename) |
Initializes the SDDS output dataset. | |
int32_t | SDDS_Parallel_InitializeOutput (SDDS_DATASET *SDDS_dataset, const char *description, const char *contents, const char *filename) |
Initializes the SDDS output dataset for parallel processing. | |
int32_t | SDDS_SetNoRowCounts (SDDS_DATASET *SDDS_dataset, int32_t value) |
Sets the flag to enable or disable row counts in the SDDS dataset. | |
int32_t | SDDS_WriteLayout (SDDS_DATASET *SDDS_dataset) |
Writes the SDDS layout header to the output file. | |
int32_t | SDDS_WritePage (SDDS_DATASET *SDDS_dataset) |
Writes the current data table to the output file. | |
int32_t | SDDS_UpdatePage (SDDS_DATASET *SDDS_dataset, uint32_t mode) |
Updates the current page of the SDDS dataset. | |
int32_t | SDDS_SyncDataSet (SDDS_DATASET *SDDS_dataset) |
Synchronizes the SDDS dataset with the disk by flushing buffered data. | |
int32_t | SDDS_DefineParameter1 (SDDS_DATASET *SDDS_dataset, const char *name, const char *symbol, const char *units, const char *description, const char *format_string, int32_t type, void *fixed_value) |
Defines a data parameter with a fixed numerical value. | |
int32_t | SDDS_DefineParameter (SDDS_DATASET *SDDS_dataset, const char *name, const char *symbol, const char *units, const char *description, const char *format_string, int32_t type, char *fixed_value) |
Defines a data parameter with a fixed string value. | |
int32_t | SDDS_DefineArray (SDDS_DATASET *SDDS_dataset, const char *name, const char *symbol, const char *units, const char *description, const char *format_string, int32_t type, int32_t field_length, int32_t dimensions, const char *group_name) |
Defines a data array within the SDDS dataset. | |
int32_t | SDDS_DefineColumn (SDDS_DATASET *SDDS_dataset, const char *name, const char *symbol, const char *units, const char *description, const char *format_string, int32_t type, int32_t field_length) |
Defines a data column within the SDDS dataset. | |
int32_t | SDDS_DefineSimpleColumn (SDDS_DATASET *SDDS_dataset, const char *name, const char *unit, int32_t type) |
Defines a simple data column within the SDDS dataset. | |
int32_t | SDDS_DefineSimpleParameter (SDDS_DATASET *SDDS_dataset, const char *name, const char *unit, int32_t type) |
Defines a simple data parameter within the SDDS dataset. | |
int32_t | SDDS_DefineSimpleColumns (SDDS_DATASET *SDDS_dataset, int32_t number, char **name, char **unit, int32_t type) |
Defines multiple simple data columns of the same data type within the SDDS dataset. | |
int32_t | SDDS_DefineSimpleParameters (SDDS_DATASET *SDDS_dataset, int32_t number, char **name, char **unit, int32_t type) |
Defines multiple simple data parameters of the same data type within the SDDS dataset. | |
int32_t | SDDS_SetNameValidityFlags (uint32_t flags) |
Sets the validity flags for parameter and column names in the SDDS dataset. | |
int32_t | SDDS_IsValidName (const char *name, const char *class) |
Checks if a given name is valid for a specified class within the SDDS dataset. | |
int32_t | SDDS_DefineAssociate (SDDS_DATASET *SDDS_dataset, const char *name, const char *filename, const char *path, const char *description, const char *contents, int32_t sdds) |
Defines an associate for the SDDS dataset. | |
int32_t | SDDS_EraseData (SDDS_DATASET *SDDS_dataset) |
Erases all data entries in the SDDS dataset. | |
int32_t | SDDS_SetRowCountMode (SDDS_DATASET *SDDS_dataset, uint32_t mode) |
Sets the row count mode for the SDDS dataset. | |
void | SDDS_DisableFSync (SDDS_DATASET *SDDS_dataset) |
Disables file synchronization for the SDDS dataset. | |
void | SDDS_EnableFSync (SDDS_DATASET *SDDS_dataset) |
Enables file synchronization for the SDDS dataset. | |
int32_t | SDDS_DoFSync (SDDS_DATASET *SDDS_dataset) |
Synchronizes the SDDS dataset's file to disk. | |
Variables | |
static uint32_t | nameValidityFlags = 0 |
This file contains the implementation of the SDDS output routines.
This file provides functions for outputting data in the Self-Describing Data Sets (SDDS) format. It includes functions for creating and writing SDDS files, as well as functions for defining and appending data to the SDDS files.
Definition in file SDDS_output.c.
int32_t SDDS_DefineArray | ( | SDDS_DATASET * | SDDS_dataset, |
const char * | name, | ||
const char * | symbol, | ||
const char * | units, | ||
const char * | description, | ||
const char * | format_string, | ||
int32_t | type, | ||
int32_t | field_length, | ||
int32_t | dimensions, | ||
const char * | group_name ) |
Defines a data array within the SDDS dataset.
This function processes the definition of a data array in the SDDS dataset. It allows the user to specify the array's name, symbol, units, description, format string, data type, field length, number of dimensions, and associated group name. The function ensures that the array name is valid and unique within the dataset before defining it.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. |
[in] | name | A NULL-terminated string specifying the name of the array. This name must be unique within the dataset. |
[in] | symbol | A NULL-terminated string specifying the symbol for the array. Pass NULL if no symbol is desired. |
[in] | units | A NULL-terminated string specifying the units of the array. Pass NULL if no units are desired. |
[in] | description | A NULL-terminated string providing a description of the array. Pass NULL if no description is desired. |
[in] | format_string | A NULL-terminated string specifying the printf-style format for ASCII output. If NULL is passed, a default format is selected based on the array type. |
[in] | type | An integer representing the data type of the array. Must be one of the following:
|
[in] | field_length | An integer specifying the length of the field allotted to the array for ASCII output. If set to 0 , the field length is ignored. If negative, the field length is set to the absolute value, and leading and trailing white-space are eliminated for SDDS_STRING types upon reading. |
[in] | dimensions | An integer specifying the number of dimensions of the array. Must be greater than 0 . |
[in] | group_name | A NULL-terminated string specifying the name of the array group to which this array belongs. This allows related arrays to be grouped together (e.g., parallel arrays). |
-1
on failure, with an error message set internally.dimensions
parameter.Definition at line 1592 of file SDDS_output.c.
int32_t SDDS_DefineAssociate | ( | SDDS_DATASET * | SDDS_dataset, |
const char * | name, | ||
const char * | filename, | ||
const char * | path, | ||
const char * | description, | ||
const char * | contents, | ||
int32_t | sdds ) |
Defines an associate for the SDDS dataset.
This function defines an associate for the SDDS dataset, allowing the association of additional files or data with the primary dataset. Associates can provide supplementary information or link related datasets together. The function sets up the necessary attributes such as name, filename, path, description, contents, and SDDS flag to describe the associate.
Note: This function is NOT USED in the current implementation and will always return 0
unless compiled with RW_ASSOCIATES
defined.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. |
[in] | name | A NULL-terminated string specifying the name of the associate. This name must be unique within the dataset. |
[in] | filename | A NULL-terminated string specifying the filename of the associate. Must be a valid filename. |
[in] | path | A NULL-terminated string specifying the path to the associate. Pass NULL if no path is desired. |
[in] | description | A NULL-terminated string providing a description of the associate. Pass NULL if no description is desired. |
[in] | contents | A NULL-terminated string detailing the contents of the associate. Pass NULL if no contents are desired. |
[in] | sdds | An integer flag indicating the type of associate. Typically used to specify whether the associate is an SDDS file. |
0
if RW_ASSOCIATES
is not defined.RW_ASSOCIATES
must be defined during compilation to use this feature.filename
and path
(if provided) are valid and accessible. Definition at line 2153 of file SDDS_output.c.
int32_t SDDS_DefineColumn | ( | SDDS_DATASET * | SDDS_dataset, |
const char * | name, | ||
const char * | symbol, | ||
const char * | units, | ||
const char * | description, | ||
const char * | format_string, | ||
int32_t | type, | ||
int32_t | field_length ) |
Defines a data column within the SDDS dataset.
This function processes the definition of a data column in the SDDS dataset. It allows the user to specify the column's name, symbol, units, description, format string, data type, and field length. The function ensures that the column name is valid and unique within the dataset before defining it.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. |
[in] | name | A NULL-terminated string specifying the name of the column. This name must be unique within the dataset. |
[in] | symbol | A NULL-terminated string specifying the symbol for the column. Pass NULL if no symbol is desired. |
[in] | units | A NULL-terminated string specifying the units of the column. Pass NULL if no units are desired. |
[in] | description | A NULL-terminated string providing a description of the column. Pass NULL if no description is desired. |
[in] | format_string | A NULL-terminated string specifying the printf-style format for ASCII output. If NULL is passed, a default format is selected based on the column type. |
[in] | type | An integer representing the data type of the column. Must be one of the following:
|
[in] | field_length | An integer specifying the length of the field allotted to the column for ASCII output. If set to 0 , the field length is ignored. If negative, the field length is set to the absolute value, and leading and trailing white-space are eliminated for SDDS_STRING types upon reading. |
-1
on failure, with an error message set internally.Definition at line 1709 of file SDDS_output.c.
int32_t SDDS_DefineParameter | ( | SDDS_DATASET * | SDDS_dataset, |
const char * | name, | ||
const char * | symbol, | ||
const char * | units, | ||
const char * | description, | ||
const char * | format_string, | ||
int32_t | type, | ||
char * | fixed_value ) |
Defines a data parameter with a fixed string value.
This function processes the definition of a data parameter within the SDDS dataset. It allows the specification of a fixed string value for the parameter, which remains constant across all data entries. The function validates the parameter name, type, and format string before defining the parameter in the dataset.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. |
[in] | name | A NULL-terminated string specifying the name of the parameter. This name must be unique within the dataset. |
[in] | symbol | A NULL-terminated string specifying the symbol for the parameter. Pass NULL if no symbol is desired. |
[in] | units | A NULL-terminated string specifying the units of the parameter. Pass NULL if no units are desired. |
[in] | description | A NULL-terminated string providing a description of the parameter. Pass NULL if no description is desired. |
[in] | format_string | A NULL-terminated string specifying the printf-style format for ASCII output. If NULL is passed, a default format is selected based on the parameter type. |
[in] | type | An integer representing the data type of the parameter. Must be one of the following:
|
[in] | fixed_value | A NULL-terminated string specifying the fixed value of the parameter. For non-string types, this string should be formatted appropriately using functions like sprintf . |
-1
on failure, with an error message set internally.Definition at line 1466 of file SDDS_output.c.
int32_t SDDS_DefineParameter1 | ( | SDDS_DATASET * | SDDS_dataset, |
const char * | name, | ||
const char * | symbol, | ||
const char * | units, | ||
const char * | description, | ||
const char * | format_string, | ||
int32_t | type, | ||
void * | fixed_value ) |
Defines a data parameter with a fixed numerical value.
This function processes the definition of a data parameter within the SDDS dataset. It allows the specification of a fixed numerical value for the parameter, which remains constant across all data entries. The function validates the parameter name, type, and format string before defining the parameter in the dataset.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. |
[in] | name | A NULL-terminated string specifying the name of the parameter. This name must be unique within the dataset. |
[in] | symbol | A NULL-terminated string specifying the symbol for the parameter. Pass NULL if no symbol is desired. |
[in] | units | A NULL-terminated string specifying the units of the parameter. Pass NULL if no units are desired. |
[in] | description | A NULL-terminated string providing a description of the parameter. Pass NULL if no description is desired. |
[in] | format_string | A NULL-terminated string specifying the printf-style format for ASCII output. If NULL is passed, a default format is selected based on the parameter type. |
[in] | type | An integer representing the data type of the parameter. Must be one of the following:
|
[in] | fixed_value | A pointer to the numerical value that remains constant for this parameter across all data entries. This value is used to initialize the parameter's fixed value. |
-1
on failure, with an error message set internally.SDDS_STRING
.Definition at line 1401 of file SDDS_output.c.
int32_t SDDS_DefineSimpleColumn | ( | SDDS_DATASET * | SDDS_dataset, |
const char * | name, | ||
const char * | unit, | ||
int32_t | type ) |
Defines a simple data column within the SDDS dataset.
This function provides a simplified interface for defining a data column in the SDDS dataset. It allows the user to specify only the column's name, units, and data type, while omitting optional parameters such as symbol, description, format string, and field length. Internally, it calls SDDS_DefineColumn
with default values for the omitted parameters.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. |
[in] | name | A NULL-terminated string specifying the name of the column. This name must be unique within the dataset. |
[in] | unit | A NULL-terminated string specifying the units of the column. Pass NULL if no units are desired. |
[in] | type | An integer representing the data type of the column. Must be one of the following:
|
1
on successful definition of the column.0
on failure, with an error message set internally.Definition at line 1846 of file SDDS_output.c.
int32_t SDDS_DefineSimpleColumns | ( | SDDS_DATASET * | SDDS_dataset, |
int32_t | number, | ||
char ** | name, | ||
char ** | unit, | ||
int32_t | type ) |
Defines multiple simple data columns of the same data type within the SDDS dataset.
This function provides a streamlined way to define multiple data columns in the SDDS dataset that share the same data type. It allows the user to specify the names and units of the columns, while omitting optional attributes such as symbol, description, format string, and field length. Internally, it calls SDDS_DefineColumn
for each column with default values for the omitted parameters.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. |
[in] | number | The number of columns to define. Must be greater than or equal to 0 . |
[in] | name | An array of NULL-terminated strings specifying the names of the columns. Each name must be unique within the dataset. |
[in] | unit | An array of NULL-terminated strings specifying the units of the columns. Pass NULL for elements where no units are desired. |
[in] | type | An integer representing the data type for all the columns. Must be one of the following:
|
1
on successful definition of all specified columns.0
on failure to define any of the columns, with an error message set internally.name
array must contain unique and valid names for each column.type
must be a supported data type.number
as 0
results in no action and returns success.name
and unit
arrays are properly allocated and contain valid strings. Definition at line 1945 of file SDDS_output.c.
int32_t SDDS_DefineSimpleParameter | ( | SDDS_DATASET * | SDDS_dataset, |
const char * | name, | ||
const char * | unit, | ||
int32_t | type ) |
Defines a simple data parameter within the SDDS dataset.
This function provides a simplified interface for defining a data parameter in the SDDS dataset. It allows the user to specify only the parameter's name, units, and data type, while omitting optional attributes such as symbol, description, format string, and fixed value. Internally, it calls SDDS_DefineParameter
with default values for the omitted parameters.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. |
[in] | name | A NULL-terminated string specifying the name of the parameter. This name must be unique within the dataset. |
[in] | unit | A NULL-terminated string specifying the units of the parameter. Pass NULL if no units are desired. |
[in] | type | An integer representing the data type of the parameter. Must be one of the following:
|
1
on successful definition of the parameter.0
on failure, with an error message set internally.Definition at line 1894 of file SDDS_output.c.
int32_t SDDS_DefineSimpleParameters | ( | SDDS_DATASET * | SDDS_dataset, |
int32_t | number, | ||
char ** | name, | ||
char ** | unit, | ||
int32_t | type ) |
Defines multiple simple data parameters of the same data type within the SDDS dataset.
This function provides a streamlined way to define multiple data parameters in the SDDS dataset that share the same data type. It allows the user to specify the names and units of the parameters, while omitting optional attributes such as symbol, description, format string, and fixed value. Internally, it calls SDDS_DefineParameter
for each parameter with default values for the omitted parameters.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. |
[in] | number | The number of parameters to define. Must be greater than or equal to 0 . |
[in] | name | An array of NULL-terminated strings specifying the names of the parameters. Each name must be unique within the dataset. |
[in] | unit | An array of NULL-terminated strings specifying the units of the parameters. Pass NULL for elements where no units are desired. |
[in] | type | An integer representing the data type for all the parameters. Must be one of the following:
|
1
on successful definition of all specified parameters.0
on failure to define any of the parameters, with an error message set internally.name
array must contain unique and valid names for each parameter.type
must be a supported data type.number
as 0
results in no action and returns success.name
and unit
arrays are properly allocated and contain valid strings. Definition at line 2002 of file SDDS_output.c.
void SDDS_DisableFSync | ( | SDDS_DATASET * | SDDS_dataset | ) |
Disables file synchronization for the SDDS dataset.
This function disables the file synchronization feature for the specified SDDS dataset. File synchronization ensures that all buffered data is immediately written to disk, enhancing data integrity. By disabling this feature, the dataset will no longer perform synchronous writes, which can improve performance but may risk data loss in the event of a system failure.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. |
SDDS_SyncDataSet
will not call fsync
.Definition at line 2374 of file SDDS_output.c.
int32_t SDDS_DisconnectFile | ( | SDDS_DATASET * | SDDS_dataset | ) |
Disconnects the SDDS dataset from its associated file.
This function terminates the connection between the SDDS dataset and the file it is currently linked to. It ensures that all pending data is flushed to the file, closes the file handle, and updates the dataset's internal state to reflect that it is no longer connected to any file.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure to be disconnected. |
1
on successful disconnection.0
if an error occurred during disconnection. In this case, an error message is set internally.Definition at line 70 of file SDDS_output.c.
long SDDS_DisconnectInputFile | ( | SDDS_DATASET * | SDDS_dataset | ) |
Disconnects the input file from the SDDS dataset.
This function severs the connection between the SDDS dataset and its input file. It closes the file handle, updates the dataset's internal state to indicate disconnection, and returns the current file position before closing. After disconnection, the dataset cannot read further data from the input file until it is reconnected.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure whose input file is to be disconnected. |
ftell
) before disconnection.-1
and sets an internal error message.Definition at line 170 of file SDDS_output.c.
int32_t SDDS_DoFSync | ( | SDDS_DATASET * | SDDS_dataset | ) |
Synchronizes the SDDS dataset's file to disk.
Performs a file synchronization operation on the specified SDDS dataset to ensure that all buffered data is flushed to the storage medium. This is crucial for maintaining data integrity, especially in scenarios where unexpected shutdowns or crashes may occur.
1
.fsync
system call.1
if fsync
succeeds, indicating successful synchronization.0
if fsync
fails or if the dataset/file pointer is invalid.[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset to be synchronized. |
1
on successful synchronization.0
on failure. Definition at line 2423 of file SDDS_output.c.
void SDDS_EnableFSync | ( | SDDS_DATASET * | SDDS_dataset | ) |
Enables file synchronization for the SDDS dataset.
This function enables the file synchronization feature for the specified SDDS dataset. File synchronization ensures that all buffered data is immediately written to disk, enhancing data integrity. Enabling this feature can be crucial for applications where data consistency and reliability are paramount.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. |
SDDS_SyncDataSet
will call fsync
to flush buffers to disk.Definition at line 2398 of file SDDS_output.c.
int32_t SDDS_EraseData | ( | SDDS_DATASET * | SDDS_dataset | ) |
Erases all data entries in the SDDS dataset.
This function removes all data from the specified SDDS dataset, effectively resetting it to an empty state. It frees any allocated memory associated with data columns, parameters, and arrays, ensuring that all dynamic data is properly cleared. This is useful for reusing the dataset for new data without retaining previous entries.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. |
1
on successful erasure of all data.0
on failure, with an error message set internally.Definition at line 2244 of file SDDS_output.c.
int32_t SDDS_InitializeAppend | ( | SDDS_DATASET * | SDDS_dataset, |
const char * | filename ) |
Initializes the SDDS dataset for appending data by adding a new page to an existing file.
This function prepares the SDDS dataset for appending additional data to an existing SDDS file by initializing necessary data structures, verifying file integrity, and setting up for the addition of a new data page. It ensures that the file is writable, not compressed, and properly locked to prevent concurrent modifications.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure to be initialized for appending. |
[in] | filename | The name of the existing SDDS file to which data will be appended. If NULL , data will be appended to standard input. |
1
on successful initialization.0
on error. In this case, an internal error message is set describing the failure.filename
is NULL
, the dataset will append data from standard input.Definition at line 287 of file SDDS_output.c.
int32_t SDDS_InitializeAppendToPage | ( | SDDS_DATASET * | SDDS_dataset, |
const char * | filename, | ||
int64_t | updateInterval, | ||
int64_t * | rowsPresentReturn ) |
Initializes the SDDS dataset for appending data to the last page of an existing file.
This function sets up the SDDS dataset to append additional data rows to the last page of an existing SDDS file. It reads the existing file layout, determines the current state of data (including row counts), and prepares internal data structures to accommodate new data. The function also handles file locking, buffer management, and ensures that the file is ready for efficient data appending based on the specified update interval.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure to be initialized for appending. |
[in] | filename | The name of the existing SDDS file to which data will be appended. If NULL , data will be appended to standard input. |
[in] | updateInterval | The number of rows to write before the dataset reallocates memory or flushes data. This parameter controls the frequency of memory allocation and disk I/O operations during the append process. |
[out] | rowsPresentReturn | Pointer to an int64_t variable where the function will store the number of rows present in the dataset after initialization. This provides information on the current dataset size. |
1
on successful initialization.0
on error. In this case, an internal error message is set detailing the issue.rowsPresentReturn
is updated with the current number of rows in the dataset.filename
is NULL
, data will be appended from standard input.Definition at line 396 of file SDDS_output.c.
int32_t SDDS_InitializeOutput | ( | SDDS_DATASET * | SDDS_dataset, |
int32_t | data_mode, | ||
int32_t | lines_per_row, | ||
const char * | description, | ||
const char * | contents, | ||
const char * | filename ) |
Initializes the SDDS output dataset.
This function sets up the SDDS dataset for output operations by initializing the necessary structures, configuring the data mode (ASCII, Binary, or Parallel), handling file opening (including compressed files), and setting dataset metadata such as description and contents. It ensures that the dataset is ready for writing data according to the specified parameters.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure to be initialized for output. |
[in] | data_mode | The data mode for the output dataset. Acceptable values are:
|
[in] | lines_per_row | The number of lines per row in the output dataset. This parameter is used only for ASCII output and is typically set to 1. |
[in] | description | A string containing the description of the output dataset. Pass NULL if no description is desired. |
[in] | contents | A string detailing the contents of the output dataset. Pass NULL if no contents are desired. |
[in] | filename | The name of the file to which the dataset will be written. If NULL , the dataset will be written to standard output. |
1
on successful initialization.0
if an error occurred during initialization. In this case, an error message is set internally.SDDS_dataset
pointer must be valid and point to a properly allocated SDDS_DATASET structure.SDDS_OUTPUT_ENDIANESS
can be set to "big" or "little" to declare the byte order.lines_per_row
is set appropriately to match the data structure.Definition at line 595 of file SDDS_output.c.
int32_t SDDS_IsValidName | ( | const char * | name, |
const char * | class ) |
Checks if a given name is valid for a specified class within the SDDS dataset.
This function validates whether the provided name adheres to the naming conventions and rules defined by the current name validity flags for the specified class (e.g., parameter, column). It ensures that the name contains only allowed characters and follows the required structure.
[in] | name | The name to be validated. Must be a NULL-terminated string. |
[in] | class | The class type to which the name belongs (e.g., "parameter", "column"). This is used primarily for error reporting. |
1
if the name is valid for the specified class.0
if the name is invalid, with an error message set internally.SDDS_SetNameValidityFlags
.Definition at line 2080 of file SDDS_output.c.
int32_t SDDS_Parallel_InitializeOutput | ( | SDDS_DATASET * | SDDS_dataset, |
const char * | description, | ||
const char * | contents, | ||
const char * | filename ) |
Initializes the SDDS output dataset for parallel processing.
This function configures the SDDS dataset for parallel output operations. It sets the dataset's description, contents, and filename, ensuring that the output is in binary mode as parallel processing with compressed files is not supported. The function initializes necessary structures and prepares the dataset for efficient parallel data writing.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure to be initialized for parallel output. |
[in] | description | A string containing the description of the dataset. Pass NULL if no description is desired. |
[in] | contents | A string detailing the contents of the dataset. Pass NULL if no contents are desired. |
[in] | filename | The name of the file to which the dataset will be written. If NULL , the dataset will be written to standard output. |
1
on successful initialization.0
if an error occurred during initialization. In this case, an error message is set internally.SDDS_dataset
pointer must be valid and point to a properly allocated SDDS_DATASET structure.SDDS_OUTPUT_ENDIANESS
can be set to "big" or "little" to declare the byte order.Definition at line 748 of file SDDS_output.c.
int32_t SDDS_ReconnectFile | ( | SDDS_DATASET * | SDDS_dataset | ) |
Reconnects the SDDS dataset to its previously associated file.
This function re-establishes the connection between the SDDS dataset and the file it was previously linked to before being disconnected. It opens the file in read/write mode, seeks to the appropriate position, and updates the dataset's internal state to reflect that it is connected.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure to be reconnected. |
1
on successful reconnection.0
if an error occurred during reconnection. In this case, an error message is set internally.Definition at line 126 of file SDDS_output.c.
int32_t SDDS_ReconnectInputFile | ( | SDDS_DATASET * | SDDS_dataset, |
long | position ) |
Reconnects the input file for the SDDS dataset at a specified position.
This function re-establishes the connection between the SDDS dataset and its input file, positioning the file pointer at the specified byte offset. This allows the dataset to resume reading from a specific location within the input file.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure to reconnect. |
[in] | position | The byte offset position in the input file where reconnection should occur. |
1
on successful reconnection.0
on failure. In this case, an internal error message is set.Definition at line 229 of file SDDS_output.c.
int32_t SDDS_SetNameValidityFlags | ( | uint32_t | flags | ) |
Sets the validity flags for parameter and column names in the SDDS dataset.
This function allows the user to configure the rules for validating names of parameters and columns within the SDDS dataset. The validity flags determine the set of allowed characters and naming conventions.
[in] | flags | A bitmask representing the desired name validity flags. Possible flags include:
|
Definition at line 2043 of file SDDS_output.c.
int32_t SDDS_SetNoRowCounts | ( | SDDS_DATASET * | SDDS_dataset, |
int32_t | value ) |
Sets the flag to enable or disable row counts in the SDDS dataset.
This function configures the SDDS dataset to either include or exclude row counts in the output. Row counts provide metadata about the number of rows written, which can be useful for data integrity and validation. Disabling row counts can improve performance when such metadata is unnecessary.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure to be configured. |
[in] | value | The flag value to set:
|
1
on successful configuration.0
if an error occurred (e.g., attempting to change the flag after the layout has been written).SDDS_dataset
must be initialized and not have written the layout yet.Definition at line 847 of file SDDS_output.c.
int32_t SDDS_SetRowCountMode | ( | SDDS_DATASET * | SDDS_dataset, |
uint32_t | mode ) |
Sets the row count mode for the SDDS dataset.
This function configures how row counts are managed within the SDDS dataset. The row count mode determines whether row counts are variable, fixed, or entirely omitted during data writing. Proper configuration of row count modes can enhance data integrity and performance based on specific use cases.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. |
[in] | mode | The row count mode to be set. Must be one of the following:
|
1
on successful configuration of the row count mode.0
on failure, with an error message set internally.SDDS_FIXEDROWCOUNT
mode may require specifying additional parameters such as row increment.Definition at line 2326 of file SDDS_output.c.
int32_t SDDS_SyncDataSet | ( | SDDS_DATASET * | SDDS_dataset | ) |
Synchronizes the SDDS dataset with the disk by flushing buffered data.
This function attempts to ensure that any buffered data associated with the SDDS dataset is written to the disk using the fsync
system call. However, on certain platforms such as VxWorks, Windows, Linux, and macOS, this functionality is not implemented and the function simply returns success. This behavior should be considered when relying on data synchronization across different operating systems.
[in] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. |
0
on success, indicating that data synchronization is either not needed or was successful.-1
) on failure to synchronize the data, with an error message set internally.fsync
system call.Definition at line 1333 of file SDDS_output.c.
int32_t SDDS_UpdatePage | ( | SDDS_DATASET * | SDDS_dataset, |
uint32_t | mode ) |
Updates the current page of the SDDS dataset.
This function finalizes and writes the current page of the SDDS dataset based on the specified mode. The mode can be either FLUSH_TABLE
, indicating that the current page is complete and should be written to disk, or 0
for other update operations. Depending on the data mode (ASCII or Binary), the function delegates the update process to the appropriate handler.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. |
[in] | mode | The update mode, which can be:
|
1
on successful update of the current page.0
if an error occurred during the update process. An error message is set internally in this case.FLUSH_TABLE
mode ensures that all buffered data is written to the disk, which can be useful for data integrity.Definition at line 1285 of file SDDS_output.c.
int32_t SDDS_WriteLayout | ( | SDDS_DATASET * | SDDS_dataset | ) |
Writes the SDDS layout header to the output file.
This function serializes and writes the layout information of the SDDS dataset to the output file. The layout defines the structure of the data tables, including parameters, arrays, columns, and associates. The function handles different file types, including standard, gzip-compressed, and LZMA-compressed files, and ensures that the layout is written in the correct byte order and format based on the dataset's configuration.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure whose layout is to be written. |
1
on successful writing of the layout.0
if an error occurred during the writing process. An internal error message is set in this case.SDDS_OUTPUT_ENDIANESS
can influence the byte order declared in the layout.Definition at line 893 of file SDDS_output.c.
int32_t SDDS_WritePage | ( | SDDS_DATASET * | SDDS_dataset | ) |
Writes the current data table to the output file.
This function serializes and writes the current data table of the SDDS dataset to the output file. It must be preceded by a call to SDDS_WriteLayout
to ensure that the dataset layout is properly defined in the output file. Depending on the data mode (ASCII or Binary), the function delegates the writing process to the appropriate handler.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. |
1
on successful writing of the data table.0
if an error occurred during the write process. An error message is set internally in this case.SDDS_WriteLayout
must have been called successfully before writing any pages.Definition at line 1222 of file SDDS_output.c.
|
static |
Definition at line 2014 of file SDDS_output.c.