ianmcook commented on code in PR #39081:
URL: https://github.com/apache/arrow/pull/39081#discussion_r1432959936
##########
http/examples/get/server.go:
##########
@@ -0,0 +1,98 @@
+package main
+
+import (
+ "fmt"
+ "log"
+ "math/rand"
+ "net/http"
+
+ "github.com/apache/arrow/go/v15/arrow"
+ "github.com/apache/arrow/go/v15/arrow/array"
+ "github.com/apache/arrow/go/v15/arrow/ipc"
+ "github.com/apache/arrow/go/v15/arrow/memory"
+)
+
+var schema = arrow.NewSchema([]arrow.Field{
+ {Name: "a", Type: arrow.PrimitiveTypes.Int64},
+ {Name: "b", Type: arrow.PrimitiveTypes.Int64},
+ {Name: "c", Type: arrow.PrimitiveTypes.Int64},
+ {Name: "d", Type: arrow.PrimitiveTypes.Int64},
+}, nil)
+
+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 := 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)
+ }
+ }
+
+ return batches
+}
+
+func main() {
+ batches := GetPutData()
+
+ http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
+ hdrs := w.Header()
+ hdrs.Add("access-control-allow-origin", "http://localhost:8080")
Review Comment:
```suggestion
hdrs.Add("access-control-allow-origin", "http://localhost:8000")
```
--
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]