UNPKG

apache-arrow

Version:

Apache Arrow columnar in-memory format

82 lines (80 loc) 3.29 kB
"use strict"; // automatically generated by the FlatBuffers compiler, do not modify Object.defineProperty(exports, "__esModule", { value: true }); exports.DictionaryEncoding = void 0; const flatbuffers = require("flatbuffers"); const dictionary_kind_js_1 = require("./dictionary-kind.js"); const int_js_1 = require("./int.js"); class DictionaryEncoding { constructor() { this.bb = null; this.bb_pos = 0; } __init(i, bb) { this.bb_pos = i; this.bb = bb; return this; } static getRootAsDictionaryEncoding(bb, obj) { return (obj || new DictionaryEncoding()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } static getSizePrefixedRootAsDictionaryEncoding(bb, obj) { bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH); return (obj || new DictionaryEncoding()).__init(bb.readInt32(bb.position()) + bb.position(), bb); } /** * The known dictionary id in the application where this data is used. In * the file or streaming formats, the dictionary ids are found in the * DictionaryBatch messages */ id() { const offset = this.bb.__offset(this.bb_pos, 4); return offset ? this.bb.readInt64(this.bb_pos + offset) : BigInt('0'); } /** * The dictionary indices are constrained to be non-negative integers. If * this field is null, the indices must be signed int32. To maximize * cross-language compatibility and performance, implementations are * recommended to prefer signed integer types over unsigned integer types * and to avoid uint64 indices unless they are required by an application. */ indexType(obj) { const offset = this.bb.__offset(this.bb_pos, 6); return offset ? (obj || new int_js_1.Int()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null; } /** * By default, dictionaries are not ordered, or the order does not have * semantic meaning. In some statistical, applications, dictionary-encoding * is used to represent ordered categorical data, and we provide a way to * preserve that metadata here */ isOrdered() { const offset = this.bb.__offset(this.bb_pos, 8); return offset ? !!this.bb.readInt8(this.bb_pos + offset) : false; } dictionaryKind() { const offset = this.bb.__offset(this.bb_pos, 10); return offset ? this.bb.readInt16(this.bb_pos + offset) : dictionary_kind_js_1.DictionaryKind.DenseArray; } static startDictionaryEncoding(builder) { builder.startObject(4); } static addId(builder, id) { builder.addFieldInt64(0, id, BigInt('0')); } static addIndexType(builder, indexTypeOffset) { builder.addFieldOffset(1, indexTypeOffset, 0); } static addIsOrdered(builder, isOrdered) { builder.addFieldInt8(2, +isOrdered, +false); } static addDictionaryKind(builder, dictionaryKind) { builder.addFieldInt16(3, dictionaryKind, dictionary_kind_js_1.DictionaryKind.DenseArray); } static endDictionaryEncoding(builder) { const offset = builder.endObject(); return offset; } } exports.DictionaryEncoding = DictionaryEncoding; //# sourceMappingURL=dictionary-encoding.js.map