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/06/04 03:59:59 UTC

[arrow] branch master updated: ARROW-2640: [JS] Write schema metadata

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 9aa7c52  ARROW-2640: [JS] Write schema metadata
9aa7c52 is described below

commit 9aa7c52bebc6e7ca95f59cbe73608570d2ee5bcb
Author: ptaylor <pa...@me.com>
AuthorDate: Sun Jun 3 23:59:55 2018 -0400

    ARROW-2640: [JS] Write schema metadata
    
    Forgot to serialize schema metadata. Resolves https://issues.apache.org/jira/browse/ARROW-2640
    
    Author: ptaylor <pa...@me.com>
    
    Closes #2086 from trxcllnt/js-write-schema-metadata and squashes the following commits:
    
    953232c0 <ptaylor> write schema metadata
---
 js/src/ipc/writer/binary.ts | 24 ++++++++++++++++++++++--
 1 file changed, 22 insertions(+), 2 deletions(-)

diff --git a/js/src/ipc/writer/binary.ts b/js/src/ipc/writer/binary.ts
index d8b1d7e..166d4b8 100644
--- a/js/src/ipc/writer/binary.ts
+++ b/js/src/ipc/writer/binary.ts
@@ -588,14 +588,34 @@ function writeMessage(b: Builder, node: Message) {
 }
 
 function writeSchema(b: Builder, node: Schema) {
+
     const fieldOffsets = node.fields.map((f) => writeField(b, f));
     const fieldsOffset =
         _Schema.startFieldsVector(b, fieldOffsets.length) ||
         _Schema.createFieldsVector(b, fieldOffsets);
+
+    let metadata: number | undefined = undefined;
+    if (node.metadata && node.metadata.size > 0) {
+        metadata = _Schema.createCustomMetadataVector(
+            b,
+            [...node.metadata].map(([k, v]) => {
+                const key = b.createString(`${k}`);
+                const val = b.createString(`${v}`);
+                return (
+                    _KeyValue.startKeyValue(b) ||
+                    _KeyValue.addKey(b, key) ||
+                    _KeyValue.addValue(b, val) ||
+                    _KeyValue.endKeyValue(b)
+                );
+            })
+        );
+    }
+
     return (
         _Schema.startSchema(b) ||
         _Schema.addFields(b, fieldsOffset) ||
         _Schema.addEndianness(b, platformIsLittleEndian ? _Endianness.Little : _Endianness.Big) ||
+        (metadata !== undefined && _Schema.addCustomMetadata(b, metadata)) ||
         _Schema.endSchema(b)
     );
 }
@@ -662,8 +682,8 @@ function writeField(b: Builder, node: Field) {
         metadata = _Field.createCustomMetadataVector(
             b,
             [...node.metadata].map(([k, v]) => {
-                const key = b.createString(k);
-                const val = b.createString(v);
+                const key = b.createString(`${k}`);
+                const val = b.createString(`${v}`);
                 return (
                     _KeyValue.startKeyValue(b) ||
                     _KeyValue.addKey(b, key) ||

-- 
To stop receiving notification emails like this one, please contact
wesm@apache.org.