Skip to content

Commit 9ee598f

Browse files
authored
Merge branch 'master' into todoRename
2 parents fd014c4 + c27ec26 commit 9ee598f

File tree

7 files changed

+330
-27
lines changed

7 files changed

+330
-27
lines changed

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
^\.github$
2020
^\.vscode$
2121
^\.zed$
22+
^\.lintr$
2223

2324
^\.gitlab-ci\.yml$
2425

GOVERNANCE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Governance for the R data.table project
1+
# Governance for the R data.table project
22

33
# Purpose and scope
44

@@ -121,7 +121,7 @@ Funds acquired by the data.table project will be disbursed at the discretion of
121121

122122
# Code of conduct
123123

124-
The full Code of Conduct can be found [here](CODE_OF_CONDUCT.md), including details for reporting violations.
124+
The full Code of Conduct can be found [here](.github/CODE_OF_CONDUCT.md), including details for reporting violations.
125125

126126
## Reporting Responsibility
127127

man/fread.Rd

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,15 @@ Currently, the \code{yaml} setting is somewhat inflexible with respect to incorp
118118
119119
When \code{input} begins with http://, https://, ftp://, ftps://, or file://, \code{fread} detects this and \emph{downloads} the target to a temporary file (at \code{tempfile()}) before proceeding to read the file as usual. URLS (ftps:// and https:// as well as ftp:// and http://) paths are downloaded with \code{download.file} and \code{method} set to \code{getOption("download.file.method")}, defaulting to \code{"auto"}; and file:// is downloaded with \code{download.file} with \code{method="internal"}. NB: this implies that for file://, even files found on the current machine will be "downloaded" (i.e., hard-copied) to a temporary file. See \code{\link{download.file}} for more details.
120120
121+
\bold{Automatic Decompression:}
122+
123+
In many cases, \code{fread} can automatically detect and decompress files with common compression extensions directly, without needing an explicit connection object or shell commands. This works by checking the file extension.
124+
125+
\itemize{
126+
\item \code{.gz} and \code{.bz2} are supported out of the box.
127+
\item \code{.zip} is also supported. If the archive contains a single data file, \code{fread} will read it. If the archive contains multiple files, \code{fread} will produce an error.
128+
}
129+
121130
\bold{Shell commands:}
122131
123132
\code{fread} accepts shell commands for convenience. The input command is run and its output written to a file in \code{tmpdir} (\code{\link{tempdir}()} by default) to which \code{fread} is applied "as normal". The details are platform dependent -- \code{system} is used on UNIX environments, \code{shell} otherwise; see \code{\link[base]{system}}.

src/fmelt.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -282,23 +282,23 @@ SEXP checkVars(SEXP DT, SEXP id, SEXP measure, Rboolean verbose) {
282282
}
283283

284284
struct processData {
285-
SEXP RCHK; // a 2 item list holding vars (result of checkVars) and not_NA_indices. PROTECTed up in fmelt so that preprocess() doesn't need to PROTECT. To pass rchk, #2865
286-
SEXP idcols, // convenience pointers into RCHK[0][0], RCHK[0][1] and RCHK[1] respectively
287-
variable_table, // NULL or data for variable column(s).
288-
valuecols, // list with one element per output/value column, each element is an integer vector.
289-
not_NA_indices;
290-
int *isfactor,
291-
*leach, // length of each element of the valuecols(measure.vars) list.
292-
*isidentical; // are all inputs for this value column the same type?
293-
int lids, // number of id columns.
294-
lvars, // number of variable columns.
295-
lvalues, // number of value columns.
296-
lmax, // max length of valuecols elements / number of times to repeat ids.
297-
totlen, // of output/long DT result of melt operation.
298-
nrow; // of input/wide DT to be melted.
285+
SEXP RCHK; // a 2 item list holding vars (result of checkVars) and not_NA_indices. PROTECTed up in fmelt so that preprocess() doesn't need to PROTECT. To pass rchk, #2865
286+
SEXP idcols; // convenience pointers into RCHK[0][0], RCHK[0][1] and RCHK[1] respectively
287+
SEXP variable_table; // NULL or data for variable column(s).
288+
SEXP valuecols; // list with one element per output/value column, each element is an integer vector.
289+
SEXP not_NA_indices;
290+
int *isfactor;
291+
int *leach; // length of each element of the valuecols(measure.vars) list.
292+
int *isidentical; // are all inputs for this value column the same type?
293+
int lids; // number of id columns.
294+
int lvars; // number of variable columns.
295+
int lvalues; // number of value columns.
296+
int lmax; // max length of valuecols elements / number of times to repeat ids.
297+
int totlen; // of output/long DT result of melt operation.
298+
int nrow; // of input/wide DT to be melted.
299299
SEXPTYPE *maxtype;
300-
bool measure_is_list,
301-
narm; // remove missing values?
300+
bool measure_is_list;
301+
bool narm; // remove missing values?
302302
};
303303

