Skip to content

Commit bcd3eee

Browse files
committed
fix(parquet): Types to fix parquet module build
1 parent 040153c commit bcd3eee

File tree

5 files changed

+21
-21
lines changed

5 files changed

+21
-21
lines changed

modules/parquet/src/parquetjs/codecs/plain.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ function encodeValues_BYTE_ARRAY(values: Buffer[]): Buffer {
194194
let buf_pos = 0;
195195
for (let i = 0; i < values.length; i++) {
196196
buf.writeUInt32LE(values[i].length, buf_pos);
197-
values[i].copy(buf, buf_pos + 4);
197+
values[i].copy(buf as Uint8Array, buf_pos + 4);
198198
buf_pos += 4 + values[i].length;
199199
}
200200
return buf;
@@ -222,7 +222,7 @@ function encodeValues_FIXED_LEN_BYTE_ARRAY(values: Buffer[], opts: ParquetCodecO
222222
throw new Error(`invalid value for FIXED_LEN_BYTE_ARRAY: ${values[i]}`);
223223
}
224224
}
225-
return Buffer.concat(values);
225+
return Buffer.concat(values as Uint8Array[]);
226226
}
227227

228228
function decodeValues_FIXED_LEN_BYTE_ARRAY(

modules/parquet/src/parquetjs/codecs/rle.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export function encodeValues(
4040
if (repeats === 0 && run.length % 8 === 0 && values[i] === values[i + 1]) {
4141
// If we have any data in runs we need to encode them
4242
if (run.length) {
43-
buf = Buffer.concat([buf, encodeRunBitpacked(run, opts)]);
43+
buf = Buffer.concat([buf, encodeRunBitpacked(run, opts)] as Uint8Array[]);
4444
run = [];
4545
}
4646
repeats = 1;
@@ -49,17 +49,17 @@ export function encodeValues(
4949
} else {
5050
// If values changes we need to post any previous repeated values
5151
if (repeats) {
52-
buf = Buffer.concat([buf, encodeRunRepeated(values[i - 1], repeats, opts)]);
52+
buf = Buffer.concat([buf, encodeRunRepeated(values[i - 1], repeats, opts)] as Uint8Array[]);
5353
repeats = 0;
5454
}
5555
run.push(values[i]);
5656
}
5757
}
5858

5959
if (repeats) {
60-
buf = Buffer.concat([buf, encodeRunRepeated(values[values.length - 1], repeats, opts)]);
60+
buf = Buffer.concat([buf, encodeRunRepeated(values[values.length - 1], repeats, opts)] as Uint8Array[]);
6161
} else if (run.length) {
62-
buf = Buffer.concat([buf, encodeRunBitpacked(run, opts)]);
62+
buf = Buffer.concat([buf, encodeRunBitpacked(run, opts)] as Uint8Array[]);
6363
}
6464

6565
if (opts.disableEnvelope) {
@@ -70,7 +70,7 @@ export function encodeValues(
7070

7171
// @ts-ignore buffer polyfill
7272
envelope.writeUInt32LE(buf.length, undefined);
73-
buf.copy(envelope, 4);
73+
buf.copy(envelope as Uint8Array, 4);
7474

7575
return envelope;
7676
}
@@ -175,7 +175,7 @@ function encodeRunBitpacked(values: number[], opts: ParquetCodecOptions): Buffer
175175
}
176176
}
177177

178-
return Buffer.concat([Buffer.from(varint.encode(((values.length / 8) << 1) | 1)), buf]);
178+
return Buffer.concat([Buffer.from(varint.encode(((values.length / 8) << 1) | 1)), buf] as Uint8Array[]);
179179
}
180180

181181
function encodeRunRepeated(value: number, count: number, opts: ParquetCodecOptions): Buffer {
@@ -190,5 +190,5 @@ function encodeRunRepeated(value: number, count: number, opts: ParquetCodecOptio
190190
value >> 8; // TODO - this looks wrong
191191
}
192192

193-
return Buffer.concat([Buffer.from(varint.encode(count << 1)), buf]);
193+
return Buffer.concat([Buffer.from(varint.encode(count << 1)), buf] as Uint8Array[]);
194194
}

