apache-arrow
Version:
Apache Arrow columnar in-memory format
103 lines (101 loc) • 3.89 kB
JavaScript
"use strict";
// automatically generated by the FlatBuffers compiler, do not modify
Object.defineProperty(exports, "__esModule", { value: true });
exports.RecordBatch = void 0;
const tslib_1 = require("tslib");
const flatbuffers = tslib_1.__importStar(require("flatbuffers"));
const body_compression_js_1 = require("./body-compression.js");
const buffer_js_1 = require("./buffer.js");
const field_node_js_1 = require("./field-node.js");
/**
* A data header describing the shared memory layout of a "record" or "row"
* batch. Some systems call this a "row batch" internally and others a "record
* batch".
*/
class RecordBatch {
constructor() {
this.bb = null;
this.bb_pos = 0;
}
__init(i, bb) {
this.bb_pos = i;
this.bb = bb;
return this;
}
static getRootAsRecordBatch(bb, obj) {
return (obj || new RecordBatch()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
static getSizePrefixedRootAsRecordBatch(bb, obj) {
bb.setPosition(bb.position() + flatbuffers.SIZE_PREFIX_LENGTH);
return (obj || new RecordBatch()).__init(bb.readInt32(bb.position()) + bb.position(), bb);
}
/**
* number of records / rows. The arrays in the batch should all have this
* length
*/
length() {
const offset = this.bb.__offset(this.bb_pos, 4);
return offset ? this.bb.readInt64(this.bb_pos + offset) : this.bb.createLong(0, 0);
}
/**
* Nodes correspond to the pre-ordered flattened logical schema
*/
nodes(index, obj) {
const offset = this.bb.__offset(this.bb_pos, 6);
return offset ? (obj || new field_node_js_1.FieldNode()).__init(this.bb.__vector(this.bb_pos + offset) + index * 16, this.bb) : null;
}
nodesLength() {
const offset = this.bb.__offset(this.bb_pos, 6);
return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
}
/**
* Buffers correspond to the pre-ordered flattened buffer tree
*
* The number of buffers appended to this list depends on the schema. For
* example, most primitive arrays will have 2 buffers, 1 for the validity
* bitmap and 1 for the values. For struct arrays, there will only be a
* single buffer for the validity (nulls) bitmap
*/
buffers(index, obj) {
const offset = this.bb.__offset(this.bb_pos, 8);
return offset ? (obj || new buffer_js_1.Buffer()).__init(this.bb.__vector(this.bb_pos + offset) + index * 16, this.bb) : null;
}
buffersLength() {
const offset = this.bb.__offset(this.bb_pos, 8);
return offset ? this.bb.__vector_len(this.bb_pos + offset) : 0;
}
/**
* Optional compression of the message body
*/
compression(obj) {
const offset = this.bb.__offset(this.bb_pos, 10);
return offset ? (obj || new body_compression_js_1.BodyCompression()).__init(this.bb.__indirect(this.bb_pos + offset), this.bb) : null;
}
static startRecordBatch(builder) {
builder.startObject(4);
}
static addLength(builder, length) {
builder.addFieldInt64(0, length, builder.createLong(0, 0));
}
static addNodes(builder, nodesOffset) {
builder.addFieldOffset(1, nodesOffset, 0);
}
static startNodesVector(builder, numElems) {
builder.startVector(16, numElems, 8);
}
static addBuffers(builder, buffersOffset) {
builder.addFieldOffset(2, buffersOffset, 0);
}
static startBuffersVector(builder, numElems) {
builder.startVector(16, numElems, 8);
}
static addCompression(builder, compressionOffset) {
builder.addFieldOffset(3, compressionOffset, 0);
}
static endRecordBatch(builder) {
const offset = builder.endObject();
return offset;
}
}
exports.RecordBatch = RecordBatch;
//# sourceMappingURL=record-batch.js.map