@@ -1030,27 +1030,38 @@ type dictBuilder[T arrow.ValueType] struct {
10301030 dictionaryBuilder
10311031}
10321032
1033- func (b * dictBuilder [T ]) UnsafeAppend (v T ) error {
1033+ func (b * dictBuilder [T ]) UnsafeAppend (v T ) {
1034+ // SAFETY: it is safe to ignore the value returned by the calls to `unsafeAppendValue()`
1035+ // here since `UnsafeAppend()` is statically typed and the only case in which that method
1036+ // errors is when trying to insert an invalid `interface{}` into the `memoTable`.
1037+ var err error
10341038 switch val := any (v ).(type ) {
10351039 case arrow.Duration :
1036- return b .unsafeAppendValue (int64 (val ))
1040+ err = b .unsafeAppendValue (int64 (val ))
10371041 case arrow.Timestamp :
1038- return b .unsafeAppendValue (int64 (val ))
1042+ err = b .unsafeAppendValue (int64 (val ))
10391043 case arrow.Time32 :
1040- return b .unsafeAppendValue (int32 (val ))
1044+ err = b .unsafeAppendValue (int32 (val ))
10411045 case arrow.Time64 :
1042- return b .unsafeAppendValue (int64 (val ))
1046+ err = b .unsafeAppendValue (int64 (val ))
10431047 case arrow.Date32 :
1044- return b .unsafeAppendValue (int32 (val ))
1048+ err = b .unsafeAppendValue (int32 (val ))
10451049 case arrow.Date64 :
1046- return b .unsafeAppendValue (int64 (val ))
1050+ err = b .unsafeAppendValue (int64 (val ))
10471051 case arrow.MonthInterval :
1048- return b .unsafeAppendValue (int32 (val ))
1052+ err = b .unsafeAppendValue (int32 (val ))
10491053 }
1050- return b .unsafeAppendValue (v )
1054+ err = b .unsafeAppendValue (v )
1055+ debug .Assert (err == nil , "Trying to insert wrong type into memoTable even though this method is statically typed. This is an implementation bug." )
10511056}
10521057
10531058func (b * dictBuilder [T ]) Append (v T ) error {
1059+ // TODO: it is safe to ignore the value returned by the calls to `appendValue()`
1060+ // here since `Append()` is statically typed and the only case in which that
1061+ // method errors is when trying to insert an invalid `interface{}` into the `memoTable`.
1062+ //
1063+ // This would be a breaking change to the public API of `dictBuilder`, so it needs
1064+ // to happen over a major release.
10541065 switch val := any (v ).(type ) {
10551066 case arrow.Duration :
10561067 return b .appendValue (int64 (val ))
@@ -1118,6 +1129,12 @@ func (b *BinaryDictionaryBuilder) Append(v []byte) error {
11181129 return nil
11191130 }
11201131
1132+ // TODO: it is safe to ignore the value returned by the call to `appendBytes()`
1133+ // here since `Append()` is statically typed and the only case in which that
1134+ // method errors is when trying to insert an invalid `interface{}` into the `memoTable`.
1135+ //
1136+ // This would be a breaking change to the public API of `BinaryDictionaryBuilder`,
1137+ // so it needs to happen over a major release.
11211138 return b .appendBytes (v )
11221139}
11231140
@@ -1194,6 +1211,13 @@ type fixedSizeDictionaryBuilder[T fsbType] struct {
11941211}
11951212
11961213func (b * fixedSizeDictionaryBuilder [T ]) Append (v T ) error {
1214+ // TODO: it is safe to ignore the value returned by the calls to `appendValue()`
1215+ // and `appendBytes()` here since `Append()` is statically typed and the only
1216+ // case in which these method error is when trying to insert an invalid
1217+ // `interface{}` into the `memoTable`.
1218+ //
1219+ // This would be a breaking change to the public API of `fixedSizeDictionaryBuilder`,
1220+ // so it needs to happen over a major release.
11971221 if v , ok := any (v ).([]byte ); ok {
11981222 return b .appendBytes (v [:b .byteWidth ])
11991223 }
@@ -1224,6 +1248,12 @@ type FixedSizeBinaryDictionaryBuilder struct {
12241248}
12251249
12261250func (b * FixedSizeBinaryDictionaryBuilder ) Append (v []byte ) error {
1251+ // TODO: it is safe to ignore the value returned by the calls to `appendValue()`
1252+ // here since `Append()` is statically typed and the only case in which that
1253+ // method errors is when trying to insert an invalid `interface{}` into the `memoTable`.
1254+ //
1255+ // This would be a breaking change to the public API of `FixedSizeBinaryDictionaryBuilder`,
1256+ // so it needs to happen over a major release.
12271257 return b .appendValue (v [:b .byteWidth ])
12281258}
12291259
0 commit comments