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


##########
http/examples/get/client.go:
##########
@@ -0,0 +1,53 @@
+package main
+
+import (
+       "fmt"
+       "net/http"
+       "time"
+
+       "github.com/apache/arrow/go/v15/arrow"
+       "github.com/apache/arrow/go/v15/arrow/ipc"
+       "github.com/apache/arrow/go/v15/arrow/memory"
+)
+
+func main() {
+       start := time.Now()
+       resp, err := http.Get("http://localhost:8000";)
+       if err != nil {
+               panic(err)
+       }
+
+       if resp.StatusCode != http.StatusOK {
+               panic(fmt.Errorf("got non-200 status: %d", resp.StatusCode))
+       }
+       defer resp.Body.Close()
+
+       rdr, err := ipc.NewReader(resp.Body, 
ipc.WithAllocator(memory.DefaultAllocator))
+       if err != nil {
+               panic(err)
+       }
+       defer rdr.Release()
+
+       batches := make([]arrow.Record, 0)
+       defer func() {
+               for _, b := range batches {
+                       b.Release()
+               }
+       }()
+
+       for rdr.Next() {
+               rec := rdr.Record()
+               rec.Retain()
+               batches = append(batches, rec)
+       }
+
+       if rdr.Err() != nil {
+               panic(rdr.Err())
+       }
+
+       execTime := time.Since(start)
+
+       fmt.Println(resp.ContentLength, " bytes recieved")

Review Comment:
   we can probably wrap the `resp.Body` with a simple counter pass through or a 
bufio object buffering the bytes allowing us to count them as we pass them to 
the `ipc` reader.



-- 
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