Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
kylebarron committed Nov 22, 2023
1 parent c573733 commit 7f31556
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 47 deletions.
10 changes: 5 additions & 5 deletions src/field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export function parseField(buffer: ArrayBuffer, ptr: number): arrow.Field {
for (let i = 0; i < nChildren; i++) {
childrenFields[i] = parseField(
buffer,
dataView.getUint32(ptrToChildrenPtrs + i * 4, true)
dataView.getUint32(ptrToChildrenPtrs + i * 4, true),
);
}

Expand Down Expand Up @@ -194,7 +194,7 @@ function parseFlags(flag: bigint): Flags {
function parseNullTerminatedString(
dataView: DataView,
ptr: number,
maxBytesToRead: number = Infinity
maxBytesToRead: number = Infinity,
): string {
const maxPtr = Math.min(ptr + maxBytesToRead, dataView.byteLength);
let end = ptr;
Expand All @@ -213,7 +213,7 @@ function parseNullTerminatedString(
*/
function parseMetadata(
dataView: DataView,
ptr: number
ptr: number,
): Map<string, string> | null {
const numEntries = dataView.getInt32(ptr, true);
if (numEntries === 0) {
Expand All @@ -227,14 +227,14 @@ function parseMetadata(
const keyByteLength = dataView.getInt32(ptr, true);
ptr += 4;
const key = UTF8_DECODER.decode(
new Uint8Array(dataView.buffer, ptr, keyByteLength)
new Uint8Array(dataView.buffer, ptr, keyByteLength),
);
ptr += keyByteLength;

const valueByteLength = dataView.getInt32(ptr, true);
ptr += 4;
const value = UTF8_DECODER.decode(
new Uint8Array(dataView.buffer, ptr, valueByteLength)
new Uint8Array(dataView.buffer, ptr, valueByteLength),
);
ptr += valueByteLength;

Expand Down
2 changes: 1 addition & 1 deletion src/record-batch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export function parseRecordBatch(
buffer: ArrayBuffer,
arrayPtr: number,
schemaPtr: number,
copy: boolean = false
copy: boolean = false,
): arrow.RecordBatch {
const field = parseField(buffer, schemaPtr);
if (!isStructField(field)) {
Expand Down
82 changes: 41 additions & 41 deletions src/vector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export function parseVector<T extends DataType>(
buffer: ArrayBuffer,
ptr: number,
dataType: T,
copy: boolean = false
copy: boolean = false,
): arrow.Vector<T> {
const data = parseData(buffer, ptr, dataType, copy);
return arrow.makeVector(data);
Expand All @@ -26,7 +26,7 @@ export function parseData<T extends DataType>(
buffer: ArrayBuffer,
ptr: number,
dataType: T,
copy: boolean = false
copy: boolean = false,
): arrow.Data<T> {
const dataView = new DataView(buffer);

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

Expand All @@ -68,7 +68,7 @@ export function parseData<T extends DataType>(
dataView.buffer,
validityPtr,
length,
copy
copy,
);
const byteLength = (length * dataType.bitWidth) / 8;
const data = copy
Expand All @@ -90,7 +90,7 @@ export function parseData<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 @@ -113,7 +113,7 @@ export function parseData<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 @@ -139,7 +139,7 @@ export function parseData<T extends DataType>(
dataView.buffer,
validityPtr,
length,
copy
copy,
);
const byteLength = (length * dataType.bitWidth) / 8;
const data = copy
Expand All @@ -161,13 +161,13 @@ export function parseData<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 @@ -186,7 +186,7 @@ export function parseData<T extends DataType>(
dataView.buffer,
validityPtr,
length,
copy
copy,
);
const byteLength = (length * dataType.bitWidth) / 8;
const data = copy
Expand All @@ -208,13 +208,13 @@ export function parseData<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 @@ -233,7 +233,7 @@ export function parseData<T extends DataType>(
dataView.buffer,
validityPtr,
length,
copy
copy,
);

// What's the bitwidth here?
Expand All @@ -259,16 +259,16 @@ export function parseData<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 @@ -296,14 +296,14 @@ export function parseData<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 @@ -339,16 +339,16 @@ export function parseData<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 @@ -376,14 +376,14 @@ export function parseData<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 @@ -419,16 +419,16 @@ export function parseData<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 @@ -447,15 +447,15 @@ export function parseData<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 @@ -478,14 +478,14 @@ export function parseData<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 @@ -514,7 +514,7 @@ export function parseData<T extends DataType>(
dataView.buffer,
validityPtr,
length,
copy
copy,
);

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

return arrow.makeData({
Expand All @@ -554,8 +554,8 @@ export function parseData<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 @@ -564,8 +564,8 @@ export function parseData<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 @@ -588,8 +588,8 @@ export function parseData<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 @@ -633,7 +633,7 @@ function parseNullBitmap(
buffer: ArrayBuffer,
validityPtr: number,
length: number,
copy: boolean
copy: boolean,
): NullBitmap {
if (validityPtr === 0) {
return null;
Expand All @@ -653,7 +653,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 7f31556

Please sign in to comment.