Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
kylebarron committed Jan 31, 2024
1 parent 679ee7e commit 9a20129
Showing 1 changed file with 47 additions and 47 deletions.
94 changes: 47 additions & 47 deletions src/vector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export function parseVector<T extends DataType>(
buffer: ArrayBuffer,
ptr: number,
dataType: T,
copy: boolean = true
copy: boolean = true,
): arrow.Vector<T> {
const data = parseData(buffer, ptr, dataType, copy);
return arrow.makeVector(data);
Expand All @@ -51,7 +51,7 @@ export function parseData<T extends DataType>(
buffer: ArrayBuffer,
ptr: number,
dataType: T,
copy: boolean = true
copy: boolean = true,
): arrow.Data<T> {
const dataView = new DataView(buffer);

Expand All @@ -77,7 +77,7 @@ export function parseData<T extends DataType>(
buffer,
dataView.getUint32(ptrToChildrenPtrs + i * 4, true),
dataType.children[i].type,
copy
copy,
);
}

Expand Down Expand Up @@ -166,7 +166,7 @@ function parseDataContent<T extends DataType>({
dataView.buffer,
validityPtr,
length,
copy
copy,
);
const byteLength = (length * dataType.bitWidth) / 8;
const data = copy
Expand All @@ -188,7 +188,7 @@ function parseDataContent<T extends DataType>({
dataView.buffer,
validityPtr,
length,
copy
copy,
);
// bitwidth doesn't exist on float types I guess
const byteLength = length * dataType.ArrayType.BYTES_PER_ELEMENT;
Expand All @@ -211,7 +211,7 @@ function parseDataContent<T extends DataType>({
dataView.buffer,
validityPtr,
length,
copy
copy,
);

// Boolean arrays are bit-packed. This means the byte length should be the number of elements,
Expand All @@ -237,7 +237,7 @@ function parseDataContent<T extends DataType>({
dataView.buffer,
validityPtr,
length,
copy
copy,
);
const byteLength = (length * dataType.bitWidth) / 8;
const data = copy
Expand All @@ -259,13 +259,13 @@ function parseDataContent<T extends DataType>({
dataView.buffer,
validityPtr,
length,
copy
copy,
);

let byteWidth = getDateByteWidth(dataType);
const data = copy
? new dataType.ArrayType(
copyBuffer(dataView.buffer, dataPtr, length * byteWidth)
copyBuffer(dataView.buffer, dataPtr, length * byteWidth),
)
: new dataType.ArrayType(dataView.buffer, dataPtr, length);
return arrow.makeData({
Expand All @@ -284,7 +284,7 @@ function parseDataContent<T extends DataType>({
dataView.buffer,
validityPtr,
length,
copy
copy,
);
const byteLength = (length * dataType.bitWidth) / 8;
const data = copy
Expand All @@ -306,13 +306,13 @@ function parseDataContent<T extends DataType>({
dataView.buffer,
validityPtr,
length,
copy
copy,
);

let byteWidth = getTimeByteWidth(dataType);
const data = copy
? new dataType.ArrayType(
copyBuffer(dataView.buffer, dataPtr, length * byteWidth)
copyBuffer(dataView.buffer, dataPtr, length * byteWidth),
)
: new dataType.ArrayType(dataView.buffer, dataPtr, length);
return arrow.makeData({
Expand All @@ -331,13 +331,13 @@ function parseDataContent<T extends DataType>({
dataView.buffer,
validityPtr,
length,
copy
copy,
);

let byteWidth = getTimeByteWidth(dataType);
const data = copy
? new dataType.ArrayType(
copyBuffer(dataView.buffer, dataPtr, length * byteWidth)
copyBuffer(dataView.buffer, dataPtr, length * byteWidth),
)
: new dataType.ArrayType(dataView.buffer, dataPtr, length);
return arrow.makeData({
Expand All @@ -356,7 +356,7 @@ function parseDataContent<T extends DataType>({
dataView.buffer,
validityPtr,
length,
copy
copy,
);

// What's the bitwidth here?
Expand All @@ -382,16 +382,16 @@ function parseDataContent<T extends DataType>({
dataView.buffer,
validityPtr,
length,
copy
copy,
);

const valueOffsets = copy
? new Int32Array(
copyBuffer(
dataView.buffer,
offsetsPtr,
(length + 1) * Int32Array.BYTES_PER_ELEMENT
)
(length + 1) * Int32Array.BYTES_PER_ELEMENT,
),
)
: new Int32Array(dataView.buffer, offsetsPtr, length + 1);

Expand Down Expand Up @@ -419,14 +419,14 @@ function parseDataContent<T extends DataType>({
dataView.buffer,
validityPtr,
length,
copy
copy,
);

// The original value offsets are an Int64Array, which Arrow JS does not yet support natively
const originalValueOffsets = new BigInt64Array(
dataView.buffer,
offsetsPtr,
length + 1
length + 1,
);

// Copy the Int64Array to an Int32Array
Expand Down Expand Up @@ -462,16 +462,16 @@ function parseDataContent<T extends DataType>({
dataView.buffer,
validityPtr,
length,
copy
copy,
);

const valueOffsets = copy
? new Int32Array(
copyBuffer(
dataView.buffer,
offsetsPtr,
(length + 1) * Int32Array.BYTES_PER_ELEMENT
)
(length + 1) * Int32Array.BYTES_PER_ELEMENT,
),
)
: new Int32Array(dataView.buffer, offsetsPtr, length + 1);

Expand Down Expand Up @@ -499,14 +499,14 @@ function parseDataContent<T extends DataType>({
dataView.buffer,
validityPtr,
length,
copy
copy,
);

// The original value offsets are an Int64Array, which Arrow JS does not yet support natively
const originalValueOffsets = new BigInt64Array(
dataView.buffer,
offsetsPtr,
length + 1
length + 1,
);

// Copy the Int64Array to an Int32Array
Expand Down Expand Up @@ -542,16 +542,16 @@ function parseDataContent<T extends DataType>({
dataView.buffer,
validityPtr,
length,
copy
copy,
);
const data = copy
? new dataType.ArrayType(
copyBuffer(dataView.buffer, dataPtr, length * dataType.byteWidth)
copyBuffer(dataView.buffer, dataPtr, length * dataType.byteWidth),
)
: new dataType.ArrayType(
dataView.buffer,
dataPtr,
length * dataType.byteWidth
length * dataType.byteWidth,
);
return arrow.makeData({
type: dataType,
Expand All @@ -570,15 +570,15 @@ function parseDataContent<T extends DataType>({
dataView.buffer,
validityPtr,
length,
copy
copy,
);
const valueOffsets = copy
? new Int32Array(
copyBuffer(
dataView.buffer,
offsetsPtr,
(length + 1) * Int32Array.BYTES_PER_ELEMENT
)
(length + 1) * Int32Array.BYTES_PER_ELEMENT,
),
)
: new Int32Array(dataView.buffer, offsetsPtr, length + 1);

Expand All @@ -601,14 +601,14 @@ function parseDataContent<T extends DataType>({
dataView.buffer,
validityPtr,
length,
copy
copy,
);

// The original value offsets are an Int64Array, which Arrow JS does not yet support natively
const originalValueOffsets = new BigInt64Array(
dataView.buffer,
offsetsPtr,
length + 1
length + 1,
);

// Copy the Int64Array to an Int32Array
Expand Down Expand Up @@ -637,7 +637,7 @@ function parseDataContent<T extends DataType>({
dataView.buffer,
validityPtr,
length,
copy
copy,
);

return arrow.makeData({
Expand All @@ -656,7 +656,7 @@ function parseDataContent<T extends DataType>({
dataView.buffer,
validityPtr,
length,
copy
copy,
);

return arrow.makeData({
Expand All @@ -676,15 +676,15 @@ function parseDataContent<T extends DataType>({
dataView.buffer,
validityPtr,
length,
copy
copy,
);
const valueOffsets = copy
? new Int32Array(
copyBuffer(
dataView.buffer,
offsetsPtr,
(length + 1) * Int32Array.BYTES_PER_ELEMENT
)
(length + 1) * Int32Array.BYTES_PER_ELEMENT,
),
)
: new Int32Array(dataView.buffer, offsetsPtr, length + 1);

Expand All @@ -707,8 +707,8 @@ function parseDataContent<T extends DataType>({
copyBuffer(
dataView.buffer,
offsetsPtr,
(length + 1) * Int32Array.BYTES_PER_ELEMENT
)
(length + 1) * Int32Array.BYTES_PER_ELEMENT,
),
)
: new Int32Array(dataView.buffer, offsetsPtr, length + 1);

Expand All @@ -717,8 +717,8 @@ function parseDataContent<T extends DataType>({
copyBuffer(
dataView.buffer,
typeIdsPtr,
(length + 1) * Int8Array.BYTES_PER_ELEMENT
)
(length + 1) * Int8Array.BYTES_PER_ELEMENT,
),
)
: new Int8Array(dataView.buffer, typeIdsPtr, length + 1);

Expand All @@ -741,8 +741,8 @@ function parseDataContent<T extends DataType>({
copyBuffer(
dataView.buffer,
typeIdsPtr,
(length + 1) * Int8Array.BYTES_PER_ELEMENT
)
(length + 1) * Int8Array.BYTES_PER_ELEMENT,
),
)
: new Int8Array(dataView.buffer, typeIdsPtr, length + 1);

Expand Down Expand Up @@ -770,7 +770,7 @@ function getDateByteWidth(type: arrow.Date_): number {
}

function getTimeByteWidth(
type: arrow.Time | arrow.Timestamp | arrow.Duration
type: arrow.Time | arrow.Timestamp | arrow.Duration,
): number {
switch (type.unit) {
case arrow.TimeUnit.SECOND:
Expand All @@ -787,7 +787,7 @@ function parseNullBitmap(
buffer: ArrayBuffer,
validityPtr: number,
length: number,
copy: boolean
copy: boolean,
): NullBitmap {
if (validityPtr === 0) {
return null;
Expand All @@ -807,7 +807,7 @@ function parseNullBitmap(
function copyBuffer(
buffer: ArrayBuffer,
ptr: number,
byteLength: number
byteLength: number,
): ArrayBuffer {
const newBuffer = new ArrayBuffer(byteLength);
const newBufferView = new Uint8Array(newBuffer);
Expand Down

0 comments on commit 9a20129

Please sign in to comment.