UNPKG

apache-arrow

Version:
129 lines (127 loc) 4.81 kB
// automatically generated by the FlatBuffers compiler, do not modify import * as flatbuffers from 'flatbuffers'; import { Endianness } from './endianness.mjs'; import { Field } from './field.mjs'; import { KeyValue } from './key-value.mjs'; /** * ---------------------------------------------------------------------- * A Schema describes the columns in a row batch */ export class Schema { constructor() { this.bb = null; this.bb_pos = 0; } __init(i, bb) { this.bb_pos = i; this.bb = bb; return this; } static getRootAsSchema(bb, obj) { return (obj || new Schema()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } static getSizePrefixedRootAsSchema(bb, obj) { bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); return (obj || new Schema()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } /** * endianness of the buffer * it is Little Endian by default * if endianness doesn't match the underlying system then the vectors need to be converted */ endianness() { const offset = this.bb.__offset(this.bb_pos, 4); return offset ? this.bb.readInt16(this.bb_pos + offset) : Endianness.Little; } fields(index, obj) { const offset = this.bb.__offset(this.bb_pos, 6); return offset ? (obj || new Field()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; } fieldsLength() { const offset = this.bb.__offset(this.bb_pos, 6); return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; } customMetadata(index, obj) { const offset = this.bb.__offset(this.bb_pos, 8); return offset ? (obj || new KeyValue()).__init(this.bb.__indirect(this.bb.__vector(this.bb_pos + offset) + index * 4), this.bb) : null; } customMetadataLength() { const offset = this.bb.__offset(this.bb_pos, 8); return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; } /** * Features used in the stream/file. */ features(index) { const offset = this.bb.__offset(this.bb_pos, 10); return offset ? this.bb.readInt64(this.bb.__vector(this.bb_pos + offset) + index * 8) : this.bb.createLong(0, 0); } featuresLength() { const offset = this.bb.__offset(this.bb_pos, 10); return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0; } static startSchema(builder) { builder.startObject(4); } static addEndianness(builder, endianness) { builder.addFieldInt16(0, endianness, Endianness.Little); } static addFields(builder, fieldsOffset) { builder.addFieldOffset(1, fieldsOffset, 0); } static createFieldsVector(builder, data) { builder.startVector(4, data.length, 4); for (let i = data.length - 1; i >= 0; i--) { builder.addOffset(data[i]); } return builder.endVector(); } static startFieldsVector(builder, numElems) { builder.startVector(4, numElems, 4); } static addCustomMetadata(builder, customMetadataOffset) { builder.addFieldOffset(2, customMetadataOffset, 0); } static createCustomMetadataVector(builder, data) { builder.startVector(4, data.length, 4); for (let i = data.length - 1; i >= 0; i--) { builder.addOffset(data[i]); } return builder.endVector(); } static startCustomMetadataVector(builder, numElems) { builder.startVector(4, numElems, 4); } static addFeatures(builder, featuresOffset) { builder.addFieldOffset(3, featuresOffset, 0); } static createFeaturesVector(builder, data) { builder.startVector(8, data.length, 8); for (let i = data.length - 1; i >= 0; i--) { builder.addInt64(data[i]); } return builder.endVector(); } static startFeaturesVector(builder, numElems) { builder.startVector(8, numElems, 8); } static endSchema(builder) { const offset = builder.endObject(); return offset; } static finishSchemaBuffer(builder, offset) { builder.finish(offset); } static finishSizePrefixedSchemaBuffer(builder, offset) { builder.finish(offset, undefined, true); } static createSchema(builder, endianness, fieldsOffset, customMetadataOffset, featuresOffset) { Schema.startSchema(builder); Schema.addEndianness(builder, endianness); Schema.addFields(builder, fieldsOffset); Schema.addCustomMetadata(builder, customMetadataOffset); Schema.addFeatures(builder, featuresOffset); return Schema.endSchema(builder); } } //# sourceMappingURL=schema.mjs.map