2
* Licensed to the Apache Software Foundation (ASF) under one or more
3
* contributor license agreements. See the NOTICE file distributed with
4
* this work for additional information regarding copyright ownership.
5
* The ASF licenses this file to you under the Apache License, Version 2.0
6
* (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
9
* http://www.apache.org/licenses/LICENSE-2.0
11
* Unless required by applicable law or agreed to in writing, software
12
* distributed under the License is distributed on an "AS IS" BASIS,
13
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
14
* implied. See the License for the specific language governing
15
* permissions and limitations under the License.
22
#define CLOSE_EXTERN }
27
#include <avro/platform.h>
30
#include <avro/basics.h>
31
#include <avro/legacy.h>
32
#include <avro/schema.h>
33
#include <avro/value.h>
35
typedef struct avro_reader_t_ *avro_reader_t;
36
typedef struct avro_writer_t_ *avro_writer_t;
42
avro_reader_t avro_reader_file(FILE * fp);
43
avro_reader_t avro_reader_file_fp(FILE * fp, int should_close);
44
avro_writer_t avro_writer_file(FILE * fp);
45
avro_writer_t avro_writer_file_fp(FILE * fp, int should_close);
46
avro_reader_t avro_reader_memory(const char *buf, int64_t len);
47
avro_writer_t avro_writer_memory(const char *buf, int64_t len);
50
avro_reader_memory_set_source(avro_reader_t reader, const char *buf, int64_t len);
53
avro_writer_memory_set_dest(avro_writer_t writer, const char *buf, int64_t len);
55
int avro_read(avro_reader_t reader, void *buf, int64_t len);
56
int avro_skip(avro_reader_t reader, int64_t len);
57
int avro_write(avro_writer_t writer, void *buf, int64_t len);
59
void avro_reader_reset(avro_reader_t reader);
61
void avro_writer_reset(avro_writer_t writer);
62
int64_t avro_writer_tell(avro_writer_t writer);
63
void avro_writer_flush(avro_writer_t writer);
65
void avro_writer_dump(avro_writer_t writer, FILE * fp);
66
void avro_reader_dump(avro_reader_t reader, FILE * fp);
68
int avro_reader_is_eof(avro_reader_t reader);
70
void avro_reader_free(avro_reader_t reader);
71
void avro_writer_free(avro_writer_t writer);
73
int avro_schema_to_json(const avro_schema_t schema, avro_writer_t out);
76
* Reads a binary-encoded Avro value from the given reader object,
77
* storing the result into dest.
81
avro_value_read(avro_reader_t reader, avro_value_t *dest);
84
* Writes a binary-encoded Avro value to the given writer object.
88
avro_value_write(avro_writer_t writer, avro_value_t *src);
91
* Returns the size of the binary encoding of the given Avro value.
95
avro_value_sizeof(avro_value_t *src, size_t *size);
98
/* File object container */
99
typedef struct avro_file_reader_t_ *avro_file_reader_t;
100
typedef struct avro_file_writer_t_ *avro_file_writer_t;
102
int avro_file_writer_create(const char *path, avro_schema_t schema,
103
avro_file_writer_t * writer);
104
int avro_file_writer_create_fp(FILE *fp, const char *path, int should_close,
105
avro_schema_t schema, avro_file_writer_t * writer);
106
int avro_file_writer_create_with_codec(const char *path,
107
avro_schema_t schema, avro_file_writer_t * writer,
108
const char *codec, size_t block_size);
109
int avro_file_writer_create_with_codec_fp(FILE *fp, const char *path, int should_close,
110
avro_schema_t schema, avro_file_writer_t * writer,
111
const char *codec, size_t block_size);
112
int avro_file_writer_open(const char *path, avro_file_writer_t * writer);
113
int avro_file_writer_open_bs(const char *path, avro_file_writer_t * writer, size_t block_size);
114
int avro_file_reader(const char *path, avro_file_reader_t * reader);
115
int avro_file_reader_fp(FILE *fp, const char *path, int should_close,
116
avro_file_reader_t * reader);
119
avro_file_reader_get_writer_schema(avro_file_reader_t reader);
121
int avro_file_writer_sync(avro_file_writer_t writer);
122
int avro_file_writer_flush(avro_file_writer_t writer);
123
int avro_file_writer_close(avro_file_writer_t writer);
125
int avro_file_reader_close(avro_file_reader_t reader);
128
avro_file_reader_read_value(avro_file_reader_t reader, avro_value_t *dest);
131
avro_file_writer_append_value(avro_file_writer_t writer, avro_value_t *src);
134
avro_file_writer_append_encoded(avro_file_writer_t writer,
135
const void *buf, int64_t len);
138
* Legacy avro_datum_t API
141
int avro_read_data(avro_reader_t reader,
142
avro_schema_t writer_schema,
143
avro_schema_t reader_schema, avro_datum_t * datum);
144
int avro_skip_data(avro_reader_t reader, avro_schema_t writer_schema);
145
int avro_write_data(avro_writer_t writer,
146
avro_schema_t writer_schema, avro_datum_t datum);
147
int64_t avro_size_data(avro_writer_t writer,
148
avro_schema_t writer_schema, avro_datum_t datum);
150
int avro_file_writer_append(avro_file_writer_t writer, avro_datum_t datum);
152
int avro_file_reader_read(avro_file_reader_t reader,
153
avro_schema_t readers_schema, avro_datum_t * datum);