@@ -35,6 +35,10 @@ import (
3535// Magic string identifying an Apache Arrow file.
3636var Magic = []byte ("ARROW1" )
3737
38+ func tostr (b []byte ) string {
39+ return unsafe .String (& b [0 ], len (b ))
40+ }
41+
3842const (
3943 currentMetadataVersion = MetadataV5
4044 minMetadataVersion = MetadataV4
@@ -184,8 +188,7 @@ func fieldFromFB(field *flatbuf.Field, pos dictutils.FieldPos, memo *dictutils.M
184188 o arrow.Field
185189 )
186190
187- name := field .Name ()
188- o .Name = unsafe .String (& name [0 ], len (name ))
191+ o .Name = tostr (field .Name ())
189192 o .Nullable = field .Nullable ()
190193 o .Metadata , err = metadataFromFB (field )
191194 if err != nil {
@@ -462,7 +465,7 @@ func (fv *fieldVisitor) visit(field arrow.Field) {
462465 field .Type = dt .StorageType ()
463466 fv .visit (field )
464467 fv .meta [ExtensionTypeKeyName ] = dt .ExtensionName ()
465- fv .meta [ExtensionMetadataKeyName ] = string ( dt .Serialize () )
468+ fv .meta [ExtensionMetadataKeyName ] = dt .Serialize ()
466469
467470 case * arrow.DictionaryType :
468471 field .Type = dt .ValueType
@@ -988,7 +991,7 @@ func timeFromFB(data flatbuf.Time) (arrow.DataType, error) {
988991
989992func timestampFromFB (data flatbuf.Timestamp ) (arrow.DataType , error ) {
990993 unit := unitFromFB (data .Unit ())
991- tz := string (data .Timezone ())
994+ tz := tostr (data .Timezone ())
992995 return & arrow.TimestampType {Unit : unit , TimeZone : tz }, nil
993996}
994997
@@ -1044,8 +1047,8 @@ func metadataFromFB(md customMetadataer) (arrow.Metadata, error) {
10441047 if ! md .CustomMetadata (& kv , i ) {
10451048 return arrow.Metadata {}, fmt .Errorf ("arrow/ipc: could not read key-value %d from flatbuffer" , i )
10461049 }
1047- keys [i ] = string (kv .Key ())
1048- vals [i ] = string (kv .Value ())
1050+ keys [i ] = tostr (kv .Key ())
1051+ vals [i ] = tostr (kv .Value ())
10491052 }
10501053
10511054 return arrow .NewMetadata (keys , vals ), nil
0 commit comments