@@ -15,15 +15,18 @@ import {
1515
1616import * as fs from 'fs' ;
1717import * as path from 'path' ;
18+ import { Stream } from 'stream' ;
19+
20+ import * as config from '../configuration/configuration' ;
1821import * as fileUtils from '../utils/fileUtils' ;
1922
2023import { FileInfo } from './fileInfo' ;
2124import { FileTypes } from './fileTypes' ;
2225import { ViewTypes } from './viewTypes' ;
2326import { statusBar } from './statusBar' ;
2427
25- import { Stream } from 'stream' ;
2628import { ViewCommands } from '../commands/viewCommands' ;
29+ import { Settings } from '../configuration/Settings' ;
2730
2831// eslint-disable-next-line @typescript-eslint/naming-convention
2932const { Table} = require ( 'tableschema' ) ;
@@ -55,9 +58,6 @@ export class TableView {
5558
5659
5760 // TODO: move the settings below to tabular data viewer config options later
58- // default page data size for incremental data loading into table view
59- private readonly _pageDataSize : number = 100000 ;
60-
6161 // infer table schema rows sample size limit
6262 private readonly _inferDataSize = 100 ;
6363
@@ -279,14 +279,14 @@ export class TableView {
279279 dataStream . on ( 'data' , ( row : any ) => {
280280 tableRows . push ( row ) ;
281281 rowCount ++ ;
282- if ( ( rowCount % ( this . _pageDataSize * 10 ) ) === 0 ) {
282+ if ( ( rowCount % ( this . dataPageSize * 10 ) ) === 0 ) {
283283 console . log ( `tabular.data.view:refresh(): parsing rows ${ rowCount . toLocaleString ( ) } + ...` ) ;
284284 if ( this . visible ) {
285285 statusBar . showMessage ( `Parsing rows ${ rowCount . toLocaleString ( ) } +` ) ;
286286 }
287287 }
288288
289- if ( rowCount === this . _pageDataSize ) {
289+ if ( rowCount === this . dataPageSize ) {
290290 // send initial set of data rows to table view for display
291291 this . loadData ( tableRows ) ;
292292 // TODO: add pause/resume stream later
@@ -309,13 +309,13 @@ export class TableView {
309309 statusBar . totalRows = tableRows . length ;
310310 }
311311
312- if ( tableRows . length < this . _pageDataSize ) {
312+ if ( tableRows . length < this . dataPageSize ) {
313313 // load first page of data
314314 this . loadData ( tableRows ) ;
315315 // clear data loading status bar message
316316 statusBar . showMessage ( '' ) ;
317317 }
318- else if ( tableRows . length > this . _pageDataSize ) {
318+ else if ( tableRows . length > this . dataPageSize ) {
319319 // load remaining table rows
320320 const dataPageIndex : number = 1 ;
321321 this . addData ( dataPageIndex ) ;
@@ -344,7 +344,7 @@ export class TableView {
344344 }
345345
346346 // send initial set of data rows to table view for display
347- const nextRows : number = Math . min ( this . _pageDataSize , this . _totalRows ) ;
347+ const nextRows : number = Math . min ( this . dataPageSize , this . _totalRows ) ;
348348 const initialDataRows : Array < any > = tableRows . slice ( 0 , nextRows ) ;
349349 this . webviewPanel . webview . postMessage ( {
350350 command : 'refresh' ,
@@ -353,7 +353,8 @@ export class TableView {
353353 tableConfig : this . _tableConfig ,
354354 tableSchema : this . _tableSchema ,
355355 totalRows : this . _totalRows ,
356- tableData : initialDataRows
356+ tableData : initialDataRows ,
357+ dataPageSize : this . dataPageSize
357358 } ) ;
358359 }
359360
@@ -363,7 +364,7 @@ export class TableView {
363364 * @param dataPage Requested data page index for loading the next set of data rows.
364365 */
365366 public async addData ( dataPage : number ) : Promise < void > {
366- let nextRows : number = dataPage * this . _pageDataSize ;
367+ let nextRows : number = dataPage * this . dataPageSize ;
367368 if ( this . _loadedDataPage <= dataPage && nextRows < this . _totalRows ) {
368369 // console.log(`tabular.data.view:addData(): loading rows ${nextRows.toLocaleString()}+ ...`);
369370 if ( this . visible ) {
@@ -372,7 +373,7 @@ export class TableView {
372373
373374 // get the next set of data rows to load in table view
374375 const dataRows : Array < any > =
375- this . _tableData . slice ( nextRows , Math . min ( nextRows + this . _pageDataSize , this . _totalRows ) ) ;
376+ this . _tableData . slice ( nextRows , Math . min ( nextRows + this . dataPageSize , this . _totalRows ) ) ;
376377
377378 // increment next rows for data loading status update
378379 nextRows += dataRows . length ;
@@ -563,6 +564,13 @@ export class TableView {
563564 return delimiter ;
564565 }
565566
567+ /**
568+ * Gets data page size configuration setting.
569+ */
570+ get dataPageSize ( ) : number {
571+ return < number > config . get ( Settings . dataPageSize ) ;
572+ }
573+
566574 /**
567575 * Creates webview html content for the webview panel display.
568576 *
0 commit comments