|
| 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 | +% The address of the HTTP server that |
| 19 | +% returns Arrow IPC Stream responses. |
| 20 | +server = "http://localhost:8008"; |
| 21 | + |
| 22 | +% Diagnostic output. |
| 23 | +disp("Reading Arrow IPC Stream from " + server + "..."); |
| 24 | + |
| 25 | +% Start timing. |
| 26 | +tic; |
| 27 | + |
| 28 | +% Make an HTTP GET request to the local server |
| 29 | +% to fetch an Arrow IPC Stream and read all the |
| 30 | +% data into memory as a byte (uint8) array. |
| 31 | +options = weboptions(ContentType="binary"); |
| 32 | +bytes = webread(server, options); |
| 33 | + |
| 34 | +% Construct an Arrow RecordBatchStreamReader from the in-memory bytes. |
| 35 | +reader = arrow.io.ipc.RecordBatchStreamReader.fromBytes(bytes); |
| 36 | + |
| 37 | +% Read an Arrow table from the in-memory bytes. |
| 38 | +arrowTable = reader.readTable(); |
| 39 | + |
| 40 | +% Stop timing. |
| 41 | +time = toc; |
| 42 | +% Round elapsed time to two decimal places. |
| 43 | +time = round(time, 2); |
| 44 | + |
| 45 | +% Number of bytes received. |
| 46 | +nbytes = length(bytes); |
| 47 | + |
| 48 | +% Diagnostic output. |
| 49 | +disp("DONE ✔"); |
| 50 | +disp("---------------"); |
| 51 | +disp("Results") |
| 52 | +disp("---------------"); |
| 53 | +disp("Time (s): " + sprintf("%.2f", time)); |
| 54 | +disp("Num Bytes: " + string(nbytes)); |
| 55 | +disp("Num Rows:" + string(arrowTable.NumRows)); |
| 56 | +disp("Num Columns:" + string(arrowTable.NumColumns)); |
0 commit comments