40#define LOG_MAX_COLUMNS 25
42#define LOG_MAX_SERIES 4
44#define LOG_NAME_MAX 28
46#define LOG_SAMPLE_MAX 16
50#define LOG_ROW_MAX 1024
62 size_t (*
read)(
void *ctx,
char *buf,
size_t max);
84 bool (*
size)(
void *ctx,
size_t *bytes);
85 bool (*seek)(
void *ctx,
size_t offset);
160 size_t store_size,
char **fields,
int max_fields,
177 LOG_ERR_TOO_MANY_COLUMNS,
249#define LOG_DEFAULT_MAX_ROWS 60000
251#define LOG_TIME_AUTO (-2)
346 const int *columns,
int n_columns,
log_data_t *out);
log_err_t
Result of a CSV import step.
Definition log_csv.h:171
void log_data_free(log_data_t *data)
Free the sample arrays of a build.
Definition log_csv.c:707
void log_csv_opts_default(log_csv_opts_t *opts)
Set the default import options.
Definition log_csv.c:146
log_err_t log_csv_analyse(log_source_t *src, const log_csv_opts_t *opts, log_analysis_t *out)
Two streaming passes: geometry and evidence, then per-column statistics.
Definition log_csv.c:668
#define LOG_SAMPLES
Number of sample cells kept per column.
Definition log_csv.h:48
char log_csv_sniff(const char *sample, size_t len)
Guess the delimiter from a text sample: the most consistent, widest split.
Definition log_reader.c:419
const char * log_csv_delimiter_label(char delimiter)
Label of a delimiter.
Definition log_reader.c:372
log_err_t log_csv_build(log_source_t *src, const log_analysis_t *a, const int *columns, int n_columns, log_data_t *out)
Materialise the selected columns.
Definition log_csv.c:1041
#define LOG_MAX_COLUMNS
Ceilings.
Definition log_csv.h:40
void log_reader_init(log_reader_t *r, log_source_t *src)
Set up a row splitter.
Definition log_reader.c:192
#define LOG_SAMPLE_MAX
Room for one sample cell, bytes, with its terminator.
Definition log_csv.h:46
const char * log_err_str(log_err_t err)
Text for an import error.
Definition log_csv.c:46
void log_source_stdio(log_source_t *src, void *file)
A source over an open stdio stream. file is a FILE*.
Definition log_reader.c:180
int log_reader_row(log_reader_t *r, char delimiter, char *store, size_t store_size, char **fields, int max_fields, int *total_fields)
Read one row.
Definition log_reader.c:272
#define LOG_NAME_MAX
Room for a column name, bytes, with its terminator.
Definition log_csv.h:44
#define LOG_MAX_SERIES
Most series the build materialises.
Definition log_csv.h:42
void log_set_allocator(void *(*alloc_fn)(size_t), void(*free_fn)(void *))
Where the sample arrays come from.
Definition log_csv.c:40
const char log_csv_delimiters[4]
The candidate delimiters, in the order they are scored.
Definition log_reader.c:370
void log_source_memory(log_source_t *src, log_mem_ctx_t *ctx, const char *text, size_t len)
A source over a block of memory.
Definition log_reader.c:90
Locale-tolerant numeric parsing with unit suffixes.
log_conv_t
Decimal convention of a file.
Definition log_numbers.h:48
#define LOG_UNIT_MAX
Longest unit suffix the parser reads in one cell, characters.
Definition log_numbers.h:45
log_ambig_t
What a wholly ambiguous file defaults to.
Definition log_numbers.h:57
Result of the analysis of a whole file.
Definition log_csv.h:209
int long_rows
Definition log_csv.h:226
bool truncated
Definition log_csv.h:228
int max_fields
Definition log_csv.h:227
int ragged_rows
Definition log_csv.h:225
char time_unit[LOG_UNIT_MAX]
Definition log_csv.h:222
int n_columns
Definition log_csv.h:218
int row_count
Definition log_csv.h:224
log_ambig_t ambiguous_as
Definition log_csv.h:216
bool convention_conflict
Definition log_csv.h:214
log_conv_t convention
Definition log_csv.h:211
bool convention_forced
Definition log_csv.h:212
bool cut_row
The file ends inside a row, without its line feed.
Definition log_csv.h:235
bool convention_confident
Definition log_csv.h:213
log_votes_t votes
Definition log_csv.h:215
log_column_t columns[LOG_MAX_COLUMNS]
Definition log_csv.h:219
int time_index
Definition log_csv.h:221
char delimiter
Definition log_csv.h:210
Analysis of one column.
Definition log_csv.h:191
char sample[LOG_SAMPLES][LOG_SAMPLE_MAX]
Definition log_csv.h:195
double last
Definition log_csv.h:205
char name[LOG_NAME_MAX]
Definition log_csv.h:193
double min
Definition log_csv.h:202
bool unit_from_values
Definition log_csv.h:198
int parsed
Definition log_csv.h:197
double max
Definition log_csv.h:203
double first
Definition log_csv.h:204
bool mixed_units
Definition log_csv.h:199
int non_empty
Definition log_csv.h:196
bool monotonic
Definition log_csv.h:201
char raw_header[LOG_NAME_MAX]
Definition log_csv.h:192
char unit[LOG_UNIT_MAX]
Definition log_csv.h:194
bool numeric
Definition log_csv.h:200
Options of the CSV import.
Definition log_csv.h:239
log_conv_t convention
Definition log_csv.h:241
int time_index
Definition log_csv.h:243
const char * time_unit
Definition log_csv.h:244
int max_rows
Definition log_csv.h:245
char delimiter
Definition log_csv.h:240
log_ambig_t ambiguous_as
Definition log_csv.h:242
Materialised data of the selected columns.
Definition log_csv.h:315
double rate_hz
Definition log_csv.h:331
char time_name[LOG_NAME_MAX]
Definition log_csv.h:322
char time_unit[LOG_UNIT_MAX]
Definition log_csv.h:323
log_conv_t convention
Definition log_csv.h:324
int unparsed_cells
Definition log_csv.h:326
double max_gap_s
Definition log_csv.h:330
char delimiter
Definition log_csv.h:325
float * time
Definition log_csv.h:318
int n_fields
Definition log_csv.h:317
int count
Definition log_csv.h:316
double median_dt_s
Definition log_csv.h:329
log_field_t field[LOG_MAX_SERIES]
Definition log_csv.h:320
double duration_s
Definition log_csv.h:328
float * value[LOG_MAX_SERIES]
Definition log_csv.h:319
One plotted field.
Definition log_csv.h:303
char unit[LOG_UNIT_MAX]
Definition log_csv.h:305
bool mixed_units
Definition log_csv.h:311
bool constant
Definition log_csv.h:310
int column
Definition log_csv.h:307
float max
Definition log_csv.h:309
char group[LOG_NAME_MAX]
Definition log_csv.h:306
float min
Definition log_csv.h:308
char name[LOG_NAME_MAX]
Definition log_csv.h:304
State of the memory source.
Definition log_csv.h:89
const char * text
Definition log_csv.h:90
size_t pos
Definition log_csv.h:92
size_t len
Definition log_csv.h:91
Streaming row splitter: quotes, doubled quotes, and CRLF.
Definition log_csv.h:120
log_source_t * src
Definition log_csv.h:121
bool failed
Definition log_csv.h:127
bool overflow
Definition log_csv.h:128
size_t len
Definition log_csv.h:123
bool eof
Definition log_csv.h:125
bool started
Definition log_csv.h:126
char buf[256]
Definition log_csv.h:122
bool cut
Definition log_csv.h:129
size_t pos
Definition log_csv.h:124
A byte source that can be read from the top more than once.
Definition log_csv.h:61
bool(*) rewind(void *ctx)
Definition log_csv.h:63
bool(*) size(void *ctx, size_t *bytes)
Optional, both or neither: the length of the input in bytes, and a move to an offset from its start,...
Definition log_csv.h:84
size_t(*) read(void *ctx, char *buf, size_t max)
Definition log_csv.h:62
bool(*) error(void *ctx)
Did the last read fail, as opposed to reaching the end?
Definition log_csv.h:72
Running tally of the evidence seen so far.
Definition log_numbers.h:106