loicalleyne commented on code in PR #36796: URL: https://github.com/apache/arrow/pull/36796#discussion_r1293980910
########## go/arrow/avro/reader.go: ########## @@ -0,0 +1,490 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package avro + +import ( + "errors" + "fmt" + "io" + "sync" + "sync/atomic" + + "github.com/apache/arrow/go/v13/arrow" + "github.com/apache/arrow/go/v13/arrow/array" + "github.com/apache/arrow/go/v13/arrow/internal/debug" + "github.com/apache/arrow/go/v13/arrow/memory" + "github.com/linkedin/goavro/v2" +) + +// Reader wraps goavro/OCFReader and creates array.Records from a schema. +type OCFReader struct { + r *goavro.OCFReader + schema *arrow.Schema + + refs int64 + bld *array.RecordBuilder + cur arrow.Record + err error + + chunk int + done bool + next func() bool + + mem memory.Allocator + + topLevel bool + once sync.Once + + fieldConverter []func(val string) + columnFilter []string + columnTypes map[string]arrow.DataType + + stringsCanBeNull bool + nulls []string +} + +// NewReader returns a reader that reads from an Avro OCF file and creates +// arrow.Records from the converted schema. +func NewOCFReader(r io.Reader, opts ...Option) *OCFReader { + ocfr, err := goavro.NewOCFReader(r) + if err != nil { + panic(fmt.Errorf("%w: could not create avro ocfreader", arrow.ErrInvalid)) + } + + rr := &OCFReader{ + r: ocfr, + //schema: schema, + refs: 1, + chunk: 1, + stringsCanBeNull: false, Review Comment: removed reader from this PR -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
