Changeset: 50387c8c1e95 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/50387c8c1e95
Modified Files:
        monetdb5/modules/mal/pp_algebra.c
        monetdb5/modules/mal/pp_hash.c
        monetdb5/modules/mal/pp_hash.h
        monetdb5/modules/mal/pp_mat.c
Branch: default
Log Message:

don't allocate h->vals for fetch/perfect hash tables


diffs (117 lines):

diff --git a/monetdb5/modules/mal/pp_algebra.c 
b/monetdb5/modules/mal/pp_algebra.c
--- a/monetdb5/modules/mal/pp_algebra.c
+++ b/monetdb5/modules/mal/pp_algebra.c
@@ -1580,7 +1580,7 @@ LALGgroup(Client ctx, bat *rid, bat *uid
                        err = createException(MAL, "igroup.group", 
SQLSTATE(HY013) MAL_MALLOC_FAIL);
                        goto error;
                }
-               u->pl_io = (struct 
pipeline_io*)ht_create(b->ttype?b->ttype:TYPE_oid, 1, NULL, 0);
+               u->pl_io = (struct 
pipeline_io*)ht_create(b->ttype?b->ttype:TYPE_oid, 1, NULL, 0, false);
                if (u->pl_io == NULL) {
                        err = createException(MAL, "igroup.group", 
SQLSTATE(HY013) MAL_MALLOC_FAIL);
                        goto error;
@@ -1853,7 +1853,7 @@ LALGderive(Client ctx, bat *rid, bat *ui
                        goto error;
                }
                /* Lookup parent hash */
-               u->pl_io = (struct 
pipeline_io*)ht_create(b->ttype?b->ttype:TYPE_oid, 1, (hash_table*)H->pl_io, 0);
+               u->pl_io = (struct 
pipeline_io*)ht_create(b->ttype?b->ttype:TYPE_oid, 1, (hash_table*)H->pl_io, 0, 
false);
                if (u->pl_io == NULL) {
                        BBPunfix(H->batCacheid);
                        err = createException(MAL, "igroup.group", 
SQLSTATE(HY013) MAL_MALLOC_FAIL);
diff --git a/monetdb5/modules/mal/pp_hash.c b/monetdb5/modules/mal/pp_hash.c
--- a/monetdb5/modules/mal/pp_hash.c
+++ b/monetdb5/modules/mal/pp_hash.c
@@ -42,12 +42,13 @@ static hash_table *
 _ht_init(hash_table *h)
 {
        if (h->gids == NULL) {
-               h->vals = (char*)GDKmalloc(h->size * (size_t)h->width);
+               if (!h->perfect)
+                       h->vals = (char*)GDKmalloc(h->size * (size_t)h->width);
                h->gids = (hash_key_t*)GDKzalloc(sizeof(hash_key_t)* h->size);
                if (ATOMvarsized(h->type)) {
                        h->pinned = GDKzalloc(sizeof(*h->pinned)*1024);
                }
-               if (h->vals == NULL || h->gids == NULL)
+               if ((!h->perfect && h->vals == NULL) || h->gids == NULL)
                        goto error;
                if (h->p) {
                        assert(h->pl_io.type == PIPELINE_IO_HASH_TABLE);
@@ -88,7 +89,7 @@ ht_destroy(hash_table *ht)
 }
 
 static hash_table *
-_ht_create( int type, size_t size, hash_table *p, int vkey)
+_ht_create( int type, size_t size, hash_table *p, int vkey, bool perfect)
 {
        hash_table *h = (hash_table*)GDKzalloc(sizeof(hash_table));
        if (!h)
@@ -113,6 +114,7 @@ _ht_create( int type, size_t size, hash_
        h->pinned = NULL;
        h->pinned_nr = 0; /* no more than 1024 */
        h->vkey = vkey;
+       h->perfect = perfect;
        if (type == TYPE_str && !h->vkey) {
                h->cmp = (fcmp)str_cmp;
                h->hsh = (fhsh)str_hsh;
@@ -136,13 +138,13 @@ _ht_create( int type, size_t size, hash_
 }
 
 hash_table *
-ht_create(int type, size_t size, hash_table *p, int vkey)
+ht_create(int type, size_t size, hash_table *p, int vkey, bool perfect)
 {
        if (size < HT_MIN_SIZE)
                size = HT_MIN_SIZE;
        if (size > HT_MAX_SIZE)
                size = HT_MAX_SIZE;
-       return _ht_create(type, size, p, vkey);
+       return _ht_create(type, size, p, vkey, perfect);
 }
 
 #define prnt(Type) \
@@ -520,7 +522,7 @@ OAHASHnew(Client cntxt, MalBlkPtr m, Mal
                BBPreclaim(pht);
                return createException(MAL, "oahash.new", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
        }
-       b->pl_io = (struct pipeline_io*)ht_create(tt, (size_t)size, parent, 
vkey);
+       b->pl_io = (struct pipeline_io*)ht_create(tt, (size_t)size, parent, 
vkey, false);
        BBPreclaim(pht);
        if (b->pl_io == NULL) {
                BBPunfix(b->batCacheid);
@@ -551,8 +553,7 @@ FHASHnew(Client cntxt, MalBlkPtr m, MalS
                BBPreclaim(pht);
                return createException(MAL, "fhash.new", SQLSTATE(HY013) 
MAL_MALLOC_FAIL);
        }
-       hash_table *ht = ht_create(tt, (size_t)max, parent, 0);
-       ht->perfect = true;
+       hash_table *ht = ht_create(tt, (size_t)max, parent, 0, true);
        b->pl_io = (struct pipeline_io*)ht;
        BBPreclaim(pht);
        if (b->pl_io == NULL) {
diff --git a/monetdb5/modules/mal/pp_hash.h b/monetdb5/modules/mal/pp_hash.h
--- a/monetdb5/modules/mal/pp_hash.h
+++ b/monetdb5/modules/mal/pp_hash.h
@@ -132,8 +132,7 @@ str_hsh( str v )
        }
        return (lng)h;
 }
-
-extern hash_table *ht_create(int type, size_t size, hash_table *p, int vkey);
+extern hash_table *ht_create(int type, size_t size, hash_table *p, int vkey, 
bool perfect /* no need to store the values, these are offsets */);
 extern int ht_rehash(hash_table *ht);
 extern void ht_print(stream *fdout, BAT *b);
 
diff --git a/monetdb5/modules/mal/pp_mat.c b/monetdb5/modules/mal/pp_mat.c
--- a/monetdb5/modules/mal/pp_mat.c
+++ b/monetdb5/modules/mal/pp_mat.c
@@ -136,7 +136,7 @@ MATnew(Client cntxt, MalBlkPtr mb, MalSt
                        break;
                BATnegateprops(b);
                if (hashsize)
-                       b->pl_io = (struct pipeline_io*)ht_create(tt, 
(size_t)(hashsize), pmat?(hash_table*)pmat->bat[i]->pl_io:NULL, 0);
+                       b->pl_io = (struct pipeline_io*)ht_create(tt, 
(size_t)(hashsize), pmat?(hash_table*)pmat->bat[i]->pl_io:NULL, 0, false);
        }
        if (i < mat->nr) {
                mat_destroy(mat);
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to