Skip to content

Commit f3f7ce0

Browse files
authored
updated printf strings (#7031)
1 parent 05f5777 commit f3f7ce0

File tree

1 file changed

+42
-42
lines changed

1 file changed

+42
-42
lines changed

src/fread.c

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1368,7 +1368,7 @@ int freadMain(freadMainArgs _args) {
13681368
else
13691369
DTPRINT(_(" None of the NAstrings look like numbers.\n"));
13701370
}
1371-
if (args.skipNrow >= 0) DTPRINT(_(" skip num lines = %"PRId64"\n"), (int64_t)args.skipNrow);
1371+
if (args.skipNrow >= 0) DTPRINT(_(" skip num lines = %"PRId64"\n"), args.skipNrow);
13721372
if (args.skipString) DTPRINT(_(" skip to string = <<%s>>\n"), args.skipString);
13731373
DTPRINT(_(" show progress = %d\n"), args.showProgress);
13741374
DTPRINT(_(" 0/1 column will be read as %s\n"), args.logical01? "boolean" : "integer");
@@ -1621,8 +1621,8 @@ int freadMain(freadMainArgs _args) {
16211621
pos = ch;
16221622
ch = sof;
16231623
while (ch<pos) row1line+=(*ch++=='\n');
1624-
if (verbose) DTPRINT(_("Found skip='%s' on line %"PRIu64". Taking this to be header row or first row of data.\n"),
1625-
args.skipString, (uint64_t)row1line);
1624+
if (verbose) DTPRINT(_("Found skip='%s' on line %d. Taking this to be header row or first row of data.\n"),
1625+
args.skipString, row1line);
16261626
ch = pos;
16271627
}
16281628
else if (args.skipNrow >= 0) {
@@ -1635,12 +1635,12 @@ int freadMain(freadMainArgs _args) {
16351635
}
16361636
}
16371637
if (ch > sof && verbose)
1638-
DTPRINT(_(" Skipped to line %"PRIu64" in the file"), (uint64_t)row1line);
1638+
DTPRINT(_(" Skipped to line %d in the file"), row1line);
16391639
if (ch>=eof)
16401640
STOP(Pl_(row1line,
1641-
"skip=%"PRIu64" but the input only has %"PRIu64" line",
1642-
"skip=%"PRIu64" but the input only has %"PRIu64" lines"),
1643-
(uint64_t)args.skipNrow, (uint64_t)row1line);
1641+
"skip=%"PRId64" but the input only has %d line",
1642+
"skip=%"PRId64" but the input only has %d lines"),
1643+
args.skipNrow, row1line);
16441644
pos = ch;
16451645
}
16461646

