Skip to content

Commit eb029bd

Browse files
authored
[Issue #41] - Slimmed down FixedTFramedTransport class (#46)
* Removed fixedTTransport class This may not be necessary, since we have upgraded Thrift to a version above 0.9.2. See https://github.com/apache/thrift/blob/master/CHANGES.md\#092 * Re-adding TFrameTransport patch so is supported.
1 parent ce1f98b commit eb029bd

File tree

1 file changed

+8
-22
lines changed

1 file changed

+8
-22
lines changed

lib/util.ts

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,11 @@ import fs, { WriteStream } from 'fs'
44
import * as parquet_thrift from '../gen-nodejs/parquet_types'
55
import { NewFileMetaData } from './types/types'
66

7-
/** We need to use a patched version of TFramedTransport where
8-
* readString returns the original buffer instead of a string if the
9-
* buffer can not be safely encoded as utf8 (see http://bit.ly/2GXeZEF)
10-
*/
11-
12-
13-
type Enums = typeof parquet_thrift.Encoding | typeof parquet_thrift.FieldRepetitionType | typeof parquet_thrift.Type | typeof parquet_thrift.CompressionCodec | typeof parquet_thrift.PageType | typeof parquet_thrift.ConvertedType;
14-
15-
type ThriftObject = NewFileMetaData | parquet_thrift.PageHeader | parquet_thrift.BloomFilterHeader | parquet_thrift.OffsetIndex | parquet_thrift.ColumnIndex | NewFileMetaData;
16-
17-
// May not be needed anymore, Issue at https://github.com/LibertyDSNP/parquetjs/issues/41
7+
/**
8+
* We need to patch Thrift's TFramedTransport class bc the TS type definitions
9+
* do not define a `readPos` field, even though the class implementation has
10+
* one.
11+
*/
1812
class fixedTFramedTransport extends thrift.TFramedTransport {
1913
inBuf: Buffer
2014
readPos: number
@@ -23,19 +17,11 @@ class fixedTFramedTransport extends thrift.TFramedTransport {
2317
this.inBuf = inBuf
2418
this.readPos = 0
2519
}
26-
27-
readString(len = 0): string {
28-
this.ensureAvailable(len);
29-
var buffer = this.inBuf.slice(this.readPos, this.readPos + len);
30-
var str = this.inBuf.toString('utf8', this.readPos, this.readPos + len);
31-
this.readPos += len;
32-
//@ts-ignore
33-
return (Buffer.from(str).equals(buffer)) ? str : buffer;
34-
}
3520
}
3621

37-
38-
/** Patch PageLocation to be three element array that has getters/setters
22+
type Enums = typeof parquet_thrift.Encoding | typeof parquet_thrift.FieldRepetitionType | typeof parquet_thrift.Type | typeof parquet_thrift.CompressionCodec | typeof parquet_thrift.PageType | typeof parquet_thrift.ConvertedType;
23+
24+
type ThriftObject = NewFileMetaData | parquet_thrift.PageHeader | parquet_thrift.BloomFilterHeader | parquet_thrift.OffsetIndex | parquet_thrift.ColumnIndex | NewFileMetaData;/** Patch PageLocation to be three element array that has getters/setters
3925
* for each of the properties (offset, compressed_page_size, first_row_index)
4026
* This saves space considerably as we do not need to store the full variable
4127
* names for every PageLocation

0 commit comments

Comments
 (0)