in arrow/csv/reader.go [387:518]
func (r *Reader) initFieldConverter(bldr array.Builder) func(string) {
switch dt := bldr.Type().(type) {
case *arrow.BooleanType:
return func(str string) {
r.parseBool(bldr, str)
}
case *arrow.Int8Type:
return func(str string) {
r.parseInt8(bldr, str)
}
case *arrow.Int16Type:
return func(str string) {
r.parseInt16(bldr, str)
}
case *arrow.Int32Type:
return func(str string) {
r.parseInt32(bldr, str)
}
case *arrow.Int64Type:
return func(str string) {
r.parseInt64(bldr, str)
}
case *arrow.Uint8Type:
return func(str string) {
r.parseUint8(bldr, str)
}
case *arrow.Uint16Type:
return func(str string) {
r.parseUint16(bldr, str)
}
case *arrow.Uint32Type:
return func(str string) {
r.parseUint32(bldr, str)
}
case *arrow.Uint64Type:
return func(str string) {
r.parseUint64(bldr, str)
}
case *arrow.Float16Type:
return func(str string) {
r.parseFloat16(bldr, str)
}
case *arrow.Float32Type:
return func(str string) {
r.parseFloat32(bldr, str)
}
case *arrow.Float64Type:
return func(str string) {
r.parseFloat64(bldr, str)
}
case *arrow.StringType:
// specialize the implementation when we know we cannot have nulls
if r.stringsCanBeNull {
return func(str string) {
if r.isNull(str) {
bldr.AppendNull()
} else {
bldr.(*array.StringBuilder).Append(str)
}
}
} else {
return func(str string) {
bldr.(*array.StringBuilder).Append(str)
}
}
case *arrow.LargeStringType:
// specialize the implementation when we know we cannot have nulls
if r.stringsCanBeNull {
return func(str string) {
if r.isNull(str) {
bldr.AppendNull()
} else {
bldr.(*array.LargeStringBuilder).Append(str)
}
}
} else {
return func(str string) {
bldr.(*array.LargeStringBuilder).Append(str)
}
}
case *arrow.TimestampType:
return func(str string) {
r.parseTimestamp(bldr, str, dt.Unit)
}
case *arrow.Date32Type:
return func(str string) {
r.parseDate32(bldr, str)
}
case *arrow.Date64Type:
return func(str string) {
r.parseDate64(bldr, str)
}
case *arrow.Time32Type:
return func(str string) {
r.parseTime32(bldr, str, dt.Unit)
}
case *arrow.Decimal128Type:
return func(str string) {
r.parseDecimal128(bldr, str, dt.Precision, dt.Scale)
}
case *arrow.Decimal256Type:
return func(str string) {
r.parseDecimal256(bldr, str, dt.Precision, dt.Scale)
}
case *arrow.FixedSizeListType:
return func(s string) {
r.parseFixedSizeList(bldr.(*array.FixedSizeListBuilder), s, int(dt.Len()))
}
case arrow.ListLikeType:
return func(s string) {
r.parseListLike(bldr.(array.ListLikeBuilder), s)
}
case *arrow.BinaryType:
return func(s string) {
r.parseBinaryType(bldr, s)
}
case *arrow.LargeBinaryType:
return func(s string) {
r.parseLargeBinaryType(bldr, s)
}
case *arrow.FixedSizeBinaryType:
return func(s string) {
r.parseFixedSizeBinaryType(bldr, s, dt.Bytes())
}
case arrow.ExtensionType:
return func(s string) {
r.parseExtension(bldr, s)
}
default:
panic(fmt.Errorf("arrow/csv: unhandled field type %T", bldr.Type()))
}
}