@@ -104,6 +104,7 @@ static void Usage();
104104void takeCheckPoint (char * ,myoff_t );
105105myoff_t readCheckPoint (FILE * );
106106static char * getFormatRate (myoff_t pos );
107+ static char * getFormatPercent (myoff_t totalFileSize ,myoff_t pos );
107108
108109#define DEFAULT_TICKER 10000 /* Print out status every N records */
109110
@@ -115,6 +116,7 @@ BOOL addEquals = TRUE;
115116BOOL printHeaders = TRUE;
116117BOOL useRDW = TRUE;
117118BOOL streamOutput = FALSE;
119+ BOOL streamInput = TRUE;
118120commonFields_t commonF = {0 };
119121enum outputFormat_e outputFormat = OF_CSV ;
120122FILE * infoStream ;
@@ -273,6 +275,7 @@ int main( int argc, char *argv[] )
273275 break ;
274276 case 'i' :
275277 inputFile = mqoptarg ;
278+ streamInput = FALSE;
276279 break ;
277280 case 'm' :
278281 maxRecords = atoi (mqoptarg );
@@ -971,9 +974,8 @@ int main( int argc, char *argv[] )
971974
972975 if (totalRecords % ticker == 0 && totalRecords > startingRecords )
973976 {
974- pos = ftello (fp );
975- formatRate = getFormatRate (pos );
976- fprintf (infoStream ,"Processed %u records [%5.2f%%] %s\n" ,totalRecords ,(totalFileSize > 0 )?((float )(100.0 * pos )/totalFileSize ):(float )0 ,formatRate );
977+ fprintf (infoStream ,"Processed %u records %s %s\n" ,totalRecords ,
978+ getFormatPercent (totalFileSize ,pos ), getFormatRate (pos ));
977979 if (!streamOutput && outputFormat != OF_JSON )
978980 takeCheckPoint (checkPointFileName ,pos );
979981 }
@@ -1316,12 +1318,13 @@ static char *getFormatRate(myoff_t pos)
13161318 time_t elapsedTime = currentTime - startTime ;
13171319 char * units ;
13181320
1319- if (elapsedTime == 0 )
1321+ if (streamInput ) {
1322+ strcpy (formatRateString ,"" );
1323+ } else if (elapsedTime == 0 ) {
13201324 strcpy (formatRateString ,"at too fast to count" );
1321- else {
1325+ } else {
13221326 long long formatRate = pos / elapsedTime ;
1323- if (formatRate > (1024 * 1024 ))
1324- {
1327+ if (formatRate > (1024 * 1024 )) {
13251328 units = "MB" ;
13261329 sprintf (formatRateString , "at %lld %s/sec" ,formatRate /(1024 * 1024 ),units );
13271330 } else if (formatRate > 1024 ) {
@@ -1334,3 +1337,13 @@ static char *getFormatRate(myoff_t pos)
13341337 }
13351338 return formatRateString ;
13361339}
1340+ static char formatPercentString [10 ];
1341+ static char * getFormatPercent (myoff_t totalFileSize ,myoff_t pos )
1342+ {
1343+ if (streamInput ) {
1344+ strcpy (formatPercentString ,"" );
1345+ } else {
1346+ sprintf (formatPercentString ,"[%5.2f%%]" , (float )(100.0 * pos )/totalFileSize );
1347+ }
1348+ return formatPercentString ;
1349+ }
0 commit comments