Changeset: 442eb3fc8ffa for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/442eb3fc8ffa
Modified Files:
        monetdb5/modules/mal/groupby.c
        monetdb5/modules/mal/projectionpath.c
Branch: resource_management
Log Message:

further use arena allocator in mal


diffs (118 lines):

diff --git a/monetdb5/modules/mal/groupby.c b/monetdb5/modules/mal/groupby.c
--- a/monetdb5/modules/mal/groupby.c
+++ b/monetdb5/modules/mal/groupby.c
@@ -74,19 +74,20 @@ GROUPcollect(Client cntxt, MalBlkPtr mb,
 
        (void) mb;
        (void) cntxt;
-       a = (AGGRtask *) GDKmalloc(sizeof(*a));
+       allocator *ma = mb->ma;
+       a = (AGGRtask *) ma_alloc(ma, sizeof(*a));
        if (a == NULL)
                return NULL;
        *a = (AGGRtask) {
-               .bid = GDKzalloc(pci->argc * sizeof(bat)),
-               .cols = GDKzalloc(pci->argc * sizeof(BAT *)),
-               .unique = GDKzalloc(pci->argc * sizeof(BUN)),
+               .bid = ma_zalloc(ma, pci->argc * sizeof(bat)),
+               .cols = ma_zalloc(ma, pci->argc * sizeof(BAT *)),
+               .unique = ma_zalloc(ma, pci->argc * sizeof(BUN)),
        };
        if (a->cols == NULL || a->bid == NULL || a->unique == NULL) {
-               GDKfree(a->cols);
-               GDKfree(a->bid);
-               GDKfree(a->unique);
-               GDKfree(a);
+               //GDKfree(a->cols);
+               //GDKfree(a->bid);
+               //GDKfree(a->unique);
+               //GDKfree(a);
                return NULL;
        }
        for (i = pci->retc; i < pci->argc; i++, a->last++) {
@@ -95,10 +96,10 @@ GROUPcollect(Client cntxt, MalBlkPtr mb,
                if (a->cols[a->last] == NULL) {
                        for (a->last--; a->last >= 0; a->last--)
                                BBPunfix(a->cols[a->last]->batCacheid);
-                       GDKfree(a->cols);
-                       GDKfree(a->bid);
-                       GDKfree(a->unique);
-                       GDKfree(a);
+                       //GDKfree(a->cols);
+                       //GDKfree(a->bid);
+                       //GDKfree(a->unique);
+                       //GDKfree(a);
                        return NULL;
                }
                bs = BATsample(b, 1000);
@@ -143,17 +144,17 @@ GROUPcollectSort(AGGRtask *a, int start,
                        }
 }
 
-static void
-GROUPdelete(AGGRtask *a)
-{
-       for (a->last--; a->last >= 0; a->last--) {
-               BBPunfix(a->cols[a->last]->batCacheid);
-       }
-       GDKfree(a->bid);
-       GDKfree(a->cols);
-       GDKfree(a->unique);
-       GDKfree(a);
-}
+//static void
+//GROUPdelete(AGGRtask *a)
+//{
+//     for (a->last--; a->last >= 0; a->last--) {
+//             BBPunfix(a->cols[a->last]->batCacheid);
+//     }
+//     GDKfree(a->bid);
+//     GDKfree(a->cols);
+//     GDKfree(a->unique);
+//     GDKfree(a);
+//}
 
 /*
  * The groups optimizer takes a grouping sequence and attempts to
@@ -209,7 +210,10 @@ GROUPmulticolumngroup(Client cntxt, MalB
                        BBPrelease(oldext);
                        BBPrelease(oldhist);
                } while (msg == MAL_SUCCEED && ++i < aggr->last);
-       GROUPdelete(aggr);
+       // GROUPdelete(aggr);
+       for (aggr->last--; aggr->last >= 0; aggr->last--) {
+               BBPunfix(aggr->cols[aggr->last]->batCacheid);
+       }
        return msg;
 }
 
diff --git a/monetdb5/modules/mal/projectionpath.c 
b/monetdb5/modules/mal/projectionpath.c
--- a/monetdb5/modules/mal/projectionpath.c
+++ b/monetdb5/modules/mal/projectionpath.c
@@ -28,7 +28,7 @@ ALGprojectionpath(Client cntxt, MalBlkPt
 
        if (pci->argc <= 1)
                throw(MAL, "algebra.projectionpath", SQLSTATE(HY013) "INTERNAL 
ERROR");
-       joins = (BAT **) GDKzalloc(pci->argc * sizeof(BAT *));
+       joins = (BAT **) ma_zalloc(mb->ma, pci->argc * sizeof(BAT *));
        if (joins == NULL)
                throw(MAL, "algebra.projectionpath", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
        for (i = pci->retc; i < pci->argc; i++) {
@@ -39,7 +39,7 @@ ALGprojectionpath(Client cntxt, MalBlkPt
                                && b->ttype != TYPE_msk)) {
                        while (--i >= pci->retc)
                                BBPunfix(joins[i - pci->retc]->batCacheid);
-                       GDKfree(joins);
+                       //GDKfree(joins);
                        BBPreclaim(b);
                        throw(MAL, "algebra.projectionpath", "%s",
                                  b ? SEMANTIC_TYPE_MISMATCH : 
INTERNAL_BAT_ACCESS);
@@ -50,7 +50,7 @@ ALGprojectionpath(Client cntxt, MalBlkPt
        b = BATprojectchain(joins);
        for (i = pci->retc; i < pci->argc; i++)
                BBPunfix(joins[i - pci->retc]->batCacheid);
-       GDKfree(joins);
+       //GDKfree(joins);
        if (b) {
                *r = b->batCacheid;
                BBPkeepref(b);
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to