func GetPutData()

in http/get_simple/go/server/server.go [38:85]


func GetPutData() []arrow.Record {
	const (
		totalRecords = 100000000
		length       = 4096
		ncolumns     = 4
		seed         = 42
	)

	var (
		r    = rand.New(rand.NewSource(seed))
		mem  = memory.DefaultAllocator
		arrs = make([]arrow.Array, 0, ncolumns)
	)
	for i := 0; i < ncolumns; i++ {
		buf := memory.NewResizableBuffer(mem)
		buf.Resize(length * 8)
		_, err := r.Read(buf.Buf())
		if err != nil {
			panic(err)
		}
		defer buf.Release()

		data := array.NewData(arrow.PrimitiveTypes.Int64, length, []*memory.Buffer{nil, buf}, nil, 0, 0)
		defer data.Release()
		a := array.NewInt64Data(data)
		defer a.Release()
		arrs = append(arrs, a)
	}

	batch := array.NewRecord(schema, arrs, length)
	defer batch.Release()

	batches := make([]arrow.Record, 0)
	records := int64(0)
	for records < totalRecords {
		if records+length > totalRecords {
			lastLen := totalRecords - records
			batches = append(batches, batch.NewSlice(0, lastLen))
			records += lastLen
		} else {
			batch.Retain()
			batches = append(batches, batch)
			records += length
		}
	}

	return batches
}