Skip to content

Commit

Permalink
GH-33681: [JS] Update flatbuffers (#33682)
Browse files Browse the repository at this point in the history
Closes #33681

Merge after #33680 

After this change, we require bigint support. 

Authored-by: Dominik Moritz <domoritz@gmail.com>
Signed-off-by: Dominik Moritz <domoritz@gmail.com>
  • Loading branch information
domoritz committed Jan 17, 2023
1 parent 85a111f commit 627caf3
Show file tree
Hide file tree
Showing 72 changed files with 316 additions and 208 deletions.
1 change: 0 additions & 1 deletion js/gulp/package-task.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ const createTypeScriptPackageJson = (target, format) => (orig) => ({
sideEffects: false,
esm: { mode: `auto`, sourceMap: true },
dependencies: {
'@types/flatbuffers': '*',
'@types/node': '*',
...orig.dependencies
}
Expand Down
2 changes: 1 addition & 1 deletion js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"@types/pad-left": "2.1.1",
"command-line-args": "5.2.1",
"command-line-usage": "6.1.3",
"flatbuffers": "2.0.4",
"flatbuffers": "23.1.4",
"json-bignum": "^0.0.3",
"pad-left": "^2.1.0",
"tslib": "^2.4.1"
Expand Down
5 changes: 1 addition & 4 deletions js/src/builder/valid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import { DataType } from '../type.js';
import { valueToString } from '../util/pretty.js';
import { BigIntAvailable } from '../util/compat.js';

/**
* Dynamically compile the null values into an `isValid()` function whose
Expand Down Expand Up @@ -70,8 +69,6 @@ export function createIsValidFunction<T extends DataType = any, TNull = any>(nul
function valueToCase(x: any) {
if (typeof x !== 'bigint') {
return valueToString(x);
} else if (BigIntAvailable) {
return `${valueToString(x)}n`;
}
return `"${valueToString(x)}"`;
return `${valueToString(x)}n`;
}
4 changes: 2 additions & 2 deletions js/src/factories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ function inferType(value: readonly unknown[]): dtypes.DataType {
}
continue;
}
throw new TypeError('Unable to infer Vector type from input values, explicit type declaration expected');
throw new TypeError('Unable to infer Vector type from input values, explicit type declaration expected.');
}

if (numbersCount + nullsCount === value.length) {
Expand Down Expand Up @@ -165,7 +165,7 @@ function inferType(value: readonly unknown[]): dtypes.DataType {
return new dtypes.Struct([...fields.values()]);
}

throw new TypeError('Unable to infer Vector type from input values, explicit type declaration expected');
throw new TypeError('Unable to infer Vector type from input values, explicit type declaration expected.');
}

/**
Expand Down
7 changes: 7 additions & 0 deletions js/src/fb/File_generated.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// automatically generated by the FlatBuffers compiler, do not modify

export { Block } from './block.js';
export { Footer } from './footer.js';
export { KeyValue } from './key-value.js';
export { MetadataVersion } from './metadata-version.js';
export { Schema } from './schema.js';
16 changes: 16 additions & 0 deletions js/src/fb/Message_generated.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// automatically generated by the FlatBuffers compiler, do not modify

export { BodyCompression } from './body-compression.js';
export { BodyCompressionMethod } from './body-compression-method.js';
export { Buffer } from './buffer.js';
export { CompressionType } from './compression-type.js';
export { DictionaryBatch } from './dictionary-batch.js';
export { FieldNode } from './field-node.js';
export { KeyValue } from './key-value.js';
export { Message } from './message.js';
export { MessageHeader, unionToMessageHeader, unionListToMessageHeader } from './message-header.js';
export { MetadataVersion } from './metadata-version.js';
export { RecordBatch } from './record-batch.js';
export { Schema } from './schema.js';
export { SparseTensor } from './sparse-tensor.js';
export { Tensor } from './tensor.js';
36 changes: 36 additions & 0 deletions js/src/fb/Schema_generated.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// automatically generated by the FlatBuffers compiler, do not modify

export { Binary } from './binary.js';
export { Bool } from './bool.js';
export { Date } from './date.js';
export { DateUnit } from './date-unit.js';
export { Decimal } from './decimal.js';
export { DictionaryEncoding } from './dictionary-encoding.js';
export { DictionaryKind } from './dictionary-kind.js';
export { Duration } from './duration.js';
export { Endianness } from './endianness.js';
export { Field } from './field.js';
export { FixedSizeBinary } from './fixed-size-binary.js';
export { FixedSizeList } from './fixed-size-list.js';
export { FloatingPoint } from './floating-point.js';
export { Int } from './int.js';
export { Interval } from './interval.js';
export { IntervalUnit } from './interval-unit.js';
export { KeyValue } from './key-value.js';
export { LargeBinary } from './large-binary.js';
export { LargeList } from './large-list.js';
export { LargeUtf8 } from './large-utf8.js';
export { List } from './list.js';
export { Map } from './map.js';
export { Null } from './null.js';
export { Precision } from './precision.js';
export { RunEndEncoded } from './run-end-encoded.js';
export { Schema } from './schema.js';
export { Struct_ } from './struct-.js';
export { Time } from './time.js';
export { TimeUnit } from './time-unit.js';
export { Timestamp } from './timestamp.js';
export { Type, unionToType, unionListToType } from './type.js';
export { Union } from './union.js';
export { UnionMode } from './union-mode.js';
export { Utf8 } from './utf8.js';
12 changes: 12 additions & 0 deletions js/src/fb/SparseTensor_generated.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// automatically generated by the FlatBuffers compiler, do not modify

export { Buffer } from './buffer.js';
export { Int } from './int.js';
export { SparseMatrixCompressedAxis } from './sparse-matrix-compressed-axis.js';
export { SparseMatrixIndexCSX } from './sparse-matrix-index-csx.js';
export { SparseTensor } from './sparse-tensor.js';
export { SparseTensorIndex, unionToSparseTensorIndex, unionListToSparseTensorIndex } from './sparse-tensor-index.js';
export { SparseTensorIndexCOO } from './sparse-tensor-index-coo.js';
export { SparseTensorIndexCSF } from './sparse-tensor-index-csf.js';
export { TensorDim } from './tensor-dim.js';
export { Type, unionToType, unionListToType } from './type.js';
6 changes: 6 additions & 0 deletions js/src/fb/Tensor_generated.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// automatically generated by the FlatBuffers compiler, do not modify

export { Buffer } from './buffer.js';
export { Tensor } from './tensor.js';
export { TensorDim } from './tensor-dim.js';
export { Type, unionToType, unionListToType } from './type.js';
2 changes: 1 addition & 1 deletion js/src/fb/binary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as flatbuffers from 'flatbuffers';
export class Binary {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Binary {
__init(i:number, bb:flatbuffers.ByteBuffer):Binary {
this.bb_pos = i;
this.bb = bb;
return this;
Expand Down
12 changes: 6 additions & 6 deletions js/src/fb/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as flatbuffers from 'flatbuffers';
export class Block {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Block {
__init(i:number, bb:flatbuffers.ByteBuffer):Block {
this.bb_pos = i;
this.bb = bb;
return this;
Expand All @@ -14,7 +14,7 @@ __init(i:number, bb:flatbuffers.ByteBuffer):Block {
/**
* Index to the start of the RecordBlock (note this is past the Message header)
*/
offset():flatbuffers.Long {
offset():bigint {
return this.bb!.readInt64(this.bb_pos);
}

Expand All @@ -29,20 +29,20 @@ metaDataLength():number {
* Length of the data (this is aligned so there can be a gap between this and
* the metadata).
*/
bodyLength():flatbuffers.Long {
bodyLength():bigint {
return this.bb!.readInt64(this.bb_pos + 16);
}

static sizeOf():number {
return 24;
}

static createBlock(builder:flatbuffers.Builder, offset: flatbuffers.Long, metaDataLength: number, bodyLength: flatbuffers.Long):flatbuffers.Offset {
static createBlock(builder:flatbuffers.Builder, offset: bigint, metaDataLength: number, bodyLength: bigint):flatbuffers.Offset {
builder.prep(8, 24);
builder.writeInt64(bodyLength);
builder.writeInt64(BigInt(bodyLength ?? 0));
builder.pad(4);
builder.writeInt32(metaDataLength);
builder.writeInt64(offset);
builder.writeInt64(BigInt(offset ?? 0));
return builder.offset();
}

Expand Down
3 changes: 1 addition & 2 deletions js/src/fb/body-compression-method.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* strategies for compressing the IPC message body (like whole-body
* compression rather than buffer-level) in the future
*/
export enum BodyCompressionMethod{
export enum BodyCompressionMethod {
/**
* Each constituent buffer is first compressed with the indicated
* compressor, and then written with the uncompressed length in the first 8
Expand All @@ -17,4 +17,3 @@ export enum BodyCompressionMethod{
*/
BUFFER = 0
}

2 changes: 1 addition & 1 deletion js/src/fb/body-compression.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { CompressionType } from './compression-type.js';
export class BodyCompression {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):BodyCompression {
__init(i:number, bb:flatbuffers.ByteBuffer):BodyCompression {
this.bb_pos = i;
this.bb = bb;
return this;
Expand Down
2 changes: 1 addition & 1 deletion js/src/fb/bool.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import * as flatbuffers from 'flatbuffers';
export class Bool {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Bool {
__init(i:number, bb:flatbuffers.ByteBuffer):Bool {
this.bb_pos = i;
this.bb = bb;
return this;
Expand Down
12 changes: 6 additions & 6 deletions js/src/fb/buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import * as flatbuffers from 'flatbuffers';
export class Buffer {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Buffer {
__init(i:number, bb:flatbuffers.ByteBuffer):Buffer {
this.bb_pos = i;
this.bb = bb;
return this;
Expand All @@ -19,7 +19,7 @@ __init(i:number, bb:flatbuffers.ByteBuffer):Buffer {
* The relative offset into the shared memory page where the bytes for this
* buffer starts
*/
offset():flatbuffers.Long {
offset():bigint {
return this.bb!.readInt64(this.bb_pos);
}

Expand All @@ -30,18 +30,18 @@ offset():flatbuffers.Long {
* after a buffer, but such padding bytes do not need to be accounted for in
* the size here.
*/
length():flatbuffers.Long {
length():bigint {
return this.bb!.readInt64(this.bb_pos + 8);
}

static sizeOf():number {
return 16;
}

static createBuffer(builder:flatbuffers.Builder, offset: flatbuffers.Long, length: flatbuffers.Long):flatbuffers.Offset {
static createBuffer(builder:flatbuffers.Builder, offset: bigint, length: bigint):flatbuffers.Offset {
builder.prep(8, 16);
builder.writeInt64(length);
builder.writeInt64(offset);
builder.writeInt64(BigInt(length ?? 0));
builder.writeInt64(BigInt(offset ?? 0));
return builder.offset();
}

Expand Down
3 changes: 1 addition & 2 deletions js/src/fb/compression-type.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// automatically generated by the FlatBuffers compiler, do not modify

export enum CompressionType{
export enum CompressionType {
LZ4_FRAME = 0,
ZSTD = 1
}

3 changes: 1 addition & 2 deletions js/src/fb/date-unit.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// automatically generated by the FlatBuffers compiler, do not modify

export enum DateUnit{
export enum DateUnit {
DAY = 0,
MILLISECOND = 1
}

2 changes: 1 addition & 1 deletion js/src/fb/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { DateUnit } from './date-unit.js';
export class Date {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Date {
__init(i:number, bb:flatbuffers.ByteBuffer):Date {
this.bb_pos = i;
this.bb = bb;
return this;
Expand Down
2 changes: 1 addition & 1 deletion js/src/fb/decimal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import * as flatbuffers from 'flatbuffers';
export class Decimal {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Decimal {
__init(i:number, bb:flatbuffers.ByteBuffer):Decimal {
this.bb_pos = i;
this.bb = bb;
return this;
Expand Down
10 changes: 5 additions & 5 deletions js/src/fb/dictionary-batch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { RecordBatch } from './record-batch.js';
export class DictionaryBatch {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):DictionaryBatch {
__init(i:number, bb:flatbuffers.ByteBuffer):DictionaryBatch {
this.bb_pos = i;
this.bb = bb;
return this;
Expand All @@ -31,9 +31,9 @@ static getSizePrefixedRootAsDictionaryBatch(bb:flatbuffers.ByteBuffer, obj?:Dict
return (obj || new DictionaryBatch()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}

id():flatbuffers.Long {
id():bigint {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? this.bb!.readInt64(this.bb_pos + offset) : this.bb!.createLong(0, 0);
return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
}

data(obj?:RecordBatch):RecordBatch|null {
Expand All @@ -55,8 +55,8 @@ static startDictionaryBatch(builder:flatbuffers.Builder) {
builder.startObject(3);
}

static addId(builder:flatbuffers.Builder, id:flatbuffers.Long) {
builder.addFieldInt64(0, id, builder.createLong(0, 0));
static addId(builder:flatbuffers.Builder, id:bigint) {
builder.addFieldInt64(0, id, BigInt('0'));
}

static addData(builder:flatbuffers.Builder, dataOffset:flatbuffers.Offset) {
Expand Down
10 changes: 5 additions & 5 deletions js/src/fb/dictionary-encoding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Int } from './int.js';
export class DictionaryEncoding {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):DictionaryEncoding {
__init(i:number, bb:flatbuffers.ByteBuffer):DictionaryEncoding {
this.bb_pos = i;
this.bb = bb;
return this;
Expand All @@ -29,9 +29,9 @@ static getSizePrefixedRootAsDictionaryEncoding(bb:flatbuffers.ByteBuffer, obj?:D
* the file or streaming formats, the dictionary ids are found in the
* DictionaryBatch messages
*/
id():flatbuffers.Long {
id():bigint {
const offset = this.bb!.__offset(this.bb_pos, 4);
return offset ? this.bb!.readInt64(this.bb_pos + offset) : this.bb!.createLong(0, 0);
return offset ? this.bb!.readInt64(this.bb_pos + offset) : BigInt('0');
}

/**
Expand Down Expand Up @@ -66,8 +66,8 @@ static startDictionaryEncoding(builder:flatbuffers.Builder) {
builder.startObject(4);
}

static addId(builder:flatbuffers.Builder, id:flatbuffers.Long) {
builder.addFieldInt64(0, id, builder.createLong(0, 0));
static addId(builder:flatbuffers.Builder, id:bigint) {
builder.addFieldInt64(0, id, BigInt('0'));
}

static addIndexType(builder:flatbuffers.Builder, indexTypeOffset:flatbuffers.Offset) {
Expand Down
3 changes: 1 addition & 2 deletions js/src/fb/dictionary-kind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
* Dictionaries might be explicit maps between integers and values
* allowing for non-contiguous index values
*/
export enum DictionaryKind{
export enum DictionaryKind {
DenseArray = 0
}

2 changes: 1 addition & 1 deletion js/src/fb/duration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { TimeUnit } from './time-unit.js';
export class Duration {
bb: flatbuffers.ByteBuffer|null = null;
bb_pos = 0;
__init(i:number, bb:flatbuffers.ByteBuffer):Duration {
__init(i:number, bb:flatbuffers.ByteBuffer):Duration {
this.bb_pos = i;
this.bb = bb;
return this;
Expand Down
3 changes: 1 addition & 2 deletions js/src/fb/endianness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
* ----------------------------------------------------------------------
* Endianness of the platform producing the data
*/
export enum Endianness{
export enum Endianness {
Little = 0,
Big = 1
}

0 comments on commit 627caf3

Please sign in to comment.