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.
18
#ifndef AVRO_RESOLVER_H
19
#define AVRO_RESOLVER_H
22
#define CLOSE_EXTERN }
27
#include <avro/schema.h>
28
#include <avro/value.h>
31
* A <i>resolved value</i> is a special kind of value that knows how to
32
* implement Avro's schema resolution rules to translate between a
33
* writer schema and a reader schema. A resolved value doesn't store or
34
* process data itself; instead, it wraps an existing value instance.
36
* There are two resolved value classes. In the first (@ref
37
* avro_resolved_writer_t), the resolved value is an instance of the
38
* writer schema, and wraps an instance of the reader schema. This is
39
* used, for instance, when reading from an Avro data file; you want the
40
* end result to be a reader schema value, and the resolved value allows
41
* the file reader to ignore the schema resolution and simply fill in
42
* the values of the writer schema. You can only set the values of a
43
* resolved writer; you must use the original wrapped value to read.
45
* With other class (@ref avro_resolved_reader_t), the resolved value is
46
* an instance of the reader schema, and wraps an instance of the writer
47
* schema. This is used when resolving an existing Avro value to
48
* another schema; you've already got the value in the original (writer)
49
* schema, and want to transparently treat it as if it were an instance
50
* of the new (reader) schema. You can only read the values of a
51
* resolved reader; you must use the original wrapped value to write.
53
* For both classes, the “self” pointer of the resolved value is an
54
* avro_value_t pointer, which points at the wrapped value.
59
* Create a new resolved writer implementation for the given writer and
64
avro_resolved_writer_new(avro_schema_t writer_schema,
65
avro_schema_t reader_schema);
68
* Creates a new resolved writer value.
72
avro_resolved_writer_new_value(avro_value_iface_t *iface,
76
* Sets the wrapped value for a resolved writer. This must be an
77
* instance of the reader schema. We create our own reference to the
82
avro_resolved_writer_set_dest(avro_value_t *resolved,
87
* Clears the wrapped value for a resolved writer.
91
avro_resolved_writer_clear_dest(avro_value_t *resolved);
95
* Create a new resolved reader implementation for the given writer and
100
avro_resolved_reader_new(avro_schema_t writer_schema,
101
avro_schema_t reader_schema);
104
* Creates a new resolved reader value.
108
avro_resolved_reader_new_value(avro_value_iface_t *iface,
109
avro_value_t *value);
112
* Sets the wrapped value for a resolved reader. This must be an
113
* instance of the reader schema. We create our own reference to the
118
avro_resolved_reader_set_source(avro_value_t *resolved,
123
* Clears the wrapped value for a resolved reader.
127
avro_resolved_reader_clear_source(avro_value_t *resolved);