From eded0b647f295877c71d3538585d5dff3ce4b3cd Mon Sep 17 00:00:00 2001 From: Dominik Moritz Date: Wed, 2 Oct 2024 22:26:34 -0400 Subject: [PATCH] GH-44246: [JS] encourage more efficient APIs in the examples --- js/README.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/js/README.md b/js/README.md index f3dd3fef890..140fa77f209 100644 --- a/js/README.md +++ b/js/README.md @@ -52,7 +52,7 @@ import { tableFromIPC } from 'apache-arrow'; const arrow = readFileSync('simple.arrow'); const table = tableFromIPC(arrow); -console.table(table.toArray()); +console.table([...table]); /* foo, bar, baz @@ -64,6 +64,20 @@ null, null, null */ ``` +The most efficient way to work with an Arrow `Table` is to access the column Vectors (which you can get with `getChild` and `getChildAt`). + +```js +table.getChildAt(0).get(0); // 1 +``` + +If you need to access the rows, you can iterate over the table and access a row proxy. + +```js +for (const row of table) { + console.log(row); +} +``` + ### Create a Table when the Arrow file is split across buffers ```js