![]() |
Nilorea Library
C utilities for networking, threading, graphics
|
Data Structures | |
| struct | AVRO_FIELD |
| Avro schema field (for records) More... | |
| struct | AVRO_READER |
| Avro read cursor for decoding. More... | |
| struct | AVRO_SCHEMA |
| Avro schema definition. More... | |
Macros | |
| #define | AVRO_MAGIC "Obj\x01" |
| Avro object container file magic bytes. | |
| #define | AVRO_MAGIC_LEN 4 |
| Avro magic length. | |
| #define | AVRO_SYNC_LEN 16 |
| Avro sync marker length. | |
Enumerations | |
| enum | AVRO_TYPE { AVRO_NULL = 0 , AVRO_BOOLEAN , AVRO_INT , AVRO_LONG , AVRO_FLOAT , AVRO_DOUBLE , AVRO_BYTES , AVRO_STRING , AVRO_RECORD , AVRO_ENUM , AVRO_ARRAY , AVRO_MAP , AVRO_UNION , AVRO_FIXED } |
| Avro schema type enumeration. More... | |
Functions | |
| cJSON * | avro_decode_container (const AVRO_SCHEMA *schema, const N_STR *avro_data) |
| Decode an Avro container format N_STR into a cJSON array of records. | |
| cJSON * | avro_decode_datum (AVRO_READER *reader, const AVRO_SCHEMA *schema) |
| Decode an Avro binary datum into cJSON according to schema. | |
| int | avro_decode_long (AVRO_READER *reader, int64_t *value) |
| Decode a zig-zag varint from reader into a 64-bit signed integer. | |
| N_STR * | avro_encode_container (const AVRO_SCHEMA *schema, const cJSON *records) |
| Encode a cJSON array of records into Avro container format N_STR. | |
| int | avro_encode_datum (N_STR **dest, const AVRO_SCHEMA *schema, const cJSON *json) |
| Encode a cJSON value as Avro binary according to schema. | |
| int | avro_encode_long (N_STR **dest, int64_t value) |
| Encode a 64-bit signed integer as zig-zag varint into N_STR. | |
| int | avro_file_to_json (const char *avro_filename, const char *schema_filename, const char *json_filename) |
| Read an Avro object container file and produce a JSON file using a schema file. | |
| int | avro_json_to_file (const char *avro_filename, const char *schema_filename, const char *json_filename) |
| Write an Avro object container file from a JSON file and schema file. | |
| N_STR * | avro_nstr_avro_to_json (const N_STR *schema_nstr, const N_STR *avro_nstr) |
| Convert Avro N_STR to JSON N_STR using schema N_STR (all in-memory) | |
| N_STR * | avro_nstr_json_to_avro (const N_STR *schema_nstr, const N_STR *json_nstr) |
| Convert JSON N_STR to Avro N_STR using schema N_STR (all in-memory) | |
| void | avro_schema_free (AVRO_SCHEMA **schema) |
| Free an Avro schema. | |
| AVRO_SCHEMA * | avro_schema_from_cjson (const cJSON *json) |
| Parse an Avro schema from a cJSON object. | |
| AVRO_SCHEMA * | avro_schema_parse (const char *json_str) |
| Parse an Avro schema from a JSON string. | |
| AVRO_SCHEMA * | avro_schema_parse_nstr (const N_STR *schema_nstr) |
| Parse schema from N_STR. | |
| char * | avro_schema_to_json (const AVRO_SCHEMA *schema) |
| Convert an Avro schema back to JSON string (caller must free) | |
| struct AVRO_FIELD |
Collaboration diagram for AVRO_FIELD:| Data Fields | ||
|---|---|---|
| char * | name | field name |
| AVRO_SCHEMA * | schema | field schema |
| struct AVRO_READER |
| struct AVRO_SCHEMA |
Collaboration diagram for AVRO_SCHEMA:| Data Fields | ||
|---|---|---|
| AVRO_FIELD * | fields |
namespace (for record, enum) fields array (for record) |
| size_t | fixed_size | fixed size |
| AVRO_SCHEMA * | items | item schema (for array) |
| char * | name | name (for record, enum, fixed) |
| size_t | nb_branches | number of union branches |
| size_t | nb_fields | number of fields (for record) |
| size_t | nb_symbols | number of enum symbols |
| char ** | symbols | enum symbols |
| AVRO_TYPE | type | schema type |
| AVRO_SCHEMA ** | union_branches | union branch schemas |
| AVRO_SCHEMA * | values | value schema (for map) |
| #define AVRO_MAGIC "Obj\x01" |
| enum AVRO_TYPE |
| cJSON * avro_decode_container | ( | const AVRO_SCHEMA * | schema, |
| const N_STR * | avro_data | ||
| ) |
Decode an Avro container format N_STR into a cJSON array of records.
Definition at line 1025 of file n_avro.c.
References __n_assert, avro_decode_bytes_raw(), avro_decode_datum(), avro_decode_long(), AVRO_MAGIC, AVRO_MAGIC_LEN, AVRO_SYNC_LEN, AVRO_READER::data, N_STR::data, Free, key, LOG_ERR, LOG_WARNING, n_log, AVRO_READER::pos, AVRO_READER::size, and N_STR::written.
Referenced by avro_file_to_json(), and avro_nstr_avro_to_json().
Here is the call graph for this function:
Here is the caller graph for this function:| cJSON * avro_decode_datum | ( | AVRO_READER * | reader, |
| const AVRO_SCHEMA * | schema | ||
| ) |
Decode an Avro binary datum into cJSON according to schema.
Definition at line 717 of file n_avro.c.
References __n_assert, AVRO_ARRAY, AVRO_BOOLEAN, AVRO_BYTES, avro_decode_bytes_raw(), avro_decode_datum(), avro_decode_long(), AVRO_DOUBLE, AVRO_ENUM, AVRO_FIXED, AVRO_FLOAT, AVRO_INT, AVRO_LONG, AVRO_MAP, AVRO_NULL, AVRO_RECORD, AVRO_STRING, AVRO_UNION, AVRO_READER::data, AVRO_SCHEMA::fields, AVRO_SCHEMA::fixed_size, Free, AVRO_SCHEMA::items, key, LOG_ERR, Malloc, n_log, AVRO_FIELD::name, AVRO_SCHEMA::nb_branches, AVRO_SCHEMA::nb_fields, AVRO_SCHEMA::nb_symbols, AVRO_READER::pos, AVRO_FIELD::schema, AVRO_READER::size, AVRO_SCHEMA::symbols, AVRO_SCHEMA::type, AVRO_SCHEMA::union_branches, and AVRO_SCHEMA::values.
Referenced by avro_decode_container(), and avro_decode_datum().
Here is the call graph for this function:
Here is the caller graph for this function:| int avro_decode_long | ( | AVRO_READER * | reader, |
| int64_t * | value | ||
| ) |
Decode a zig-zag varint from reader into a 64-bit signed integer.
Definition at line 394 of file n_avro.c.
References __n_assert, AVRO_READER::data, LOG_ERR, n_log, AVRO_READER::pos, and AVRO_READER::size.
Referenced by avro_decode_bytes_raw(), avro_decode_container(), and avro_decode_datum().
Here is the caller graph for this function:| N_STR * avro_encode_container | ( | const AVRO_SCHEMA * | schema, |
| const cJSON * | records | ||
| ) |
Encode a cJSON array of records into Avro container format N_STR.
Definition at line 942 of file n_avro.c.
References __n_assert, avro_encode_datum(), avro_encode_long(), AVRO_MAGIC, AVRO_MAGIC_LEN, avro_schema_to_json(), AVRO_SYNC_LEN, N_STR::data, Free, free_nstr, LOG_ERR, n_log, nstrcat_ex(), nstrprintf, and N_STR::written.
Referenced by avro_json_to_file(), and avro_nstr_json_to_avro().
Here is the call graph for this function:
Here is the caller graph for this function:| int avro_encode_datum | ( | N_STR ** | dest, |
| const AVRO_SCHEMA * | schema, | ||
| const cJSON * | json | ||
| ) |
Encode a cJSON value as Avro binary according to schema.
Definition at line 475 of file n_avro.c.
References __n_assert, AVRO_ARRAY, AVRO_BOOLEAN, AVRO_BYTES, AVRO_DOUBLE, avro_encode_bytes_raw(), avro_encode_datum(), avro_encode_long(), AVRO_ENUM, avro_find_union_branch(), AVRO_FIXED, AVRO_FLOAT, AVRO_INT, AVRO_LONG, AVRO_MAP, AVRO_NULL, AVRO_RECORD, AVRO_STRING, AVRO_UNION, AVRO_SCHEMA::fields, AVRO_SCHEMA::fixed_size, Free, AVRO_SCHEMA::items, key, LOG_ERR, Malloc, n_log, AVRO_FIELD::name, AVRO_SCHEMA::nb_fields, AVRO_SCHEMA::nb_symbols, nstrcat_ex(), AVRO_FIELD::schema, AVRO_SCHEMA::symbols, AVRO_SCHEMA::type, AVRO_SCHEMA::union_branches, and AVRO_SCHEMA::values.
Referenced by avro_encode_container(), and avro_encode_datum().
Here is the call graph for this function:
Here is the caller graph for this function:| int avro_encode_long | ( | N_STR ** | dest, |
| int64_t | value | ||
| ) |
Encode a 64-bit signed integer as zig-zag varint into N_STR.
Definition at line 376 of file n_avro.c.
References __n_assert, and nstrcat_ex().
Referenced by avro_encode_bytes_raw(), avro_encode_container(), and avro_encode_datum().
Here is the call graph for this function:
Here is the caller graph for this function:| int avro_file_to_json | ( | const char * | avro_filename, |
| const char * | schema_filename, | ||
| const char * | json_filename | ||
| ) |
Read an Avro object container file and produce a JSON file using a schema file.
Definition at line 1210 of file n_avro.c.
References __n_assert, avro_decode_container(), avro_schema_free(), avro_schema_parse(), char_to_nstr(), N_STR::data, file_to_nstr(), free_nstr, LOG_ERR, LOG_INFO, n_log, and nstr_to_file().
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:| int avro_json_to_file | ( | const char * | avro_filename, |
| const char * | schema_filename, | ||
| const char * | json_filename | ||
| ) |
Write an Avro object container file from a JSON file and schema file.
Definition at line 1146 of file n_avro.c.
References __n_assert, _str, avro_encode_container(), avro_schema_free(), avro_schema_parse(), N_STR::data, file_to_nstr(), free_nstr, LOG_ERR, LOG_INFO, n_log, and nstr_to_file().
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:Convert Avro N_STR to JSON N_STR using schema N_STR (all in-memory)
Definition at line 1315 of file n_avro.c.
References __n_assert, avro_decode_container(), avro_schema_free(), avro_schema_parse(), char_to_nstr(), N_STR::data, LOG_ERR, and n_log.
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:Convert JSON N_STR to Avro N_STR using schema N_STR (all in-memory)
Definition at line 1279 of file n_avro.c.
References __n_assert, _str, avro_encode_container(), avro_schema_free(), avro_schema_parse(), N_STR::data, LOG_ERR, and n_log.
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:| void avro_schema_free | ( | AVRO_SCHEMA ** | schema | ) |
Free an Avro schema.
Definition at line 222 of file n_avro.c.
References avro_schema_free(), AVRO_SCHEMA::fields, FreeNoLog, AVRO_SCHEMA::items, AVRO_FIELD::name, AVRO_SCHEMA::name, AVRO_SCHEMA::nb_branches, AVRO_SCHEMA::nb_fields, AVRO_SCHEMA::nb_symbols, AVRO_FIELD::schema, AVRO_SCHEMA::symbols, AVRO_SCHEMA::union_branches, and AVRO_SCHEMA::values.
Referenced by avro_file_to_json(), avro_json_to_file(), avro_nstr_avro_to_json(), avro_nstr_json_to_avro(), avro_schema_free(), avro_schema_from_cjson(), and main().
Here is the call graph for this function:
Here is the caller graph for this function:| AVRO_SCHEMA * avro_schema_from_cjson | ( | const cJSON * | json | ) |
Parse an Avro schema from a cJSON object.
Definition at line 73 of file n_avro.c.
References __n_assert, AVRO_ARRAY, AVRO_ENUM, AVRO_FIXED, AVRO_MAP, AVRO_NULL, AVRO_RECORD, avro_schema_free(), avro_schema_from_cjson(), avro_type_from_string(), AVRO_UNION, AVRO_SCHEMA::fields, AVRO_SCHEMA::fixed_size, Free, AVRO_SCHEMA::items, local_strdup, Malloc, AVRO_FIELD::name, AVRO_SCHEMA::name, AVRO_SCHEMA::nb_branches, AVRO_SCHEMA::nb_fields, AVRO_SCHEMA::nb_symbols, AVRO_FIELD::schema, AVRO_SCHEMA::symbols, AVRO_SCHEMA::type, AVRO_SCHEMA::union_branches, and AVRO_SCHEMA::values.
Referenced by avro_schema_from_cjson(), and avro_schema_parse().
Here is the call graph for this function:
Here is the caller graph for this function:| AVRO_SCHEMA * avro_schema_parse | ( | const char * | json_str | ) |
Parse an Avro schema from a JSON string.
Definition at line 211 of file n_avro.c.
References __n_assert, and avro_schema_from_cjson().
Referenced by avro_file_to_json(), avro_json_to_file(), avro_nstr_avro_to_json(), avro_nstr_json_to_avro(), and avro_schema_parse_nstr().
Here is the call graph for this function:
Here is the caller graph for this function:| AVRO_SCHEMA * avro_schema_parse_nstr | ( | const N_STR * | schema_nstr | ) |
Parse schema from N_STR.
Definition at line 1272 of file n_avro.c.
References __n_assert, avro_schema_parse(), and N_STR::data.
Referenced by main().
Here is the call graph for this function:
Here is the caller graph for this function:| char * avro_schema_to_json | ( | const AVRO_SCHEMA * | schema | ) |
Convert an Avro schema back to JSON string (caller must free)
Definition at line 258 of file n_avro.c.
References __n_assert, AVRO_ARRAY, AVRO_BOOLEAN, AVRO_BYTES, AVRO_DOUBLE, AVRO_ENUM, AVRO_FIXED, AVRO_FLOAT, AVRO_INT, AVRO_LONG, AVRO_MAP, AVRO_NULL, AVRO_RECORD, avro_schema_to_json(), AVRO_STRING, avro_type_to_string(), AVRO_UNION, AVRO_SCHEMA::fields, AVRO_SCHEMA::fixed_size, Free, AVRO_SCHEMA::items, AVRO_FIELD::name, AVRO_SCHEMA::name, AVRO_SCHEMA::nb_branches, AVRO_SCHEMA::nb_fields, AVRO_SCHEMA::nb_symbols, AVRO_FIELD::schema, AVRO_SCHEMA::symbols, AVRO_SCHEMA::type, AVRO_SCHEMA::union_branches, and AVRO_SCHEMA::values.
Referenced by avro_encode_container(), avro_schema_to_json(), and main().
Here is the call graph for this function:
Here is the caller graph for this function: