Changeset: a0f0e6dcddf1 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a0f0e6dcddf1
Modified Files:
        clients/Tests/MAL-signatures.stable.out
        clients/Tests/MAL-signatures.stable.out.int128
        clients/Tests/exports.stable.out
        monetdb5/modules/mal/pcre.c
        monetdb5/modules/mal/pcre.mal
        monetdb5/optimizer/opt_postfix.c
        monetdb5/optimizer/opt_prelude.c
        monetdb5/optimizer/opt_prelude.h
Branch: default
Log Message:

Reduce output from 2 to 1 oid list at like and ilike joins if possible


diffs (truncated from 494 to 300 lines):

diff --git a/clients/Tests/MAL-signatures.stable.out 
b/clients/Tests/MAL-signatures.stable.out
--- a/clients/Tests/MAL-signatures.stable.out
+++ b/clients/Tests/MAL-signatures.stable.out
@@ -588,8 +588,10 @@ stdout of test 'MAL-signatures` in direc
 [ "algebra",   "groupby",      "command algebra.groupby(X_1:bat[:oid], 
X_2:bat[:lng]):bat[:oid] ",     "ALGgroupby;",  ""      ]
 [ "algebra",   "ilike",        "command algebra.ilike(X_1:str, X_2:str):bit ", 
"PCREilike2;",  ""      ]
 [ "algebra",   "ilike",        "command algebra.ilike(X_1:str, X_2:str, 
X_3:str):bit ",        "PCREilike3;",  ""      ]
-[ "algebra",   "ilikejoin",    "command algebra.ilikejoin(X_2:bat[:str], 
X_3:bat[:str], X_4:bat[:oid], X_5:bat[:oid], X_6:bit, X_7:lng) (X_0:bat[:oid], 
X_1:bat[:oid]) ",      "ILIKEjoin1;",  ""      ]
-[ "algebra",   "ilikejoin",    "command algebra.ilikejoin(X_2:bat[:str], 
X_3:bat[:str], X_4:str, X_5:bat[:oid], X_6:bat[:oid], X_7:bit, X_8:lng) 
(X_0:bat[:oid], X_1:bat[:oid]) ",     "ILIKEjoin;",   ""      ]
+[ "algebra",   "ilikejoin",    "command algebra.ilikejoin(X_1:bat[:str], 
X_2:bat[:str], X_3:bat[:oid], X_4:bat[:oid], X_5:bit, X_6:lng):bat[:oid] ",   
"ILIKEjoin1;",  ""      ]
+[ "algebra",   "ilikejoin",    "command algebra.ilikejoin(X_2:bat[:str], 
X_3:bat[:str], X_4:bat[:oid], X_5:bat[:oid], X_6:bit, X_7:lng) (X_0:bat[:oid], 
X_1:bat[:oid]) ",      "ILIKEjoin;",   ""      ]
+[ "algebra",   "ilikejoin",    "command algebra.ilikejoin(X_1:bat[:str], 
X_2:bat[:str], X_3:str, X_4:bat[:oid], X_5:bat[:oid], X_6:bit, 
X_7:lng):bat[:oid] ",  "ILIKEjoin_esc1;",      ""      ]
+[ "algebra",   "ilikejoin",    "command algebra.ilikejoin(X_2:bat[:str], 
X_3:bat[:str], X_4:str, X_5:bat[:oid], X_6:bat[:oid], X_7:bit, X_8:lng) 
(X_0:bat[:oid], X_1:bat[:oid]) ",     "ILIKEjoin_esc;",       ""      ]
 [ "algebra",   "ilikeselect",  "command algebra.ilikeselect(X_1:bat[:str], 
X_2:bat[:oid], X_3:str, X_4:str, X_5:bit):bat[:oid] ",      "PCRElikeselect1;", 
    ""      ]
 [ "algebra",   "ilikeselect",  "command algebra.ilikeselect(X_1:bat[:str], 
X_2:bat[:oid], X_3:str, X_4:bit):bat[:oid] ",       "PCRElikeselect4;",     ""  
    ]
 [ "algebra",   "intersect",    "command algebra.intersect(X_1:bat[:any_1], 
X_2:bat[:any_1], X_3:bat[:oid], X_4:bat[:oid], X_5:bit, X_6:bit, 
X_7:lng):bat[:oid] ",      "ALGintersect;",        ""      ]
@@ -599,8 +601,10 @@ stdout of test 'MAL-signatures` in direc
 [ "algebra",   "leftjoin",     "command algebra.leftjoin(X_2:bat[:any_1], 
X_3:bat[:any_1], X_4:bat[:oid], X_5:bat[:oid], X_6:bit, X_7:lng) 
(X_0:bat[:oid], X_1:bat[:oid]) ",   "ALGleftjoin;", ""      ]
 [ "algebra",   "like", "command algebra.like(X_1:str, X_2:str):bit ",  
"PCRElike2;",   ""      ]
 [ "algebra",   "like", "command algebra.like(X_1:str, X_2:str, X_3:str):bit ", 
"PCRElike3;",   ""      ]
-[ "algebra",   "likejoin",     "command algebra.likejoin(X_2:bat[:str], 
X_3:bat[:str], X_4:bat[:oid], X_5:bat[:oid], X_6:bit, X_7:lng) (X_0:bat[:oid], 
X_1:bat[:oid]) ",       "LIKEjoin1;",   ""      ]
-[ "algebra",   "likejoin",     "command algebra.likejoin(X_2:bat[:str], 
X_3:bat[:str], X_4:str, X_5:bat[:oid], X_6:bat[:oid], X_7:bit, X_8:lng) 
(X_0:bat[:oid], X_1:bat[:oid]) ",      "LIKEjoin;",    ""      ]
+[ "algebra",   "likejoin",     "command algebra.likejoin(X_1:bat[:str], 
X_2:bat[:str], X_3:bat[:oid], X_4:bat[:oid], X_5:bit, X_6:lng):bat[:oid] ",    
"LIKEjoin1;",   ""      ]
+[ "algebra",   "likejoin",     "command algebra.likejoin(X_2:bat[:str], 
X_3:bat[:str], X_4:bat[:oid], X_5:bat[:oid], X_6:bit, X_7:lng) (X_0:bat[:oid], 
X_1:bat[:oid]) ",       "LIKEjoin;",    ""      ]
+[ "algebra",   "likejoin",     "command algebra.likejoin(X_1:bat[:str], 
X_2:bat[:str], X_3:str, X_4:bat[:oid], X_5:bat[:oid], X_6:bit, 
X_7:lng):bat[:oid] ",   "LIKEjoin_esc1;",       ""      ]
+[ "algebra",   "likejoin",     "command algebra.likejoin(X_2:bat[:str], 
X_3:bat[:str], X_4:str, X_5:bat[:oid], X_6:bat[:oid], X_7:bit, X_8:lng) 
(X_0:bat[:oid], X_1:bat[:oid]) ",      "LIKEjoin_esc;",        ""      ]
 [ "algebra",   "likeselect",   "command algebra.likeselect(X_1:bat[:str], 
X_2:bat[:oid], X_3:str, X_4:str, X_5:bit, X_6:bit):bat[:oid] ",      
"PCRElikeselect2;",     ""      ]
 [ "algebra",   "likeselect",   "command algebra.likeselect(X_1:bat[:str], 
X_2:bat[:oid], X_3:str, X_4:str, X_5:bit):bat[:oid] ",       
"PCRElikeselect3;",     ""      ]
 [ "algebra",   "likeselect",   "command algebra.likeselect(X_1:bat[:str], 
X_2:bat[:oid], X_3:str, X_4:bit):bat[:oid] ",        "PCRElikeselect5;",     "" 
     ]
