Skip to content

Commit

Permalink
Use parseData not parseVector for children (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
kylebarron authored Oct 31, 2023
1 parent 8587a32 commit ea78af1
Showing 1 changed file with 6 additions and 20 deletions.
26 changes: 6 additions & 20 deletions src/vector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ export function parseData<T extends DataType>(
}

const ptrToChildrenPtrs = dataView.getUint32(ptr + 44, true);
const children: arrow.Vector[] = new Array(Number(nChildren));
const children: arrow.Data[] = new Array(Number(nChildren));
for (let i = 0; i < nChildren; i++) {
children[i] = parseVector(
children[i] = parseData(
buffer,
dataView.getUint32(ptrToChildrenPtrs + i * 4, true),
dataType.children[i].type,
Expand Down Expand Up @@ -389,17 +389,14 @@ export function parseData<T extends DataType>(
)
: new Int32Array(dataView.buffer, offsetsPtr, length + 1);

assert(children[0].data.length === 1);
let childData = children[0].data[0];

return arrow.makeData({
type: dataType,
offset,
length,
nullCount,
nullBitmap,
valueOffsets,
child: childData,
child: children[0],
});
}

Expand All @@ -422,9 +419,6 @@ export function parseData<T extends DataType>(
valueOffsets[i] = Number(originalValueOffsets[i]);
}

assert(children[0].data.length === 1);
let childData = children[0].data[0];

// @ts-expect-error The return type is inferred wrong because we're coercing from a LargeList to
// a List
return arrow.makeData({
Expand All @@ -434,7 +428,7 @@ export function parseData<T extends DataType>(
nullCount,
nullBitmap,
valueOffsets,
child: childData,
child: children[0],
});
}

Expand All @@ -443,35 +437,27 @@ export function parseData<T extends DataType>(
const [validityPtr] = bufferPtrs;
const nullBitmap = parseNullBitmap(dataView.buffer, validityPtr, copy);

assert(children[0].data.length === 1);
let childData = children[0].data[0];

return arrow.makeData({
type: dataType,
offset,
length,
nullCount,
nullBitmap,
child: childData,
child: children[0],
});
}

if (DataType.isStruct(dataType)) {
const [validityPtr] = bufferPtrs;
const nullBitmap = parseNullBitmap(dataView.buffer, validityPtr, copy);

let childData = children.map((child) => {
assert(child.data.length === 1);
return child.data[0];
});

return arrow.makeData({
type: dataType,
offset,
length,
nullCount,
nullBitmap,
children: childData,
children,
});
}

Expand Down

0 comments on commit ea78af1

Please sign in to comment.