modules/parquet/src/parquetjs/encoder/parquet-encoder.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -376,15 +376,15 @@ async function encodeDataPage(
376376
page: Buffer;
377377
}> {
378378
/* encode repetition and definition levels */
379-
let rLevelsBuf: Buffer<ArrayBufferLike> = Buffer.alloc(0);
379+
let rLevelsBuf: Buffer = Buffer.alloc(0);
380380
if (column.rLevelMax > 0) {
381381
rLevelsBuf = encodeValues(PARQUET_RDLVL_TYPE, PARQUET_RDLVL_ENCODING, data.rlevels, {
382382
bitWidth: getBitWidth(column.rLevelMax)
383383
// disableEnvelope: false
384384
});
385385
}
386386

387-
let dLevelsBuf: Buffer<ArrayBufferLike> = Buffer.alloc(0);
387+
let dLevelsBuf: Buffer = Buffer.alloc(0);
388388
if (column.dLevelMax > 0) {
389389
dLevelsBuf = encodeValues(PARQUET_RDLVL_TYPE, PARQUET_RDLVL_ENCODING, data.dlevels, {
390390
bitWidth: getBitWidth(column.dLevelMax)
@@ -398,7 +398,7 @@ async function encodeDataPage(
398398
bitWidth: column.typeLength
399399
});
400400

401-
const dataBuf = Buffer.concat([rLevelsBuf, dLevelsBuf, valuesBuf]);
401+
const dataBuf = Buffer.concat([rLevelsBuf, dLevelsBuf, valuesBuf] as Uint8Array[]);
402402

403403
// compression = column.compression === 'UNCOMPRESSED' ? (compression || 'UNCOMPRESSED') : column.compression;
404404
const compressedBuf = await Compression.deflate(column.compression!, dataBuf);
@@ -418,7 +418,7 @@ async function encodeDataPage(
418418

419419
/* concat page header, repetition and definition levels and values */
420420
const headerBuf = serializeThrift(header);
421-
const page = Buffer.concat([headerBuf, compressedBuf]);
421+
const page = Buffer.concat([headerBuf, compressedBuf] as Uint8Array[]);
422422

423423
return {header, headerSize: headerBuf.length, page};
424424
}
@@ -445,15 +445,15 @@ async function encodeDataPageV2(
445445
const compressedBuf = await Compression.deflate(column.compression!, valuesBuf);
446446

447447
/* encode repetition and definition levels */
448-
let rLevelsBuf: Buffer<ArrayBufferLike> = Buffer.alloc(0);
448+
let rLevelsBuf: Buffer = Buffer.alloc(0);
449449
if (column.rLevelMax > 0) {
450450
rLevelsBuf = encodeValues(PARQUET_RDLVL_TYPE, PARQUET_RDLVL_ENCODING, data.rlevels, {
451451
bitWidth: getBitWidth(column.rLevelMax),
452452
disableEnvelope: true
453453
});
454454
}
455455

456-
let dLevelsBuf: Buffer<ArrayBufferLike> = Buffer.alloc(0);
456+
let dLevelsBuf: Buffer = Buffer.alloc(0);
457457
if (column.dLevelMax > 0) {
458458
dLevelsBuf = encodeValues(PARQUET_RDLVL_TYPE, PARQUET_RDLVL_ENCODING, data.dlevels, {
459459
bitWidth: getBitWidth(column.dLevelMax),
@@ -479,7 +479,7 @@ async function encodeDataPageV2(
479479

480480
/* concat page header, repetition and definition levels and values */
481481
const headerBuf = serializeThrift(header);
482-
const page = Buffer.concat([headerBuf, rLevelsBuf, dLevelsBuf, compressedBuf]);
482+
const page = Buffer.concat([headerBuf, rLevelsBuf, dLevelsBuf, compressedBuf] as Uint8Array[]);
483483
return {header, headerSize: headerBuf.length, page};
484484
}
485485

@@ -536,7 +536,7 @@ async function encodeColumnChunk(
536536

537537
/* concat metadata header and data pages */
538538
const metadataOffset = baseOffset + pageBuf.length;
539-
const body = Buffer.concat([pageBuf, serializeThrift(metadata)]);
539+
const body = Buffer.concat([pageBuf, serializeThrift(metadata)] as Uint8Array[]);
540540
return {body, metadata, metadataOffset};
541541
}
542542

@@ -573,7 +573,7 @@ async function encodeRowGroup(
573573
metadata.columns.push(cchunk);
574574
metadata.total_byte_size = new Int64(Number(metadata.total_byte_size) + cchunkData.body.length);
575575

576-
body = Buffer.concat([body, cchunkData.body]);
576+
body = Buffer.concat([body, cchunkData.body] as Uint8Array[]);
577577
}
578578

579579
return {body, metadata};
@@ -638,7 +638,7 @@ function encodeFooter(
638638
const metadataEncoded = serializeThrift(metadata);
639639
const footerEncoded = Buffer.alloc(metadataEncoded.length + 8);
640640

641-
metadataEncoded.copy(footerEncoded);
641+
metadataEncoded.copy(footerEncoded as Uint8Array);
642642
footerEncoded.writeUInt32LE(metadataEncoded.length, metadataEncoded.length);
643643
footerEncoded.write(PARQUET_MAGIC, metadataEncoded.length + 4);
644644
return footerEncoded;

modules/parquet/src/parquetjs/parser/decoders.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ async function decodeDictionaryPage(
440440
);
441441

442442
dictCursor = {
443-
buffer: valuesBuf as unknown as Buffer<ArrayBuffer>,
443+
buffer: valuesBuf as unknown as Buffer,
444444
offset: 0,
445445
size: valuesBuf.length
446446
};

modules/parquet/src/parquetjs/utils/read-utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export function serializeThrift(obj: any): Buffer {
3030
obj.write(protocol);
3131
transport.flush();
3232

33-
return Buffer.concat(output);
33+
return Buffer.concat(output as Uint8Array[]);
3434
}
3535

3636
export function decodeThrift(obj: any, buf: Buffer, offset?: number) {

0 commit comments

Comments
 (0)