Repository navigation
Use consistent types with fwriteMainArgs.nrow. #4213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,7 +26,7 @@ int getStringLen(SEXP *col, int64_t row) { | |
| int getMaxStringLen(const SEXP *col, const int64_t n) { | ||
| int max=0; | ||
| SEXP last=NULL; | ||
| for (int i=0; i<n; ++i) { | ||
| for (int64_t i=0; i<n; ++i) { | ||
| SEXP this = *col++; | ||
| if (this==last) continue; // no point calling LENGTH() again on the same string; LENGTH is unlikely as fast as single pointer compare | ||
| int thisnchar = LENGTH(this); | ||
|
|
@@ -90,17 +90,17 @@ void writeList(SEXP *col, int64_t row, char **pch) { | |
| int getMaxListItemLen(const SEXP *col, const int64_t n) { | ||
| int max=0; | ||
| SEXP last=NULL; | ||
| for (int i=0; i<n; ++i) { | ||
| for (int64_t i=0; i<n; ++i) { | ||
| SEXP this = *col++; | ||
| if (this==last) continue; // no point calling LENGTH() again on the same string; LENGTH is unlikely as fast as single pointer compare | ||
| int32_t wf = whichWriter(this); | ||
| if (TYPEOF(this)==VECSXP || wf==INT32_MIN || isFactor(this)) { | ||
| error(_("Row %d of list column is type '%s' - not yet implemented. fwrite() can write list columns containing items which are atomic vectors of type logical, integer, integer64, double, complex and character."), | ||
| error(_("Row %"PRId64" of list column is type '%s' - not yet implemented. fwrite() can write list columns containing items which are atomic vectors of type logical, integer, integer64, double, complex and character."), | ||
| i+1, isFactor(this) ? "factor" : type2char(TYPEOF(this))); | ||
| } | ||
| int width = writerMaxLen[wf]; | ||
| if (width==0) { | ||
| if (wf!=WF_String) STOP(_("Internal error: row %d of list column has no max length method implemented"), i+1); // # nocov | ||
| if (wf!=WF_String) STOP(_("Internal error: row %"PRId64" of list column has no max length method implemented"), i+1); // # nocov | ||
| const int l = LENGTH(this); | ||
| for (int j=0; j<l; ++j) width+=LENGTH(STRING_ELT(this, j)); | ||
| } else { | ||
|
|
@@ -228,8 +228,9 @@ SEXP fwriteR( | |
| int firstListColumn = 0; | ||
| for (int j=0; j<args.ncol; j++) { | ||
| SEXP column = VECTOR_ELT(DFcoerced, j); | ||
| if (args.nrow != length(column)) | ||
| error(_("Column %d's length (%d) is not the same as column 1's length (%d)"), j+1, length(column), args.nrow); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great spot too. Yes this would cause that strange number in the error message. |
||
| if (args.nrow != length(column)) { | ||
| error(_("Column %d's length (%d) is not the same as column 1's length (%"PRId64")"), j+1, length(column), args.nrow); | ||
| } | ||
| int32_t wf = whichWriter(column); | ||
| if (wf<0) { | ||
| error(_("Column %d's type is '%s' - not yet implemented in fwrite."), j+1, type2char(TYPEOF(column))); | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great spot! Thanks.