kou commented on code in PR #19:
URL: https://github.com/apache/arrow-experiments/pull/19#discussion_r1524112067


##########
http/get_simple/ruby/client/.gitignore:
##########
@@ -0,0 +1 @@
+Gemfile.lock

Review Comment:
   * Could you add the license header?
   * Could you prepend `/` to `Gemfile.lock` path to avoid needless pattern 
match? 
   
   ```suggestion
   # Licensed to the Apache Software Foundation (ASF) under one
   # or more contributor license agreements.  See the NOTICE file
   # distributed with this work for additional information
   # regarding copyright ownership.  The ASF licenses this file
   # to you under the Apache License, Version 2.0 (the
   # "License"); you may not use this file except in compliance
   # with the License.  You may obtain a copy of the License at
   #
   #   http://www.apache.org/licenses/LICENSE-2.0
   #
   # Unless required by applicable law or agreed to in writing,
   # software distributed under the License is distributed on an
   # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   # KIND, either express or implied.  See the License for the
   # specific language governing permissions and limitations
   # under the License.
   
   /Gemfile.lock
   ```
   



##########
http/get_simple/ruby/client/client.rb:
##########
@@ -0,0 +1,61 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+require "open-uri"
+require "arrow"
+
+host = "localhost"
+port = 8008
+url = URI("http://#{host}:#{port}";)
+
+# Non-streaming
+url.open do |input|
+  input = Arrow::BufferInputStream.new(input.read)
+  reader = Arrow::RecordBatchStreamReader.new(input)
+  p reader.schema
+  p reader.read_all
+end

Review Comment:
   Sorry. open-uri isn't suitable for this case. It saves large response body 
to temporary file. It's not expected.
   
   Could you use `Net::HTTP` directly?
   
   ```suggestion
   require "net/http"
   
   require "arrow"
   
   host = "localhost"
   port = 8008
   uri = URI("http://#{host}:#{port}";)
   
   start = Time.now
   arrows_data = Net::HTTP.get(uri)
   input = Arrow::BufferInputStream.new(arrows_data)
   reader = Arrow::RecordBatchStreamReader.new(input)
   schema = reader.schema
   table = reader.read_all
   elapsed_time = Time.now - start
   
   n_received_record_batches = table[0].data.n_chunks
   puts("#{n_received_record_batches} record batches received")
   puts("%.2f seconds elapsed" % elapsed_time)
   ```



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