Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions go/arrow/ipc/file_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,9 @@ func (ctx *arrayLoaderContext) loadArray(dt arrow.DataType) array.Interface {
case *arrow.BinaryType, *arrow.StringType:
return ctx.loadBinary(dt)

case *arrow.ListType:
return ctx.loadList(dt)

default:
panic(errors.Errorf("array type %T not handled yet", dt))
}
Expand All @@ -385,6 +388,16 @@ func (ctx *arrayLoaderContext) loadCommon(nbufs int) (*flatbuf.FieldNode, []*mem
return field, buffers
}

func (ctx *arrayLoaderContext) loadChild(dt arrow.DataType) array.Interface {
if ctx.max == 0 {
panic("arrow/ipc: nested type limit reached")
}
ctx.max--
sub := ctx.loadArray(dt)
ctx.max++
return sub
}

func (ctx *arrayLoaderContext) loadNull() array.Interface {
field, buffers := ctx.loadCommon(1)
buffers = append(buffers, ctx.buffer())
Expand Down Expand Up @@ -422,6 +435,19 @@ func (ctx *arrayLoaderContext) loadBinary(dt arrow.DataType) array.Interface {
return array.MakeFromData(data)
}

func (ctx *arrayLoaderContext) loadList(dt *arrow.ListType) array.Interface {
field, buffers := ctx.loadCommon(2)
buffers = append(buffers, ctx.buffer())

sub := ctx.loadChild(dt.Elem())
defer sub.Release()

data := array.NewData(dt, int(field.Length()), buffers, []*array.Data{sub.Data()}, int(field.NullCount()), 0)
defer data.Release()

return array.NewListData(data)
}

func readDictionary(meta *memory.Buffer, types dictTypeMap, r ReadAtSeeker) (int64, array.Interface, error) {
// msg := flatbuf.GetRootAsMessage(meta.Bytes(), 0)
// var dictBatch flatbuf.DictionaryBatch
Expand Down
6 changes: 6 additions & 0 deletions go/arrow/ipc/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,12 @@ func concreteTypeFromFB(typ flatbuf.Type, data flatbuffers.Table, children []arr
case flatbuf.TypeBool:
return arrow.FixedWidthTypes.Boolean, nil

case flatbuf.TypeList:
if len(children) != 1 {
return nil, errors.Errorf("arrow/ipc: List must have exactly 1 child field (got=%d)", len(children))
}
return arrow.ListOf(children[0].Type), nil

default:
// FIXME(sbinet): implement all the other types.
panic(fmt.Errorf("arrow/ipc: type %v not implemented", flatbuf.EnumNamesType[typ]))
Expand Down