This is an automated email from the ASF dual-hosted git repository. ptaylor 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 fd0e7ba ARROW-4738: [JS] NullVector should include a null data buffer fd0e7ba is described below commit fd0e7ba6b53b2a9f9e432c200aecc66ae3e69b58 Author: ptaylor <paul.e.tay...@me.com> AuthorDate: Sat Mar 2 12:36:26 2019 -0800 ARROW-4738: [JS] NullVector should include a null data buffer Closes https://issues.apache.org/jira/browse/ARROW-4738 and https://issues.apache.org/jira/browse/ARROW-3667 Author: ptaylor <paul.e.tay...@me.com> Closes #3787 from trxcllnt/js/write-null-array-data-buffer and squashes the following commits: d8456c14 <ptaylor> read and write a zero-length data buffer for NullVector --- js/src/data.ts | 2 +- js/src/visitor/jsonvectorassembler.ts | 2 +- js/src/visitor/vectorassembler.ts | 4 +++- js/src/visitor/vectorloader.ts | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/js/src/data.ts b/js/src/data.ts index 2c63b78..de7cd7e 100644 --- a/js/src/data.ts +++ b/js/src/data.ts @@ -174,7 +174,7 @@ export class Data<T extends DataType = DataType> { // Convenience methods for creating Data instances for each of the Arrow Vector types // /** @nocollapse */ - public static Null<T extends Null>(type: T, offset: number, length: number, nullCount: number, nullBitmap: NullBuffer) { + public static Null<T extends Null>(type: T, offset: number, length: number, nullCount: number, nullBitmap: NullBuffer, _data?: NullBuffer) { return new Data(type, offset, length, nullCount, [undefined, undefined, toUint8Array(nullBitmap)]); } /** @nocollapse */ diff --git a/js/src/visitor/jsonvectorassembler.ts b/js/src/visitor/jsonvectorassembler.ts index 291a057..9d71ea4 100644 --- a/js/src/visitor/jsonvectorassembler.ts +++ b/js/src/visitor/jsonvectorassembler.ts @@ -77,7 +77,7 @@ export class JSONVectorAssembler extends Visitor { ...super.visit(Vector.new(data.clone(type, offset, length, 0, buffers))) }; } - public visitNull() { return {}; } + public visitNull() { return { 'DATA': [] }; } public visitBool<T extends Bool>({ values, offset, length }: VType<T>) { return { 'DATA': [...iterateBits(values, offset, length, null, getBool)] }; } diff --git a/js/src/visitor/vectorassembler.ts b/js/src/visitor/vectorassembler.ts index 3cbcb4e..169a159 100644 --- a/js/src/visitor/vectorassembler.ts +++ b/js/src/visitor/vectorassembler.ts @@ -82,7 +82,9 @@ export class VectorAssembler extends Visitor { return super.visit(vector); } - public visitNull<T extends Null>(_nullV: VType<T>) { return this; } + public visitNull<T extends Null>(_nullV: VType<T>) { + return addBuffer.call(this, new Uint8Array(0)); + } public visitDictionary<T extends Dictionary>(vector: VType<T>) { // Assemble the indices here, Dictionary assembled separately. return this.visit(vector.indices); diff --git a/js/src/visitor/vectorloader.ts b/js/src/visitor/vectorloader.ts index dad8f0c..f21ca44 100644 --- a/js/src/visitor/vectorloader.ts +++ b/js/src/visitor/vectorloader.ts @@ -49,7 +49,7 @@ export class VectorLoader extends Visitor { return super.visit(node instanceof Field ? node.type : node); } - public visitNull <T extends type.Null> (type: T, { length, nullCount } = this.nextFieldNode()) { return Data.Null(type, 0, length, nullCount, this.readNullBitmap(type, nullCount)); } + public visitNull <T extends type.Null> (type: T, { length, nullCount } = this.nextFieldNode()) { return Data.Null(type, 0, length, nullCount, this.readNullBitmap(type, nullCount), this.readData(type)); } public visitBool <T extends type.Bool> (type: T, { length, nullCount } = this.nextFieldNode()) { return Data.Bool(type, 0, length, nullCount, this.readNullBitmap(type, nullCount), this.readData(type)); } public visitInt <T extends type.Int> (type: T, { length, nullCount } = this.nextFieldNode()) { return Data.Int(type, 0, length, nullCount, this.readNullBitmap(type, nullCount), this.readData(type)); } public visitFloat <T extends type.Float> (type: T, { length, nullCount } = this.nextFieldNode()) { return Data.Float(type, 0, length, nullCount, this.readNullBitmap(type, nullCount), this.readData(type)); }