@loaders.gl/parquet 4.4.0-alpha.9 → 4.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -376,7 +376,7 @@ async function encodeDataPage(
376
376
  page: Buffer;
377
377
  }> {
378
378
  /* encode repetition and definition levels */
379
- let rLevelsBuf = Buffer.alloc(0);
379
+ let rLevelsBuf: Buffer = Buffer.alloc(0);
380
380
  if (column.rLevelMax > 0) {
381
381
  rLevelsBuf = encodeValues(PARQUET_RDLVL_TYPE, PARQUET_RDLVL_ENCODING, data.rlevels, {
382
382
  bitWidth: getBitWidth(column.rLevelMax)
@@ -384,7 +384,7 @@ async function encodeDataPage(
384
384
  });
385
385
  }
386
386
 
387
- let dLevelsBuf = Buffer.alloc(0);
387
+ let dLevelsBuf: Buffer = Buffer.alloc(0);
388
388
  if (column.dLevelMax > 0) {
389
389
  dLevelsBuf = encodeValues(PARQUET_RDLVL_TYPE, PARQUET_RDLVL_ENCODING, data.dlevels, {
390
390
  bitWidth: getBitWidth(column.dLevelMax)
@@ -398,7 +398,7 @@ async function encodeDataPage(
398
398
  bitWidth: column.typeLength
399
399
  });
400
400
 
401
- const dataBuf = Buffer.concat([rLevelsBuf, dLevelsBuf, valuesBuf]);
401
+ const dataBuf = Buffer.concat([rLevelsBuf, dLevelsBuf, valuesBuf] as Uint8Array[]);
402
402
 
403
403
  // compression = column.compression === 'UNCOMPRESSED' ? (compression || 'UNCOMPRESSED') : column.compression;
404
404
  const compressedBuf = await Compression.deflate(column.compression!, dataBuf);
@@ -418,7 +418,7 @@ async function encodeDataPage(
418
418
 
419
419
  /* concat page header, repetition and definition levels and values */
420
420
  const headerBuf = serializeThrift(header);
421
- const page = Buffer.concat([headerBuf, compressedBuf]);
421
+ const page = Buffer.concat([headerBuf, compressedBuf] as Uint8Array[]);
422
422
 
423
423
  return {header, headerSize: headerBuf.length, page};
424
424
  }
@@ -445,7 +445,7 @@ async function encodeDataPageV2(
445
445
  const compressedBuf = await Compression.deflate(column.compression!, valuesBuf);
446
446
 
447
447
  /* encode repetition and definition levels */
448
- let rLevelsBuf = Buffer.alloc(0);
448
+ let rLevelsBuf: Buffer = Buffer.alloc(0);
449
449
  if (column.rLevelMax > 0) {
450
450
  rLevelsBuf = encodeValues(PARQUET_RDLVL_TYPE, PARQUET_RDLVL_ENCODING, data.rlevels, {
451
451
  bitWidth: getBitWidth(column.rLevelMax),
@@ -453,7 +453,7 @@ async function encodeDataPageV2(
453
453
  });
454
454
  }
455
455
 
456
- let dLevelsBuf = Buffer.alloc(0);
456
+ let dLevelsBuf: Buffer = Buffer.alloc(0);
457
457
  if (column.dLevelMax > 0) {
458
458
  dLevelsBuf = encodeValues(PARQUET_RDLVL_TYPE, PARQUET_RDLVL_ENCODING, data.dlevels, {
459
459
  bitWidth: getBitWidth(column.dLevelMax),
@@ -479,7 +479,7 @@ async function encodeDataPageV2(
479
479
 
480
480
  /* concat page header, repetition and definition levels and values */
481
481
  const headerBuf = serializeThrift(header);
482
- const page = Buffer.concat([headerBuf, rLevelsBuf, dLevelsBuf, compressedBuf]);
482
+ const page = Buffer.concat([headerBuf, rLevelsBuf, dLevelsBuf, compressedBuf] as Uint8Array[]);
483
483
  return {header, headerSize: headerBuf.length, page};
484
484
  }
485
485
 
@@ -536,7 +536,7 @@ async function encodeColumnChunk(
536
536
 
537
537
  /* concat metadata header and data pages */
538
538
  const metadataOffset = baseOffset + pageBuf.length;
539
- const body = Buffer.concat([pageBuf, serializeThrift(metadata)]);
539
+ const body = Buffer.concat([pageBuf, serializeThrift(metadata)] as Uint8Array[]);
540
540
  return {body, metadata, metadataOffset};
541
541
  }
542
542
 
@@ -573,7 +573,7 @@ async function encodeRowGroup(
573
573
  metadata.columns.push(cchunk);
574
574
  metadata.total_byte_size = new Int64(Number(metadata.total_byte_size) + cchunkData.body.length);
575
575
 
576
- body = Buffer.concat([body, cchunkData.body]);
576
+ body = Buffer.concat([body, cchunkData.body] as Uint8Array[]);
577
577
  }
578
578
 
579
579
  return {body, metadata};
@@ -638,7 +638,7 @@ function encodeFooter(
638
638
  const metadataEncoded = serializeThrift(metadata);
639
639
  const footerEncoded = Buffer.alloc(metadataEncoded.length + 8);
640
640
 
641
- metadataEncoded.copy(footerEncoded);
641
+ metadataEncoded.copy(footerEncoded as Uint8Array);
642
642
  footerEncoded.writeUInt32LE(metadataEncoded.length, metadataEncoded.length);
643
643
  footerEncoded.write(PARQUET_MAGIC, metadataEncoded.length + 4);
644
644
  return footerEncoded;
@@ -424,7 +424,7 @@ async function decodeDictionaryPage(
424
424
  ): Promise<(string | ArrayBuffer)[]> {
425
425
  const cursorEnd = cursor.offset + pageHeader.compressed_page_size;
426
426
 
427
- let dictCursor = {
427
+ let dictCursor: CursorBuffer = {
428
428
  offset: 0,
429
429
  buffer: cursor.buffer.slice(cursor.offset, cursorEnd),
430
430
  size: cursorEnd - cursor.offset
@@ -475,7 +475,7 @@ function preserveBinary(d: any): ArrayBuffer | ArrayBufferView | string {
475
475
  }
476
476
  // Convert to ArrayBuffer
477
477
  if (Buffer.isBuffer(d)) {
478
- return d.buffer.slice(d.byteOffset, d.byteLength);
478
+ return new Uint8Array(d.buffer, d.byteOffset, d.byteLength).slice().buffer;
479
479
  }
480
480
  return d.toString();
481
481
  }
@@ -30,7 +30,7 @@ export function serializeThrift(obj: any): Buffer {
30
30
  obj.write(protocol);
31
31
  transport.flush();
32
32
 
33
- return Buffer.concat(output);
33
+ return Buffer.concat(output as Uint8Array[]);
34
34
  }
35
35
 
36
36
  export function decodeThrift(obj: any, buf: Buffer, offset?: number) {