Changeset: 3f1002580157 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/3f1002580157
Modified Files:
        gdk/gdk_bat.c
        gdk/gdk_project.c
        monetdb5/modules/atoms/batxml.c
        monetdb5/modules/atoms/json.c
        monetdb5/modules/atoms/mtime.c
        monetdb5/modules/atoms/str.c
        monetdb5/modules/kernel/algebra.c
        monetdb5/modules/kernel/bat5.c
        monetdb5/modules/kernel/batcolor.c
        monetdb5/modules/mal/manifold.c
        monetdb5/modules/mal/txtsim.c
        sql/backends/monet5/UDF/pyapi3/emit3.c
        sql/backends/monet5/sql_rank.c
        sql/backends/monet5/vaults/fits/fits.c
        sql/backends/monet5/vaults/netcdf/netcdf.c
Branch: default
Log Message:

Don't assume tkey is false on a newly created bat.


diffs (truncated from 362 to 300 lines):

diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -970,8 +970,7 @@ COLcopy(BAT *b, int tt, bool writable, r
                BUN h = BATcount(b);
                bn->tsorted = bi.sorted;
                bn->trevsorted = bi.revsorted;
-               if (bi.key)
-                       BATkey(bn, true);
+               BATkey(bn, bi.key);
                bn->tnonil = bi.nonil;
                bn->tnil = bi.nil;
                if (bi.nosorted > 0 && bi.nosorted < h)
@@ -996,6 +995,7 @@ COLcopy(BAT *b, int tt, bool writable, r
        } else {
                bn->tsorted = bn->trevsorted = false; /* set based on count 
later */
                bn->tnonil = bn->tnil = false;
+               bn->tkey = false;
                bn->tnosorted = bn->tnorevsorted = 0;
                bn->tnokey[0] = bn->tnokey[1] = 0;
        }
diff --git a/gdk/gdk_project.c b/gdk/gdk_project.c
--- a/gdk/gdk_project.c
+++ b/gdk/gdk_project.c
@@ -1141,6 +1141,7 @@ BATprojectchain(BAT **bats)
        bn->trevsorted = ba[0].cnt <= 1;
        bn->tnonil = nonil & b->tnonil;
        bn->tseqbase = oid_nil;
+       bn->tkey = (ba[0].cnt <= 1);
        /* note, b may point to one of the bats in tobedeleted, so
         * reclaim after the last use of b */
        while (ndelete-- > 0)
diff --git a/monetdb5/modules/atoms/batxml.c b/monetdb5/modules/atoms/batxml.c
--- a/monetdb5/modules/atoms/batxml.c
+++ b/monetdb5/modules/atoms/batxml.c
@@ -50,6 +50,7 @@
                (X)->tsorted =  false;                                          
                                \
                (X)->trevsorted =  false;                                       
                                \
                (X)->tnonil = true;                                             
                                        \
+               (X)->tkey = false;                                              
                                        \
        } while (0)
 
 #define finalizeResult(X,Y,Z)                                  \
diff --git a/monetdb5/modules/atoms/json.c b/monetdb5/modules/atoms/json.c
--- a/monetdb5/modules/atoms/json.c
+++ b/monetdb5/modules/atoms/json.c
@@ -2030,9 +2030,6 @@ JSONunfoldInternal(bat *od, bat *key, ba
                JSONfree(jt);
                throw(MAL, "json.unfold", SQLSTATE(HY013) MAL_MALLOC_FAIL);
        }
-       bk->tsorted = true;
-       bk->trevsorted = false;
-       bk->tnonil = true;
 
        if (od) {
                bo = COLnew(0, TYPE_oid, 64, TRANSIENT);
@@ -2041,9 +2038,6 @@ JSONunfoldInternal(bat *od, bat *key, ba
                        JSONfree(jt);
                        throw(MAL, "json.unfold", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
                }
-               bo->tsorted = true;
-               bo->trevsorted = false;
-               bo->tnonil = true;
        }
 
        bv = COLnew(0, TYPE_json, 64, TRANSIENT);
@@ -2053,9 +2047,6 @@ JSONunfoldInternal(bat *od, bat *key, ba
                BBPreclaim(bk);
                throw(MAL, "json.unfold", SQLSTATE(HY013) MAL_MALLOC_FAIL);
        }
-       bv->tsorted = true;
-       bv->trevsorted = false;
-       bv->tnonil = true;
 
        if (jt->elm[0].kind == JSON_ARRAY || jt->elm[0].kind == JSON_OBJECT)
                msg = JSONunfoldContainer(jt, 0, (od ? bo : 0), bk, bv, &o);
@@ -2097,9 +2088,6 @@ JSONkeyTable(bat *ret, json *js)
                JSONfree(jt);
                throw(MAL, "json.keys", SQLSTATE(HY013) MAL_MALLOC_FAIL);
        }
