Skip to content
Merged
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 SEXP nqgrp;
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 @@ SEXP bmerge(SEXP idt, SEXP xdt, SEXP icolsArg, SEXP xcolsArg, SEXP xoArg, SEXP r
mult = FIRST;
else if (!strcmp(CHAR(STRING_ELT(multArg, 0)), "last"))
mult = LAST;
else if (!strcmp(CHAR(STRING_ELT(multArg, 0)), "error"))
mult = ERR;
else
internal_error(__func__, "invalid value for 'mult'"); // # nocov

Expand Down Expand Up @@ -426,7 +428,7 @@ void bmerge_r(int xlowIn, int xuppIn, int ilowIn, int iuppIn, int col, int thisg
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 @@ void bmerge_r(int xlowIn, int xuppIn, int ilowIn, int iuppIn, int col, int thisg
}
} 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