@@ -1925,7 +1925,7 @@ int freadMain(freadMainArgs _args) {
19251925
}
19261926
if (verbose) {
19271927
if (nrowLimit<INT64_MAX) {
1928-
DTPRINT(_(" Number of sampling jump points = %d because nrow limit (%"PRIu64") supplied\n"), nJumps, (uint64_t)nrowLimit);
1928+
DTPRINT(_(" Number of sampling jump points = %d because nrow limit (%"PRId64") supplied\n"), nJumps, nrowLimit);
19291929
} else if (jump0size==0) {
19301930
DTPRINT(_(" Number of sampling jump points = %d because jump0size==0\n"), nJumps);
19311931
} else {
@@ -2109,7 +2109,7 @@ int freadMain(freadMainArgs _args) {
21092109
bytesRead=0; // Bytes in the data section (i.e. excluding column names, header and footer, if any)
21102110

21112111
if (sampleLines <= jumpLines) {
2112-
if (verbose) DTPRINT(_(" All rows were sampled since file is small so we know nrow=%"PRIu64" exactly\n"), (uint64_t)sampleLines);
2112+
if (verbose) DTPRINT(_(" All rows were sampled since file is small so we know nrow=%"PRId64" exactly\n"), sampleLines);
21132113
estnrow = allocnrow = sampleLines;
21142114
} else {
21152115
bytesRead = eof - firstRowStart;
@@ -2122,19 +2122,19 @@ int freadMain(freadMainArgs _args) {
21222122
// blank lines have length 1 so for fill=true apply a +100% maximum. It'll be grown if needed.
21232123
if (verbose) {
21242124
DTPRINT(" =====\n"); // # notranslate
2125-
DTPRINT(_(" Sampled %"PRIu64" rows (handled \\n inside quoted fields) at %d jump points\n"), (uint64_t)sampleLines, nJumps);
2126-
DTPRINT(_(" Bytes from first data row on line %d to the end of last row: %"PRIu64"\n"), row1line, (uint64_t)bytesRead);
2125+
DTPRINT(_(" Sampled %"PRId64" rows (handled \\n inside quoted fields) at %d jump points\n"), sampleLines, nJumps);
2126+
DTPRINT(_(" Bytes from first data row on line %d to the end of last row: %td\n"), row1line, bytesRead);
21272127
DTPRINT(_(" Line length: mean=%.2f sd=%.2f min=%d max=%d\n"), meanLineLen, sd, minLen, maxLen);
2128-
DTPRINT(_(" Estimated number of rows: %"PRIu64" / %.2f = %"PRIu64"\n"), (uint64_t)bytesRead, meanLineLen, (uint64_t)estnrow);
2129-
DTPRINT(_(" Initial alloc = %"PRIu64" rows (%"PRIu64" + %d%%) using bytes/max(mean-2*sd,min) clamped between [1.1*estn, 2.0*estn]\n"),
2130-
(uint64_t)allocnrow, (uint64_t)estnrow, (int)(100.0*allocnrow/estnrow-100.0));
2128+
DTPRINT(_(" Estimated number of rows: %td / %.2f = %"PRId64"\n"), bytesRead, meanLineLen, estnrow);
2129+
DTPRINT(_(" Initial alloc = %"PRId64" rows (%"PRId64" + %d%%) using bytes/max(mean-2*sd,min) clamped between [1.1*estn, 2.0*estn]\n"),
2130+
allocnrow, estnrow, (int)(100.0*allocnrow/estnrow-100.0));
21312131
DTPRINT(" =====\n"); // # notranslate
21322132
} else {
2133-
if (sampleLines > allocnrow) INTERNAL_STOP("sampleLines(%"PRIu64") > allocnrow(%"PRIu64")", (uint64_t)sampleLines, (uint64_t)allocnrow); // # nocov
2133+
if (sampleLines > allocnrow) INTERNAL_STOP("sampleLines(%"PRId64") > allocnrow(%"PRId64")", sampleLines, allocnrow); // # nocov
21342134
}
21352135
}
21362136
if (nrowLimit < allocnrow) {
2137-
if (verbose) DTPRINT(_(" Alloc limited to lower nrows=%"PRIu64" passed in.\n"), (uint64_t)nrowLimit);
2137+
if (verbose) DTPRINT(_(" Alloc limited to lower nrows=%"PRId64" passed in.\n"), nrowLimit);
21382138
estnrow = allocnrow = nrowLimit;
21392139
}
21402140
}
@@ -2210,7 +2210,7 @@ int freadMain(freadMainArgs _args) {
22102210
rowSize8 = 0;
22112211
size = malloc(sizeof(*size) * ncol); // TODO: remove size[] when we implement Pasha's idea to += size inside processor
22122212
if (!size)
2213-
STOP(_("Failed to allocate %d bytes for '%s': %s"), (int)(sizeof(*size) * ncol), "size", strerror(errno)); // # nocov
2213+
STOP(_("Failed to allocate %zu bytes for '%s': %s"), sizeof(*size) * ncol, "size", strerror(errno)); // # nocov
22142214
nStringCols = 0;
22152215
nNonStringCols = 0;
22162216
for (int j=0; j<ncol; j++) {
@@ -2241,8 +2241,8 @@ int freadMain(freadMainArgs _args) {
22412241
//*********************************************************************************************
22422242
if (verbose) {
22432243
DTPRINT(_("[10] Allocate memory for the datatable\n"));
2244-
DTPRINT(_(" Allocating %d column slots (%d - %d dropped) with %"PRIu64" rows\n"),
2245-
ncol-ndrop, ncol, ndrop, (uint64_t)allocnrow);
2244+
DTPRINT(_(" Allocating %d column slots (%d - %d dropped) with %"PRId64" rows\n"),
2245+
ncol-ndrop, ncol, ndrop, allocnrow);
22462246
}
22472247
size_t DTbytes = allocateDT(type, size, ncol, ndrop, allocnrow);
22482248
double tAlloc = wallclock();
@@ -2270,7 +2270,7 @@ int freadMain(freadMainArgs _args) {
22702270
// For the 44GB file with 12875 columns, the max line len is 108,497. We may want each chunk to write to its
22712271
// own page (4k) of the final column, hence 1000 rows of the smallest type (4 byte int) is just
22722272
// under 4096 to leave space for R's header + malloc's header.
2273-
size_t chunkBytes = umax((size_t)(1000*meanLineLen), 1ULL/*MB*/ *1024*1024);
2273+
size_t chunkBytes = umax((uint64_t)(1000*meanLineLen), 1ULL/*MB*/ *1024*1024);
22742274
// Index of the first jump to read. May be modified if we ever need to restart
22752275
// reading from the middle of the file.
22762276
int jump0 = 0;
@@ -2289,22 +2289,22 @@ int freadMain(freadMainArgs _args) {
22892289
ASSERT(nJumps==1 /*when nrowLimit supplied*/ || nJumps==2 /*small files*/, "nJumps (%d) != 1|2", nJumps);
22902290
nJumps=1;
22912291
}
2292-
int64_t initialBuffRows = (int64_t)allocnrow / nJumps;
2292+
int64_t initialBuffRows = allocnrow / nJumps;
22932293

22942294
// Catch initialBuffRows==0 when max_nrows is small, seg fault #2243
22952295
// Rather than 10, maybe 1 would work too but then 1.5 grow factor * 1 would still be 1. This clamp
22962296
// should only engage when max_nrows is supplied, and supplied small too, so doesn't matter too much.
22972297
if (initialBuffRows < 10) initialBuffRows = 10;
22982298

2299-
if (initialBuffRows > INT32_MAX) STOP(_("Buffer size %"PRId64" is too large\n"), (int64_t)initialBuffRows);
2299+
if (initialBuffRows > INT32_MAX) STOP(_("Buffer size %"PRId64" is too large\n"), initialBuffRows);
23002300
nth = imin(nJumps, nth);
23012301

23022302
if (verbose) DTPRINT(_("[11] Read the data\n"));
23032303
while(true){ // we'll return here to reread any columns with out-of-sample type exceptions, or dirty jumps
23042304
restartTeam = false;
23052305
if (verbose)
2306-
DTPRINT(" jumps=[%d..%d), chunk_size=%"PRIu64", total_size=%"PRIu64"\n", jump0, nJumps, (uint64_t)chunkBytes, (uint64_t)(eof-pos)); // # notranslate
2307-
ASSERT(allocnrow <= nrowLimit, "allocnrow(%"PRIu64") <= nrowLimit(%"PRIu64")", (uint64_t)allocnrow, (uint64_t)nrowLimit);
2306+
DTPRINT(" jumps=[%d..%d), chunk_size=%zu, total_size=%td\n", jump0, nJumps, chunkBytes, eof-pos); // # notranslate
2307+
ASSERT(allocnrow <= nrowLimit, "allocnrow(%"PRId64") <= nrowLimit(%"PRId64")", allocnrow, nrowLimit);
23082308
#pragma omp parallel num_threads(nth)
23092309
{
23102310
int me = omp_get_thread_num();
@@ -2533,10 +2533,10 @@ int freadMain(freadMainArgs _args) {
25332533
if (verbose) {
25342534
char temp[1001];
25352535
int len = snprintf(temp, 1000,
2536-
_("Column %d%s%.*s%s bumped from '%s' to '%s' due to <<%.*s>> on row %"PRIu64"\n"),
2536+
_("Column %d%s%.*s%s bumped from '%s' to '%s' due to <<%.*s>> on row %"PRId64"\n"),
25372537
j+1, colNames?" <<":"", colNames?(colNames[j].len):0, colNames?(colNamesAnchor+colNames[j].off):"", colNames?">>":"",
25382538
typeName[IGNORE_BUMP(joldType)], typeName[IGNORE_BUMP(thisType)],
2539-
(int)(tch-fieldStart), fieldStart, (uint64_t)(ctx.DTi+myNrow));
2539+
(int)(tch-fieldStart), fieldStart, (int64_t)(ctx.DTi+myNrow));
25402540
if (len > 1000) len = 1000;
25412541
if (len > 0) {
25422542
typeBumpMsg = realloc(typeBumpMsg, typeBumpMsgSize + len + 1);
@@ -2583,7 +2583,7 @@ int freadMain(freadMainArgs _args) {
25832583
}
25842584
else if (headPos!=thisJumpStart && nrowLimit>0) { // do not care for dirty jumps since we do not read data and only want to know types
25852585
// # nocov start
2586-
snprintf(internalErr, internalErrSize, "invalid head position. jump=%d, headPos=%p, thisJumpStart=%p, sof=%p", jump, (void*)headPos, (void*)thisJumpStart, (void*)sof); // # notranslate
2586+
snprintf(internalErr, internalErrSize, "invalid head position. jump=%d, headPos=%p, thisJumpStart=%p, sof=%p", jump, headPos, thisJumpStart, sof); // # notranslate
25872587
stopTeam = true;
25882588
// # nocov end
25892589
}
@@ -2656,7 +2656,7 @@ int freadMain(freadMainArgs _args) {
26562656
}
26572657
dropFill = malloc(sizeof(*dropFill) * ndropFill);
26582658
if (!dropFill)
2659-
STOP(_("Failed to allocate %d bytes for '%s'."), (int)(sizeof(*dropFill) * ndropFill), "dropFill"); // # nocov
2659+
STOP(_("Failed to allocate %zu bytes for '%s'."), sizeof(*dropFill) * ndropFill, "dropFill"); // # nocov
26602660
int i=0;
26612661
for (int j=max_col; j<ncol; ++j) {
26622662
type[j] = CT_DROP;
@@ -2677,15 +2677,15 @@ int freadMain(freadMainArgs _args) {
26772677
if (extraAllocRows && nrowLimit>0) { // no allocating needed for nrows=0
26782678
allocnrow += extraAllocRows;
26792679
if (allocnrow > nrowLimit) allocnrow = nrowLimit;
2680-
if (verbose) DTPRINT(_(" Too few rows allocated. Allocating additional %"PRIu64" rows (now nrows=%"PRIu64") and continue reading from jump %d\n"),
2681-
(uint64_t)extraAllocRows, (uint64_t)allocnrow, jump0);
2680+
if (verbose) DTPRINT(_(" Too few rows allocated. Allocating additional %"PRId64" rows (now nrows=%"PRId64") and continue reading from jump %d\n"),
2681+
extraAllocRows, allocnrow, jump0);
26822682
allocateDT(type, size, ncol, ncol - nStringCols - nNonStringCols, allocnrow);
26832683
extraAllocRows = 0;
26842684
continue;
26852685
}
26862686
if (restartTeam && nrowLimit>0) { // no restarting needed for nrows=0 since we discard read data anyway
26872687
if (verbose) DTPRINT(_(" Restarting team from jump %d. nSwept==%d quoteRule==%d\n"), jump0, nSwept, quoteRule);
2688-
ASSERT(nSwept>0 || quoteRuleBumpedCh!=NULL, "team restart but nSwept==%d and quoteRuleBumpedCh==%p", nSwept, (void *)quoteRuleBumpedCh); // # nocov
2688+
ASSERT(nSwept>0 || quoteRuleBumpedCh!=NULL, "team restart but nSwept==%d and quoteRuleBumpedCh==%p", nSwept, quoteRuleBumpedCh); // # nocov
26892689
continue;
26902690
}
26912691
// else nrowLimit applied and stopped early normally
@@ -2773,17 +2773,17 @@ int freadMain(freadMainArgs _args) {
27732773
ch = headPos;
27742774
int tt = countfields(&ch);
27752775
if (fill>0) {
2776-
DTWARN(_("Stopped early on line %"PRIu64". Expected %d fields but found %d. Consider fill=%d or even more based on your knowledge of the input file. Use fill=Inf for reading the whole file for detecting the number of fields. First discarded non-empty line: <<%s>>"),
2777-
(uint64_t)DTi+row1line, ncol, tt, tt, strlim(skippedFooter,500));
2776+
DTWARN(_("Stopped early on line %"PRId64". Expected %d fields but found %d. Consider fill=%d or even more based on your knowledge of the input file. Use fill=Inf for reading the whole file for detecting the number of fields. First discarded non-empty line: <<%s>>"),
2777+
DTi+row1line, ncol, tt, tt, strlim(skippedFooter,500));
27782778
} else {
2779-
DTWARN(_("Stopped early on line %"PRIu64". Expected %d fields but found %d. Consider fill=TRUE. First discarded non-empty line: <<%s>>"),
2780-
(uint64_t)DTi+row1line, ncol, tt, strlim(skippedFooter,500));
2779+
DTWARN(_("Stopped early on line %"PRId64". Expected %d fields but found %d. Consider fill=TRUE. First discarded non-empty line: <<%s>>"),
2780+
DTi+row1line, ncol, tt, strlim(skippedFooter,500));
27812781
}
27822782
}
27832783
}
27842784
}
27852785
if (quoteRuleBumpedCh!=NULL && quoteRuleBumpedCh<headPos) {
2786-
DTWARN(_("Found and resolved improper quoting out-of-sample. First healed line %"PRIu64": <<%s>>. If the fields are not quoted (e.g. field separator does not appear within any field), try quote=\"\" to avoid this warning."), (uint64_t)quoteRuleBumpedLine, strlim(quoteRuleBumpedCh, 500));
2786+
DTWARN(_("Found and resolved improper quoting out-of-sample. First healed line %"PRId64": <<%s>>. If the fields are not quoted (e.g. field separator does not appear within any field), try quote=\"\" to avoid this warning."), quoteRuleBumpedLine, strlim(quoteRuleBumpedCh, 500));
27872787
}
27882788

27892789
if (verbose) {
@@ -2793,14 +2793,14 @@ int freadMain(freadMainArgs _args) {
27932793
DTPRINT(_("%8.3fs (%3.0f%%) sep="), tLayout-tMap, 100.0*(tLayout-tMap)/tTot);
27942794
DTPRINT(sep=='\t' ? "'\\t'" : (sep=='\n' ? "'\\n'" : "'%c'"), sep); // # notranslate
27952795
DTPRINT(_(" ncol=%d and header detection\n"), ncol);
2796-
DTPRINT(_("%8.3fs (%3.0f%%) Column type detection using %"PRIu64" sample rows\n"),
2797-
tColType-tLayout, 100.0*(tColType-tLayout)/tTot, (uint64_t)sampleLines);
2798-
DTPRINT(_("%8.3fs (%3.0f%%) Allocation of %"PRIu64" rows x %d cols (%.3fGB) of which %"PRIu64" (%3.0f%%) rows used\n"),
2799-
tAlloc-tColType, 100.0*(tAlloc-tColType)/tTot, (uint64_t)allocnrow, ncol, DTbytes/(1024.0*1024*1024), (uint64_t)DTi, 100.0*DTi/allocnrow);
2796+
DTPRINT(_("%8.3fs (%3.0f%%) Column type detection using %"PRId64" sample rows\n"),
2797+
tColType-tLayout, 100.0*(tColType-tLayout)/tTot, sampleLines);
2798+
DTPRINT(_("%8.3fs (%3.0f%%) Allocation of %"PRId64" rows x %d cols (%.3fGB) of which %"PRId64" (%3.0f%%) rows used\n"),
2799+
tAlloc-tColType, 100.0*(tAlloc-tColType)/tTot, allocnrow, ncol, DTbytes/(1024.0*1024*1024), DTi, 100.0*DTi/allocnrow);
28002800
thRead/=nth; thPush/=nth;
28012801
double thWaiting = tReread-tAlloc-thRead-thPush;
2802-
DTPRINT(_("%8.3fs (%3.0f%%) Reading %d chunks (%d swept) of %.3fMB (each chunk %d rows) using %d threads\n"),
2803-
tReread-tAlloc, 100.0*(tReread-tAlloc)/tTot, nJumps, nSwept, (double)chunkBytes/(1024*1024), (int)(DTi/nJumps), nth);
2802+
DTPRINT(_("%8.3fs (%3.0f%%) Reading %d chunks (%d swept) of %.3fMB (each chunk %"PRId64" rows) using% d threads\n"),
2803+
tReread-tAlloc, 100.0*(tReread-tAlloc)/tTot, nJumps, nSwept, (double)chunkBytes/(1024*1024), DTi/nJumps, nth);
28042804
DTPRINT(_(" + %8.3fs (%3.0f%%) Parse to row-major thread buffers (grown %d times)\n"), thRead, 100.0*thRead/tTot, buffGrown);
28052805
DTPRINT(_(" + %8.3fs (%3.0f%%) Transpose\n"), thPush, 100.0*thPush/tTot);
28062806
DTPRINT(_(" + %8.3fs (%3.0f%%) Waiting\n"), thWaiting, 100.0*thWaiting/tTot);

0 commit comments

Comments
 (0)