-       bn->tsorted = true;
-       bn->trevsorted = false;
-       bn->tnonil = true;
 
        for (i = jt->elm[0].next; i; i = jt->elm[i].next) {
                r = JSONgetValue(jt, i);
@@ -2197,9 +2185,6 @@ JSONvalueTable(bat *ret, json *js)
                JSONfree(jt);
                throw(MAL, "json.values", SQLSTATE(HY013) MAL_MALLOC_FAIL);
        }
-       bn->tsorted = true;
-       bn->trevsorted = false;
-       bn->tnonil = true;
 
        for (i = jt->elm[0].next; i; i = jt->elm[i].next) {
                if (jt->elm[i].kind == JSON_ELEMENT)
diff --git a/monetdb5/modules/atoms/mtime.c b/monetdb5/modules/atoms/mtime.c
--- a/monetdb5/modules/atoms/mtime.c
+++ b/monetdb5/modules/atoms/mtime.c
@@ -183,8 +183,8 @@ NAME##_bulk(Client cntxt, MalBlkPtr mb, 
        BATsetcount(bn, ci.ncand);                                              
                                        \
        bn->tnonil = !nils;                                                     
                                                \
        bn->tnil = nils;                                                        
                                                \
+       bn->tkey = ci.ncand < 2;                                                
                                        \
        SETFLAGS(ci.ncand);                                                     
                                                \
-       bn->tkey = false;                                                       
                                                \
 bailout:                                                                       
                                                        \
        if (b1) {                                                               
                                                        \
                bat_iterator_end(&b1i);                                         
                                        \
@@ -302,7 +302,7 @@ NAME##_bulk(Client cntxt, MalBlkPtr mb, 
        bn->tnil = nils;                                                        
                                                \
        bn->tsorted = ci1.ncand < 2;                                            
                                \
        bn->trevsorted = ci1.ncand < 2;                                         
                                \
-       bn->tkey = false;                                                       
                                                \
+       bn->tkey = ci1.ncand < 2;                                               
                                        \
 bailout:                                                                       
                                                        \
        CLEAR_EXTRA_MULTI(res);                                                 
                                        \
        bat_iterator_end(&b1i);                                                 
                                        \
@@ -380,7 +380,7 @@ NAME##_bulk_p1(Client cntxt, MalBlkPtr m
        bn->tnil = nils;                                                        
                                                \
        bn->tsorted = ci2.ncand < 2;                                            
                                \
        bn->trevsorted = ci2.ncand < 2;                                         
                                \
-       bn->tkey = false;                                                       
                                                \
+       bn->tkey = ci2.ncand < 2;                                               
                                        \
 bailout:                                                                       
                                                        \
        CLEAR_EXTRA_MULTI(res);                                                 
                                        \
        if (b2) {                                                               
                                                        \
@@ -457,7 +457,7 @@ NAME##_bulk_p2(Client cntxt, MalBlkPtr m
        bn->tnil = nils;                                                        
                                                \
        bn->tsorted = ci1.ncand < 2;                                            
                                \
        bn->trevsorted = ci1.ncand < 2;                                         
                                \
-       bn->tkey = false;                                                       
                                                \
+       bn->tkey = ci1.ncand < 2;                                               
                                        \
 bailout:                                                                       
                                                        \
        CLEAR_EXTRA_MULTI(res);                                                 
                                        \
        if (b1) {                                                               
                                                        \
diff --git a/monetdb5/modules/atoms/str.c b/monetdb5/modules/atoms/str.c
--- a/monetdb5/modules/atoms/str.c
+++ b/monetdb5/modules/atoms/str.c
@@ -5358,7 +5358,7 @@ STRcontainsselect(Client cntxt, MalBlkPt
        do {                                                                    
        \
                B->tnil = false;                                                
\
                B->tnonil = true;                                               
\
-               B->tkey = true;                                         \
+               B->tkey = true;                                                 
\
                B->tsorted = true;                                              
\
                B->trevsorted = true;                                   \
                B->tseqbase = 0;                                                
\
diff --git a/monetdb5/modules/kernel/algebra.c 
b/monetdb5/modules/kernel/algebra.c
--- a/monetdb5/modules/kernel/algebra.c
+++ b/monetdb5/modules/kernel/algebra.c
@@ -468,6 +468,7 @@ ALGmarkselect(bat *r1, bat *r2, const ba
        res1->tnil = false;
        res1->tnonil = true;
        res2->tnonil = false;
+       res2->tkey = false;
 
        BBPreclaim(g);
        BBPreclaim(m);
@@ -567,6 +568,7 @@ ALGouterselect(bat *r1, bat *r2, const b
        res1->tnil = false;
        res1->tnonil = true;
        res2->tnonil = false;
+       res2->tkey = false;
 
        BBPreclaim(g);
        BBPreclaim(m);
diff --git a/monetdb5/modules/kernel/bat5.c b/monetdb5/modules/kernel/bat5.c
--- a/monetdb5/modules/kernel/bat5.c
+++ b/monetdb5/modules/kernel/bat5.c
@@ -1209,7 +1209,7 @@ BKCshrinkBATmap(bat *ret, const bat *bid
        bn->tsorted = false;
        bn->trevsorted = false;
        bn->tseqbase = oid_nil;
-
+       bn->tkey = false;
 
        BBPunfix(b->batCacheid);
        BBPunfix(bs->batCacheid);
diff --git a/monetdb5/modules/kernel/batcolor.c 
b/monetdb5/modules/kernel/batcolor.c
--- a/monetdb5/modules/kernel/batcolor.c
+++ b/monetdb5/modules/kernel/batcolor.c
@@ -49,6 +49,7 @@ static str CLRbat##NAME(bat *ret, const 
        bn->trevsorted=false;                                                   
                                        \
        bn->tnil = false;                                                       
                                                \
        bn->tnonil = true;                                                      
                                                \
+       bn->tkey = false;                                                       
                                                \
                                                                                
                                                                \
        bi = bat_iterator(b);                                                   
                                        \
                                                                                
                                                                \
@@ -136,6 +137,7 @@ static str CLRbat##NAME(bat *ret, const 
        bn->trevsorted=false;                                                   
                                        \
        bn->tnil = false;                                                       
                                                \
        bn->tnonil = true;                                                      
                                                \
+       bn->tkey = false;                                                       
                                                \
                                                                                
                                                                \
        bi = bat_iterator(b);                                                   
                                        \
        b2i = bat_iterator(b2);                                                 
                                        \
diff --git a/monetdb5/modules/mal/manifold.c b/monetdb5/modules/mal/manifold.c
--- a/monetdb5/modules/mal/manifold.c
+++ b/monetdb5/modules/mal/manifold.c
@@ -394,6 +394,7 @@ MANIFOLDevaluate(Client cntxt, MalBlkPtr
        mat[0].b->tnonil = false;
        mat[0].b->tsorted = false;
        mat[0].b->trevsorted = false;
+       mat[0].b->tkey = false;
        mat[0].bi = (BATiter) {.b = NULL, };
        mat[0].first = (void *) Tloc(mat[0].b, 0);
        mat[0].last = (void *) Tloc(mat[0].b, BATcount(mat[0].b));
diff --git a/monetdb5/modules/mal/txtsim.c b/monetdb5/modules/mal/txtsim.c
--- a/monetdb5/modules/mal/txtsim.c
+++ b/monetdb5/modules/mal/txtsim.c
@@ -614,14 +614,14 @@ TXTSIMminjarowinkler(bit *res, str *x, s
 #define VALUE(s, x) (s##vars + VarHeapVal(s##vals, (x), s##width))
 #define APPEND(b, o) (((oid *) b->theap->base)[b->batCount++] = (o))
 
-#define PREP_BAT_STRITEM(B, CI, SI)                                            
                        \
+#define PREP_BAT_STRITEM(B, CI, SI)                                            
                                \
                do {                                                            
                                                        \
                        for (n = 0; n < CI.ncand; n++) {                        
                                \
                                SI[n].matches = 0;                              
                                                \
                                SI[n].o = canditer_next(&CI);                   
                                \
                                SI[n].val = (str) VALUE(B, SI[n].o - 
B->hseqbase);              \
                                SI[n].cp_sequence = NULL;                       
                                        \
-                               SI[n].len = UTF8_strlen(SI[n].val);             
                        \
+                               SI[n].len = UTF8_strlen(SI[n].val);             
                                \
                                SI[n].cp_seq_len = str_strlen(SI[n].val);       
                        \
                                if ((msg = str_2_codepointseq(&SI[n])) != 
MAL_SUCCEED)  \
                                        goto exit;                              
                                                        \
@@ -630,30 +630,30 @@ TXTSIMminjarowinkler(bit *res, str *x, s
                } while (false)
 
 #define FINALIZE_BATS(L, R, LCI, RCI, LSI, RSI)        \
-               do {                                                            
                \
+               do {                                                            
        \
                        assert(BATcount(L) == BATcount(R));     \
-                       BATsetcount(L, BATcount(L));                    \
-                       BATsetcount(R, BATcount(R));                    \
-                       for (n = 0; n < LCI.ncand; n++) {               \
-                               if (LSI[n].matches > 1) {                       
\
-                                       L->tkey = false;                        
        \
-                                       break;                                  
                \
-                               }                                               
                        \
-                       }                                                       
                        \
-                       if (n == LCI.ncand) {                                   
\
+                       BATsetcount(L, BATcount(L));            \
+                       BATsetcount(R, BATcount(R));            \
+                       for (n = 0; n < LCI.ncand; n++) {       \
+                               if (LSI[n].matches > 1) {               \
+                                       L->tkey = false;                        
\
+                                       break;                                  
        \
+                               }                                               
                \
+                       }                                                       
                \
+                       if (n == LCI.ncand) {                           \
                                L->tkey = true;                                 
\
-                       }                                                       
                        \
-                       for (n = 0; n < RCI.ncand; n++) {               \
-                               if (RSI[n].matches > 1) {                       
\
-                                       R->tkey = false;                        
        \
-                                       break;                                  
                \
-                               }                                               
                        \
-                       }                                                       
                        \
-                       if (n == RCI.ncand) {                                   
\
+                       }                                                       
                \
+                       for (n = 0; n < RCI.ncand; n++) {       \
+                               if (RSI[n].matches > 1) {               \
+                                       R->tkey = false;                        
\
+                                       break;                                  
        \
+                               }                                               
                \
+                       }                                                       
                \
+                       if (n == RCI.ncand) {                           \
                                R->tkey = true;                                 
\
-                       }                                                       
                        \
-                       BATordered(L);                                          
        \
-                       BATordered(R);                                          
        \
+                       }                                                       
                \
+                       BATordered(L);                                          
\
+                       BATordered(R);                                          
\
                        L->theap->dirty |= BATcount(L) > 0;     \
                        R->theap->dirty |= BATcount(R) > 0;     \
                } while (false)
diff --git a/sql/backends/monet5/UDF/pyapi3/emit3.c 
b/sql/backends/monet5/UDF/pyapi3/emit3.c
--- a/sql/backends/monet5/UDF/pyapi3/emit3.c
+++ b/sql/backends/monet5/UDF/pyapi3/emit3.c
@@ -328,6 +328,7 @@ PyObject *PyEmit_Emit(PyEmitObject *self
                                /* we're not maintaining properties */
                                self->cols[i].b->tsorted = false;
                                self->cols[i].b->trevsorted = false;
+                               self->cols[i].b->tkey = false;
 
                                switch (self->cols[i].b->ttype) {
                                        case TYPE_bit:
diff --git a/sql/backends/monet5/sql_rank.c b/sql/backends/monet5/sql_rank.c
--- a/sql/backends/monet5/sql_rank.c
+++ b/sql/backends/monet5/sql_rank.c
@@ -217,7 +217,7 @@ SQLrow_number(Client cntxt, MalBlkPtr mb
                        msg = createException(SQL, "sql.row_number", 
SQLSTATE(HY013) MAL_MALLOC_FAIL);
                        goto bailout;
                }
-               r->tsorted = r->trevsorted = BATcount(b) <= 1;
_______________________________________________
checkin-list mailing list -- checkin-list@monetdb.org
To unsubscribe send an email to checkin-list-le...@monetdb.org

Reply via email to