func OptionalFieldSnappy(r *OptionalField) {
	r.compression = sch.CompressionCodec_SNAPPY
}
OptionalFieldSnappy sets the compression for a column to snappy
It is an optional arg to NewOptionalField
package parquet
import (
	"bytes"
	"compress/gzip"
	"math/bits"
	"strings"
	"github.com/valyala/bytebufferpool"
	"fmt"
	"io"
	"github.com/golang/snappy"
	"github.com/parsyl/parquet/internal/rle"
	sch "github.com/parsyl/parquet/schema"
)
type RepetitionType int
const (
	Unseen   RepetitionType = -1
	Required RepetitionType = 0
	Optional RepetitionType = 1
	Repeated RepetitionType = 2
)
var (
	buffpool = bytebufferpool.Pool{}
)
type RepetitionTypes []RepetitionType
func (r RepetitionTypes) MaxDef() uint8 {
	var out uint8
	for _, rt := range r {
		if rt == Optional || rt == Repeated {
			out++
		}
	}
	return out
}
func (r RepetitionTypes) MaxRep() uint8 {
	var out uint8
	for _, rt := range r {
		if rt == Repeated {
			out++
		}
	}
	return out
}
type RequiredField struct {
	pth         []string
	compression sch.CompressionCodec
}
func NewRequiredField(pth []string, opts ...func(*RequiredField)) RequiredField {
	r := RequiredField{
		pth:         pth,
		compression: sch.CompressionCodec_SNAPPY,
	}
	for _, opt := range opts {
		opt(&r)
	}
	return r
}
func RequiredFieldSnappy(r *RequiredField) {
	r.compression = sch.CompressionCodec_SNAPPY
}
func RequiredFieldGzip(r *RequiredField) {
	r.compression = sch.CompressionCodec_GZIP
}
func RequiredFieldUncompressed(r *RequiredField) {
	r.compression = sch.CompressionCodec_UNCOMPRESSED
}
func (f *RequiredField) DoWrite(w io.Writer, meta *Metadata, vals []byte, count int, stats Stats) error {
	buff := buffpool.Get()
	defer buffpool.Put(buff)
	l, cl, vals, err := compress(f.compression, buff, vals)
	if err != nil {
		return err
	}
	if err := meta.WritePageHeader(w, f.pth, l, cl, count, count, 0, 0, f.compression, stats); err != nil {
		return err
	}
	_, err = w.Write(vals)
	return err
}
func (f *RequiredField) DoRead(r io.ReadSeeker, pg Page) (io.Reader, []int, error) {
	var nRead int
	var out []byte
	var sizes []int
	for nRead < pg.N {
		ph, err := PageHeader(r)
		if err != nil {
			return nil, nil, err
		}
		sizes = append(sizes, int(ph.DataPageHeader.NumValues))
		data, err := pageData(r, ph, pg)
		if err != nil {
			return nil, nil, err
		}
		out = append(out, data...)
		nRead += int(ph.DataPageHeader.NumValues)
	}
	return bytes.NewBuffer(out), sizes, nil
}
func (f *RequiredField) Name() string {
	return strings.Join(f.pth, ".")
}
func (f *RequiredField) Path() []string {
	return f.pth
}
type MaxLevel struct {
	Def uint8
	Rep uint8
}
type OptionalField struct {
	Defs           []uint8
	Reps           []uint8
	pth            []string
	MaxLevels      MaxLevel
	compression    sch.CompressionCodec
	RepetitionType FieldFunc
	Types          []int
	repeated       bool
}
func getRepetitionTypes(in []int) RepetitionTypes {
	out := make([]RepetitionType, len(in))
	for i, x := range in {
		out[i] = RepetitionType(x)
	}
	return RepetitionTypes(out)
}
func NewOptionalField(pth []string, types []int, opts ...func(*OptionalField)) OptionalField {
	rts := getRepetitionTypes(types)
	f := OptionalField{
		pth:         pth,
		compression: sch.CompressionCodec_SNAPPY,
		MaxLevels: MaxLevel{
			Def: rts.MaxDef(),
			Rep: rts.MaxRep(),
		},
		RepetitionType: fieldFuncs[types[len(types)-1]],
		Types:          types,
		repeated:       rts.MaxRep() > 0,
	}
	for _, opt := range opts {
		opt(&f)
	}
	return f
}