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


##########
http/examples/get/client.js:
##########
@@ -0,0 +1,29 @@
+const Arrow = require('apache-arrow');
+
+const url = 'http://localhost:8000';
+
+async function getArrowData(url) {
+  try {
+    const response = await fetch(url);
+    const table = await Arrow.tableFromIPC(response);
+    return table;
+  } catch (error) {
+    console.error('Error:', error.message);
+    throw error;
+  }
+}
+
+async function runExample(url) {
+  const startTime = new Date();
+  try {
+    const table = await getArrowData(url);
+    const endTime = new Date();
+    const duration = (endTime - startTime) / 1000;
+    console.log(`${table.batches.length} record batches received`);
+    console.log(`${duration.toFixed(2)} seconds elapsed`);
+  } catch (error) {
+    console.error('Error:', error.message);
+  }
+}

Review Comment:
   I think we can use this simpler version without extra functions and 
variables. 



##########
http/examples/get/client.js:
##########
@@ -0,0 +1,29 @@
+const Arrow = require('apache-arrow');
+
+const url = 'http://localhost:8000';
+
+async function getArrowData(url) {
+  try {
+    const response = await fetch(url);
+    const table = await Arrow.tableFromIPC(response);
+    return table;
+  } catch (error) {
+    console.error('Error:', error.message);
+    throw error;
+  }
+}
+
+async function runExample(url) {
+  const startTime = new Date();
+  try {
+    const table = await getArrowData(url);
+    const endTime = new Date();
+    const duration = (endTime - startTime) / 1000;
+    console.log(`${table.batches.length} record batches received`);
+    console.log(`${duration.toFixed(2)} seconds elapsed`);
+  } catch (error) {
+    console.error('Error:', error.message);
+  }
+}

Review Comment:
   ```suggestion
   async function runExample(url) {
     const startTime = new Date();
     
     const table = await Arrow.tableFromIPC(fetch(url));
     
     const duration = (new Date() - startTime) / 1000;
     console.log(`${table.batches.length} record batches received`);
     console.log(`${duration.toFixed(2)} seconds elapsed`);
   }
   ```



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