Skip to content

Commit

Permalink
cbindlist
Browse files Browse the repository at this point in the history
add cbind by reference, timing

R prototype of mergelist

wording

use lower overhead funs

stick to int32 for now, correct R_alloc

bmerge C refactor for codecov and one loop for speed

address revealed codecov gaps

refactor vecseq for codecov

seqexp helper, some alloccol export on C

bmerge codecov, types handled in R bmerge already

better comment seqexp

bmerge mult=error #655

multiple new C utils

swap if branches

explain new C utils

comments mostly

reduce conflicts to PR #4386

comment C code

address multiple matches during update-on-join #3747

Revert "address multiple matches during update-on-join #3747"

This reverts commit b64c0c3.

merge.dt has temporarily mult arg, for testing

minor changes to cbindlist c

dev mergelist, for single pair now

add quiet option to cc()

mergelist tests

add check for names to perhaps.dt

rm mult from merge.dt method

rework, clean, polish multer, fix righ and full joins

make full join symmetric

mergepair inner function to loop on

extra check for symmetric

mergelist manual

ensure no df-dt passed where list expected

comments and manual

handle 0 cols tables

more tests

more tests and debugging

move more logic closer to bmerge, simplify mergepair

more tests

revert not used changes

reduce not needed checks, cleanup

copy arg behavior, manual, no tests yet

cbindlist manual, export both

cleanup processing bmerge to dtmatch

test function match order for easier preview

vecseq gets short-circuit

batch test allow browser

big cleanup

remmove unneeded stuff, reduce diff

more cleanup, minor manual fixes

add proper test scripts

Merge branch 'master' into cbind-merge-list

comment out not used code for coverage

more tests, some nocopy opts

rename sql test script, should fix codecov

simplify dtmatch inner branch

more precise copy, now copy only T or F

unused arg not yet in api, wording

comments and refer issues

codecov

hasindex coverage

codecov gap

tests for join using key, cols argument

fix missing import forderv

more tests, improve missing on handling

more tests for order of inner and full join for long keys

new allow.cartesian option, #4383, #914

reduce diff, improve codecov

reduce diff, comments

need more DT, not lists, mergelist 3+ tbls

proper escape heavy check

unit tests

more tests, address overalloc failure

mergelist and cbindlist retain index

manual, examples

fix manual

minor clarify in manual

retain keys, right outer join for snowflake schema joins

duplicates in cbindlist

recycling in cbindlist

escape 0 input in copyCols

empty input handling

closing cbindlist

vectorized _on_ and _join.many_ arg

rename dtmatch to dtmerge

vectorized args: how, mult
push down input validation
add support for cross join, semi join, anti join

full join, reduce overhead for mult=error

mult default value dynamic

fix manual

add "see details" to Rd

mention shared on in arg description

amend feedback from Michael

semi and anti joins will not reorder x columns

Merge branch 'master' into cbind-merge-list

spelling, thx to @jan-glx

check all new funs used and add comments

bugfix, sort=T needed for now

Merge branch 'master' into cbind-merge-list

Update NEWS.md

Merge branch 'master' into cbind-merge-list

Merge branch 'master' into cbind-merge-list

NEWS placement

numbering

ascArg->order

Merge remote-tracking branch 'origin/cbind-merge-list' into cbind-merge-list

attempt to restore from master

Update to stopf() error style

Need isFrame for now

More quality checks: any(!x)->!all(x); use vapply_1{b,c,i}

really restore from master

try to PROTECT() before duplicate()

update error message in test

appease the rchk gods

extraneous space

missing ';'

use catf

simplify perhapsDataTableR

move sqlite.Rraw.manual into other.Rraw

simplify for loop

Merge remote-tracking branch 'origin/cbind-merge-list' into cbind-merge-list
  • Loading branch information
MichaelChirico committed Oct 1, 2024
1 parent 0ab0f5e commit 8bba6af
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/data.table.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,12 @@ SEXP islockedR(SEXP x);
bool need2utf8(SEXP x);
SEXP coerceUtf8IfNeeded(SEXP x);
SEXP coerceAs(SEXP x, SEXP as, SEXP copyArg);
int NROW(SEXP x);
int NCOL(SEXP x);
bool isDataTable(SEXP x);
bool isDataList(SEXP x);
bool perhapsDataTable(SEXP x);
SEXP perhapsDataTableR(SEXP x);
void internal_error(const char *call_name, const char *format, ...);

// types.c
Expand Down
83 changes: 83 additions & 0 deletions src/utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,89 @@ SEXP startsWithAny(const SEXP x, const SEXP y, SEXP start) {
return ScalarLogical(false);
}

