libsf3
Loading...
Searching...
No Matches
Data Structures | Macros | Enumerations | Functions
sf3_table.h File Reference
#include "sf3_core.h"
Include dependency graph for sf3_table.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  sf3_column_spec
 Description of a column within the table. More...
 
struct  sf3_table
 

Macros

#define SF3_FORMAT_ID_TABLE   0x07
 The format_id for a table file.
 

Enumerations

enum  sf3_column_type {
  SF3_COLUMN_UINT8 = 0x01 , SF3_COLUMN_UINT16 = 0x02 , SF3_COLUMN_UINT32 = 0x04 , SF3_COLUMN_UINT64 = 0x08 ,
  SF3_COLUMN_INT8 = 0x11 , SF3_COLUMN_INT16 = 0x12 , SF3_COLUMN_INT32 = 0x14 , SF3_COLUMN_INT64 = 0x18 ,
  SF3_COLUMN_FLOAT16 = 0x22 , SF3_COLUMN_FLOAT32 = 0x24 , SF3_COLUMN_FLOAT64 = 0x28 , SF3_COLUMN_STRING = 0x31 ,
  SF3_COLUMN_TIMESTAMP = 0x48 , SF3_COLUMN_HIGH_RESOLUTION_TIMESTAMP = 0x58 , SF3_COLUMN_BOOLEAN = 0x61
}
 The column value types that can be stored. More...
 

Functions

SF3_INLINE const char * sf3_table_data (const struct sf3_table *table)
 Returns a pointer to the encoded table data.
 
SF3_INLINE const struct sf3_column_specsf3_table_next_column (const struct sf3_column_spec *column)
 
SF3_INLINE const struct sf3_column_specsf3_table_column (const struct sf3_table *table, uint16_t column)
 
SF3_INLINE const char * sf3_table_row (const struct sf3_table *table, uint64_t row)
 
SF3_EXPORT const char * sf3_table_cell (const struct sf3_table *table, uint64_t row, uint64_t column, const struct sf3_column_spec **spec)
 
SF3_INLINE uint8_t sf3_table_element_size (const struct sf3_column_spec *column)
 Returns the number of bytes per element of the given column.
 
SF3_INLINE uint32_t sf3_table_element_count (const struct sf3_column_spec *column)
 Returns the number of elements in a cell of the given column.
 
SF3_EXPORT const char * sf3_table_column_type (enum sf3_column_type type)
 Returns a human-readable string description of the column type.
 
SF3_EXPORT size_t sf3_table_size (const struct sf3_table *table)
 Computes the size of the table file in bytes.
 

Macro Definition Documentation

◆ SF3_FORMAT_ID_TABLE

#define SF3_FORMAT_ID_TABLE   0x07

The format_id for a table file.

Definition at line 6 of file sf3_table.h.

Enumeration Type Documentation

◆ sf3_column_type

The column value types that can be stored.

Enumerator
SF3_COLUMN_UINT8 

The column elements are stored in 8-bit unsigned format.

SF3_COLUMN_UINT16 

The column elements are stored in 16-bit unsigned format.

SF3_COLUMN_UINT32 

The column elements are stored in 32-bit unsigned format.

SF3_COLUMN_UINT64 

The column elements are stored in 64-bit unsigned format.

SF3_COLUMN_INT8 

The column elements are stored in 8-bit signed format.

SF3_COLUMN_INT16 

The column elements are stored in 16-bit signed format.

SF3_COLUMN_INT32 

The column elements are stored in 32-bit signed format.

SF3_COLUMN_INT64 

The column elements are stored in 64-bit signed format.

SF3_COLUMN_FLOAT16 

The column elements are stored in 16-bit IEEE half-precision float format.

SF3_COLUMN_FLOAT32 

The column elements are stored in 32-bit IEEE single-precision float format.

SF3_COLUMN_FLOAT64 

The column elements are stored in 64-bit IEEE double-precision float format.

SF3_COLUMN_STRING 

The column element is a singular null-terminated string.

SF3_COLUMN_TIMESTAMP 

The column elements are stored in 64-bit signed format in the UNIX epoch.

SF3_COLUMN_HIGH_RESOLUTION_TIMESTAMP 

The column elements are stored in 64-bit signed format in the UNIX epoch, with a nanosecond precision.

SF3_COLUMN_BOOLEAN 

The column elements are stored in 8-bit unsigned format, where any value above 0 is "true" and 0 is "false".

Definition at line 9 of file sf3_table.h.

Function Documentation

◆ sf3_table_cell()

SF3_EXPORT const char * sf3_table_cell ( const struct sf3_table table,
uint64_t  row,
uint64_t  column,
const struct sf3_column_spec **  spec 
)

Returns a pointer to the start of the given cell. Also returns ap ointer to the associated column descriptor in spec. If an invalid row or column index is given, null is returned instead and the spec pointer is considered invalid.

Note that this function needs to scan over all columns preceding the requested column. If you are reading out multiple rows of the same column, writing your own iteration with the cached offset of the column start would be much more efficient.

Definition at line 117 of file sf3_table.h.

◆ sf3_table_column()

SF3_INLINE const struct sf3_column_spec * sf3_table_column ( const struct sf3_table table,
uint16_t  column 
)

Returns the column spec at the requested index. If an invalid column index is given, null is returned instead.

Definition at line 91 of file sf3_table.h.

◆ sf3_table_column_type()

SF3_EXPORT const char * sf3_table_column_type ( enum sf3_column_type  type)

Returns a human-readable string description of the column type.

Definition at line 142 of file sf3_table.h.

◆ sf3_table_data()

SF3_INLINE const char * sf3_table_data ( const struct sf3_table table)

Returns a pointer to the encoded table data.

Definition at line 77 of file sf3_table.h.

◆ sf3_table_element_count()

SF3_INLINE uint32_t sf3_table_element_count ( const struct sf3_column_spec column)

Returns the number of elements in a cell of the given column.

Definition at line 136 of file sf3_table.h.

◆ sf3_table_element_size()

SF3_INLINE uint8_t sf3_table_element_size ( const struct sf3_column_spec column)

Returns the number of bytes per element of the given column.

Definition at line 131 of file sf3_table.h.

◆ sf3_table_next_column()

SF3_INLINE const struct sf3_column_spec * sf3_table_next_column ( const struct sf3_column_spec column)

Returns the next column spec after this one. Note that this function does not perform any bounds checking whatsoever. It is up to you to ensure you do not call this with the last column spec of a table.

Definition at line 85 of file sf3_table.h.

◆ sf3_table_row()

SF3_INLINE const char * sf3_table_row ( const struct sf3_table table,
uint64_t  row 
)

Returns a pointer to the start of the given row. If an invalid row index is given, null is returned instead.

Definition at line 102 of file sf3_table.h.

◆ sf3_table_size()

SF3_EXPORT size_t sf3_table_size ( const struct sf3_table table)

Computes the size of the table file in bytes.

Definition at line 164 of file sf3_table.h.