zeroshade commented on code in PR #35769:
URL: https://github.com/apache/arrow/pull/35769#discussion_r1238625042
##########
go/arrow/internal/testing/gen/random_array_gen.go:
##########
@@ -350,6 +350,40 @@ func (r *RandomArrayGenerator) LargeString(size int64,
minLength, maxLength int6
return bldr.NewArray()
}
+func (r *RandomArrayGenerator) StringView(size int64, minLength, maxLength
int64, nullProb float64) arrow.Array {
+ return r.generateBinaryView(arrow.BinaryTypes.StringView, size,
minLength, maxLength, nullProb)
+}
+
+func (r *RandomArrayGenerator) generateBinaryView(dt arrow.DataType, size
int64, minLength, maxLength int64, nullProb float64) arrow.Array {
+ lengths := r.Int32(size, int32(minLength), int32(maxLength),
nullProb).(*array.Int32)
+ defer lengths.Release()
+
+ bldr := array.NewBuilder(r.mem, dt).(array.StringLikeBuilder)
+ defer bldr.Release()
+
+ r.extra++
+ dist := rand.New(rand.NewSource(r.seed + r.extra))
+
+ buf := make([]byte, 0, maxLength)
+ gen := func(n int32) string {
+ out := buf[:n]
+ for i := range out {
+ out[i] = uint8(dist.Int31n(int32('z')-int32('A')+1) +
int32('A'))
+ }
+ return string(out)
+ }
+
+ for i := 0; i < lengths.Len(); i++ {
+ if lengths.IsValid(i) {
+ bldr.Append(gen(lengths.Value(i)))
+ } else {
+ bldr.AppendNull()
+ }
Review Comment:
I'm not going to modify the generated code. Everything in this folder is
generated by flatc from the .fbs files.
--
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]