// if (length(x)) length(x[[1L]]) else 0L
int NROW(SEXP x) {

Check warning on line 443 in src/utils.c

View check run for this annotation

Codecov / codecov/patch

src/utils.c#L443

Added line #L443 was not covered by tests
// used in src/mergelist.c and below in commented out set_row_names
if (!LENGTH(x))

Check warning on line 445 in src/utils.c

View check run for this annotation

Codecov / codecov/patch

src/utils.c#L445

Added line #L445 was not covered by tests
return 0; // # nocov # not yet reached from anywhere, cbindlist uses it but escapes for !NCOL(x)
return length(VECTOR_ELT(x, 0));

Check warning on line 447 in src/utils.c

View check run for this annotation

Codecov / codecov/patch

src/utils.c#L447

Added line #L447 was not covered by tests
}

// length(x)
int NCOL(SEXP x) {

Check warning on line 451 in src/utils.c

View check run for this annotation

Codecov / codecov/patch

src/utils.c#L451

Added line #L451 was not covered by tests
// used in src/mergelist.c
// to be an abstraction layer on C level
return LENGTH(x);

Check warning on line 454 in src/utils.c

View check run for this annotation

Codecov / codecov/patch

src/utils.c#L454

Added line #L454 was not covered by tests
}

/*
Below commented out functions will be uncommented when addressing #4439
// c("data.table","data.frame")
static SEXP char2_dtdf() {
SEXP char2_dtdf = PROTECT(allocVector(STRSXP, 2));
SET_STRING_ELT(char2_dtdf, 0, char_datatable);
SET_STRING_ELT(char2_dtdf, 1, char_dataframe);
UNPROTECT(1);
return char2_dtdf;
}
// .set_row_names(x)
static SEXP set_row_names(int n) {
SEXP ans = R_NilValue;
if (n) {
ans = PROTECT(allocVector(INTSXP, 2));
INTEGER(ans)[0] = NA_INTEGER;
INTEGER(ans)[1] = -n;
} else {
ans = PROTECT(allocVector(INTSXP, 0));
}
UNPROTECT(1);
return ans;
}
// setDT(x) ## not in-place!
SEXP setDT(SEXP x) {
if (!isNewList(x))
error("internal error: C setDT should be called only on a list"); // # nocov
setAttrib(x, R_ClassSymbol, char2_dtdf());
setAttrib(x, sym_rownames, set_row_names(NROW(x)));
return alloccolwrapper(x, GetOption(sym_alloccol, R_NilValue), GetOption(sym_verbose, R_NilValue));
}*/

// inherits(x, "data.table")
bool isDataTable(SEXP x) {
return INHERITS(x, char_datatable);

Check warning on line 493 in src/utils.c

View check run for this annotation

Codecov / codecov/patch

src/utils.c#L492-L493

Added lines #L492 - L493 were not covered by tests
}

// rectangular list; NB does not allow length-1 recycling
// length(x) <= 1L || length(unique(lengths(x))) == 1L
static inline bool equalLens(SEXP x) {
int n = LENGTH(x);
if (n < 2)
return true;
R_xlen_t nr = xlength(VECTOR_ELT(x, 0));
for (int i=1; i<n; ++i) {
if (xlength(VECTOR_ELT(x, i)) != nr)
return false;

Check warning on line 505 in src/utils.c

View check run for this annotation

Codecov / codecov/patch

src/utils.c#L498-L505

Added lines #L498 - L505 were not covered by tests
}
return true;

Check warning on line 507 in src/utils.c

View check run for this annotation

Codecov / codecov/patch

src/utils.c#L507

Added line #L507 was not covered by tests
}

// setDT()-friendly rectangular list, i.e.
// is.list(x) && equalLens(x) && (!length(x) || !is.null(names(x)))
bool isDataList(SEXP x) {
return isNewList(x) && (!LENGTH(x) || (equalLens(x) && !isNull(getAttrib(x, R_NamesSymbol))));

Check warning on line 513 in src/utils.c

View check run for this annotation

Codecov / codecov/patch

src/utils.c#L512-L513

Added lines #L512 - L513 were not covered by tests
}

// TODO: use isDataFrame (when included in any R release).
// isDataTable(x) || isFrame(x) || isDataList(x)
bool perhapsDataTable(SEXP x) {
return isDataTable(x) || isFrame(x) || isDataList(x);

Check warning on line 519 in src/utils.c

View check run for this annotation

Codecov / codecov/patch

src/utils.c#L518-L519

Added lines #L518 - L519 were not covered by tests
}
SEXP perhapsDataTableR(SEXP x) {
return ScalarLogical(perhapsDataTable(x));

Check warning on line 522 in src/utils.c

View check run for this annotation

Codecov / codecov/patch

src/utils.c#L521-L522

Added lines #L521 - L522 were not covered by tests
}

void internal_error(const char *call_name, const char *format, ...) {
char buff[1024];
va_list args;
Expand Down

0 comments on commit 8bba6af

Please sign in to comment.