File tree Expand file tree Collapse file tree 4 files changed +106
-0
lines changed
http/get_simple/ruby/client Expand file tree Collapse file tree 4 files changed +106
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ /Gemfile.lock
Original file line number Diff line number Diff line change
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ source "https://rubygems.org"
19
+
20
+ gem "red-arrow"
Original file line number Diff line number Diff line change
1
+ <!-- -
2
+ Licensed to the Apache Software Foundation (ASF) under one
3
+ or more contributor license agreements. See the NOTICE file
4
+ distributed with this work for additional information
5
+ regarding copyright ownership. The ASF licenses this file
6
+ to you under the Apache License, Version 2.0 (the
7
+ "License"); you may not use this file except in compliance
8
+ with the License. You may obtain a copy of the License at
9
+
10
+ http://www.apache.org/licenses/LICENSE-2.0
11
+
12
+ Unless required by applicable law or agreed to in writing,
13
+ software distributed under the License is distributed on an
14
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
+ KIND, either express or implied. See the License for the
16
+ specific language governing permissions and limitations
17
+ under the License.
18
+ -->
19
+
20
+ # HTTP GET Arrow Data: Simple Ruby Client Example
21
+
22
+ This directory contains a minimal example of an HTTP client implemented in Ruby.
23
+
24
+ The client:
25
+
26
+ 1 . Sends an HTTP GET request to a server.
27
+ 2 . Receives an HTTP 200 response from the server, with the response body containing an Arrow IPC stream of record batches.
28
+ 3 . Creates an Arrow table from the record batches.
29
+
30
+ To run this example, first start one of the server examples in the parent directory, then:
31
+
32
+ ``` sh
33
+ bundle install
34
+ bundle exec ruby client.rb
35
+ ```
Original file line number Diff line number Diff line change
1
+ # Licensed to the Apache Software Foundation (ASF) under one
2
+ # or more contributor license agreements. See the NOTICE file
3
+ # distributed with this work for additional information
4
+ # regarding copyright ownership. The ASF licenses this file
5
+ # to you under the Apache License, Version 2.0 (the
6
+ # "License"); you may not use this file except in compliance
7
+ # with the License. You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing,
12
+ # software distributed under the License is distributed on an
13
+ # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14
+ # KIND, either express or implied. See the License for the
15
+ # specific language governing permissions and limitations
16
+ # under the License.
17
+
18
+ require "net/http"
19
+ require "arrow"
20
+
21
+ uri = URI ( "http://localhost:8008" )
22
+
23
+ start = Time . now
24
+ arrows_data = Net ::HTTP . get ( uri )
25
+ input = Arrow ::BufferInputStream . new ( arrows_data )
26
+ reader = Arrow ::RecordBatchStreamReader . new ( input )
27
+ schema = reader . schema
28
+ table = reader . read_all
29
+ elapsed_time = Time . now - start
30
+
31
+ n_received_record_batches = table [ 0 ] . data . n_chunks
32
+ puts ( "#{ n_received_record_batches } record batches received" )
33
+ puts ( "%.2f seconds elapsed" % elapsed_time )
You can’t perform that action at this time.
0 commit comments