@@ -16,14 +16,13 @@ import {promisifyAll} from '@google-cloud/promisify';
16
16
import arrify = require( 'arrify' ) ;
17
17
import { ServiceError } from 'google-gax' ;
18
18
import { decorateStatus } from './decorateStatus' ;
19
- import { PassThrough } from 'stream' ;
19
+ import { PassThrough , Transform } from 'stream' ;
20
20
21
21
// eslint-disable-next-line @typescript-eslint/no-var-requires
22
22
const concat = require ( 'concat-stream' ) ;
23
23
import * as is from 'is' ;
24
24
// eslint-disable-next-line @typescript-eslint/no-var-requires
25
25
const pumpify = require ( 'pumpify' ) ;
26
- import * as through from 'through2' ;
27
26
28
27
import {
29
28
Family ,
@@ -810,10 +809,8 @@ Please use the format 'prezzy' or '${instance.name}/tables/prezzy'.`);
810
809
811
810
requestStream ! . on ( 'request' , ( ) => numRequestsMade ++ ) ;
812
811
813
- rowStream = pumpify . obj ( [
814
- requestStream ,
815
- chunkTransformer ,
816
- through . obj ( ( rowData , enc , next ) => {
812
+ const toRowStream = new Transform ( {
813
+ transform : ( rowData , _ , next ) => {
817
814
if (
818
815
chunkTransformer . _destroyed ||
819
816
// eslint-disable-next-line @typescript-eslint/no-explicit-any
@@ -826,8 +823,11 @@ Please use the format 'prezzy' or '${instance.name}/tables/prezzy'.`);
826
823
const row = this . row ( rowData . key ) ;
827
824
row . data = rowData . data ;
828
825
next ( null , row ) ;
829
- } ) ,
830
- ] ) ;
826
+ } ,
827
+ objectMode : true ,
828
+ } ) ;
829
+
830
+ rowStream = pumpify . obj ( [ requestStream , chunkTransformer , toRowStream ] ) ;
831
831
832
832
rowStream . on ( 'error' , ( error : ServiceError ) => {
833
833
if ( IGNORED_STATUS_CODES . has ( error . code ) ) {
@@ -1561,19 +1561,24 @@ Please use the format 'prezzy' or '${instance.name}/tables/prezzy'.`);
1561
1561
appProfileId : this . bigtable . appProfileId ,
1562
1562
} ;
1563
1563
1564
+ const rowKeysStream = new Transform ( {
1565
+ transform ( key , enc , next ) {
1566
+ next ( null , {
1567
+ key : key . rowKey ,
1568
+ offset : key . offsetBytes ,
1569
+ } ) ;
1570
+ } ,
1571
+ objectMode : true ,
1572
+ } ) ;
1573
+
1564
1574
return pumpify . obj ( [
1565
1575
this . bigtable . request ( {
1566
1576
client : 'BigtableClient' ,
1567
1577
method : 'sampleRowKeys' ,
1568
1578
reqOpts,
1569
1579
gaxOpts : gaxOptions ,
1570
1580
} ) ,
1571
- through . obj ( ( key , enc , next ) => {
1572
- next ( null , {
1573
- key : key . rowKey ,
1574
- offset : key . offsetBytes ,
1575
- } ) ;
1576
- } ) ,
1581
+ rowKeysStream ,
1577
1582
] ) ;
1578
1583
}
1579
1584
0 commit comments