Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions inst/tests/tests.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -15403,6 +15403,20 @@ DT = data.table(d=sample(seq(as.Date("2015-01-01"), as.Date("2015-01-05"), by="d
test(2070.01, typeof(DT$d), "double")
test(2070.02, DT[, .N, keyby=d, verbose=TRUE], output="Column 1.*date.*8 byte double.*no fractions are present.*4 byte integer.*to save space and time")

# coverage along with switch+default pairing
test(2071.01, dcast(data.table(id=1, grp=1, e=expression(1)), id ~ grp, value.var='e'), error="Unsupported column type in fcast val: 'expression'")
test(2071.02, is_na(data.table(expression(1))), error="Unsupported column type 'expression'")
test(2071.03, is_na(data.table(1L), 2L), error="Item 1 of 'cols' is 2 which is outside")
test(2071.04, is_na(list(1L, 1:2)), error="Column 2 of input list x is length 2, inconsistent")
test(2071.05, any_na(data.table(1L), 2L), error="Item 1 of 'cols' is 2 which is outside")
test(2071.06, any_na(list(1L, 1:2)), error="Column 2 of input list x is length 2, inconsistent")
test(2071.07, any_na(data.table(as.raw(0L))), FALSE)
test(2071.08, any_na(data.table(c(1+1i, NA))))
test(2071.09, any_na(data.table(expression(1))), error="Unsupported column type 'expression'")
test(2071.10, dcast(data.table(a=1, b=1, l=list(list(1))), a ~ b, value.var='l'),
data.table(a=1, `1`=list(list(1)), key='a'))
test(2071.11, dcast(data.table(a = 1, b = 2, c = 3), a ~ b, value.var = 'c', fill = '2'),
data.table(a=1, `2`=3, key='a'))

###################################
# Add new tests above this line #
Expand Down
4 changes: 2 additions & 2 deletions src/assign.c
Original file line number Diff line number Diff line change
Expand Up @@ -1021,8 +1021,8 @@ void writeNA(SEXP v, const int from, const int n)
// If there's ever a way added to R API to pass NA_STRING to allocVector() to tell it to initialize with NA not "", would be great
for (int i=from; i<=to; ++i) SET_STRING_ELT(v, i, NA_STRING);
break;
case VECSXP :
// list columns already have each item initialized to NULL
case VECSXP : case EXPRSXP :
// list & expression columns already have each item initialized to NULL
break;
default :
error("Internal error: writeNA passed a vector of type '%s'", type2char(TYPEOF(v))); // # nocov
Expand Down
11 changes: 7 additions & 4 deletions src/bmerge.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,10 +265,11 @@ void bmerge_r(int xlowIn, int xuppIn, int ilowIn, int iuppIn, int col, int thisg
}
if (col>-1 && op[col] != EQ) {
switch (op[col]) {
case LE : xlow = xlowIn; break;
case LT : xupp = xlow + 1; xlow = xlowIn; break;
case GE : if (ival.i != NA_INTEGER) xupp = xuppIn; break;
case GT : xlow = xupp - 1; if (ival.i != NA_INTEGER) xupp = xuppIn; break;
case LE : xlow = xlowIn; break;
case LT : xupp = xlow + 1; xlow = xlowIn; break;
case GE : if (ival.i != NA_INTEGER) xupp = xuppIn; break;
case GT : xlow = xupp - 1; if (ival.i != NA_INTEGER) xupp = xuppIn; break;
default : error("Internal error in bmerge_r for '%s' column. Unrecognized value op[col]=%d", type2char(TYPEOF(xc)), op[col]); // #nocov
}
// for LE/LT cases, we need to ensure xlow excludes NA indices, != EQ is checked above already
if (op[col] <= 3 && xlow<xupp-1 && ival.i != NA_INTEGER && INTEGER(xc)[XIND(xlow+1)] == NA_INTEGER) {
Expand Down Expand Up @@ -376,6 +377,7 @@ void bmerge_r(int xlowIn, int xuppIn, int ilowIn, int iuppIn, int col, int thisg
case LT : xupp = xlow + 1; if (!isivalNA) xlow = xlowIn; break;
case GE : if (!isivalNA) xupp = xuppIn; break;
case GT : xlow = xupp - 1; if (!isivalNA) xupp = xuppIn; break;
default : error("Internal error in bmerge_r for '%s' column. Unrecognized value op[col]=%d", type2char(TYPEOF(xc)), op[col]); // #nocov
}
// for LE/LT cases, we need to ensure xlow excludes NA indices, != EQ is checked above already
if (op[col] <= 3 && xlow<xupp-1 && !isivalNA && (!isInt64 ? ISNAN(dxc[XIND(xlow+1)]) : (DtoLL(dxc[XIND(xlow+1)]) == NA_INT64_LL))) {
Expand Down Expand Up @@ -546,6 +548,7 @@ void bmerge_r(int xlowIn, int xuppIn, int ilowIn, int iuppIn, int col, int thisg
if (iupp<iuppIn)
bmerge_r(xlowIn, xuppIn, iupp-1, iuppIn, col, 1, lowmax && xupp-1==xlowIn, uppmax);
break;
default : break; // do nothing
}
}

2 changes: 1 addition & 1 deletion src/fcast.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

// TO DO: margins
SEXP fcast(SEXP lhs, SEXP val, SEXP nrowArg, SEXP ncolArg, SEXP idxArg, SEXP fill, SEXP fill_d, SEXP is_agg) {

int nrows=INTEGER(nrowArg)[0], ncols=INTEGER(ncolArg)[0];
int nlhs=length(lhs), nval=length(val), *idx = INTEGER(idxArg);
SEXP target;
Expand Down Expand Up @@ -80,6 +79,7 @@ SEXP fcast(SEXP lhs, SEXP val, SEXP nrowArg, SEXP ncolArg, SEXP idxArg, SEXP fil
}
}
break;
default: error("Unsupported column type in fcast val: '%s'", type2char(TYPEOF(thiscol))); // #nocov
}
if (count) UNPROTECT(1);
}
Expand Down
5 changes: 3 additions & 2 deletions src/frank.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ SEXP dt_na(SEXP x, SEXP cols) {
}
break;
default:
error("Unknown column type '%s'", type2char(TYPEOF(v)));
error("Unsupported column type '%s'", type2char(TYPEOF(v)));
}
}
UNPROTECT(1);
Expand Down Expand Up @@ -127,6 +127,7 @@ SEXP frank(SEXP xorderArg, SEXP xstartArg, SEXP xlenArg, SEXP ties_method) {
// INTEGER(ans)[xorder[j]-1] = k++;
// }
// break;
default: error("Internal error: unknown ties value in frank: %d", ties); // #nocov
}
}
UNPROTECT(1);
Expand Down Expand Up @@ -198,7 +199,7 @@ SEXP anyNA(SEXP x, SEXP cols) {
}
break;
default:
error("Unknown column type '%s'", type2char(TYPEOF(v)));
error("Unsupported column type '%s'", type2char(TYPEOF(v)));
}
if (LOGICAL(ans)[0]) break;
}
Expand Down
5 changes: 3 additions & 2 deletions src/frollR.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,11 @@ SEXP frollfunR(SEXP fun, SEXP obj, SEXP k, SEXP fill, SEXP algo, SEXP align, SEX
if (!badaptive) frollsum(ialgo, dx[i], inx[i], &dans[i*nk+j], iik[j], ialign, dfill, bnarm, ihasna, bverbose);
else fadaptiverollsum(ialgo, dx[i], inx[i], &dans[i*nk+j], ikl[j], dfill, bnarm, ihasna, bverbose);
break;
default: error("Internal error: Unknown sfun value in froll: %d", sfun); // #nocov
}
}
}

