Skip to content

Commit

Permalink
fix: Fix build from typed array to multiple batches.
Browse files Browse the repository at this point in the history
  • Loading branch information
jheer committed Sep 16, 2024
1 parent 3c09442 commit cc50c71
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/build/column-from-array.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ function columnFromTypedArray(values, { maxBatchRows, useBigInt }) {
const batches = [];
const batchType = isInt64ArrayType(arrayType) && !useBigInt ? Int64Batch : DirectBatch;
const add = (start, end) => batches.push(new batchType({
length: limit,
length: end - start,
nullCount: 0,
type,
validity: new uint8Array(0),
values: values.subarray(start, end)
}));

Expand Down
7 changes: 7 additions & 0 deletions test/column-from-array-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,13 @@ describe('columnFromArray', () => {
assert.strictEqual(col.nullCount, 10);
assert.strictEqual(col.data.length, 4);
assert.deepStrictEqual(col.data.map(d => d.length), [10, 10, 10, 3]);

const floats = Float64Array.from({ length: 10 }, Math.random);
const tcol = test(floats, null, { maxBatchRows: 4 });
assert.strictEqual(tcol.nullCount, 0);
assert.strictEqual(tcol.length, 10);
assert.strictEqual(tcol.data.length, 3);
assert.deepStrictEqual(tcol.data.map(d => d.length), [4, 4, 2]);
});

it('builds columns from typed arrays', () => {
Expand Down

0 comments on commit cc50c71

Please sign in to comment.