@@ -104,6 +104,7 @@ static void Usage();
104
104
void takeCheckPoint (char * ,myoff_t );
105
105
myoff_t readCheckPoint (FILE * );
106
106
static char * getFormatRate (myoff_t pos );
107
+ static char * getFormatPercent (myoff_t totalFileSize ,myoff_t pos );
107
108
108
109
#define DEFAULT_TICKER 10000 /* Print out status every N records */
109
110
@@ -115,6 +116,7 @@ BOOL addEquals = TRUE;
115
116
BOOL printHeaders = TRUE;
116
117
BOOL useRDW = TRUE;
117
118
BOOL streamOutput = FALSE;
119
+ BOOL streamInput = TRUE;
118
120
commonFields_t commonF = {0 };
119
121
enum outputFormat_e outputFormat = OF_CSV ;
120
122
FILE * infoStream ;
@@ -273,6 +275,7 @@ int main( int argc, char *argv[] )
273
275
break ;
274
276
case 'i' :
275
277
inputFile = mqoptarg ;
278
+ streamInput = FALSE;
276
279
break ;
277
280
case 'm' :
278
281
maxRecords = atoi (mqoptarg );
@@ -971,9 +974,8 @@ int main( int argc, char *argv[] )
971
974
972
975
if (totalRecords % ticker == 0 && totalRecords > startingRecords )
973
976
{
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 ));
977
979
if (!streamOutput && outputFormat != OF_JSON )
978
980
takeCheckPoint (checkPointFileName ,pos );
979
981
}
@@ -1316,12 +1318,13 @@ static char *getFormatRate(myoff_t pos)
1316
1318
time_t elapsedTime = currentTime - startTime ;
1317
1319
char * units ;
1318
1320
1319
- if (elapsedTime == 0 )
1321
+ if (streamInput ) {
1322
+ strcpy (formatRateString ,"" );
1323
+ } else if (elapsedTime == 0 ) {
1320
1324
strcpy (formatRateString ,"at too fast to count" );
1321
- else {
1325
+ } else {
1322
1326
long long formatRate = pos / elapsedTime ;
1323
- if (formatRate > (1024 * 1024 ))
1324
- {
1327
+ if (formatRate > (1024 * 1024 )) {
1325
1328
units = "MB" ;
1326
1329
sprintf (formatRateString , "at %lld %s/sec" ,formatRate /(1024 * 1024 ),units );
1327
1330
} else if (formatRate > 1024 ) {
@@ -1334,3 +1337,13 @@ static char *getFormatRate(myoff_t pos)
1334
1337
}
1335
1338
return formatRateString ;
1336
1339
}
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