@@ -6,11 +6,25 @@ import * as parquet_schema from './schema';
6
6
import * as parquet_codec from './codec' ;
7
7
import * as parquet_compression from './compression' ;
8
8
import * as parquet_types from './types' ;
9
- import BufferReader , { BufferReaderOptions } from './bufferReader' ;
9
+ import BufferReader , { BufferReaderOptions } from './bufferReader' ;
10
10
import * as bloomFilterReader from './bloomFilterIO/bloomFilterReader' ;
11
11
import fetch from 'cross-fetch' ;
12
- import { ParquetCodec , Parameter , PageData , SchemaDefinition , ParquetType , FieldDefinition , ParquetField , ClientS3 , ClientParameters , FileMetaDataExt , NewPageHeader , RowGroupExt , ColumnChunkExt } from './declare' ;
13
- import { Cursor , Options } from './codec/types' ;
12
+ import {
13
+ ParquetCodec ,
14
+ Parameter ,
15
+ PageData ,
16
+ SchemaDefinition ,
17
+ ParquetType ,
18
+ FieldDefinition ,
19
+ ParquetField ,
20
+ ClientS3 ,
21
+ ClientParameters ,
22
+ FileMetaDataExt ,
23
+ NewPageHeader ,
24
+ RowGroupExt ,
25
+ ColumnChunkExt
26
+ } from './declare' ;
27
+ import { Cursor , Options } from './codec/types' ;
14
28
15
29
const {
16
30
getBloomFiltersFor,
@@ -35,7 +49,7 @@ const PARQUET_RDLVL_ENCODING = 'RLE';
35
49
/**
36
50
* A parquet cursor is used to retrieve rows from a parquet file in order
37
51
*/
38
- class ParquetCursor {
52
+ class ParquetCursor {
39
53
40
54
metadata : FileMetaDataExt ;
41
55
envelopeReader : ParquetEnvelopeReader ;
@@ -44,13 +58,14 @@ class ParquetCursor {
44
58
rowGroup : Array < unknown > ;
45
59
rowGroupIndex : number ;
46
60
cursorIndex : number ;
61
+
47
62
/**
48
63
* Create a new parquet reader from the file metadata and an envelope reader.
49
64
* It is usually not recommended to call this constructor directly except for
50
65
* advanced and internal use cases. Consider using getCursor() on the
51
66
* ParquetReader instead
52
67
*/
53
- constructor ( metadata : FileMetaDataExt , envelopeReader : ParquetEnvelopeReader , schema : parquet_schema . ParquetSchema , columnList : Array < Array < unknown > > ) {
68
+ constructor ( metadata : FileMetaDataExt , envelopeReader : ParquetEnvelopeReader , schema : parquet_schema . ParquetSchema , columnList : Array < Array < unknown > > ) {
54
69
this . metadata = metadata ;
55
70
this . envelopeReader = envelopeReader ;
56
71
this . schema = schema ;
@@ -72,9 +87,9 @@ class ParquetCursor {
72
87
}
73
88
74
89
let rowBuffer = await this . envelopeReader . readRowGroup (
75
- this . schema ,
76
- this . metadata . row_groups [ this . rowGroupIndex ] ,
77
- this . columnList ) ;
90
+ this . schema ,
91
+ this . metadata . row_groups [ this . rowGroupIndex ] ,
92
+ this . columnList ) ;
78
93
79
94
this . rowGroup = parquet_shredder . materializeRecords ( this . schema , rowBuffer ) ;
80
95
this . rowGroupIndex ++ ;
@@ -363,7 +378,7 @@ export class ParquetReader {
363
378
}
364
379
365
380
decodePages ( buffer : Buffer , opts : Options ) {
366
- return decodePages ( buffer , opts ) ;
381
+ return decodePages ( buffer , opts ) ;
367
382
}
368
383
369
384
}
@@ -375,6 +390,7 @@ export class ParquetReader {
375
390
* rows from a parquet file use the ParquetReader instead
376
391
*/
377
392
let ParquetEnvelopeReaderIdCounter = 0 ;
393
+
378
394
export class ParquetEnvelopeReader {
379
395
readFn : ( offset : number , length : number , file ?: string ) => Promise < Buffer > ;
380
396
close : ( ) => unknown ;
@@ -393,7 +409,7 @@ export class ParquetEnvelopeReader {
393
409
return Promise . reject ( 'external references are not supported' ) ;
394
410
}
395
411
396
- return parquet_util . fread ( fileDescriptor , offset , length ) ;
412
+ return parquet_util . fread ( fileDescriptor , offset , length ) ;
397
413
} ;
398
414
399
415
let closeFn = parquet_util . fclose . bind ( undefined , fileDescriptor ) ;
@@ -407,15 +423,15 @@ export class ParquetEnvelopeReader {
407
423
return Promise . reject ( 'external references are not supported' ) ;
408
424
}
409
425
410
- return Promise . resolve ( buffer . slice ( offset , offset + length ) ) ;
426
+ return Promise . resolve ( buffer . slice ( offset , offset + length ) ) ;
411
427
} ;
412
428
413
429
let closeFn = ( ) => ( { } ) ;
414
430
return new ParquetEnvelopeReader ( readFn , closeFn , buffer . length , options ) ;
415
431
}
416
432
417
433
static async openS3 ( client : ClientS3 , params : ClientParameters , options ?: BufferReaderOptions ) {
418
- let fileStat = async ( ) => client . headObject ( params ) . promise ( ) . then ( ( d : { ContentLength : number } ) => d . ContentLength ) ;
434
+ let fileStat = async ( ) => client . headObject ( params ) . promise ( ) . then ( ( d : { ContentLength : number } ) => d . ContentLength ) ;
419
435
420
436
let readFn = async ( offset : number , length : number , file ?: string ) => {
421
437
if ( file ) {
0 commit comments