Changeset: 35b633299b4f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/35b633299b4f
Modified Files:
clients/Tests/MAL-signatures-hge.test
clients/Tests/MAL-signatures.test
monetdb5/modules/mal/pp_hash.c
monetdb5/modules/mal/pp_hash.h
sql/backends/monet5/sql_pp_statement.c
Branch: default
Log Message:
we now have oahash.build i.s.o oahash.build_combined_table and
oahash.build_table
diffs (truncated from 824 to 300 lines):
diff --git a/clients/Tests/MAL-signatures-hge.test
b/clients/Tests/MAL-signatures-hge.test
--- a/clients/Tests/MAL-signatures-hge.test
+++ b/clients/Tests/MAL-signatures-hge.test
@@ -50454,15 +50454,15 @@ command netcdf.test(X_0:str):int
NCDFtest
Returns number of variables in a given NetCDF dataset (file)
oahash
-build_combined_table
-command oahash.build_combined_table(X_0:bat[:any_1], X_1:bat[:oid], X_2:bit)
(X_3:bat[:oid], X_4:bat[:any_1])
-OAHASHbuild_tbl_cmbd
-Add the `key`-s with a `parent_slotid` to the hash table. Returns the
`slot_id` per `key` and the updated `ht_sink`
+build
+pattern oahash.build(X_0:bat[:any_1], X_1:bat[:oid], X_2:bit) (X_3:bat[:oid],
X_4:bat[:any_1])
+OAHASHbuild
+Add `keys` with `parents` to the `hashtable`. If `need_has_nil`, denote if
`keys` contains NULL. Returns corresponding `gids` of the `keys` and the
updated `hashtable`
oahash
-build_table
-command oahash.build_table(X_0:bat[:any_1], X_1:bit) (X_2:bat[:oid],
X_3:bat[:any_1])
-OAHASHbuild_tbl
-Add the `key`-s to the hash table. Returns the `slot_id` per `key` and the
updated `ht_sink`
+build
+pattern oahash.build(X_0:bat[:any_1], X_1:bit) (X_2:bat[:oid], X_3:bat[:any_1])
+OAHASHbuild
+Add `keys` to the `hashtable`. If `need_has_nil`, denote if `keys` contains
NULL. Returns corresponding `gids` of the `keys` and the updated `hashtable`
oahash
combined_mprobe
command oahash.combined_mprobe(X_0:bat[:any_1], X_1:bat[:oid], X_2:bat[:oid],
X_3:bat[:any_1], X_4:bit, X_5:bit) (X_6:bat[:oid], X_7:bat[:oid], X_8:bat[:bit])
diff --git a/clients/Tests/MAL-signatures.test
b/clients/Tests/MAL-signatures.test
--- a/clients/Tests/MAL-signatures.test
+++ b/clients/Tests/MAL-signatures.test
@@ -38639,15 +38639,15 @@ command netcdf.test(X_0:str):int
NCDFtest
Returns number of variables in a given NetCDF dataset (file)
oahash
-build_combined_table
-command oahash.build_combined_table(X_0:bat[:any_1], X_1:bat[:oid], X_2:bit)
(X_3:bat[:oid], X_4:bat[:any_1])
-OAHASHbuild_tbl_cmbd
-Add the `key`-s with a `parent_slotid` to the hash table. Returns the
`slot_id` per `key` and the updated `ht_sink`
+build
+pattern oahash.build(X_0:bat[:any_1], X_1:bat[:oid], X_2:bit) (X_3:bat[:oid],
X_4:bat[:any_1])
+OAHASHbuild
+Add `keys` with `parents` to the `hashtable`. If `need_has_nil`, denote if
`keys` contains NULL. Returns corresponding `gids` of the `keys` and the
updated `hashtable`
oahash
-build_table
-command oahash.build_table(X_0:bat[:any_1], X_1:bit) (X_2:bat[:oid],
X_3:bat[:any_1])
-OAHASHbuild_tbl
-Add the `key`-s to the hash table. Returns the `slot_id` per `key` and the
updated `ht_sink`
+build
+pattern oahash.build(X_0:bat[:any_1], X_1:bit) (X_2:bat[:oid], X_3:bat[:any_1])
+OAHASHbuild
+Add `keys` to the `hashtable`. If `need_has_nil`, denote if `keys` contains
NULL. Returns corresponding `gids` of the `keys` and the updated `hashtable`
oahash
combined_mprobe
command oahash.combined_mprobe(X_0:bat[:any_1], X_1:bat[:oid], X_2:bat[:oid],
X_3:bat[:any_1], X_4:bit, X_5:bit) (X_6:bat[:oid], X_7:bat[:oid], X_8:bat[:bit])
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
@@ -11,6 +11,7 @@
#include "monetdb_config.h"
#include "gdk.h"
#include "gdk_time.h"
+#include "mal_arguments.h"
#include "mal_interpreter.h"
#include "mal_instruction.h"
#include "mal_exception.h"
@@ -560,7 +561,7 @@ UHASHext(Client cntxt, MalBlkPtr m, MalS
/* ***** HASH OPERATORS ***** */
-#define BATaprep_heap(BT, SB, SK, FName) \
+#define aprep_heap(BT, SB, SK) \
do { \
MT_lock_set(&SB->theaplock); \
MT_lock_set(&BT->theaplock); \
@@ -568,32 +569,32 @@ UHASHext(Client cntxt, MalBlkPtr m, MalS
MT_lock_unset(&BT->theaplock); \
MT_lock_unset(&SB->theaplock); \
local_storage = true; \
- pipeline_lock(p); \
+ pipeline_lock(pl); \
if (!SK->allocators) { \
- SK->allocators =
(allocator**)GDKzalloc(p->p->nr_workers*sizeof(allocator*)); \
+ SK->allocators =
(allocator**)GDKzalloc(pl->p->nr_workers*sizeof(allocator*)); \
if (!SK->allocators) { \
- pipeline_unlock(p); \
- err = createException(MAL, FName,
SQLSTATE(HY013) MAL_MALLOC_FAIL); \
+ pipeline_unlock(pl); \
+ err = createException(MAL,
"oahash.build", SQLSTATE(HY013) MAL_MALLOC_FAIL); \
goto error; \
} else { \
- SK->nr_allocators = p->p->nr_workers; \
+ SK->nr_allocators = pl->p->nr_workers; \
} \
} \
- pipeline_unlock(p); \
- assert(p->wid < p->p->nr_workers); \
- if (!SK->allocators[p->wid]) { \
+ pipeline_unlock(pl); \
+ assert(pl->wid < pl->p->nr_workers); \
+ if (!SK->allocators[pl->wid]) { \
char name[MT_NAME_LEN]; \
- snprintf(name, sizeof(name), "pp%d", p->wid); \
- SK->allocators[p->wid] = create_allocator(name,
false); \
- if (!SK->allocators[p->wid]) { \
- err = createException(MAL, FName,
SQLSTATE(HY013) MAL_MALLOC_FAIL); \
+ snprintf(name, sizeof(name), "pp%d", pl->wid); \
+ SK->allocators[pl->wid] =
create_allocator(name, false); \
+ if (!SK->allocators[pl->wid]) { \
+ err = createException(MAL,
"oahash.build", SQLSTATE(HY013) MAL_MALLOC_FAIL); \
goto error; \
} \
} \
} else if (BATcount(BT) && BATcount(SB) == 0 &&
SB->tvheap->parentid == SB->batCacheid) { \
MT_lock_unset(&BT->theaplock); \
MT_lock_unset(&SB->theaplock); \
- BATswap_heaps(SB, BT, p); \
+ BATswap_heaps(SB, BT, pl); \
} else if (SB->tvheap->parentid != BT->tvheap->parentid) { \
int i = 0; \
for(i = 0; i < SK->pinned_nr; i++) { \
@@ -614,13 +615,13 @@ UHASHext(Client cntxt, MalBlkPtr m, MalS
} \
} while(0)
-#define BATgroup(Type) \
+#define group(Type) \
do { \
Type *bp = Tloc(b, 0); \
Type *vals = h->vals; \
\
TIMEOUT_LOOP_IDX_DECL(i, cnt, qry_ctx) { \
- if (*upd_has_nil) \
+ if (need_has_nil) \
(void)ATOMIC_OR(&h->has_nil,
is_##Type##_nil(bp[i])); \
bool fnd = 0; \
gid g = 0; \
@@ -638,7 +639,7 @@ UHASHext(Client cntxt, MalBlkPtr m, MalS
slots = ht_preclaim(private); \
slot = ATOMIC_ADD_GID(&h->last,
slots); \
if (((slot*100)/70) >=
(gid)h->size) { \
- hash_rehash(h, p, err);
\
+ hash_rehash(h, pl,
err); \
vals = h->vals; \
continue; \
} \
@@ -658,7 +659,7 @@ UHASHext(Client cntxt, MalBlkPtr m, MalS
} \
} while (0)
-#define BATvgroup() \
+#define vgroup() \
do { \
oid *vals = h->vals; \
struct canditer ci; \
@@ -683,7 +684,7 @@ UHASHext(Client cntxt, MalBlkPtr m, MalS
slots = ht_preclaim(private); \
slot = ATOMIC_ADD_GID(&h->last,
slots); \
if (((slot*100)/70) >=
(gid)h->size) { \
- hash_rehash(h, p, err);
\
+ hash_rehash(h, pl,
err); \
vals = h->vals; \
continue; \
} \
@@ -703,13 +704,13 @@ UHASHext(Client cntxt, MalBlkPtr m, MalS
} \
} while (0)
-#define BATfgroup(Type, BaseType) \
+#define fgroup(Type, BaseType) \
do { \
Type *bp = Tloc(b, 0); \
Type *vals = h->vals; \
\
TIMEOUT_LOOP_IDX_DECL(i, cnt, qry_ctx) { \
- if (*upd_has_nil) \
+ if (need_has_nil) \
(void)ATOMIC_OR(&h->has_nil,
is_##Type##_nil(bp[i])); \
bool fnd = 0; \
gid g = 0; \
@@ -727,7 +728,7 @@ UHASHext(Client cntxt, MalBlkPtr m, MalS
slots = ht_preclaim(private); \
slot = ATOMIC_ADD_GID(&h->last,
slots); \
if (((slot*100)/70) >=
(gid)h->size) { \
- hash_rehash(h, p, err);
\
+ hash_rehash(h, pl,
err); \
vals = h->vals; \
continue; \
} \
@@ -747,7 +748,7 @@ UHASHext(Client cntxt, MalBlkPtr m, MalS
} \
} while (0)
-#define BATagroup() \
+#define agroup() \
do { \
BATiter bi = bat_iterator(b); \
char **vals = h->vals; \
@@ -756,7 +757,7 @@ UHASHext(Client cntxt, MalBlkPtr m, MalS
bool fnd = 0; \
var_t voff = VarHeapVal(bi.base,i,bi.width);
\
void *bpi = voff == 0 ? (void*) ATOMnilptr((bi).type) :
(void *) ((bi).vh->base+voff); \
- if (*upd_has_nil) \
+ if (need_has_nil) \
(void)ATOMIC_OR(&h->has_nil, (voff == 0)); \
gid g = 0; \
while (!fnd) { \
@@ -772,7 +773,7 @@ UHASHext(Client cntxt, MalBlkPtr m, MalS
slots = ht_preclaim(private); \
slot = ATOMIC_ADD_GID(&h->last,
slots); \
if (((slot*100)/70) >=
(gid)h->size) { \
- hash_rehash(h, p, err);
\
+ hash_rehash(h, pl,
err); \
vals = h->vals; \
continue; \
} \
@@ -793,7 +794,7 @@ UHASHext(Client cntxt, MalBlkPtr m, MalS
bat_iterator_end(&bi); \
} while (0)
-#define BATagroup_(P) \
+#define agroup_(P) \
do { \
BATiter bi = bat_iterator(b); \
char **vals = h->vals; \
@@ -804,7 +805,7 @@ UHASHext(Client cntxt, MalBlkPtr m, MalS
bool fnd = 0; \
var_t voff = VarHeapVal(bi.base,i,bi.width);
\
void *bpi = voff == 0 ? (void*)
ATOMnilptr((bi).type) : (void *) ((bi).vh->base+voff); \
- if (*upd_has_nil) \
+ if (need_has_nil) \
(void)ATOMIC_OR(&h->has_nil, (voff ==
0)); \
gid g = 0; \
while (!fnd) { \
@@ -820,7 +821,7 @@ UHASHext(Client cntxt, MalBlkPtr m, MalS
slots =
ht_preclaim(private); \
slot =
ATOMIC_ADD_GID(&h->last, slots); \
if (((slot*100)/70) >=
(gid)h->size) { \
- hash_rehash(h,
p, err); \
+ hash_rehash(h,
pl, err); \
vals = h->vals;
\
continue; \
} \
@@ -844,7 +845,7 @@ UHASHext(Client cntxt, MalBlkPtr m, MalS
bool fnd = 0; \
var_t voff = VarHeapVal(bi.base,i,bi.width);
\
void *bpi = voff == 0 ? (void*)
ATOMnilptr((bi).type) : (void *) ((bi).vh->base+voff); \
- if (*upd_has_nil) \
+ if (need_has_nil) \
(void)ATOMIC_OR(&h->has_nil, (voff ==
0)); \
gid g = 0; \
while (!fnd) { \
@@ -860,7 +861,7 @@ UHASHext(Client cntxt, MalBlkPtr m, MalS
slots =
ht_preclaim(private); \
slot =
ATOMIC_ADD_GID(&h->last, slots); \
if (((slot*100)/70) >=
(gid)h->size) { \
- hash_rehash(h,
p, err); \
+ hash_rehash(h,
pl, err); \
vals = h->vals;
\
continue; \
} \
@@ -882,143 +883,13 @@ UHASHext(Client cntxt, MalBlkPtr m, MalS
bat_iterator_end(&bi); \
} while (0)
-static str
-OAHASHbuild_tbl(Client ctx, bat *slot_id, bat *ht_sink, const bat *key, const
bit *upd_has_nil)
-{
- (void)ctx;
- Pipeline *p = pipeline_get_thread_private_pipeline();
- bool private = 0, local_storage = false;
- str err = NULL;
- BAT *g = NULL, *u = NULL, *b = NULL;
-
- /* for now we only work with shared ht_sink in the build phase */
- assert(*ht_sink && !is_bat_nil(*ht_sink));
-
- b = BATdescriptor(*key);
- u = BATdescriptor(*ht_sink);
- if (!b || !u) {
- err = createException(SQL, "oahash.build_table",
SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
- goto error;
- }
- hash_table *h = (hash_table*)u->pl_io;
- assert(h && h->pl_io.type == PIPELINE_IO_HASH_TABLE);
-
- BUN cnt = BATcount(b);
- g = COLnew(b->hseqbase, TYPE_oid, cnt, TRANSIENT);
- if (g == NULL) {
- err = createException(MAL, "oahash.build_table",
SQLSTATE(HY013) MAL_MALLOC_FAIL);
- goto error;
- }
-
- if (cnt) {
- ATOMIC_BASE_TYPE expected = 0;
- int tt = b->ttype;
- gid *gp = Tloc(g, 0);
-
- h->empty = false;
- int slots = 0;
- gid slot = 0;
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]