You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by we...@apache.org on 2018/07/25 18:03:33 UTC
[arrow] branch master updated: ARROW-2777: [JS] Friendlier
onboarding readme
This is an automated email from the ASF dual-hosted git repository.
wesm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/arrow.git
The following commit(s) were added to refs/heads/master by this push:
new 16bbdd4 ARROW-2777: [JS] Friendlier onboarding readme
16bbdd4 is described below
commit 16bbdd47a73782588090872adf54a11b9c95aa6e
Author: lmeyerov <lm...@gmail.com>
AuthorDate: Wed Jul 25 14:03:25 2018 -0400
ARROW-2777: [JS] Friendlier onboarding readme
-- Link slack, tutorials, unit tests
-- Add example of creating a Table from pure JS
Author: lmeyerov <lm...@gmail.com>
Closes #2200 from lmeyerov/patch-3 and squashes the following commits:
dda23d35 <lmeyerov> fix(remove slack from js docs)
a2ddcb17 <lmeyerov> docs(js - getting started)
---
js/README.md | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/js/README.md b/js/README.md
index 76fae6d..b02ff34 100644
--- a/js/README.md
+++ b/js/README.md
@@ -39,6 +39,7 @@ Apache Arrow is the emerging standard for large in-memory columnar data ([Spark]
# Usage
+
## Get a table from an Arrow file on disk (in IPC format)
```es6
@@ -83,6 +84,31 @@ console.log(table.toString());
*/
```
+## Create a Table from JavaScript arrays
+
+```es6
+const fields = [{
+ name: 'precipitation',
+ type: { name: 'floatingpoint', precision: 'SINGLE'},
+ nullable: false, children: []
+ }, {
+ name: 'date',
+ type: { name: 'date', unit: 'MILLISECOND' },
+ nullable: false, children: []
+ }];
+const rainAmounts = Array.from({length: LENGTH}, () => Number((Math.random() * 20).toFixed(1)));
+const rainDates = Array.from({length: LENGTH}, (_, i) => Date.now() - 1000 * 60 * 60 * 24 * i);
+
+const LENGTH = 2000;
+const rainfall = arrow.Table.from({
+ schema: { fields: fields },
+ batches: [{
+ count: LENGTH,
+ columns: [
+ {name: "precipitation", count: LENGTH, VALIDITY: [], DATA: rainAmounts },
+ {name: "date", count: LENGTH, VALIDITY: [], DATA: rainDates } ] }] })
+```
+
## Load data with `fetch`
```es6
@@ -158,6 +184,12 @@ Index, origin_city
*/
```
+# Tutorials and examples
+
+* [JavaScript Introduction to Arrow][5]
+* [Manipulating flat arrays arrow-style][6]
+* [/js/test/unit](https://github.com/apache/arrow/tree/master/js/test/unit) - Unit tests for Table and Vector
+
# Getting involved
See [develop.md](https://github.com/apache/arrow/blob/master/develop.md)
@@ -242,3 +274,5 @@ Full list of broader Apache Arrow [projects & organizations](https://github.com/
[2]: https://github.com/apache/arrow/tree/master/format
[3]: https://issues.apache.org/jira/browse/ARROW
[4]: https://github.com/apache/arrow
+[5]: https://beta.observablehq.com/@theneuralbit/introduction-to-apache-arrow
+[6]: https://beta.observablehq.com/@lmeyerov/manipulating-flat-arrays-arrow-style