diff --git a/clients/Tests/MAL-signatures.stable.out.int128 
b/clients/Tests/MAL-signatures.stable.out.int128
--- a/clients/Tests/MAL-signatures.stable.out.int128
+++ b/clients/Tests/MAL-signatures.stable.out.int128
@@ -697,8 +697,10 @@ stdout of test 'MAL-signatures` in direc
 [ "algebra",   "groupby",      "command algebra.groupby(X_1:bat[:oid], 
X_2:bat[:lng]):bat[:oid] ",     "ALGgroupby;",  ""      ]
 [ "algebra",   "ilike",        "command algebra.ilike(X_1:str, X_2:str):bit ", 
"PCREilike2;",  ""      ]
 [ "algebra",   "ilike",        "command algebra.ilike(X_1:str, X_2:str, 
X_3:str):bit ",        "PCREilike3;",  ""      ]
-[ "algebra",   "ilikejoin",    "command algebra.ilikejoin(X_2:bat[:str], 
X_3:bat[:str], X_4:bat[:oid], X_5:bat[:oid], X_6:bit, X_7:lng) (X_0:bat[:oid], 
X_1:bat[:oid]) ",      "ILIKEjoin1;",  ""      ]
-[ "algebra",   "ilikejoin",    "command algebra.ilikejoin(X_2:bat[:str], 
X_3:bat[:str], X_4:str, X_5:bat[:oid], X_6:bat[:oid], X_7:bit, X_8:lng) 
(X_0:bat[:oid], X_1:bat[:oid]) ",     "ILIKEjoin;",   ""      ]
+[ "algebra",   "ilikejoin",    "command algebra.ilikejoin(X_1:bat[:str], 
X_2:bat[:str], X_3:bat[:oid], X_4:bat[:oid], X_5:bit, X_6:lng):bat[:oid] ",   
"ILIKEjoin1;",  ""      ]
+[ "algebra",   "ilikejoin",    "command algebra.ilikejoin(X_2:bat[:str], 
X_3:bat[:str], X_4:bat[:oid], X_5:bat[:oid], X_6:bit, X_7:lng) (X_0:bat[:oid], 
X_1:bat[:oid]) ",      "ILIKEjoin;",   ""      ]
+[ "algebra",   "ilikejoin",    "command algebra.ilikejoin(X_1:bat[:str], 
X_2:bat[:str], X_3:str, X_4:bat[:oid], X_5:bat[:oid], X_6:bit, 
X_7:lng):bat[:oid] ",  "ILIKEjoin_esc1;",      ""      ]
+[ "algebra",   "ilikejoin",    "command algebra.ilikejoin(X_2:bat[:str], 
X_3:bat[:str], X_4:str, X_5:bat[:oid], X_6:bat[:oid], X_7:bit, X_8:lng) 
(X_0:bat[:oid], X_1:bat[:oid]) ",     "ILIKEjoin_esc;",       ""      ]
 [ "algebra",   "ilikeselect",  "command algebra.ilikeselect(X_1:bat[:str], 
X_2:bat[:oid], X_3:str, X_4:str, X_5:bit):bat[:oid] ",      "PCRElikeselect1;", 
    ""      ]
 [ "algebra",   "ilikeselect",  "command algebra.ilikeselect(X_1:bat[:str], 
X_2:bat[:oid], X_3:str, X_4:bit):bat[:oid] ",       "PCRElikeselect4;",     ""  
    ]
 [ "algebra",   "intersect",    "command algebra.intersect(X_1:bat[:any_1], 
X_2:bat[:any_1], X_3:bat[:oid], X_4:bat[:oid], X_5:bit, X_6:bit, 
X_7:lng):bat[:oid] ",      "ALGintersect;",        ""      ]
@@ -708,8 +710,10 @@ stdout of test 'MAL-signatures` in direc
 [ "algebra",   "leftjoin",     "command algebra.leftjoin(X_2:bat[:any_1], 
X_3:bat[:any_1], X_4:bat[:oid], X_5:bat[:oid], X_6:bit, X_7:lng) 
(X_0:bat[:oid], X_1:bat[:oid]) ",   "ALGleftjoin;", ""      ]
 [ "algebra",   "like", "command algebra.like(X_1:str, X_2:str):bit ",  
"PCRElike2;",   ""      ]
 [ "algebra",   "like", "command algebra.like(X_1:str, X_2:str, X_3:str):bit ", 
"PCRElike3;",   ""      ]
-[ "algebra",   "likejoin",     "command algebra.likejoin(X_2:bat[:str], 
X_3:bat[:str], X_4:bat[:oid], X_5:bat[:oid], X_6:bit, X_7:lng) (X_0:bat[:oid], 
X_1:bat[:oid]) ",       "LIKEjoin1;",   ""      ]
-[ "algebra",   "likejoin",     "command algebra.likejoin(X_2:bat[:str], 
X_3:bat[:str], X_4:str, X_5:bat[:oid], X_6:bat[:oid], X_7:bit, X_8:lng) 
(X_0:bat[:oid], X_1:bat[:oid]) ",      "LIKEjoin;",    ""      ]
+[ "algebra",   "likejoin",     "command algebra.likejoin(X_1:bat[:str], 
X_2:bat[:str], X_3:bat[:oid], X_4:bat[:oid], X_5:bit, X_6:lng):bat[:oid] ",    
"LIKEjoin1;",   ""      ]
+[ "algebra",   "likejoin",     "command algebra.likejoin(X_2:bat[:str], 
X_3:bat[:str], X_4:bat[:oid], X_5:bat[:oid], X_6:bit, X_7:lng) (X_0:bat[:oid], 
X_1:bat[:oid]) ",       "LIKEjoin;",    ""      ]
+[ "algebra",   "likejoin",     "command algebra.likejoin(X_1:bat[:str], 
X_2:bat[:str], X_3:str, X_4:bat[:oid], X_5:bat[:oid], X_6:bit, 
X_7:lng):bat[:oid] ",   "LIKEjoin_esc1;",       ""      ]
+[ "algebra",   "likejoin",     "command algebra.likejoin(X_2:bat[:str], 
X_3:bat[:str], X_4:str, X_5:bat[:oid], X_6:bat[:oid], X_7:bit, X_8:lng) 
(X_0:bat[:oid], X_1:bat[:oid]) ",      "LIKEjoin_esc;",        ""      ]
 [ "algebra",   "likeselect",   "command algebra.likeselect(X_1:bat[:str], 
X_2:bat[:oid], X_3:str, X_4:str, X_5:bit, X_6:bit):bat[:oid] ",      
"PCRElikeselect2;",     ""      ]
 [ "algebra",   "likeselect",   "command algebra.likeselect(X_1:bat[:str], 
X_2:bat[:oid], X_3:str, X_4:str, X_5:bit):bat[:oid] ",       
"PCRElikeselect3;",     ""      ]
 [ "algebra",   "likeselect",   "command algebra.likeselect(X_1:bat[:str], 
X_2:bat[:oid], X_3:str, X_4:bit):bat[:oid] ",        "PCRElikeselect5;",     "" 
     ]
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -1315,8 +1315,10 @@ str IDentifier(identifier *retval, str *
 ssize_t IDfromString(const char *src, size_t *len, identifier *retval, bool 
external);
 str IDprelude(void *ret);
 ssize_t IDtoString(str *retval, size_t *len, const char *handle, bool 
external);
-str ILIKEjoin(bat *r1, bat *r2, const bat *lid, const bat *rid, const str 
*esc, const bat *slid, const bat *srid, const bit *nil_matches, const lng 
*estimate);
-str ILIKEjoin1(bat *r1, bat *r2, const bat *lid, const bat *rid, const bat 
*slid, const bat *srid, const bit *nil_matches, const lng *estimate);
+str ILIKEjoin(bat *r1, bat *r2, const bat *lid, const bat *rid, const bat 
*slid, const bat *srid, const bit *nil_matches, const lng *estimate);
+str ILIKEjoin1(bat *r1, const bat *lid, const bat *rid, const bat *slid, const 
bat *srid, const bit *nil_matches, const lng *estimate);
+str ILIKEjoin_esc(bat *r1, bat *r2, const bat *lid, const bat *rid, const str 
*esc, const bat *slid, const bat *srid, const bit *nil_matches, const lng 
*estimate);
+str ILIKEjoin_esc1(bat *r1, const bat *lid, const bat *rid, const str *esc, 
const bat *slid, const bat *srid, const bit *nil_matches, const lng *estimate);
 str INET_comp_CS(bit *retval, const inet *val1, const inet *val2);
 str INET_comp_CSE(bit *retval, const inet *val1, const inet *val2);
 str INET_comp_CW(bit *retval, const inet *val1, const inet *val2);
@@ -1421,8 +1423,10 @@ ssize_t JSONtoString(str *s, size_t *len
 str JSONunfold(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
 str JSONvalueArray(json *ret, json *arg);
 str JSONvalueTable(bat *ret, json *j);
-str LIKEjoin(bat *r1, bat *r2, const bat *lid, const bat *rid, const str *esc, 
const bat *slid, const bat *srid, const bit *nil_matches, const lng *estimate);
-str LIKEjoin1(bat *r1, bat *r2, const bat *lid, const bat *rid, const bat 
*slid, const bat *srid, const bit *nil_matches, const lng *estimate);
+str LIKEjoin(bat *r1, bat *r2, const bat *lid, const bat *rid, const bat 
*slid, const bat *srid, const bit *nil_matches, const lng *estimate);
+str LIKEjoin1(bat *r1, const bat *lid, const bat *rid, const bat *slid, const 
bat *srid, const bit *nil_matches, const lng *estimate);
+str LIKEjoin_esc(bat *r1, bat *r2, const bat *lid, const bat *rid, const str 
*esc, const bat *slid, const bat *srid, const bit *nil_matches, const lng 
*estimate);
+str LIKEjoin_esc1(bat *r1, const bat *lid, const bat *rid, const str *esc, 
const bat *slid, const bat *srid, const bit *nil_matches, const lng *estimate);
 str MACROprocessor(Client cntxt, MalBlkPtr mb, Symbol t);
 int MAL_MAXCLIENTS;
 int MALadmission_claim(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci, lng argclaim);
@@ -2381,6 +2385,7 @@ str hgeRef;
 str identityRef;
 str ifthenelseRef;
 str ilikeRef;
+str ilikejoinRef;
 str ilikeselectRef;
 str ilikethetaselectRef;
 str ilikeuselectRef;
@@ -2437,6 +2442,7 @@ str levenshtein_impl(int *result, str *s
 str levenshteinbasic2_impl(int *result, str *s, str *t);
 str levenshteinbasic_impl(int *result, str *s, str *t);
 str likeRef;
+str likejoinRef;
 str likeselectRef;
 str likethetaselectRef;
 str likeuselectRef;
diff --git a/monetdb5/modules/mal/pcre.c b/monetdb5/modules/mal/pcre.c
--- a/monetdb5/modules/mal/pcre.c
+++ b/monetdb5/modules/mal/pcre.c
@@ -81,10 +81,14 @@ mal_export str PCRElikeselect3(bat *ret,
 mal_export str PCRElikeselect4(bat *ret, const bat *bid, const bat *cid, const 
str *pat, const bit *anti);
 mal_export str PCRElikeselect5(bat *ret, const bat *bid, const bat *sid, const 
str *pat, const bit *anti);
 
-mal_export str LIKEjoin(bat *r1, bat *r2, const bat *lid, const bat *rid, 
const str *esc, const bat *slid, const bat *srid, const bit *nil_matches, const 
lng *estimate);
-mal_export str LIKEjoin1(bat *r1, bat *r2, const bat *lid, const bat *rid, 
const bat *slid, const bat *srid, const bit *nil_matches, const lng *estimate);
-mal_export str ILIKEjoin(bat *r1, bat *r2, const bat *lid, const bat *rid, 
const str *esc, const bat *slid, const bat *srid, const bit *nil_matches, const 
lng *estimate);
-mal_export str ILIKEjoin1(bat *r1, bat *r2, const bat *lid, const bat *rid, 
const bat *slid, const bat *srid, const bit *nil_matches, const lng *estimate);
+mal_export str LIKEjoin_esc(bat *r1, bat *r2, const bat *lid, const bat *rid, 
const str *esc, const bat *slid, const bat *srid, const bit *nil_matches, const 
lng *estimate);
+mal_export str LIKEjoin_esc1(bat *r1, const bat *lid, const bat *rid, const 
str *esc, const bat *slid, const bat *srid, const bit *nil_matches, const lng 
*estimate);
+mal_export str LIKEjoin(bat *r1, bat *r2, const bat *lid, const bat *rid, 
const bat *slid, const bat *srid, const bit *nil_matches, const lng *estimate);
+mal_export str LIKEjoin1(bat *r1, const bat *lid, const bat *rid, const bat 
*slid, const bat *srid, const bit *nil_matches, const lng *estimate);
+mal_export str ILIKEjoin_esc(bat *r1, bat *r2, const bat *lid, const bat *rid, 
const str *esc, const bat *slid, const bat *srid, const bit *nil_matches, const 
lng *estimate);
+mal_export str ILIKEjoin_esc1(bat *r1, const bat *lid, const bat *rid, const 
str *esc, const bat *slid, const bat *srid, const bit *nil_matches, const lng 
*estimate);
+mal_export str ILIKEjoin(bat *r1, bat *r2, const bat *lid, const bat *rid, 
const bat *slid, const bat *srid, const bit *nil_matches, const lng *estimate);
+mal_export str ILIKEjoin1(bat *r1, const bat *lid, const bat *rid, const bat 
*slid, const bat *srid, const bit *nil_matches, const lng *estimate);
 
 /* current implementation assumes simple %keyword% [keyw%]* */
 struct RE {
@@ -2252,9 +2256,11 @@ pcrejoin(BAT *r1, BAT *r2, BAT *l, BAT *
        r1->tkey = true;
        r1->tsorted = true;
        r1->trevsorted = true;
-       r2->tkey = true;
-       r2->tsorted = true;
-       r2->trevsorted = true;
+       if (r2) {
+               r2->tkey = true;
+               r2->tsorted = true;
+               r2->trevsorted = true;
+       }
 
        /* nested loop implementation for PCRE join */
        for (BUN ri = 0; ri < rci.ncand; ri++) {
@@ -2348,19 +2354,21 @@ pcrejoin(BAT *r1, BAT *r2, BAT *l, BAT *
                        if (BUNlast(r1) == BATcapacity(r1)) {
                                newcap = BATgrows(r1);
                                BATsetcount(r1, BATcount(r1));
-                               BATsetcount(r2, BATcount(r2));
+                               if (r2)
+                                       BATsetcount(r2, BATcount(r2));
                                if (BATextend(r1, newcap) != GDK_SUCCEED ||
-                                       BATextend(r2, newcap) != GDK_SUCCEED) {
+                                       (r2 && BATextend(r2, newcap) != 
GDK_SUCCEED)) {
                                        msg = createException(MAL, "pcre.join", 
SQLSTATE(HY013) MAL_MALLOC_FAIL);
                                        goto bailout;
                                }
-                               assert(BATcapacity(r1) == BATcapacity(r2));
+                               assert(!r2 || BATcapacity(r1) == 
BATcapacity(r2));
                        }
                        if (BATcount(r1) > 0) {
                                if (lastl + 1 != lo)
                                        r1->tseqbase = oid_nil;
                                if (nl == 0) {
-                                       r2->trevsorted = false;
+                                       if (r2)
+                                               r2->trevsorted = false;
                                        if (lastl > lo) {
                                                r1->tsorted = false;
                                                r1->tkey = false;
@@ -2372,7 +2380,8 @@ pcrejoin(BAT *r1, BAT *r2, BAT *l, BAT *
                                }
                        }
                        APPEND(r1, lo);
-                       APPEND(r2, ro);
+                       if (r2)
+                               APPEND(r2, ro);
                        lastl = lo;
                        nl++;
                }
@@ -2395,37 +2404,52 @@ pcrejoin(BAT *r1, BAT *r2, BAT *l, BAT *
                        pcrere = 0;
 #endif
                }
-               if (nl > 1) {
-                       r2->tkey = false;
-                       r2->tseqbase = oid_nil;
+               if (r2) {
+                       if (nl > 1) {
+                               r2->tkey = false;
+                               r2->tseqbase = oid_nil;
+                               r1->trevsorted = false;
+                       } else if (nl == 0) {
+                               rskipped = BATcount(r2) > 0;
+                       } else if (rskipped) {
+                               r2->tseqbase = oid_nil;
+                       }
+               } else if (nl > 1) {
                        r1->trevsorted = false;
-               } else if (nl == 0) {
-                       rskipped = BATcount(r2) > 0;
-               } else if (rskipped) {
-                       r2->tseqbase = oid_nil;
                }
        }
-       assert(BATcount(r1) == BATcount(r2));
+       assert(!r2 || BATcount(r1) == BATcount(r2));
        /* also set other bits of heap to correct value to indicate size */
        BATsetcount(r1, BATcount(r1));
-       BATsetcount(r2, BATcount(r2));
+       if (r2)
+               BATsetcount(r2, BATcount(r2));
        if (BATcount(r1) > 0) {
                if (BATtdense(r1))
                        r1->tseqbase = ((oid *) r1->theap.base)[0];
-               if (BATtdense(r2))
+               if (r2 && BATtdense(r2))
                        r2->tseqbase = ((oid *) r2->theap.base)[0];
        } else {
-               r1->tseqbase = r2->tseqbase = 0;
+               r1->tseqbase = 0;
+               if (r2)
+                       r2->tseqbase = 0;
        }
-       TRC_DEBUG(ALGO, 
-                         
"pcrejoin(l=%s,r=%s)=(%s#"BUNFMT"%s%s,%s#"BUNFMT"%s%s\n",
-                         BATgetId(l), BATgetId(r),
-                         BATgetId(r1), BATcount(r1),
-                         r1->tsorted ? "-sorted" : "",
-                         r1->trevsorted ? "-revsorted" : "",
-                         BATgetId(r2), BATcount(r2),
-                         r2->tsorted ? "-sorted" : "",
-                         r2->trevsorted ? "-revsorted" : "");
+       if (r2)
+               TRC_DEBUG(ALGO, 
+                               
"pcrejoin(l=%s,r=%s)=(%s#"BUNFMT"%s%s,%s#"BUNFMT"%s%s\n",
+                               BATgetId(l), BATgetId(r),
+                               BATgetId(r1), BATcount(r1),
+                               r1->tsorted ? "-sorted" : "",
+                               r1->trevsorted ? "-revsorted" : "",
+                               BATgetId(r2), BATcount(r2),
+                               r2->tsorted ? "-sorted" : "",
+                               r2->trevsorted ? "-revsorted" : "");
+       else
+               TRC_DEBUG(ALGO, 
+                       "pcrejoin(l=%s,r=%s)=(%s#"BUNFMT"%s%s\n",
+                       BATgetId(l), BATgetId(r),
+                       BATgetId(r1), BATcount(r1),
+                       r1->tsorted ? "-sorted" : "",
+                       r1->trevsorted ? "-revsorted" : "");
        return MAL_SUCCEED;
 
   bailout:
@@ -2466,8 +2490,9 @@ PCREjoin(bat *r1, bat *r2, bat lid, bat 
        if (!is_bat_nil(srid) && (candright = BATdescriptor(srid)) == NULL)
                goto fail;
        result1 = COLnew(0, TYPE_oid, BATcount(left), TRANSIENT);
-       result2 = COLnew(0, TYPE_oid, BATcount(left), TRANSIENT);
-       if (result1 == NULL || result2 == NULL) {
+       if (r2)
+               result2 = COLnew(0, TYPE_oid, BATcount(left), TRANSIENT);
+       if (!result1 || (r2 && !result2)) {
                msg = createException(MAL, "pcre.join", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
                goto fail;
        }
@@ -2477,20 +2502,24 @@ PCREjoin(bat *r1, bat *r2, bat lid, bat 
        result1->tsorted = true;
        result1->trevsorted = true;
        result1->tseqbase = 0;
-       result2->tnil = false;
-       result2->tnonil = true;
-       result2->tkey = true;
-       result2->tsorted = true;
-       result2->trevsorted = true;
-       result2->tseqbase = 0;
+       if (r2) {
+               result2->tnil = false;
+               result2->tnonil = true;
+               result2->tkey = true;
+               result2->tsorted = true;
+               result2->trevsorted = true;
+               result2->tseqbase = 0;
+       }
        msg = pcrejoin(result1, result2, left, right, candleft, candright,
                                   esc, caseignore);
        if (msg)
                goto fail;
        *r1 = result1->batCacheid;
-       *r2 = result2->batCacheid;
        BBPkeepref(*r1);
-       BBPkeepref(*r2);
+       if (r2) {
+               *r2 = result2->batCacheid;
+               BBPkeepref(*r2);
+       }
        BBPunfix(left->batCacheid);
        BBPunfix(right->batCacheid);
        if (candleft)
@@ -2518,7 +2547,7 @@ PCREjoin(bat *r1, bat *r2, bat lid, bat 
 }
 
 str
-LIKEjoin(bat *r1, bat *r2, const bat *lid, const bat *rid, const str *esc, 
const bat *slid, const bat *srid, const bit *nil_matches, const lng *estimate)
+LIKEjoin_esc(bat *r1, bat *r2, const bat *lid, const bat *rid, const str *esc, 
const bat *slid, const bat *srid, const bit *nil_matches, const lng *estimate)
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to