zeroshade commented on code in PR #34079:
URL: https://github.com/apache/arrow/pull/34079#discussion_r1101675200


##########
go/arrow/scalar/scalar.go:
##########
@@ -908,6 +937,51 @@ func MakeArrayFromScalar(sc Scalar, length int, mem 
memory.Allocator) (arrow.Arr
                        data.Release()
                }()
                return array.MakeFromData(data), nil
+       case *RunEndEncoded:
+               dt := s.DataType().(*arrow.RunEndEncodedType)
+               totalLen := uint64(s.RunLength * int64(length))
+
+               var endBytes []byte
+               switch dt.RunEnds().ID() {
+               case arrow.INT16:
+                       if totalLen > math.MaxInt16 {
+                               return nil, fmt.Errorf("%w: final length 
overflows int16 run ends", arrow.ErrInvalid)
+                       }
+
+                       v := int16(totalLen)
+                       endBytes = (*[2]byte)(unsafe.Pointer(&v))[:]
+               case arrow.INT32:
+                       if totalLen > math.MaxInt32 {
+                               return nil, fmt.Errorf("%w: final length 
overflows int16 run ends", arrow.ErrInvalid)
+                       }
+
+                       v := int32(totalLen)
+                       endBytes = (*[4]byte)(unsafe.Pointer(&v))[:]
+               case arrow.INT64:
+                       if totalLen > math.MaxInt64 {
+                               return nil, fmt.Errorf("%w: final length 
overflows int16 run ends", arrow.ErrInvalid)
+                       }

Review Comment:
   Sure it is, the total len could be larger than an `int64` which is why I'm 
using `uint64` to hold the value



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to