for (R_len_t i=0; i<nx; i++) { // raise errors and warnings, as of now messages are not being produced
for (R_len_t j=0; j<nk; j++) {
if (bverbose && (dans[i*nk+j].message[0][0] != '\0')) Rprintf("%s: %d:\n%s", __func__, i*nk+j+1, dans[i*nk+j].message[0]);
Expand All @@ -200,7 +201,7 @@ SEXP frollfunR(SEXP fun, SEXP obj, SEXP k, SEXP fill, SEXP algo, SEXP align, SEX
if (dans[i*nk+j].status == 3) error("%s: %d: %s", __func__, i*nk+j+1, dans[i*nk+j].message[3]); // # nocov because only caused by malloc
}
}

if (bverbose) Rprintf("%s: processing of %d column(s) and %d window(s) took %.3fs\n", __func__, nx, nk, omp_get_wtime()-tic);

UNPROTECT(protecti);
Expand Down
17 changes: 14 additions & 3 deletions src/ijoin.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ SEXP lookup(SEXP ux, SEXP xlen, SEXP indices, SEXP gaps, SEXP overlaps, SEXP mul
if (count[i]) type_count[i] = 1;
}
break;
default: error("Internal error: unknown type in mult=%d in lookup: %d", mult, type); // #nocov
}
break;

