apache-arrow
Version:
Apache Arrow columnar in-memory format
78 lines (76 loc) • 2.54 kB
JavaScript
// automatically generated by the FlatBuffers compiler, do not modify
Object.defineProperty(exports, "__esModule", { value: true });
exports.Decimal = void 0;
const flatbuffers = require("flatbuffers");
/**
* Exact decimal value represented as an integer value in two's
* complement. Currently only 128-bit (16-byte) and 256-bit (32-byte) integers
* are used. The representation uses the endianness indicated
* in the Schema.
*/
class Decimal {
constructor() {
this.bb = null;
this.bb_pos = 0;
}
__init(i, bb) {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsDecimal(bb, obj) {
return (obj || new Decimal()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsDecimal(bb, obj) {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new Decimal()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
/**
* Total number of decimal digits
*/
precision() {
const offset = this.bb.__offset(this.bb_pos, 4);
return offset ? this.bb.readInt32(this.bb_pos + offset) : 0;
}
/**
* Number of digits after the decimal point "."
*/
scale() {
const offset = this.bb.__offset(this.bb_pos, 6);
return offset ? this.bb.readInt32(this.bb_pos + offset) : 0;
}
/**
* Number of bits per value. The only accepted widths are 128 and 256.
* We use bitWidth for consistency with Int::bitWidth.
*/
bitWidth() {
const offset = this.bb.__offset(this.bb_pos, 8);
return offset ? this.bb.readInt32(this.bb_pos + offset) : 128;
}
static startDecimal(builder) {
builder.startObject(3);
}
static addPrecision(builder, precision) {
builder.addFieldInt32(0, precision, 0);
}
static addScale(builder, scale) {
builder.addFieldInt32(1, scale, 0);
}
static addBitWidth(builder, bitWidth) {
builder.addFieldInt32(2, bitWidth, 128);
}
static endDecimal(builder) {
const offset = builder.endObject();
return offset;
}
static createDecimal(builder, precision, scale, bitWidth) {
Decimal.startDecimal(builder);
Decimal.addPrecision(builder, precision);
Decimal.addScale(builder, scale);
Decimal.addBitWidth(builder, bitWidth);
return Decimal.endDecimal(builder);
}
}
exports.Decimal = Decimal;
//# sourceMappingURL=decimal.js.map
;