reader

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 13, 2024 License: Apache-2.0 Imports: 23 Imported by: 1

Documentation

Overview

Package reader contains helpers for reading data and loading to Arrow.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUndefinedInput = errors.New("nil input")
	ErrInvalidInput   = errors.New("invalid input")
)
View Source
var (
	ErrNullStructData = errors.New("null struct data")
)

Functions

func InputMap

func InputMap(a any) (map[string]any, error)

InputMap takes structured input data and attempts to decode it to map[string]any. Input data can be json in string or []byte, or any other Go data type which can be decoded by MapStructure/v2. MapStructure/v2: github.com/go-viper/mapstructure/v2

func TextMarshalerHookFunc

func TextMarshalerHookFunc() mapstructure.DecodeHookFuncValue

TextMarshalerHookFunc returns a DecodeHookFuncValue that checks for the encoding.TextMarshaler interface and calls the MarshalText function if found.

Types

type DataReader added in v0.3.0

type DataReader struct {
	// contains filtered or unexported fields
}

func NewReader added in v0.3.0

func NewReader(schema *arrow.Schema, source DataSource, opts ...Option) (*DataReader, error)

func (*DataReader) Err added in v0.3.0

func (r *DataReader) Err() error

Err returns the last error encountered during the reading of data.

func (*DataReader) ReadToRecord added in v0.3.0

func (r *DataReader) ReadToRecord(a any) (arrow.Record, error)

func (*DataReader) Release added in v0.3.0

func (r *DataReader) Release()

Release decreases the reference count by 1. When the reference count goes to zero, the memory is freed. Release may be called simultaneously from multiple goroutines.

func (*DataReader) Retain added in v0.3.0

func (r *DataReader) Retain()

Retain increases the reference count by 1. Retain may be called simultaneously from multiple goroutines.

func (*DataReader) Schema added in v0.3.0

func (r *DataReader) Schema() *arrow.Schema

type DataSource added in v0.3.0

type DataSource int
const (
	DataSourceGo DataSource = iota
	DataSourceJSON
	DataSourceAvro
)

type Encoder

type Encoder struct {
	// contains filtered or unexported fields
}

An Encoder takes structured data and converts it into an interface following the mapstructure tags.

func New

func New(cfg *EncoderConfig) *Encoder

New returns a new encoder for the configuration.

func (*Encoder) Encode

func (e *Encoder) Encode(input any) (any, error)

Encode takes the input and uses reflection to encode it to an interface based on the mapstructure spec.

type EncoderConfig

type EncoderConfig struct {
	// EncodeHook, if set, is a way to provide custom encoding. It
	// will be called before structs and primitive types.
	EncodeHook mapstructure.DecodeHookFunc
}

EncoderConfig is the configuration used to create a new encoder.

type Option added in v0.3.0

type Option func(config)

Option configures an Avro reader/writer.

func WithAllocator added in v0.3.0

func WithAllocator(mem memory.Allocator) Option

WithAllocator specifies the Arrow memory allocator used while building records.

func WithJSONDecoder added in v0.3.0

func WithJSONDecoder() Option

WithJSONDecoder specifies whether to use goccy/json-go as the Bodkin Reader's decoder. The default is the Bodkin DataLoader, a linked list of builders which reduces recursive lookups in maps when loading data.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL