File tree Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Expand file tree Collapse file tree 1 file changed +53
-0
lines changed Original file line number Diff line number Diff line change 1+ package main
2+
3+ import (
4+ "fmt"
5+ "net/http"
6+ "time"
7+
8+ "github.com/apache/arrow/go/v15/arrow"
9+ "github.com/apache/arrow/go/v15/arrow/ipc"
10+ "github.com/apache/arrow/go/v15/arrow/memory"
11+ )
12+
13+ func main () {
14+ start := time .Now ()
15+ resp , err := http .Get ("http://localhost:8000" )
16+ if err != nil {
17+ panic (err )
18+ }
19+
20+ if resp .StatusCode != http .StatusOK {
21+ panic (fmt .Errorf ("got non-200 status: %d" , resp .StatusCode ))
22+ }
23+ defer resp .Body .Close ()
24+
25+ rdr , err := ipc .NewReader (resp .Body , ipc .WithAllocator (memory .DefaultAllocator ))
26+ if err != nil {
27+ panic (err )
28+ }
29+ defer rdr .Release ()
30+
31+ batches := make ([]arrow.Record , 0 )
32+ defer func () {
33+ for _ , b := range batches {
34+ b .Release ()
35+ }
36+ }()
37+
38+ for rdr .Next () {
39+ rec := rdr .Record ()
40+ rec .Retain ()
41+ batches = append (batches , rec )
42+ }
43+
44+ if rdr .Err () != nil {
45+ panic (rdr .Err ())
46+ }
47+
48+ execTime := time .Since (start )
49+
50+ fmt .Println (resp .ContentLength , " bytes recieved" )
51+ fmt .Println (len (batches ), " record batches received" )
52+ fmt .Println (execTime .Seconds (), " seconds elapsed" )
53+ }
You can’t perform that action at this time.
0 commit comments