2

当我构建具有结构的箭头记录并且该结构具有类型为的字段时arrow.FixedWidthTypes.Boolean,它稍后会在尝试访问布尔值时出现以下错误:

    runtime error: invalid memory address or nil pointer dereference

以下代码成功读取了字符串值,但没有读取布尔值:

mem := memory.NewGoAllocator()

fields := []arrow.Field{
    {Name: "my struct", Type: arrow.StructOf([]arrow.Field{
        {Name: "my string", Type: arrow.BinaryTypes.String},
        {Name: "my bool", Type: arrow.FixedWidthTypes.Boolean},
    }...)},
}

schema := arrow.NewSchema(fields, nil)

bld := array.NewRecordBuilder(mem, schema)
defer bld.Release()

sb := bld.Field(0).(*array.StructBuilder)
f1b := sb.FieldBuilder(0).(*array.StringBuilder)
f2b := sb.FieldBuilder(1).(*array.BooleanBuilder)

sb.AppendValues([]bool{true})
f1b.AppendValues([]string{"someone", "was", "here"}, nil)
f2b.AppendValues([]bool{false, true, true}, nil)

r := bld.NewRecord()

struc := r.Column(0).(*array.Struct)

Expect(struc.Field(0).(*array.String).Value(0)).ToNot(Panic())
Expect(struc.Field(1).(*array.Boolean).Value(0)).To(Panic())

4

0 回答 0