304304
static void preprocess(SEXP DT, SEXP id, SEXP measure, SEXP varnames, SEXP valnames, Rboolean narm, Rboolean verbose, struct processData *data) {

src/freadR.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -265,15 +265,13 @@ bool userOverride(int8_t *type, lenOff *colNames, const char *anchor, const int
265265
colNamesSxp = R_NilValue;
266266
SET_VECTOR_ELT(RCHK, 1, colNamesSxp = allocVector(STRSXP, ncol));
267267
for (int i = 0; i < ncol; i++) {
268-
SEXP elem;
269268
if (colNames == NULL || colNames[i].len <= 0) {
270269
char buff[12];
271270
snprintf(buff, sizeof(buff), "V%d", i + 1); // # notranslate
272-
elem = mkChar(buff); // no PROTECT as passed immediately to SET_STRING_ELT
271+
SET_STRING_ELT(colNamesSxp, i, mkChar(buff)); // no PROTECT as passed immediately to SET_STRING_ELT
273272
} else {
274-
elem = mkCharLenCE(anchor + colNames[i].off, colNames[i].len, ienc); // no PROTECT as passed immediately to SET_STRING_ELT
273+
SET_STRING_ELT(colNamesSxp, i, mkCharLenCE(anchor + colNames[i].off, colNames[i].len, ienc)); // no PROTECT as passed immediately to SET_STRING_ELT
275274
}
276-
SET_STRING_ELT(colNamesSxp, i, elem);
277275
}
278276
// "use either select= or drop= but not both" was checked earlier in freadR
279277
applyDrop(dropSxp, type, ncol, /*dropSource=*/-1);

src/quickselect.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
// from good ol' Numerical Recipes in C
44

5-
static inline void iswap(int *a, int *b) {int tmp=*a; *a=*b; *b=tmp;}
6-
static inline void dswap(double *a, double *b) {double tmp=*a; *a=*b; *b=tmp;}
7-
static inline void i64swap(int64_t *a, int64_t *b) {int64_t tmp=*a; *a=*b; *b=tmp;}
5+
static inline void iswap(int *a, int *b) { int tmp = *a; *a = *b; *b = tmp; }
6+
static inline void dswap(double *a, double *b) { double tmp = *a; *a = *b; *b = tmp; }
7+
static inline void i64swap(int64_t *a, int64_t *b) { int64_t tmp = *a; *a = *b; *b = tmp; }
88

99
#undef BODY
1010
#define BODY(SWAP) \
@@ -30,7 +30,7 @@ static inline void i64swap(int64_t *a, int64_t *b) {int64_t tmp=*a; *a=*b; *b=tm
3030
SWAP(x + l, x + l + 1); \
3131
} \
3232
unsigned long i = l + 1, j = ir; \
33-
a=x[l + 1]; \
33+
a = x[l + 1]; \
3434
for (;;) { \
3535
do i++; while (x[i] < a); \
3636
do j--; while (x[j] > a); \
@@ -44,7 +44,7 @@ static inline void i64swap(int64_t *a, int64_t *b) {int64_t tmp=*a; *a=*b; *b=tm
4444
} \
4545
} \
4646
a = x[med]; \
47-
if (n%2 == 1) { \
47+
if (n % 2 == 1) { \
4848
return (double)a; \
4949
} else { \
5050
b = x[med + 1]; \

0 commit comments

Comments
 (0)