-
Notifications
You must be signed in to change notification settings - Fork 83
/
map_test_record_container.go
49 lines (41 loc) · 1.11 KB
/
map_test_record_container.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Code generated by github.com/actgardner/gogen-avro/v8. DO NOT EDIT.
/*
* SOURCE:
* schema.avsc
*/
package avro
import (
"io"
"github.com/actgardner/gogen-avro/v9/compiler"
"github.com/actgardner/gogen-avro/v9/container"
"github.com/actgardner/gogen-avro/v9/vm"
)
func NewMapTestRecordWriter(writer io.Writer, codec container.Codec, recordsPerBlock int64) (*container.Writer, error) {
str := NewMapTestRecord()
return container.NewWriter(writer, codec, recordsPerBlock, str.Schema())
}
// container reader
type MapTestRecordReader struct {
r io.Reader
p *vm.Program
}
func NewMapTestRecordReader(r io.Reader) (*MapTestRecordReader, error) {
containerReader, err := container.NewReader(r)
if err != nil {
return nil, err
}
t := NewMapTestRecord()
deser, err := compiler.CompileSchemaBytes([]byte(containerReader.AvroContainerSchema()), []byte(t.Schema()))
if err != nil {
return nil, err
}
return &MapTestRecordReader{
r: containerReader,
p: deser,
}, nil
}
func (r MapTestRecordReader) Read() (MapTestRecord, error) {
t := NewMapTestRecord()
err := vm.Eval(r.r, r.p, &t)
return t, err
}