11"use strict" ;
22Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
3+ exports . TFRecordsBuilder = exports . FeatureType = void 0 ;
34const tensorFlowRecordsProtoBuf_pb_1 = require ( "./tensorFlowRecordsProtoBuf_pb" ) ;
45const tensorFlowHelpers_1 = require ( "./tensorFlowHelpers" ) ;
56const stream_1 = require ( "stream" ) ;
@@ -17,15 +18,12 @@ var FeatureType;
1718 FeatureType [ FeatureType [ "Binary" ] = 1 ] = "Binary" ;
1819 FeatureType [ FeatureType [ "Int64" ] = 2 ] = "Int64" ;
1920 FeatureType [ FeatureType [ "Float" ] = 3 ] = "Float" ;
20- } ) ( FeatureType = exports . FeatureType || ( exports . FeatureType = { } ) ) ;
21+ } ) ( FeatureType || ( exports . FeatureType = FeatureType = { } ) ) ;
2122/**
2223 * @name - TFRecords Builder Class
2324 * @description - Create a TFRecords object
2425 */
2526class TFRecordsBuilder {
26- constructor ( ) {
27- this . features = new tensorFlowRecordsProtoBuf_pb_1 . Features ( ) ;
28- }
2927 /**
3028 * @records - An Array of TFRecord Buffer created with releaseTFRecord()
3129 * @description - Return a Buffer representation of a TFRecords object
@@ -34,9 +32,9 @@ class TFRecordsBuilder {
3432 return Buffer . concat ( records . map ( ( record ) => {
3533 const length = record . length ;
3634 // Get TFRecords CRCs for TFRecords Header and Footer
37- const bufferLength = tensorFlowHelpers_1 . getInt64Buffer ( length ) ;
38- const bufferLengthMaskedCRC = tensorFlowHelpers_1 . getInt32Buffer ( tensorFlowHelpers_1 . maskCrc ( tensorFlowHelpers_1 . crc32c ( bufferLength ) ) ) ;
39- const bufferDataMaskedCRC = tensorFlowHelpers_1 . getInt32Buffer ( tensorFlowHelpers_1 . maskCrc ( tensorFlowHelpers_1 . crc32c ( record ) ) ) ;
35+ const bufferLength = ( 0 , tensorFlowHelpers_1 . getInt64Buffer ) ( length ) ;
36+ const bufferLengthMaskedCRC = ( 0 , tensorFlowHelpers_1 . getInt32Buffer ) ( ( 0 , tensorFlowHelpers_1 . maskCrc ) ( ( 0 , tensorFlowHelpers_1 . crc32c ) ( bufferLength ) ) ) ;
37+ const bufferDataMaskedCRC = ( 0 , tensorFlowHelpers_1 . getInt32Buffer ) ( ( 0 , tensorFlowHelpers_1 . maskCrc ) ( ( 0 , tensorFlowHelpers_1 . crc32c ) ( record ) ) ) ;
4038 // Concatenate all TFRecords Header, Data and Footer buffer
4139 return Buffer . concat ( [ bufferLength ,
4240 bufferLengthMaskedCRC ,
@@ -58,14 +56,17 @@ class TFRecordsBuilder {
5856 transform : ( record , encoding , callback ) => {
5957 const length = record . length ;
6058 // Get TFRecords CRCs for TFRecords Header and Footer
61- const bufferLength = tensorFlowHelpers_1 . getInt64Buffer ( length ) ;
62- const bufferLengthMaskedCRC = tensorFlowHelpers_1 . getInt32Buffer ( tensorFlowHelpers_1 . maskCrc ( tensorFlowHelpers_1 . crc32c ( bufferLength ) ) ) ;
63- const bufferDataMaskedCRC = tensorFlowHelpers_1 . getInt32Buffer ( tensorFlowHelpers_1 . maskCrc ( tensorFlowHelpers_1 . crc32c ( record ) ) ) ;
59+ const bufferLength = ( 0 , tensorFlowHelpers_1 . getInt64Buffer ) ( length ) ;
60+ const bufferLengthMaskedCRC = ( 0 , tensorFlowHelpers_1 . getInt32Buffer ) ( ( 0 , tensorFlowHelpers_1 . maskCrc ) ( ( 0 , tensorFlowHelpers_1 . crc32c ) ( bufferLength ) ) ) ;
61+ const bufferDataMaskedCRC = ( 0 , tensorFlowHelpers_1 . getInt32Buffer ) ( ( 0 , tensorFlowHelpers_1 . maskCrc ) ( ( 0 , tensorFlowHelpers_1 . crc32c ) ( record ) ) ) ;
6462 callback ( undefined , Buffer . concat ( [ bufferLength , bufferLengthMaskedCRC , record , bufferDataMaskedCRC ] ) ) ;
6563 } ,
6664 highWaterMark,
6765 } ) ;
6866 }
67+ constructor ( ) {
68+ this . features = new tensorFlowRecordsProtoBuf_pb_1 . Features ( ) ;
69+ }
6970 /**
7071 * @key - Feature Key
7172 * @type - Feature Type
@@ -87,7 +88,7 @@ class TFRecordsBuilder {
8788 case FeatureType . String :
8889 const stringList = new tensorFlowRecordsProtoBuf_pb_1 . BytesList ( ) ;
8990 values . forEach ( ( value ) => {
90- stringList . addValue ( tensorFlowHelpers_1 . textEncode ( value ) ) ;
91+ stringList . addValue ( ( 0 , tensorFlowHelpers_1 . textEncode ) ( value ) ) ;
9192 } ) ;
9293 feature . setBytesList ( stringList ) ;
9394 break ;
0 commit comments