Skip to content
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

[cbindlist/mergelist] Add ERR to the mult enum in bmerge.c #6432

Open
wants to merge 2 commits into
base: cbind-merge-list-prep
Choose a base branch
from
Open
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
8 changes: 5 additions & 3 deletions src/bmerge.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
static int ncol, *o, *xo, *retFirst, *retLength, *retIndex, *allLen1, *allGrp1, *rollends, ilen, anslen;
static int *op, nqmaxgrp;
static int ctr, nomatch; // populating matches for non-equi joins
enum {ALL, FIRST, LAST} mult = ALL;
enum {ALL, FIRST, LAST, ERR} mult = ALL;
static double roll, rollabs;
static Rboolean rollToNearest=FALSE;
#define XIND(i) (xo ? xo[(i)]-1 : i)
Expand Down Expand Up @@ -113,6 +113,8 @@
mult = FIRST;
else if (!strcmp(CHAR(STRING_ELT(multArg, 0)), "last"))
mult = LAST;
else if (!strcmp(CHAR(STRING_ELT(multArg, 0)), "error"))
mult = ERR;

Check warning on line 117 in src/bmerge.c

View check run for this annotation

Codecov / codecov/patch

src/bmerge.c#L116-L117

Added lines #L116 - L117 were not covered by tests
else
internal_error(__func__, "invalid value for 'mult'"); // # nocov

Expand Down Expand Up @@ -426,7 +428,7 @@
for (int j=ilow+1; j<iupp; j++) {
const int k = o ? o[j]-1 : j;
if (retFirst[k] != nomatch) {
if (mult == ALL) {
if (mult == ALL || mult == ERR) { // len>1 && mult==ERR already checked, no dup matches, continue as mult=ALL
// for this irow, we've matches on more than one group
allGrp1[0] = FALSE;
retFirst[ctr+ilen] = xlow+2;
Expand All @@ -448,7 +450,7 @@
}
} else {
// none of the groups so far have filled in for this index. So use it!
if (mult == ALL) {
if (mult == ALL || mult == ERR) {
retFirst[k] = xlow+2;
retLength[k] = len;
retIndex[k] = k+1;
Expand Down
Loading