SDDSlib
|
SDDS binary data input and output routines. More...
#include "SDDS.h"
#include "SDDS_internal.h"
#include "mdb.h"
#include <string.h>
#include <errno.h>
#include <unistd.h>
Go to the source code of this file.
Macros | |
#define | FSEEK_TRIES 10 |
Functions | |
double | makeFloat64FromFloat80 (unsigned char x[16], int32_t byteOrder) |
Converts a 16-byte array representing a float80 value to a double. | |
int32_t | SDDS_SetBufferedRead (int32_t dummy) |
int32_t | SDDS_SetDefaultIOBufferSize (int32_t newValue) |
int32_t | SDDS_BufferedRead (void *target, int64_t targetSize, FILE *fp, SDDS_FILEBUFFER *fBuffer, int32_t type, int32_t byteOrder) |
int32_t | SDDS_LZMABufferedRead (void *target, int64_t targetSize, struct lzmafile *lzmafp, SDDS_FILEBUFFER *fBuffer, int32_t type, int32_t byteOrder) |
int32_t | SDDS_BufferedWrite (void *target, int64_t targetSize, FILE *fp, SDDS_FILEBUFFER *fBuffer) |
int32_t | SDDS_LZMABufferedWrite (void *target, int64_t targetSize, struct lzmafile *lzmafp, SDDS_FILEBUFFER *fBuffer) |
int32_t | SDDS_FlushBuffer (FILE *fp, SDDS_FILEBUFFER *fBuffer) |
int32_t | SDDS_LZMAFlushBuffer (struct lzmafile *lzmafp, SDDS_FILEBUFFER *fBuffer) |
int32_t | SDDS_WriteBinaryPage (SDDS_DATASET *SDDS_dataset) |
int32_t | SDDS_UpdateBinaryPage (SDDS_DATASET *SDDS_dataset, uint32_t mode) |
Updates the binary page of an SDDS dataset. | |
int32_t | SDDS_fseek (FILE *fp, int64_t offset, int32_t dir) |
Sets the file position indicator for a given file stream with retry logic. | |
int32_t | SDDS_lzmaseek (struct lzmafile *lzmafp, int64_t offset, int32_t dir) |
Sets the file position indicator for a given LZMA file stream with retry logic. | |
int32_t | SDDS_WriteBinaryParameters (SDDS_DATASET *SDDS_dataset) |
Writes the binary parameters of the SDDS dataset. | |
int32_t | SDDS_WriteBinaryArrays (SDDS_DATASET *SDDS_dataset) |
Writes the binary arrays of the SDDS dataset to a file. | |
int32_t | SDDS_WriteBinaryColumns (SDDS_DATASET *SDDS_dataset) |
Writes the binary columns of an SDDS dataset to the associated file. | |
int32_t | SDDS_WriteNonNativeBinaryColumns (SDDS_DATASET *SDDS_dataset) |
Writes non-native endian binary columns of an SDDS dataset to the associated file. | |
int32_t | SDDS_WriteBinaryRow (SDDS_DATASET *SDDS_dataset, int64_t row) |
Writes a single binary row of an SDDS dataset to the associated file. | |
int32_t | SDDS_ReadRecoveryPossible (SDDS_DATASET *SDDS_dataset) |
Checks if any data in an SDDS page was recovered after an error was detected. | |
void | SDDS_SetReadRecoveryMode (SDDS_DATASET *SDDS_dataset, int32_t mode) |
Sets the read recovery mode for an SDDS dataset. | |
int32_t | SDDS_ReadBinaryPage (SDDS_DATASET *SDDS_dataset, int64_t sparse_interval, int64_t sparse_offset, int32_t sparse_statistics) |
Reads a binary page from an SDDS dataset. | |
int32_t | SDDS_ReadBinaryPageLastRows (SDDS_DATASET *SDDS_dataset, int64_t last_rows) |
Reads the last specified number of rows from a binary page of an SDDS dataset. | |
int32_t | SDDS_ReadBinaryPageDetailed (SDDS_DATASET *SDDS_dataset, int64_t sparse_interval, int64_t sparse_offset, int64_t last_rows, int32_t sparse_statistics) |
Reads a binary page from an SDDS dataset with detailed options. | |
int32_t | SDDS_WriteBinaryString (char *string, FILE *fp, SDDS_FILEBUFFER *fBuffer) |
Writes a binary string to a file with buffering. | |
int32_t | SDDS_LZMAWriteBinaryString (char *string, struct lzmafile *lzmafp, SDDS_FILEBUFFER *fBuffer) |
Writes a binary string to a file with LZMA compression. | |
char * | SDDS_ReadBinaryString (FILE *fp, SDDS_FILEBUFFER *fBuffer, int32_t skip) |
Reads a binary string from a file with buffering. | |
char * | SDDS_ReadLZMABinaryString (struct lzmafile *lzmafp, SDDS_FILEBUFFER *fBuffer, int32_t skip) |
Reads a binary string from an LZMA-compressed file with buffering. | |
int32_t | SDDS_ReadBinaryRow (SDDS_DATASET *SDDS_dataset, int64_t row, int32_t skip) |
Reads a binary row from the specified SDDS dataset. | |
int32_t | SDDS_ReadNewBinaryRows (SDDS_DATASET *SDDS_dataset) |
Reads new binary rows from the SDDS dataset. | |
int32_t | SDDS_ReadBinaryParameters (SDDS_DATASET *SDDS_dataset) |
Reads binary parameters from the specified SDDS dataset. | |
int32_t | SDDS_ReadBinaryArrays (SDDS_DATASET *SDDS_dataset) |
Reads binary arrays from an SDDS dataset. | |
int32_t | SDDS_ReadBinaryColumns (SDDS_DATASET *SDDS_dataset) |
Reads the binary columns from an SDDS dataset. | |
int32_t | SDDS_ReadNonNativeBinaryColumns (SDDS_DATASET *SDDS_dataset) |
Reads the non-native endian binary columns from an SDDS dataset. | |
int32_t | SDDS_SwapEndsColumnData (SDDS_DATASET *SDDSin) |
Swaps the endianness of the column data in an SDDS dataset. | |
int32_t | SDDS_SwapEndsParameterData (SDDS_DATASET *SDDSin) |
Swaps the endianness of the parameter data in an SDDS dataset. | |
int32_t | SDDS_SwapEndsArrayData (SDDS_DATASET *SDDSin) |
Swaps the endianness of the array data in an SDDS dataset. | |
void | SDDS_SwapShort (short *data) |
Swaps the endianness of a short integer. | |
void | SDDS_SwapUShort (unsigned short *data) |
Swaps the endianness of an unsigned short integer. | |
void | SDDS_SwapLong (int32_t *data) |
Swaps the endianness of a 32-bit integer. | |
void | SDDS_SwapULong (uint32_t *data) |
Swaps the endianness of a 32-bit unsigned integer. | |
void | SDDS_SwapLong64 (int64_t *data) |
Swaps the endianness of a 64-bit integer. | |
void | SDDS_SwapULong64 (uint64_t *data) |
Swaps the endianness of a 64-bit unsigned integer. | |
void | SDDS_SwapFloat (float *data) |
Swaps the endianness of a float. | |
void | SDDS_SwapDouble (double *data) |
Swaps the endianness of a double. | |
void | SDDS_SwapLongDouble (long double *data) |
Swaps the endianness of a long double. | |
int32_t | SDDS_ReadNonNativePage (SDDS_DATASET *SDDS_dataset) |
Reads a non-native endian page from an SDDS dataset. | |
int32_t | SDDS_ReadNonNativePageSparse (SDDS_DATASET *SDDS_dataset, uint32_t mode, int64_t sparse_interval, int64_t sparse_offset) |
Reads a sparse non-native endian page from an SDDS dataset. | |
int32_t | SDDS_ReadNonNativePageDetailed (SDDS_DATASET *SDDS_dataset, uint32_t mode, int64_t sparse_interval, int64_t sparse_offset, int64_t last_rows) |
Reads a detailed non-native endian page from an SDDS dataset. | |
int32_t | SDDS_ReadNonNativePageLastRows (SDDS_DATASET *SDDS_dataset, int64_t last_rows) |
Reads the last few rows from a non-native endian page in an SDDS dataset. | |
int32_t | SDDS_ReadNonNativeBinaryPage (SDDS_DATASET *SDDS_dataset, int64_t sparse_interval, int64_t sparse_offset) |
Reads a non-native endian binary page from an SDDS dataset. | |
int32_t | SDDS_ReadNonNativeBinaryPageLastRows (SDDS_DATASET *SDDS_dataset, int64_t last_rows) |
Reads the last few rows from a non-native endian binary page in an SDDS dataset. | |
int32_t | SDDS_ReadNonNativeBinaryPageDetailed (SDDS_DATASET *SDDS_dataset, int64_t sparse_interval, int64_t sparse_offset, int64_t last_rows) |
Reads a detailed non-native endian binary page from an SDDS dataset. | |
int32_t | SDDS_ReadNonNativeBinaryParameters (SDDS_DATASET *SDDS_dataset) |
Reads non-native endian binary parameters from an SDDS dataset. | |
int32_t | SDDS_ReadNonNativeBinaryArrays (SDDS_DATASET *SDDS_dataset) |
Reads non-native endian binary arrays from an SDDS dataset. | |
int32_t | SDDS_ReadNonNativeBinaryRow (SDDS_DATASET *SDDS_dataset, int64_t row, int32_t skip) |
Reads a non-native endian binary row from an SDDS dataset. | |
char * | SDDS_ReadNonNativeBinaryString (FILE *fp, SDDS_FILEBUFFER *fBuffer, int32_t skip) |
Reads a non-native endian binary string from a file. | |
char * | SDDS_ReadNonNativeLZMABinaryString (struct lzmafile *lzmafp, SDDS_FILEBUFFER *fBuffer, int32_t skip) |
Reads a non-native endian binary string from an LZMA-compressed file. | |
int32_t | SDDS_WriteNonNativeBinaryPage (SDDS_DATASET *SDDS_dataset) |
Writes a non-native endian binary page to an SDDS dataset. | |
int32_t | SDDS_WriteNonNativeBinaryParameters (SDDS_DATASET *SDDS_dataset) |
Writes non-native endian binary parameters to an SDDS dataset. | |
int32_t | SDDS_WriteNonNativeBinaryArrays (SDDS_DATASET *SDDS_dataset) |
Writes non-native endian binary arrays to an SDDS dataset. | |
int32_t | SDDS_WriteNonNativeBinaryRow (SDDS_DATASET *SDDS_dataset, int64_t row) |
Writes a non-native endian binary row to an SDDS dataset. | |
int32_t | SDDS_WriteNonNativeBinaryString (char *string, FILE *fp, SDDS_FILEBUFFER *fBuffer) |
Writes a non-native endian binary string to a file. | |
int32_t | SDDS_LZMAWriteNonNativeBinaryString (char *string, struct lzmafile *lzmafp, SDDS_FILEBUFFER *fBuffer) |
Writes a non-native endian binary string to an LZMA-compressed file. | |
int32_t | SDDS_UpdateNonNativeBinaryPage (SDDS_DATASET *SDDS_dataset, uint32_t mode) |
Updates a non-native endian binary page in an SDDS dataset. | |
Variables | |
static int32_t | defaultIOBufferSize = SDDS_FILEBUFFER_SIZE |
SDDS binary data input and output routines.
This file contains the implementation of binary file handling functions for the SDDS (Self-Describing Data Sets) library. It includes functions for reading and writing binary data files in the SDDS format.
Definition in file SDDS_binary.c.
#define FSEEK_TRIES 10 |
Definition at line 1230 of file SDDS_binary.c.
double makeFloat64FromFloat80 | ( | unsigned char | x[16], |
int32_t | byteOrder ) |
Converts a 16-byte array representing a float80 value to a double.
This function converts a 16-byte array, which represents an 80-bit floating-point (float80) value, to a standard double-precision (64-bit) floating-point value. The conversion handles different byte orders, supporting both big-endian and little-endian formats. On systems where long double
is implemented as 64-bit (such as Windows and Mac), this function allows reading SDDS_LONGDOUBLE SDDS files with a loss of precision by translating float80 values to double.
[in] | x | The 16-byte array representing the float80 value. |
[in] | byteOrder | The byte order of the array, either SDDS_BIGENDIAN_SEEN or SDDS_LITTLEENDIAN_SEEN . |
x
is correctly formatted as an 80-bit floating-point value. On systems where long double
is 80 bits, the conversion preserves as much precision as possible within the limitations of the double-precision format. On systems with 64-bit long double
, the function translates the value with inherent precision loss. Definition at line 5768 of file SDDS_binary.c.
int32_t SDDS_BufferedRead | ( | void * | target, |
int64_t | targetSize, | ||
FILE * | fp, | ||
SDDS_FILEBUFFER * | fBuffer, | ||
int32_t | type, | ||
int32_t | byteOrder ) |
Reads data from a file into a buffer, optimizing performance with buffering.
This function reads targetSize
bytes from the file fp
into the memory pointed to by target
. It uses the provided fBuffer
to buffer file data, improving read performance. If the data type is SDDS_LONGDOUBLE
and the long double
precision is not 18 digits, it handles conversion to double precision if the environment variable SDDS_LONGDOUBLE_64BITS
is not set.
If target
is NULL, the function skips over targetSize
bytes in the file.
target | Pointer to the memory location where the data will be stored. If NULL, the data is skipped. |
targetSize | The number of bytes to read from the file. |
fp | The file pointer from which data is read. |
fBuffer | Pointer to an SDDS_FILEBUFFER structure used for buffering file data. |
type | The SDDS data type of the data being read (e.g., SDDS_LONGDOUBLE ). |
byteOrder | The byte order of the data (SDDS_LITTLEENDIAN or SDDS_BIGENDIAN ). |
Definition at line 96 of file SDDS_binary.c.
int32_t SDDS_BufferedWrite | ( | void * | target, |
int64_t | targetSize, | ||
FILE * | fp, | ||
SDDS_FILEBUFFER * | fBuffer ) |
Writes data to a file using a buffer to optimize performance.
This function writes targetSize
bytes from the memory pointed to by target
to the file fp
. It uses the provided fBuffer
to buffer file data, improving write performance. If the buffer is full, it flushes the buffer to the file before writing more data.
target | Pointer to the memory location of the data to write. |
targetSize | The number of bytes to write to the file. |
fp | The file pointer to which data is written. |
fBuffer | Pointer to an SDDS_FILEBUFFER structure used for buffering file data. |
Definition at line 484 of file SDDS_binary.c.
int32_t SDDS_FlushBuffer | ( | FILE * | fp, |
SDDS_FILEBUFFER * | fBuffer ) |
Flushes the buffered data to a file to ensure all data is written.
This function writes any remaining data in the buffer (fBuffer
) to the file pointed to by fp
. If the buffer contains data, it writes the data to the file, resets the buffer, and flushes the file's output buffer using fflush
. This ensures that all buffered data is physically written to the file.
fp | The file pointer to which buffered data will be written. |
fBuffer | Pointer to an SDDS_FILEBUFFER structure containing the buffered data. |
fBuffer->bufferSize
is zero, the function will only call fflush(fp)
.fp
or fBuffer
is NULL
, the function sets an error message and returns 0. Definition at line 632 of file SDDS_binary.c.
int32_t SDDS_fseek | ( | FILE * | fp, |
int64_t | offset, | ||
int32_t | dir ) |
Sets the file position indicator for a given file stream with retry logic.
Attempts to set the file position indicator for the specified file stream (fp
) to a new position defined by offset
and dir
. The function retries the fseek
operation up to FSEEK_TRIES
times in case of transient failures, implementing a delay between attempts.
fp | Pointer to the FILE stream whose position indicator is to be set. |
offset | Number of bytes to offset from the position specified by dir . |
dir | Positioning directive, which can be one of:
|
0
if the operation is successful.-1
if all retry attempts fail to set the file position.The function attempts to set the file position using fseek
. If fseek
fails, it sleeps for 1 second (or 1 second using nanosleep
on vxWorks systems) before retrying. After FSEEK_TRIES
unsuccessful attempts, it reports a warning and returns -1
.
fseek
operation.fseek
errors, which will cause it to fail after retries. Definition at line 1258 of file SDDS_binary.c.
int32_t SDDS_LZMABufferedRead | ( | void * | target, |
int64_t | targetSize, | ||
struct lzmafile * | lzmafp, | ||
SDDS_FILEBUFFER * | fBuffer, | ||
int32_t | type, | ||
int32_t | byteOrder ) |
Reads data from an LZMA-compressed file into a buffer, optimizing performance with buffering.
This function reads targetSize
bytes from the LZMA-compressed file lzmafp
into the memory pointed to by target
. It uses the provided fBuffer
to buffer file data, improving read performance. If the data type is SDDS_LONGDOUBLE
and the long double
precision is not 18 digits, it handles conversion to double precision if the environment variable SDDS_LONGDOUBLE_64BITS
is not set.
If target
is NULL, the function skips over targetSize
bytes in the file.
target | Pointer to the memory location where the data will be stored. If NULL, the data is skipped. |
targetSize | The number of bytes to read from the file. |
lzmafp | The LZMA file pointer from which data is read. |
fBuffer | Pointer to an SDDS_FILEBUFFER structure used for buffering file data. |
type | The SDDS data type of the data being read (e.g., SDDS_LONGDOUBLE ). |
byteOrder | The byte order of the data (SDDS_LITTLEENDIAN or SDDS_BIGENDIAN ). |
fBuffer->bufferSize
is non-zero. If it is zero, an error is set. Definition at line 243 of file SDDS_binary.c.
int32_t SDDS_LZMABufferedWrite | ( | void * | target, |
int64_t | targetSize, | ||
struct lzmafile * | lzmafp, | ||
SDDS_FILEBUFFER * | fBuffer ) |
Writes data to an LZMA-compressed file using a buffer to optimize performance.
This function writes targetSize
bytes from the memory pointed to by target
to the LZMA-compressed file referenced by lzmafp
. It uses the provided fBuffer
to buffer data before writing to the file, which can improve write performance by reducing the number of write operations.
If there is enough space in the buffer (fBuffer
), the data is copied into the buffer. If the buffer does not have enough space to hold the data, the buffer is flushed to the file, and the function recursively calls itself to handle the remaining data.
target | Pointer to the memory location of the data to write. |
targetSize | The number of bytes to write to the file. |
lzmafp | The LZMA file pointer to which data is written. |
fBuffer | Pointer to an SDDS_FILEBUFFER structure used for buffering data. |
fBuffer->bufferSize
is non-zero. If it is zero, the function sets an error message and returns 0. Definition at line 550 of file SDDS_binary.c.
int32_t SDDS_LZMAFlushBuffer | ( | struct lzmafile * | lzmafp, |
SDDS_FILEBUFFER * | fBuffer ) |
Flushes the buffered data to an LZMA-compressed file to ensure all data is written.
This function writes any remaining data in the buffer (fBuffer
) to the LZMA-compressed file pointed to by lzmafp
. If the buffer contains data, it writes the data to the file, resets the buffer, ensuring that all buffered data is physically written to the file.
lzmafp | The LZMA file pointer to which buffered data will be written. |
fBuffer | Pointer to an SDDS_FILEBUFFER structure containing the buffered data. |
fBuffer->bufferSize
is non-zero and fBuffer
is properly initialized. Definition at line 687 of file SDDS_binary.c.
int32_t SDDS_lzmaseek | ( | struct lzmafile * | lzmafp, |
int64_t | offset, | ||
int32_t | dir ) |
Sets the file position indicator for a given LZMA file stream with retry logic.
Attempts to set the file position indicator for the specified LZMA file stream (lzmafp
) to a new position defined by offset
and dir
. The function retries the lzma_seek
operation up to FSEEK_TRIES
times in case of transient failures, implementing a delay between attempts.
lzmafp | Pointer to the lzmafile stream whose position indicator is to be set. |
offset | Number of bytes to offset from the position specified by dir . |
dir | Positioning directive, which can be one of:
|
0
if the operation is successful.-1
if all retry attempts fail to set the file position.The function attempts to set the file position using lzma_seek
. If lzma_seek
fails, it sleeps for 1 second (or 1 second using nanosleep
on vxWorks systems) before retrying. After FSEEK_TRIES
unsuccessful attempts, it reports a warning and returns -1
.
lzma_seek
operation.lzma_seek
errors, which will cause it to fail after retries. Definition at line 1312 of file SDDS_binary.c.
int32_t SDDS_LZMAWriteBinaryString | ( | char * | string, |
struct lzmafile * | lzmafp, | ||
SDDS_FILEBUFFER * | fBuffer ) |
Writes a binary string to a file with LZMA compression.
This function writes a binary string to the specified LZMA-compressed file by first writing the length of the string followed by the string's content. If the input string is NULL, an empty string is written instead. The writing operation utilizes LZMA buffered write functions to ensure data is compressed appropriately.
[in] | string | The null-terminated string to be written. If NULL, an empty string is written. |
[in] | lzmafp | The LZMA file pointer to write to. Must be a valid, open LZMA-compressed file in write mode. |
[in,out] | fBuffer | Pointer to the file buffer used for buffered writing operations. |
1 | Operation was successful. |
0 | An error occurred during writing. |
Definition at line 2553 of file SDDS_binary.c.
int32_t SDDS_LZMAWriteNonNativeBinaryString | ( | char * | string, |
struct lzmafile * | lzmafp, | ||
SDDS_FILEBUFFER * | fBuffer ) |
Writes a non-native endian binary string to an LZMA-compressed file.
This function writes a binary string to the specified LZMA-compressed file pointer, handling non-native endianness. It first writes the length of the string as a 32-bit integer with byte order swapped. If the string is not to be skipped, it then writes the string data itself followed by a null terminator. If the input string is NULL, an empty string is written instead.
[in] | string | The string to write. If NULL, an empty string is written. |
[in] | lzmafp | Pointer to the LZMAFILE where the string will be written. |
[in] | fBuffer | Pointer to the SDDS_FILEBUFFER structure used for buffered writing. |
1 | The string was successfully written and byte-swapped. |
0 | An error occurred during the write operation, such as I/O failures or memory allocation issues. |
lzmafp
is valid and open for writing. This function does not perform memory allocation for the string; it assumes that the string is already allocated and managed appropriately. Definition at line 5512 of file SDDS_binary.c.
int32_t SDDS_ReadBinaryArrays | ( | SDDS_DATASET * | SDDS_dataset | ) |
Reads binary arrays from an SDDS dataset.
This function iterates through all array definitions within the specified SDDS dataset and reads their binary data from the underlying file. It handles various compression formats, including uncompressed, LZMA-compressed, and GZIP-compressed files. For each array, the function reads its definition, dimensions, and data elements, allocating and managing memory as necessary. String arrays are handled by reading each string individually, while other data types are read in bulk.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset to read from. |
1 | All arrays were successfully read and stored. |
0 | An error occurred during the read operation, such as I/O failures, memory allocation issues, or corrupted array definitions. |
Definition at line 3057 of file SDDS_binary.c.
int32_t SDDS_ReadBinaryColumns | ( | SDDS_DATASET * | SDDS_dataset | ) |
Reads the binary columns from an SDDS dataset.
This function iterates through all column definitions within the specified SDDS dataset and reads their binary data from the underlying file. It handles various compression formats, including uncompressed, LZMA-compressed, and GZIP-compressed files. For each column, the function reads data for each row, managing memory allocation for string columns as necessary. Non-string data types are read in bulk for each column.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset to read from. |
1 | All columns were successfully read and stored. |
0 | An error occurred during the read operation, such as I/O failures, memory allocation issues, or corrupted column definitions. |
Definition at line 3222 of file SDDS_binary.c.
int32_t SDDS_ReadBinaryPage | ( | SDDS_DATASET * | SDDS_dataset, |
int64_t | sparse_interval, | ||
int64_t | sparse_offset, | ||
int32_t | sparse_statistics ) |
Reads a binary page from an SDDS dataset.
This function reads a binary page from the specified SDDS dataset. It allows for sparse reading by specifying the sparse_interval
and sparse_offset
parameters, enabling the reading of data at specified intervals or starting from a specific offset.
SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset to read from. |
sparse_interval | Interval at which to read rows. A value greater than 1 enables sparse reading. |
sparse_offset | Number of initial rows to skip before starting to read data. |
sparse_statistics | Flag indicating whether to compute statistics during sparse reading:
|
-1
if the end-of-file is reached.0
on error.The function internally calls SDDS_ReadBinaryPageDetailed
with the provided parameters to perform the actual reading. It handles various scenarios, including non-native byte orders and different data layouts (row-major or column-major).
Definition at line 2120 of file SDDS_binary.c.
int32_t SDDS_ReadBinaryPageDetailed | ( | SDDS_DATASET * | SDDS_dataset, |
int64_t | sparse_interval, | ||
int64_t | sparse_offset, | ||
int64_t | last_rows, | ||
int32_t | sparse_statistics ) |
Reads a binary page from an SDDS dataset with detailed options.
This function reads a binary page from the specified SDDS dataset, providing detailed control over the reading process. It supports sparse reading, reading a specific number of rows from the end, and computing statistics on the data.
Typically, this function is not called directly. Instead, it is invoked through higher-level functions such as SDDS_ReadBinaryPage
or SDDS_ReadBinaryPageLastRows
, which provide simplified interfaces for common reading scenarios.
SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset to read from. |
sparse_interval | Interval at which to read rows. A value greater than 1 enables sparse reading. |
sparse_offset | Number of initial rows to skip before starting to read data. |
last_rows | The number of rows to read from the end of the dataset. If 0 , all rows are read. |
sparse_statistics | Flag indicating whether to compute statistics during sparse reading:
|
-1
if the end-of-file is reached.0
on error.The function performs the following steps:
-1
.SDDS_ReadNonNativePageDetailed
if necessary.SDDS_ReadBinaryColumns
if necessary.sparse_interval
and sparse_offset
.sparse_statistics
is enabled, computes the specified statistics (average, median, min, max) on floating-point data.zLib
for gzip, LZMA libraries) must be enabled during compilation for handling compressed files. Definition at line 2202 of file SDDS_binary.c.
int32_t SDDS_ReadBinaryPageLastRows | ( | SDDS_DATASET * | SDDS_dataset, |
int64_t | last_rows ) |
Reads the last specified number of rows from a binary page of an SDDS dataset.
This function reads the last last_rows
rows from the binary page of the specified SDDS dataset. It is useful for retrieving recent data entries without processing the entire dataset.
SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset to read from. |
last_rows | The number of rows to read from the end of the dataset. |
-1
if the end-of-file is reached.0
on error.The function internally calls SDDS_ReadBinaryPageDetailed
with sparse_interval
set to 1
, sparse_offset
set to 0
, and last_rows
as specified. This configuration ensures that only the last last_rows
rows are read from the dataset.
last_rows
does not exceed the total number of rows in the dataset to avoid errors.Definition at line 2150 of file SDDS_binary.c.
int32_t SDDS_ReadBinaryParameters | ( | SDDS_DATASET * | SDDS_dataset | ) |
Reads binary parameters from the specified SDDS dataset.
This function iterates through all the parameters defined in the SDDS dataset layout and reads their values from the underlying file. It handles different data types, including strings, and manages memory allocation for string parameters. Depending on the dataset's compression settings (uncompressed, LZMA, or GZIP), it uses the appropriate reading functions to retrieve the parameter values.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset to read from. |
1 | All parameters were successfully read and stored. |
0 | An error occurred during the read operation, such as I/O errors, data type mismatches, or memory allocation failures. |
Definition at line 2945 of file SDDS_binary.c.
int32_t SDDS_ReadBinaryRow | ( | SDDS_DATASET * | SDDS_dataset, |
int64_t | row, | ||
int32_t | skip ) |
Reads a binary row from the specified SDDS dataset.
This function reads a single row of data from the given SDDS dataset. Depending on the dataset's configuration, it handles uncompressed, LZMA-compressed, or GZIP-compressed files. For each column in the dataset, the function reads the appropriate data type. If a column is of type string, it reads the string using the corresponding string reading function. If the 'skip' parameter is set, the function skips reading the data without storing it.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset to read from. |
[in] | row | The row number to read. Must be within the allocated range of rows in the dataset. |
[in] | skip | If non-zero, the function skips reading the data for each column without storing it. |
1 | The row was successfully read and stored (or skipped). |
0 | An error occurred during reading, such as I/O errors or memory allocation failures. |
Definition at line 2715 of file SDDS_binary.c.
char * SDDS_ReadBinaryString | ( | FILE * | fp, |
SDDS_FILEBUFFER * | fBuffer, | ||
int32_t | skip ) |
Reads a binary string from a file with buffering.
This function reads a binary string from the specified file by first reading the length of the string and then reading the string content based on the length. If the 'skip' parameter is set, the string data is skipped over instead of being stored. The function allocates memory for the string, which should be freed by the caller when no longer needed.
[in] | fp | The file pointer to read from. Must be an open file in binary read mode. |
[in,out] | fBuffer | Pointer to the file buffer used for buffered reading operations. |
[in] | skip | If non-zero, the string data is skipped without being stored. |
NULL | An error occurred during reading or memory allocation. |
Non-NULL | Pointer to the read string. |
Definition at line 2620 of file SDDS_binary.c.
char * SDDS_ReadLZMABinaryString | ( | struct lzmafile * | lzmafp, |
SDDS_FILEBUFFER * | fBuffer, | ||
int32_t | skip ) |
Reads a binary string from an LZMA-compressed file with buffering.
This function reads a binary string from the specified LZMA-compressed file by first reading the length of the string and then reading the string content based on the length. If the 'skip' parameter is set, the string data is skipped over instead of being stored. The function allocates memory for the string, which should be freed by the caller when no longer needed.
[in] | lzmafp | The LZMA file pointer to read from. Must be an open LZMA-compressed file in read mode. |
[in,out] | fBuffer | Pointer to the file buffer used for buffered reading operations. |
[in] | skip | If non-zero, the string data is skipped without being stored. |
NULL | An error occurred during reading or memory allocation. |
Non-NULL | Pointer to the read string. |
Definition at line 2650 of file SDDS_binary.c.
int32_t SDDS_ReadNewBinaryRows | ( | SDDS_DATASET * | SDDS_dataset | ) |
Reads new binary rows from the SDDS dataset.
This function updates the SDDS dataset by reading any new rows that have been added to the underlying file since the last read operation. It verifies that the dataset is in a compatible binary format and ensures that byte order and compression settings are supported. If the number of rows in the file exceeds the currently allocated rows in memory, the function expands the dataset's internal storage to accommodate the new rows.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset to read from. |
>0 | The number of new rows read and added to the dataset. |
-1 | An error occurred during the read operation, such as unsupported file format, I/O errors, or memory allocation failures. |
Definition at line 2841 of file SDDS_binary.c.
int32_t SDDS_ReadNonNativeBinaryArrays | ( | SDDS_DATASET * | SDDS_dataset | ) |
Reads non-native endian binary arrays from an SDDS dataset.
This function iterates through all array definitions in the specified SDDS dataset and reads their binary data from the underlying file. It handles various data types, including short, unsigned short, long, unsigned long, long long, unsigned long long, float, double, and long double. For string arrays, it reads each string individually, ensuring proper memory allocation and byte order conversion. The function supports different compression formats, including uncompressed, LZMA-compressed, and GZIP-compressed files. After reading, it swaps the endianness of the array data to match the system's native byte order.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset to read from. |
1 | All non-native endian arrays were successfully read and byte-swapped. |
0 | An error occurred during the read or byte-swapping process, such as I/O failures, memory allocation issues, or corrupted array definitions. |
Definition at line 4458 of file SDDS_binary.c.
int32_t SDDS_ReadNonNativeBinaryColumns | ( | SDDS_DATASET * | SDDS_dataset | ) |
Reads the non-native endian binary columns from an SDDS dataset.
This function is similar to SDDS_ReadBinaryColumns but specifically handles columns with non-native endianness. It iterates through all column definitions within the specified SDDS dataset and reads their binary data from the underlying file, ensuring that the byte order is correctly swapped to match the system's native endianness. The function supports various compression formats, including uncompressed, LZMA-compressed, and GZIP-compressed files.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset to read from. |
1 | All non-native endian columns were successfully read and byte-swapped. |
0 | An error occurred during the read or byte-swapping operation, such as I/O failures, memory allocation issues, or corrupted column definitions. |
Definition at line 3341 of file SDDS_binary.c.
int32_t SDDS_ReadNonNativeBinaryPage | ( | SDDS_DATASET * | SDDS_dataset, |
int64_t | sparse_interval, | ||
int64_t | sparse_offset ) |
Reads a non-native endian binary page from an SDDS dataset.
This function reads a binary page from the specified SDDS dataset, handling data with non-native endianness. It performs necessary byte order conversions to ensure correct data interpretation on the host system. The function supports sparse reading based on the provided interval and offset.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset to read from. |
[in] | sparse_interval | Interval between rows to be read for sparsity. |
[in] | sparse_offset | Offset to start reading rows for sparsity. |
>0 | Number of rows successfully read. |
0 | An error occurred during the read operation, such as I/O failures, data corruption, or unsupported data modes. |
Definition at line 4063 of file SDDS_binary.c.
int32_t SDDS_ReadNonNativeBinaryPageDetailed | ( | SDDS_DATASET * | SDDS_dataset, |
int64_t | sparse_interval, | ||
int64_t | sparse_offset, | ||
int64_t | last_rows ) |
Reads a detailed non-native endian binary page from an SDDS dataset.
This function reads a binary page from the specified SDDS dataset, handling data with non-native endianness. It supports both sparse reading and reading of the last few rows based on the provided parameters. The function performs necessary byte order conversions to ensure correct data interpretation on the host system.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset to read from. |
[in] | sparse_interval | Interval between rows to be read for sparsity. |
[in] | sparse_offset | Offset to start reading rows for sparsity. |
[in] | last_rows | Number of last rows to read from the dataset. |
>0 | Page number successfully read. |
0 | An error occurred during the read operation, such as I/O failures, data corruption, or unsupported data modes. |
Definition at line 4112 of file SDDS_binary.c.
int32_t SDDS_ReadNonNativeBinaryPageLastRows | ( | SDDS_DATASET * | SDDS_dataset, |
int64_t | last_rows ) |
Reads the last few rows from a non-native endian binary page in an SDDS dataset.
This function reads the specified number of last rows from a binary page in the given SDDS dataset, handling data with non-native endianness. It performs necessary byte order conversions to ensure correct data interpretation on the host system.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset to read from. |
[in] | last_rows | Number of last rows to read from the dataset. |
>0 | Number of rows successfully read. |
0 | An error occurred during the read operation, such as I/O failures, data corruption, or unsupported data modes. |
Definition at line 4085 of file SDDS_binary.c.
int32_t SDDS_ReadNonNativeBinaryParameters | ( | SDDS_DATASET * | SDDS_dataset | ) |
Reads non-native endian binary parameters from an SDDS dataset.
This function iterates through all parameter definitions in the specified SDDS dataset and reads their binary data from the underlying file. It handles various data types, including short, unsigned short, long, unsigned long, long long, unsigned long long, float, double, and long double. For string parameters, it reads each string individually, ensuring proper memory allocation and byte order conversion. Parameters with fixed values are processed by scanning the fixed value strings into the appropriate data types. The function supports different compression formats, including uncompressed, LZMA-compressed, and GZIP-compressed files.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset to read from. |
1 | All non-native endian parameters were successfully read and byte-swapped. |
0 | An error occurred during the read or byte-swapping process, such as I/O failures, memory allocation issues, or corrupted parameter definitions. |
Definition at line 4342 of file SDDS_binary.c.
int32_t SDDS_ReadNonNativeBinaryRow | ( | SDDS_DATASET * | SDDS_dataset, |
int64_t | row, | ||
int32_t | skip ) |
Reads a non-native endian binary row from an SDDS dataset.
This function reads a single row of data from the specified SDDS dataset, handling data with non-native endianness. It iterates through all column definitions and reads each column's data for the given row. For string columns, it ensures proper memory allocation and byte order conversion. For other data types, it reads the binary data and performs necessary byte swapping. The function supports different compression formats, including uncompressed, LZMA-compressed, and GZIP-compressed files.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset to read from. |
[in] | row | The index of the row to read. |
[in] | skip | If non-zero, the function will skip reading the row data, useful for sparse reading. |
1 | The row was successfully read and byte-swapped. |
0 | An error occurred during the read or byte-swapping process, such as I/O failures or corrupted data. |
Definition at line 4628 of file SDDS_binary.c.
char * SDDS_ReadNonNativeBinaryString | ( | FILE * | fp, |
SDDS_FILEBUFFER * | fBuffer, | ||
int32_t | skip ) |
Reads a non-native endian binary string from a file.
This function reads a binary string from the specified file pointer, handling non-native endianness. It first reads the length of the string, swaps its byte order if necessary, allocates memory for the string, reads the string data, and null-terminates it.
[in] | fp | Pointer to the FILE from which to read the string. |
[in,out] | fBuffer | Pointer to the SDDS_FILEBUFFER structure used for buffered reading. |
[in] | skip | If non-zero, the function will skip reading the string data, useful for sparse reading. |
Non-NULL | Pointer to the newly allocated string. |
NULL | An error occurred during reading or memory allocation. |
Definition at line 4751 of file SDDS_binary.c.
char * SDDS_ReadNonNativeLZMABinaryString | ( | struct lzmafile * | lzmafp, |
SDDS_FILEBUFFER * | fBuffer, | ||
int32_t | skip ) |
Reads a non-native endian binary string from an LZMA-compressed file.
This function reads a binary string from the specified LZMA-compressed file pointer, handling non-native endianness. It first reads the length of the string, swaps its byte order if necessary, allocates memory for the string, reads the string data, and null-terminates it.
[in] | lzmafp | Pointer to the LZMAFILE from which to read the string. |
[in,out] | fBuffer | Pointer to the SDDS_FILEBUFFER structure used for buffered reading. |
[in] | skip | If non-zero, the function will skip reading the string data, useful for sparse reading. |
Non-NULL | Pointer to the newly allocated string. |
NULL | An error occurred during reading or memory allocation. |
Definition at line 4785 of file SDDS_binary.c.
int32_t SDDS_ReadNonNativePage | ( | SDDS_DATASET * | SDDS_dataset | ) |
Reads a non-native endian page from an SDDS dataset.
This function reads a page of data from the specified SDDS dataset, handling data with non-native endianness. It supports both ASCII and binary data modes, performing necessary byte order conversions to ensure correct data interpretation on the host system.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset to read from. |
>0 | Number of rows successfully read. |
0 | An error occurred during the read operation, such as I/O failures, data corruption, or unsupported data modes. |
Definition at line 3884 of file SDDS_binary.c.
int32_t SDDS_ReadNonNativePageDetailed | ( | SDDS_DATASET * | SDDS_dataset, |
uint32_t | mode, | ||
int64_t | sparse_interval, | ||
int64_t | sparse_offset, | ||
int64_t | last_rows ) |
Reads a detailed non-native endian page from an SDDS dataset.
This function reads a page of data from the specified SDDS dataset, handling data with non-native endianness. It supports both ASCII and binary data modes, performing necessary byte order conversions to ensure correct data interpretation on the host system. Additionally, it allows for sparse reading and reading of the last few rows based on the provided parameters.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset to read from. |
[in] | mode | Mode flag to support future expansion. |
[in] | sparse_interval | Interval between rows to be read for sparsity. |
[in] | sparse_offset | Offset to start reading rows for sparsity. |
[in] | last_rows | Number of last rows to read from the dataset. |
>0 | Number of rows successfully read. |
0 | An error occurred during the read operation, such as I/O failures, data corruption, or unsupported data modes. |
Definition at line 3933 of file SDDS_binary.c.
int32_t SDDS_ReadNonNativePageLastRows | ( | SDDS_DATASET * | SDDS_dataset, |
int64_t | last_rows ) |
Reads the last few rows from a non-native endian page in an SDDS dataset.
This function reads the specified number of last rows from the non-native endian page of the given SDDS dataset. It handles data with non-native endianness, performing necessary byte order conversions to ensure correct data interpretation on the host system.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset to read from. |
[in] | last_rows | Number of last rows to read from the dataset. |
>0 | Number of rows successfully read. |
0 | An error occurred during the read operation, such as I/O failures, data corruption, or unsupported data modes. |
Definition at line 4000 of file SDDS_binary.c.
int32_t SDDS_ReadNonNativePageSparse | ( | SDDS_DATASET * | SDDS_dataset, |
uint32_t | mode, | ||
int64_t | sparse_interval, | ||
int64_t | sparse_offset ) |
Reads a sparse non-native endian page from an SDDS dataset.
This function reads a sparse page of data from the specified SDDS dataset, handling data with non-native endianness. Sparse reading allows for selective row retrieval based on the provided interval and offset.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset to read from. |
[in] | mode | Mode flag to support future expansion. |
[in] | sparse_interval | Interval between rows to be read for sparsity. |
[in] | sparse_offset | Offset to start reading rows for sparsity. |
>0 | Number of rows successfully read. |
0 | An error occurred during the read operation, such as I/O failures, data corruption, or unsupported data modes. |
Definition at line 3906 of file SDDS_binary.c.
int32_t SDDS_ReadRecoveryPossible | ( | SDDS_DATASET * | SDDS_dataset | ) |
Checks if any data in an SDDS page was recovered after an error was detected.
This function inspects the SDDS dataset to determine if any data recovery was possible following an error during data reading. It resets the recovery flag after checking.
SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. |
1
if recovery was possible.0
if no recovery was performed or if recovery was not possible.The function performs the following steps:
readRecoveryPossible
flag from the dataset.readRecoveryPossible
flag to 0
.readRecoveryPossible
flag.Definition at line 2054 of file SDDS_binary.c.
int32_t SDDS_SetBufferedRead | ( | int32_t | dummy | ) |
Definition at line 49 of file SDDS_binary.c.
int32_t SDDS_SetDefaultIOBufferSize | ( | int32_t | newValue | ) |
Sets the default I/O buffer size used for file operations.
This function updates the global defaultIOBufferSize
variable, which determines the size of the I/O buffer used for file read/write operations. The initial default is SDDS_FILEBUFFER_SIZE
, which is 262144 bytes.
newValue | The new default I/O buffer size in bytes. If newValue is negative, the function returns the current buffer size without changing it. If newValue is between 0 and 128 (inclusive), it is treated as 0, effectively disabling buffering. |
newValue
is greater than or equal to 0; otherwise, returns the current default buffer size without changing it. Definition at line 66 of file SDDS_binary.c.
void SDDS_SetReadRecoveryMode | ( | SDDS_DATASET * | SDDS_dataset, |
int32_t | mode ) |
Sets the read recovery mode for an SDDS dataset.
This function configures whether read recovery is possible for the specified SDDS dataset. Enabling recovery allows the dataset to attempt to recover partial data in case of read errors.
SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. |
mode | Integer flag indicating the recovery mode:
|
The function updates the readRecoveryPossible
flag within the dataset structure based on the provided mode
parameter. This flag is later checked by other functions to determine whether to attempt data recovery after encountering read errors.
Definition at line 2082 of file SDDS_binary.c.
void SDDS_SwapDouble | ( | double * | data | ) |
Swaps the endianness of a double.
This function swaps the byte order of a 64-bit double-precision floating-point number pointed to by the provided data pointer. It effectively converts the data between little-endian and big-endian formats.
[in,out] | data | Pointer to the double whose byte order is to be swapped. |
Definition at line 3834 of file SDDS_binary.c.
int32_t SDDS_SwapEndsArrayData | ( | SDDS_DATASET * | SDDSin | ) |
Swaps the endianness of the array data in an SDDS dataset.
This function iterates through all arrays defined in the specified SDDS dataset and swaps the byte order of each element to match the system's native endianness. It supports various data types including short, unsigned short, long, unsigned long, long long, unsigned long long, float, double, and long double. The function ensures that binary data is correctly interpreted on systems with different byte orders.
[in,out] | SDDSin | Pointer to the SDDS_DATASET structure representing the dataset whose array data endianness is to be swapped. |
1 | The endianness of all applicable array data elements was successfully swapped. |
Definition at line 3623 of file SDDS_binary.c.
int32_t SDDS_SwapEndsColumnData | ( | SDDS_DATASET * | SDDSin | ) |
Swaps the endianness of the column data in an SDDS dataset.
This function iterates through all columns in the specified SDDS dataset and swaps the byte order of each data element to match the system's native endianness. It supports various data types, including short, unsigned short, long, unsigned long, long long, unsigned long long, float, double, and long double. The function ensures that binary data is correctly interpreted on systems with different byte orders.
[in,out] | SDDSin | Pointer to the SDDS_DATASET structure representing the dataset whose column data endianness is to be swapped. |
1 | The endianness of all applicable column data elements was successfully swapped. |
Definition at line 3458 of file SDDS_binary.c.
int32_t SDDS_SwapEndsParameterData | ( | SDDS_DATASET * | SDDSin | ) |
Swaps the endianness of the parameter data in an SDDS dataset.
This function iterates through all parameters in the specified SDDS dataset and swaps the byte order of each data element to match the system's native endianness. It handles various data types, including short, unsigned short, long, unsigned long, long long, unsigned long long, float, double, and long double. Parameters with fixed values are skipped as their byte order is already consistent.
[in,out] | SDDSin | Pointer to the SDDS_DATASET structure representing the dataset whose parameter data endianness is to be swapped. |
1 | The endianness of all applicable parameter data elements was successfully swapped. |
Definition at line 3544 of file SDDS_binary.c.
void SDDS_SwapFloat | ( | float * | data | ) |
Swaps the endianness of a float.
This function swaps the byte order of a 32-bit floating-point number pointed to by the provided data pointer. It effectively converts the data between little-endian and big-endian formats.
[in,out] | data | Pointer to the float whose byte order is to be swapped. |
Definition at line 3815 of file SDDS_binary.c.
void SDDS_SwapLong | ( | int32_t * | data | ) |
Swaps the endianness of a 32-bit integer.
This function swaps the byte order of a 32-bit integer pointed to by the provided data pointer. It effectively converts the data between little-endian and big-endian formats.
[in,out] | data | Pointer to the 32-bit integer whose byte order is to be swapped. |
Definition at line 3739 of file SDDS_binary.c.
void SDDS_SwapLong64 | ( | int64_t * | data | ) |
Swaps the endianness of a 64-bit integer.
This function swaps the byte order of a 64-bit integer pointed to by the provided data pointer. It effectively converts the data between little-endian and big-endian formats.
[in,out] | data | Pointer to the 64-bit integer whose byte order is to be swapped. |
Definition at line 3777 of file SDDS_binary.c.
void SDDS_SwapLongDouble | ( | long double * | data | ) |
Swaps the endianness of a long double.
This function swaps the byte order of a long double floating-point number pointed to by the provided data pointer. It effectively converts the data between little-endian and big-endian formats. The function accounts for different sizes of long double based on the system's architecture.
[in,out] | data | Pointer to the long double whose byte order is to be swapped. |
Definition at line 3854 of file SDDS_binary.c.
void SDDS_SwapShort | ( | short * | data | ) |
Swaps the endianness of a short integer.
This function swaps the byte order of a 16-bit short integer pointed to by the provided data pointer. It effectively converts the data between little-endian and big-endian formats.
[in,out] | data | Pointer to the short integer whose byte order is to be swapped. |
Definition at line 3703 of file SDDS_binary.c.
void SDDS_SwapULong | ( | uint32_t * | data | ) |
Swaps the endianness of a 32-bit unsigned integer.
This function swaps the byte order of a 32-bit unsigned integer pointed to by the provided data pointer. It effectively converts the data between little-endian and big-endian formats.
[in,out] | data | Pointer to the 32-bit unsigned integer whose byte order is to be swapped. |
Definition at line 3758 of file SDDS_binary.c.
void SDDS_SwapULong64 | ( | uint64_t * | data | ) |
Swaps the endianness of a 64-bit unsigned integer.
This function swaps the byte order of a 64-bit unsigned integer pointed to by the provided data pointer. It effectively converts the data between little-endian and big-endian formats.
[in,out] | data | Pointer to the 64-bit unsigned integer whose byte order is to be swapped. |
Definition at line 3796 of file SDDS_binary.c.
void SDDS_SwapUShort | ( | unsigned short * | data | ) |
Swaps the endianness of an unsigned short integer.
This function swaps the byte order of a 16-bit unsigned short integer pointed to by the provided data pointer. It effectively converts the data between little-endian and big-endian formats.
[in,out] | data | Pointer to the unsigned short integer whose byte order is to be swapped. |
Definition at line 3721 of file SDDS_binary.c.
int32_t SDDS_UpdateBinaryPage | ( | SDDS_DATASET * | SDDS_dataset, |
uint32_t | mode ) |
Updates the binary page of an SDDS dataset.
This function updates the binary page of the specified SDDS dataset based on the provided mode. It handles writing the dataset's binary data to the associated file, managing buffering, and handling different file formats such as gzip and LZMA if applicable.
SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset to update. |
mode | Bitmask indicating the update mode. It can be:
|
1
on successful update.0
if an error occurs during the update process.The function performs several checks before updating:
SDDS_OUTPUT_ENDIANESS
to determine if a non-native binary update is required.Definition at line 1077 of file SDDS_binary.c.
int32_t SDDS_UpdateNonNativeBinaryPage | ( | SDDS_DATASET * | SDDS_dataset, |
uint32_t | mode ) |
Updates a non-native endian binary page in an SDDS dataset.
This function updates an existing binary page in the specified SDDS dataset, handling byte order reversal to convert between little-endian and big-endian formats. It supports updating rows based on the provided mode flags, such as flushing the table. The function ensures that the buffer is flushed before performing the update and writes any new rows that have been flagged for writing. It also handles fixed row counts and manages byte order conversions as necessary.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset to update. |
[in] | mode | Bitmask indicating the update mode (e.g., FLUSH_TABLE). |
1 | The binary page was successfully updated and byte-swapped. |
0 | An error occurred during the update operation, such as I/O failures, invalid row counts, or corrupted dataset definitions. |
Definition at line 5593 of file SDDS_binary.c.
int32_t SDDS_WriteBinaryArrays | ( | SDDS_DATASET * | SDDS_dataset | ) |
Writes the binary arrays of the SDDS dataset to a file.
This function writes all arrays defined in the SDDS dataset to the associated binary file. It handles arrays with and without dimensions, and manages different compression formats such as gzip and LZMA if enabled.
SDDS_dataset | Pointer to the SDDS_DATASET structure containing the dataset to write. |
1
on successful write of all arrays.0
if an error occurs during the writing process.The function performs the following steps:
SDDS_STRING
, it writes each string element using the appropriate compression method.The function handles different file formats:
SDDS_GZipWriteBinaryString
and SDDS_GZipBufferedWrite
.SDDS_LZMAWriteBinaryString
and SDDS_LZMABufferedWrite
.SDDS_WriteBinaryString
and SDDS_BufferedWrite
.zLib
or LZMA) must be enabled during compilation for handling compressed files. Definition at line 1533 of file SDDS_binary.c.
int32_t SDDS_WriteBinaryColumns | ( | SDDS_DATASET * | SDDS_dataset | ) |
Writes the binary columns of an SDDS dataset to the associated file.
This function iterates over each column defined in the SDDS dataset layout and writes its data to the binary file. It handles different data types, including strings and numeric types, and supports various compression formats such as gzip and LZMA if enabled.
Depending on the dataset's configuration, the function writes directly to a standard binary file, a gzip-compressed file, or an LZMA-compressed file. It also handles sparse data by only writing rows flagged for inclusion.
SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset to write. |
1
on successful writing of all columns.0
if an error occurs during the writing process.The function performs the following steps:
SDDS_CheckDataset
.zLib
for gzip, LZMA libraries) must be enabled during compilation for handling compressed files.Definition at line 1673 of file SDDS_binary.c.
int32_t SDDS_WriteBinaryPage | ( | SDDS_DATASET * | SDDS_dataset | ) |
Writes a binary page of data to an SDDS dataset, handling compression and buffering.
This function writes a binary page (including parameters, arrays, and row data) to the SDDS dataset pointed to by SDDS_dataset
. It handles different file types, including regular files, LZMA-compressed files, and GZIP-compressed files, and uses buffering to improve write performance.
The function performs the following steps:
It uses the appropriate buffered write functions (SDDS_BufferedWrite
, SDDS_LZMABufferedWrite
, or SDDS_GZipBufferedWrite
) depending on the file type.
SDDS_dataset | Pointer to the SDDS_DATASET structure representing the SDDS dataset to write to. |
SDDS_SetError
if any step fails. Definition at line 749 of file SDDS_binary.c.
int32_t SDDS_WriteBinaryParameters | ( | SDDS_DATASET * | SDDS_dataset | ) |
Writes the binary parameters of the SDDS dataset.
This function writes all non-fixed parameters of the SDDS dataset to the associated binary file. It handles different compression formats such as gzip and LZMA if enabled.
SDDS_dataset | Pointer to the SDDS_DATASET structure containing the dataset to write. |
1
on successful write of all parameters.0
if an error occurs during the writing process.The function performs the following steps:
SDDS_STRING
, it writes the string using the appropriate compression method.The function handles different file formats:
SDDS_GZipWriteBinaryString
and SDDS_GZipBufferedWrite
.SDDS_LZMAWriteBinaryString
and SDDS_LZMABufferedWrite
.SDDS_WriteBinaryString
and SDDS_BufferedWrite
.zLib
or LZMA) must be enabled during compilation for handling compressed files. Definition at line 1426 of file SDDS_binary.c.
int32_t SDDS_WriteBinaryRow | ( | SDDS_DATASET * | SDDS_dataset, |
int64_t | row ) |
Writes a single binary row of an SDDS dataset to the associated file.
This function writes the data of a specified row within the SDDS dataset to the binary file. It handles different data types, including strings and numeric types, and supports various compression formats such as gzip and LZMA if enabled.
Depending on the dataset's configuration, the function writes directly to a standard binary file, a gzip-compressed file, or an LZMA-compressed file.
SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset. |
row | The zero-based index of the row to write. |
1
on successful writing of the row.0
if an error occurs during the writing process.The function performs the following steps:
SDDS_CheckDataset
.zLib
for gzip, LZMA libraries) must be enabled during compilation for handling compressed files.Definition at line 1957 of file SDDS_binary.c.
int32_t SDDS_WriteBinaryString | ( | char * | string, |
FILE * | fp, | ||
SDDS_FILEBUFFER * | fBuffer ) |
Writes a binary string to a file with buffering.
This function writes a binary string to the specified file by first writing the length of the string followed by the string's content to ensure proper binary formatting. If the input string is NULL, an empty string is written instead. The writing operation utilizes a buffered approach to enhance performance.
[in] | string | The null-terminated string to be written. If NULL, an empty string is written. |
[in] | fp | The file pointer to write to. Must be an open file in binary write mode. |
[in,out] | fBuffer | Pointer to the file buffer used for buffered writing operations. |
1 | Operation was successful. |
0 | An error occurred during writing. |
Definition at line 2521 of file SDDS_binary.c.
int32_t SDDS_WriteNonNativeBinaryArrays | ( | SDDS_DATASET * | SDDS_dataset | ) |
Writes non-native endian binary arrays to an SDDS dataset.
This function iterates through all array definitions in the specified SDDS dataset and writes their binary data to the underlying file. It handles various data types, including short, unsigned short, long, unsigned long, long long, unsigned long long, float, double, and long double. For string arrays, it writes each string individually, ensuring proper memory management and byte order conversion. The function supports different compression formats, including uncompressed, LZMA-compressed, and GZIP-compressed files. After writing, it swaps the endianness of the array data to match the system's native byte order.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset to write to. |
1 | All non-native endian arrays were successfully written and byte-swapped. |
0 | An error occurred during the write operation, such as I/O failures, memory allocation issues, or corrupted array definitions. |
Definition at line 5226 of file SDDS_binary.c.
int32_t SDDS_WriteNonNativeBinaryColumns | ( | SDDS_DATASET * | SDDS_dataset | ) |
Writes non-native endian binary columns of an SDDS dataset to the associated file.
This function iterates over each column defined in the SDDS dataset layout and writes its data to the binary file using a non-native byte order. It handles different data types, including strings and numeric types, and supports various compression formats such as gzip and LZMA if enabled.
Depending on the dataset's configuration, the function writes directly to a standard binary file, a gzip-compressed file, or an LZMA-compressed file. It also handles sparse data by only writing rows flagged for inclusion.
SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset to write. |
1
on successful writing of all columns.0
if an error occurs during the writing process.The function performs the following steps:
SDDS_CheckDataset
.zLib
for gzip, LZMA libraries) must be enabled during compilation for handling compressed files.Definition at line 1816 of file SDDS_binary.c.
int32_t SDDS_WriteNonNativeBinaryPage | ( | SDDS_DATASET * | SDDS_dataset | ) |
Writes a non-native endian binary page to an SDDS dataset.
This function writes a binary page to the specified SDDS dataset, handling byte order reversal to convert between little-endian and big-endian formats. It manages various compression formats, including uncompressed, GZIP-compressed, and LZMA-compressed files. The function performs the following operations:
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset to write to. |
1 | The binary page was successfully written and byte-swapped. |
0 | An error occurred during the write operation, such as I/O failures, memory allocation issues, or corrupted dataset definitions. |
Definition at line 4862 of file SDDS_binary.c.
int32_t SDDS_WriteNonNativeBinaryParameters | ( | SDDS_DATASET * | SDDS_dataset | ) |
Writes non-native endian binary parameters to an SDDS dataset.
This function iterates through all parameter definitions in the specified SDDS dataset and writes their binary data to the underlying file. It handles various data types, including short, unsigned short, long, unsigned long, long long, unsigned long long, float, double, and long double. For string parameters, it writes each string individually, ensuring proper memory management and byte order conversion. Parameters with fixed values are skipped during the write process. The function supports different compression formats, including uncompressed, LZMA-compressed, and GZIP-compressed files.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset to write to. |
1 | All non-native endian parameters were successfully written and byte-swapped. |
0 | An error occurred during the write operation, such as I/O failures, memory allocation issues, or corrupted parameter definitions. |
Definition at line 5118 of file SDDS_binary.c.
int32_t SDDS_WriteNonNativeBinaryRow | ( | SDDS_DATASET * | SDDS_dataset, |
int64_t | row ) |
Writes a non-native endian binary row to an SDDS dataset.
This function writes a single row of data to the specified SDDS dataset, handling byte order reversal to convert between little-endian and big-endian formats. It supports various compression formats, including uncompressed, GZIP-compressed, and LZMA-compressed files. The function iterates through all column definitions, writing each column's data appropriately based on its type. For string columns, it ensures proper memory management and byte order conversion by utilizing specialized string writing functions. For non-string data types, it writes the binary data directly with the correct byte ordering.
[in,out] | SDDS_dataset | Pointer to the SDDS_DATASET structure representing the dataset to write to. |
[in] | row | The index of the row to write to the dataset. |
1 | The binary row was successfully written and byte-swapped. |
0 | An error occurred during the write operation, such as I/O failures or corrupted data. |
Definition at line 5381 of file SDDS_binary.c.
int32_t SDDS_WriteNonNativeBinaryString | ( | char * | string, |
FILE * | fp, | ||
SDDS_FILEBUFFER * | fBuffer ) |
Writes a non-native endian binary string to a file.
This function writes a binary string to the specified file pointer, handling non-native endianness. It first writes the length of the string as a 32-bit integer with byte order swapped. If the string is not to be skipped, it then writes the string data itself followed by a null terminator. If the input string is NULL, an empty string is written instead.
[in] | string | The string to write. If NULL, an empty string is written. |
[in] | fp | Pointer to the FILE where the string will be written. |
[in] | fBuffer | Pointer to the SDDS_FILEBUFFER structure used for buffered writing. |
1 | The string was successfully written and byte-swapped. |
0 | An error occurred during the write operation, such as I/O failures or memory allocation issues. |
fp
is valid and open for writing. This function does not perform memory allocation for the string; it assumes that the string is already allocated and managed appropriately. Definition at line 5473 of file SDDS_binary.c.
|
static |
Definition at line 44 of file SDDS_binary.c.