Changeset: 1b2d6f3d2635 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=1b2d6f3d2635
Modified Files:
        gdk/gdk_group.c
        gdk/gdk_join.c
        gdk/gdk_search.c
        gdk/gdk_select.c
        gdk/gdk_unique.c
Branch: Jul2015
Log Message:

Do not create hash on parent if BAT has hash or parent is not persistent.


diffs (117 lines):

diff --git a/gdk/gdk_group.c b/gdk/gdk_group.c
--- a/gdk/gdk_group.c
+++ b/gdk/gdk_group.c
@@ -778,7 +778,7 @@ BATgroup_internal(BAT **groups, BAT **ex
                                  e ? BATgetId(e) : "NULL", e ? BATcount(e) : 0,
                                  h ? BATgetId(h) : "NULL", h ? BATcount(h) : 0,
                                  subsorted);
-               if ((parent = VIEWtparent(b)) != 0) {
+               if (b->T->hash == NULL && (parent = VIEWtparent(b)) != 0) {
                        /* b is a view on another bat (b2 for now).
                         * calculate the bounds [lo, hi) in the parent
                         * that b uses */
diff --git a/gdk/gdk_join.c b/gdk/gdk_join.c
--- a/gdk/gdk_join.c
+++ b/gdk/gdk_join.c
@@ -1839,12 +1839,26 @@ hashjoin(BAT *r1, BAT *r2, BAT *l, BAT *
                return GDK_SUCCEED;
        }
 
+       rl = BUNfirst(r);
        if (VIEWtparent(r)) {
                BAT *b = BBPdescriptor(-VIEWtparent(r));
-               rl = (BUN) ((r->T->heap.base - b->T->heap.base) >> r->T->shift) 
+ BUNfirst(r);
-               r = b;
-       } else {
-               rl = BUNfirst(r);
+               if (b->batPersistence == PERSISTENT || BATcheckhash(b)) {
+                       /* only use parent's hash if it is persistent
+                        * or already has a hash */
+                       ALGODEBUG
+                               fprintf(stderr, "#hashjoin(%s#"BUNFMT"): "
+                                       "using parent(%s#"BUNFMT") for hash\n",
+                                       BATgetId(r), BATcount(r),
+                                       BATgetId(b), BATcount(b));
+                       rl = (BUN) ((r->T->heap.base - b->T->heap.base) >> 
r->T->shift) + BUNfirst(r);
+                       r = b;
+               } else {
+                       ALGODEBUG
+                               fprintf(stderr, "#hashjoin(%s#"BUNFMT"): not "
+                                       "using parent(%s#"BUNFMT") for hash\n",
+                                       BATgetId(r), BATcount(r),
+                                       BATgetId(b), BATcount(b));
+               }
        }
        rh = rl + rend;
        rl += rstart;
diff --git a/gdk/gdk_search.c b/gdk/gdk_search.c
--- a/gdk/gdk_search.c
+++ b/gdk/gdk_search.c
@@ -315,17 +315,6 @@ BAThash(BAT *b, BUN masksize)
        BAT *o = NULL;
        lng t0 = 0, t1 = 0;
 
-       if (VIEWtparent(b)) {
-               bat p = -VIEWtparent(b);
-               o = b;
-               b = BATdescriptor(p);
-               assert(b != NULL);
-               if (!ALIGNsynced(o, b) || BUNfirst(o) != BUNfirst(b)) {
-                       BBPunfix(b->batCacheid);
-                       b = o;
-                       o = NULL;
-               }
-       }
        if (BATcheckhash(b)) {
                if (o != NULL) {
                        o->T->hash = b->T->hash;
diff --git a/gdk/gdk_select.c b/gdk/gdk_select.c
--- a/gdk/gdk_select.c
+++ b/gdk/gdk_select.c
@@ -174,14 +174,28 @@ BAT_hashselect(BAT *b, BAT *s, BAT *bn, 
        assert(bn->ttype == TYPE_oid);
        assert(BAThdense(b));
        seq = b->hseqbase;
+       l = BUNfirst(b);
+       h = BUNlast(b);
        if (VIEWtparent(b)) {
                BAT *b2 = BBPdescriptor(-VIEWtparent(b));
-               l = (BUN) ((b->T->heap.base - b2->T->heap.base) >> b->T->shift) 
+ BUNfirst(b);
-               h = l + BATcount(b);
-               b = b2;
-       } else {
-               l = BUNfirst(b);
-               h = BUNlast(b);
+               if (b2->batPersistence == PERSISTENT || BATcheckhash(b2)) {
+                       /* only use parent's hash if it is persistent
+                        * or already has a hash */
+                       ALGODEBUG
+                               fprintf(stderr, "#hashselect(%s#"BUNFMT"): "
+                                       "using parent(%s#"BUNFMT") for hash\n",
+                                       BATgetId(b), BATcount(b),
+                                       BATgetId(b2), BATcount(b2));
+                       l = (BUN) ((b->T->heap.base - b2->T->heap.base) >> 
b->T->shift) + BUNfirst(b);
+                       h = l + BATcount(b);
+                       b = b2;
+               } else {
+                       ALGODEBUG
+                               fprintf(stderr, "#hashselect(%s#"BUNFMT"): not "
+                                       "using parent(%s#"BUNFMT") for hash\n",
+                                       BATgetId(b), BATcount(b),
+                                       BATgetId(b2), BATcount(b2));
+               }
        }
        if (s && BATtdense(s)) {
                /* no need for binary search in s, we just adjust the
diff --git a/gdk/gdk_unique.c b/gdk/gdk_unique.c
--- a/gdk/gdk_unique.c
+++ b/gdk/gdk_unique.c
@@ -257,7 +257,7 @@ BATsubunique(BAT *b, BAT *s)
                                  s ? BATgetId(s) : "NULL",
                                  s ? BATcount(s) : 0);
                seq = b->hseqbase;
-               if ((parent = VIEWtparent(b)) != 0) {
+               if (b->T->hash == NULL && (parent = VIEWtparent(b)) != 0) {
                        BAT *b2 = BBPdescriptor(-parent);
                        lo = (BUN) ((b->T->heap.base - b2->T->heap.base) >> 
b->T->shift) + BUNfirst(b);
                        b = b2;
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to