Expand Down Expand Up @@ -117,8 +118,10 @@ SEXP lookup(SEXP ux, SEXP xlen, SEXP indices, SEXP gaps, SEXP overlaps, SEXP mul
}
}
break;
default: error("Internal error: unknown type in mult=%d in lookup: %d", mult, type); // #nocov
}
break;
default: error("Internal error: unknown mult in lookup: %d", mult); // #nocov
}
pass1 = clock() - start;
if (LOGICAL(verbose)[0])
Expand Down Expand Up @@ -154,6 +157,7 @@ SEXP lookup(SEXP ux, SEXP xlen, SEXP indices, SEXP gaps, SEXP overlaps, SEXP mul
INTEGER(VECTOR_ELT(lookup, to[i]-1))[idx[to[i]-1]++] = i+1;
}
break;
default: error("Internal error: unknown type lookup should have been caught earlier: %d", type); // #nocov
}
Free(idx);
// generate type_lookup
Expand Down Expand Up @@ -204,9 +208,11 @@ SEXP lookup(SEXP ux, SEXP xlen, SEXP indices, SEXP gaps, SEXP overlaps, SEXP mul
// for (j=0; j<type_count[i]; j++)
// INTEGER(tt)[j] = INTEGER(vv)[j];
// }
break;
break; // #nocov
default: error("Internal error: unknown type in mult=%d in lookup should have been caught earlier: %d", mult, type); // #nocov
}
break;
break;
default: error("Internal error: unknown mult in lookup: %d", mult); // #nocov
}
}
pass3 = clock() - start;
Expand Down Expand Up @@ -314,6 +320,7 @@ SEXP overlaps(SEXP ux, SEXP imatches, SEXP multArg, SEXP typeArg, SEXP nomatchAr
++totlen;
}
break;
default: error("Internal error: unknown type in mult=ALL in overlaps: %d", mult, type); // #nocov
}
} else totlen = rows;
end1 = clock() - start;
Expand Down Expand Up @@ -454,12 +461,13 @@ SEXP overlaps(SEXP ux, SEXP imatches, SEXP multArg, SEXP typeArg, SEXP nomatchAr
}
}
break;
default: error("Internal error: unknown type in mult=%d in overlaps: %d", mult, type); // #nocov
}
break;

case FIRST:
switch (type) {
case START: case END:
case START: case END:
for (i=0; i<rows; i++) {
len = thislen;
INTEGER(f1__)[thislen] = i+1;
Expand Down Expand Up @@ -560,6 +568,7 @@ SEXP overlaps(SEXP ux, SEXP imatches, SEXP multArg, SEXP typeArg, SEXP nomatchAr
}
}
break;
default: error("Internal error: unknown type in mult=%d in overlaps: %d", mult, type); // #nocov
}
break;

Expand Down Expand Up @@ -708,8 +717,10 @@ SEXP overlaps(SEXP ux, SEXP imatches, SEXP multArg, SEXP typeArg, SEXP nomatchAr
}
}
break;
default: error("Internal error: unknown type in mult=%d in overlaps: %d", mult, type); // #nocov
}
break;
default: error("Internal error: unknown mult in overlaps: %d", mult); // #nocov
}
end2 = clock() - start;
if (LOGICAL(verbose)[0])
Expand Down
3 changes: 2 additions & 1 deletion src/nafill.c
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ SEXP nafillR(SEXP obj, SEXP type, SEXP fill, SEXP inplace, SEXP cols, SEXP verbo
if (!strcmp(CHAR(STRING_ELT(type, 0)), "const")) itype = 0;
else if (!strcmp(CHAR(STRING_ELT(type, 0)), "locf")) itype = 1;
else if (!strcmp(CHAR(STRING_ELT(type, 0)), "nocb")) itype = 2;
else error("Internal error: invalid type argument in nafillR function, should have been caught before. please report to data.table issue tracker."); // # nocov
else error("Internal error: invalid type argument in nafillR function, should have been caught before. Please report to data.table issue tracker."); // # nocov

if (itype==0 && length(fill)!=1)
error("fill must be a vector of length 1");
Expand All @@ -235,6 +235,7 @@ SEXP nafillR(SEXP obj, SEXP type, SEXP fill, SEXP inplace, SEXP cols, SEXP verbo
case INTSXP : {
nafillInteger(ix[i], inx[i], itype, ifill, &vans[i], bverbose);
} break;
default: error("Internal error: invalid type argument in nafillR function, should have been caught before. Please report to data.table issue tracker."); // # nocov
}
}
if (bverbose) toc = omp_get_wtime();
Expand Down