MonetDB: default - optimized segments2cands

2021-03-04 Thread Niels Nes
Changeset: 394775d7cb4e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=394775d7cb4e
Modified Files:
sql/storage/bat/bat_storage.c
Branch: default
Log Message:

optimized segments2cands


diffs (73 lines):

diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c
--- a/sql/storage/bat/bat_storage.c
+++ b/sql/storage/bat/bat_storage.c
@@ -2985,10 +2985,12 @@ static BAT *
 segments2cands(segment *s, sql_trans *tr, size_t start, size_t end)
 {
size_t nr = end - start, pos = 0;
+   int cur = 0;
BAT *b = COLnew(0, TYPE_msk, nr, TRANSIENT), *bn = NULL;
if (!b)
return NULL;
 
+   int *dst = Tloc(b, 0);
for( ; s; s=s->next) {
if (s->end < start)
continue;
@@ -3002,15 +3004,50 @@ segments2cands(segment *s, sql_trans *tr
lnr -= (start - s->start);
if (s->end > end)
lnr -= s->end - end;
-   /* later optimize per 32 bits */
-   for(size_t i = 0; ihttps://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Inline commonly used hash functions

2021-03-04 Thread Pedro Ferreira
Changeset: a69b9a12f6e9 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a69b9a12f6e9
Modified Files:
sql/common/sql_hash.c
sql/include/sql_hash.h
sql/server/rel_exp.c
sql/storage/objectset.c
sql/storage/sql_catalog.c
Branch: default
Log Message:

Inline commonly used hash functions


diffs (112 lines):

diff --git a/sql/common/sql_hash.c b/sql/common/sql_hash.c
--- a/sql/common/sql_hash.c
+++ b/sql/common/sql_hash.c
@@ -40,20 +40,6 @@ hash_new(sql_allocator *sa, int size, fk
return ht;
 }
 
-sql_hash_e*
-hash_add(sql_hash *h, int key, void *value)
-{
-   sql_hash_e *e = (h->sa)?SA_ZNEW(h->sa, sql_hash_e):ZNEW(sql_hash_e);
-
-   if (e == NULL)
-   return NULL;
-   e->chain = h->buckets[key&(h->size-1)];
-   h->buckets[key&(h->size-1)] = e;
-   e->key = key;
-   e->value = value;
-   return e;
-}
-
 void
 hash_del(sql_hash *h, int key, void *value)
 {
@@ -91,13 +77,3 @@ hash_destroy(sql_hash *h) /* this code s
_DELETE(h);
 }
 
-unsigned int
-hash_key(const char *restrict k)
-{
-   unsigned int h = 37; /* prime number */
-   while (*k) {
-   h = (h * 54059) ^ (k[0] * 76963); /* prime numbers */
-   k++;
-   }
-   return h;
-}
diff --git a/sql/include/sql_hash.h b/sql/include/sql_hash.h
--- a/sql/include/sql_hash.h
+++ b/sql/include/sql_hash.h
@@ -33,10 +33,32 @@ typedef struct sql_hash {
 } sql_hash;
 
 extern sql_hash *hash_new(sql_allocator *sa, int size, fkeyvalue key);
-extern sql_hash_e *hash_add(sql_hash *ht, int key, void *value);
 extern void hash_del(sql_hash *ht, int key, void *value);
 extern void hash_destroy(sql_hash *h);
 
-extern unsigned int hash_key(const char *restrict k);
+static inline sql_hash_e*
+hash_add(sql_hash *h, int key, void *value)
+{
+   sql_hash_e *e = (h->sa)?SA_NEW(h->sa, sql_hash_e):MNEW(sql_hash_e);
+
+   if (e == NULL)
+   return NULL;
+   e->chain = h->buckets[key&(h->size-1)];
+   h->buckets[key&(h->size-1)] = e;
+   e->key = key;
+   e->value = value;
+   return e;
+}
+
+static inline unsigned int
+hash_key(const char *restrict k)
+{
+   unsigned int h = 37; /* prime number */
+   while (*k) {
+   h = (h * 54059) ^ (k[0] * 76963); /* prime numbers */
+   k++;
+   }
+   return h;
+}
 
 #endif /* SQL_HASH_H */
diff --git a/sql/server/rel_exp.c b/sql/server/rel_exp.c
--- a/sql/server/rel_exp.c
+++ b/sql/server/rel_exp.c
@@ -2361,7 +2361,7 @@ exp_unsafe(sql_exp *e, int allow_identit
return 0;
 }
 
-static int
+static inline int
 exp_key( sql_exp *e )
 {
if (e->alias.name)
diff --git a/sql/storage/objectset.c b/sql/storage/objectset.c
--- a/sql/storage/objectset.c
+++ b/sql/storage/objectset.c
@@ -262,7 +262,7 @@ node_create(sql_allocator *sa, objectver
return n;
 }
 
-static int
+static inline int
 os_name_key(versionhead  *n)
 {
return hash_key(n->ov->b->name);
diff --git a/sql/storage/sql_catalog.c b/sql/storage/sql_catalog.c
--- a/sql/storage/sql_catalog.c
+++ b/sql/storage/sql_catalog.c
@@ -12,7 +12,7 @@
 
 const char *TID = "%TID%";
 
-int
+inline int
 base_key( sql_base *b )
 {
return hash_key(b->name);
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - restrict can be used here

2021-03-04 Thread Pedro Ferreira
Changeset: a84420b62940 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a84420b62940
Modified Files:
sql/storage/bat/bat_storage.c
Branch: default
Log Message:

restrict can be used here


diffs (12 lines):

diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c
--- a/sql/storage/bat/bat_storage.c
+++ b/sql/storage/bat/bat_storage.c
@@ -2990,7 +2990,7 @@ segments2cands(segment *s, sql_trans *tr
if (!b)
return NULL;
 
-   int *dst = Tloc(b, 0);
+   int *restrict dst = Tloc(b, 0);
for( ; s; s=s->next) {
if (s->end < start)
continue;
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Set the correct bits when filling a msk bat.

2021-03-04 Thread Sjoerd Mullender
Changeset: e9691ec4faab for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e9691ec4faab
Modified Files:
gdk/gdk_batop.c
Branch: default
Log Message:

Set the correct bits when filling a msk bat.


diffs (22 lines):

diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -2432,10 +2432,14 @@ BATconstant(oid hseq, int tailtype, cons
BATtseqbase(bn, oid_nil);
break;
case TYPE_msk:
-   if (*(msk*)v)
-   memset(p, 0xFF, (n + 7) / 8);
-   else
-   memset(p, 0x00, (n + 7) / 8);
+   if (*(msk*)v) {
+   memset(p, 0xFF, 4 * ((n + 31) / 32));
+   if (n & 31) {
+   uint32_t *m = p;
+   m[n / 32] &= ~((1U << (n % 32)) - 1);
+   }
+   } else
+   memset(p, 0x00, 4 * ((n + 31) / 32));
break;
case TYPE_bte:
memset(p, *(bte*)v, n);
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Approve ppc64 upgrades.

2021-03-04 Thread Sjoerd Mullender
Changeset: 9100cdc12799 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9100cdc12799
Modified Files:
sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.ppc64.int128
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.ppc64
sql/test/emptydb-upgrade-chain/Tests/upgrade.stable.out.ppc64.int128
Branch: default
Log Message:

Approve ppc64 upgrades.


diffs (truncated from 24979 to 300 lines):

diff --git 
a/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.ppc64.int128 
b/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.ppc64.int128
--- a/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.ppc64.int128
+++ b/sql/test/emptydb-upgrade-chain-hge/Tests/upgrade.stable.out.ppc64.int128
@@ -2,4208 +2,4222 @@ Running database upgrade commands:
 set schema "sys";
 delete from sys.dependencies where id < 2000;
 delete from sys.types where id < 2000;
-insert into sys.types values (0, 'void', 'any', 0, 0, 0, 0, 2000);
-insert into sys.types values (1, 'bat', 'table', 0, 0, 0, 1, 2000);
-insert into sys.types values (2, 'ptr', 'ptr', 0, 0, 0, 1, 2000);
-insert into sys.types values (3, 'bit', 'boolean', 1, 0, 2, 2, 2000);
-insert into sys.types values (4, 'str', 'char', 0, 0, 0, 3, 2000);
-insert into sys.types values (5, 'str', 'varchar', 0, 0, 0, 4, 2000);
-insert into sys.types values (6, 'str', 'clob', 0, 0, 0, 4, 2000);
-insert into sys.types values (7, 'oid', 'oid', 63, 0, 2, 6, 2000);
-insert into sys.types values (8, 'bte', 'tinyint', 8, 1, 2, 7, 2000);
-insert into sys.types values (9, 'sht', 'smallint', 16, 1, 2, 7, 2000);
-insert into sys.types values (10, 'int', 'int', 32, 1, 2, 7, 2000);
-insert into sys.types values (11, 'lng', 'bigint', 64, 1, 2, 7, 2000);
-insert into sys.types values (12, 'hge', 'hugeint', 128, 1, 2, 7, 2000);
-insert into sys.types values (13, 'bte', 'decimal', 2, 1, 10, 10, 2000);
-insert into sys.types values (14, 'sht', 'decimal', 4, 1, 10, 10, 2000);
-insert into sys.types values (15, 'int', 'decimal', 9, 1, 10, 10, 2000);
-insert into sys.types values (16, 'lng', 'decimal', 18, 1, 10, 10, 2000);
-insert into sys.types values (17, 'hge', 'decimal', 38, 1, 10, 10, 2000);
-insert into sys.types values (18, 'flt', 'real', 24, 2, 2, 11, 2000);
-insert into sys.types values (19, 'dbl', 'double', 53, 2, 2, 11, 2000);
-insert into sys.types values (20, 'int', 'month_interval', 3, 0, 10, 8, 2000);
-insert into sys.types values (21, 'lng', 'day_interval', 4, 0, 10, 9, 2000);
-insert into sys.types values (22, 'lng', 'sec_interval', 13, 1, 10, 9, 2000);
-insert into sys.types values (23, 'daytime', 'time', 7, 0, 0, 12, 2000);
-insert into sys.types values (24, 'daytime', 'timetz', 7, 1, 0, 13, 2000);
-insert into sys.types values (25, 'date', 'date', 0, 0, 0, 14, 2000);
-insert into sys.types values (26, 'timestamp', 'timestamp', 7, 0, 0, 15, 2000);
-insert into sys.types values (27, 'timestamp', 'timestamptz', 7, 1, 0, 16, 
2000);
-insert into sys.types values (28, 'blob', 'blob', 0, 0, 0, 5, 2000);
-insert into sys.types values (31, 'wkb', 'geometry', 0, 0, 0, 17, 2000);
-insert into sys.types values (32, 'wkba', 'geometrya', 0, 0, 0, 18, 2000);
-insert into sys.types values (33, 'mbr', 'mbr', 0, 0, 0, 18, 2000);
+insert into sys.types values (1, 'void', 'any', 0, 0, 0, 0, 2000);
+insert into sys.types values (2, 'bat', 'table', 0, 0, 0, 1, 2000);
+insert into sys.types values (3, 'ptr', 'ptr', 0, 0, 0, 1, 2000);
+insert into sys.types values (4, 'bit', 'boolean', 1, 0, 2, 2, 2000);
+insert into sys.types values (5, 'str', 'clob', 0, 0, 0, 4, 2000);
+insert into sys.types values (6, 'str', 'varchar', 0, 0, 0, 4, 2000);
+insert into sys.types values (7, 'str', 'char', 0, 0, 0, 3, 2000);
+insert into sys.types values (8, 'oid', 'oid', 63, 0, 2, 6, 2000);
+insert into sys.types values (9, 'bte', 'tinyint', 8, 1, 2, 7, 2000);
+insert into sys.types values (10, 'sht', 'smallint', 16, 1, 2, 7, 2000);
+insert into sys.types values (11, 'int', 'int', 32, 1, 2, 7, 2000);
+insert into sys.types values (12, 'lng', 'bigint', 64, 1, 2, 7, 2000);
+insert into sys.types values (13, 'hge', 'hugeint', 128, 1, 2, 7, 2000);
+insert into sys.types values (14, 'bte', 'decimal', 2, 1, 10, 10, 2000);
+insert into sys.types values (15, 'sht', 'decimal', 4, 1, 10, 10, 2000);
+insert into sys.types values (16, 'int', 'decimal', 9, 1, 10, 10, 2000);
+insert into sys.types values (17, 'lng', 'decimal', 18, 1, 10, 10, 2000);
+insert into sys.types values (18, 'hge', 'decimal', 38, 1, 10, 10, 2000);
+insert into sys.types values (19, 'flt', 'real', 24, 2, 2, 11, 2000);
+insert into sys.types values (20, 'dbl', 'double', 53, 2, 2, 11, 2000);
+insert into sys.types values (21, 'int', 'month_interval', 3, 0, 10, 8, 2000);
+insert into sys.types values (22, 'lng', 'day_interval', 4, 0, 10, 9, 2000);
+insert into sys.types values (23, 'lng', 'sec_interval', 13, 1, 10, 9, 2000);
+insert into sys.types values (24, 'daytime', 'time', 7, 0, 0, 

MonetDB: default - Reduce allocations while starting storage by ...

2021-03-04 Thread Pedro Ferreira
Changeset: 8935093e7353 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8935093e7353
Modified Files:
sql/backends/monet5/sql_user.c
sql/storage/bat/bat_table.c
sql/storage/sql_storage.h
sql/storage/store.c
Branch: default
Log Message:

Reduce allocations while starting storage by passing pointer to the string heap


diffs (truncated from 696 to 300 lines):

diff --git a/sql/backends/monet5/sql_user.c b/sql/backends/monet5/sql_user.c
--- a/sql/backends/monet5/sql_user.c
+++ b/sql/backends/monet5/sql_user.c
@@ -520,7 +520,7 @@ str
 monet5_user_get_def_schema(mvc *m, int user)
 {
oid rid;
-   sqlid schema_id;
+   sqlid schema_id = 0;
sql_schema *sys = NULL;
sql_table *user_info = NULL;
sql_column *users_name = NULL;
@@ -531,7 +531,6 @@ monet5_user_get_def_schema(mvc *m, int u
sql_table *auths = NULL;
sql_column *auths_id = NULL;
sql_column *auths_name = NULL;
-   void *p = 0;
str username = NULL;
str schema = NULL;
 
@@ -550,12 +549,9 @@ monet5_user_get_def_schema(mvc *m, int u
users_schema = find_sql_column(user_info, "default_schema");
rid = store->table_api.column_find_row(m->session->tr, users_name, 
username, NULL);
if (!is_oid_nil(rid))
-   p = store->table_api.column_find_value(m->session->tr, 
users_schema, rid);
+   schema_id = store->table_api.column_find_sqlid(m->session->tr, 
users_schema, rid);
 
_DELETE(username);
-   assert(p);
-   schema_id = *(sqlid *) p;
-   _DELETE(p);
 
schemas = find_sql_table(m->session->tr, sys, "schemas");
schemas_name = find_sql_column(schemas, "name");
diff --git a/sql/storage/bat/bat_table.c b/sql/storage/bat/bat_table.c
--- a/sql/storage/bat/bat_table.c
+++ b/sql/storage/bat/bat_table.c
@@ -172,6 +172,34 @@ column_find_tpe(sht)
 column_find_tpe(int)
 column_find_tpe(lng)
 
+static str
+column_find_string_start(sql_trans *tr, sql_column *c, oid rid, ptr *cbat)
+{
+   BUN q = BUN_NONE;
+   BAT **b = (BAT**) cbat;
+   str res = NULL;
+
+   *b = full_column(tr, c);
+   if (*b) {
+   if (rid < (*b)->hseqbase || rid >= (*b)->hseqbase + 
BATcount(*b))
+   q = BUN_NONE;
+   else
+   q = rid - (*b)->hseqbase;
+   }
+   if (q != BUN_NONE) {
+   BATiter bi = bat_iterator(*b);
+   res = (str) BUNtvar(bi, q);
+   }
+   return res;
+}
+
+static void
+column_find_string_end(ptr cbat)
+{
+   BAT *b = (BAT*) cbat;
+   full_destroy(NULL, b);
+}
+
 static int
 column_update_value(sql_trans *tr, sql_column *c, oid rid, void *value)
 {
@@ -621,7 +649,8 @@ bat_table_init( table_functions *tf )
tf->column_find_sht = column_find_sht;
tf->column_find_int = column_find_int;
tf->column_find_lng = column_find_lng;
-
+   tf->column_find_string_start = column_find_string_start; /* this 
function returns a pointer to the heap, use it with care! */
+   tf->column_find_string_end = column_find_string_end; /* don't forget to 
call this function to unfix the bat descriptor! */
tf->column_update_value = column_update_value;
tf->table_insert = table_insert;
tf->table_delete = table_delete;
diff --git a/sql/storage/sql_storage.h b/sql/storage/sql_storage.h
--- a/sql/storage/sql_storage.h
+++ b/sql/storage/sql_storage.h
@@ -46,6 +46,8 @@ typedef bte (*column_find_bte_fptr)(sql_
 typedef sht (*column_find_sht_fptr)(sql_trans *tr, sql_column *c, oid rid);
 typedef int (*column_find_int_fptr)(sql_trans *tr, sql_column *c, oid rid);
 typedef lng (*column_find_lng_fptr)(sql_trans *tr, sql_column *c, oid rid);
+typedef str (*column_find_string_start_fptr)(sql_trans *tr, sql_column *c, oid 
rid, ptr *cbat);
+typedef void (*column_find_string_end_fptr)(ptr cbat);
 typedef int (*column_update_value_fptr)(sql_trans *tr, sql_column *c, oid rid, 
void *value);
 typedef int (*table_insert_fptr)(sql_trans *tr, sql_table *t, ...);
 typedef int (*table_delete_fptr)(sql_trans *tr, sql_table *t, oid rid);
@@ -96,6 +98,9 @@ typedef struct table_functions {
column_find_sht_fptr column_find_sht;
column_find_int_fptr column_find_int;
column_find_lng_fptr column_find_lng;
+   column_find_string_start_fptr column_find_string_start; /* this 
function returns a pointer to the heap, use it with care! */
+   column_find_string_end_fptr column_find_string_end; /* don't forget to 
call this function to unfix the bat descriptor! */
+
column_update_value_fptr column_update_value;
table_insert_fptr table_insert;
table_delete_fptr table_delete;
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -273,14 +273,16 @@ schema_destroy(sqlstore *store, sql_sche
 static void
 load_keycolumn(sql_trans *tr, sql_key *k, oid rid)
 {

MonetDB: default - Do less copying

2021-03-04 Thread Pedro Ferreira
Changeset: 7d829a67bc49 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7d829a67bc49
Modified Files:
sql/storage/store.c
Branch: default
Log Message:

Do less copying


diffs (99 lines):

diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -541,36 +541,18 @@ load_range_partition(sql_trans *tr, sql_
 
rs = store->table_api.rids_select(tr, find_sql_column(ranges, 
"table_id"), &pt->member, &pt->member, NULL);
if ((rid = store->table_api.rids_next(rs)) != oid_nil) {
-   ValRecord vmin, vmax;
-   ptr ok, cbat;
+   ptr cbat;
str v;
 
-   vmin = vmax = (ValRecord) {.vtype = TYPE_void,};
-
+   pt->with_nills = (bit) store->table_api.column_find_bte(tr, 
find_sql_column(ranges, "with_nulls"), rid);
v = store->table_api.column_find_string_start(tr, 
find_sql_column(ranges, "minimum"), rid, &cbat);
-   ok = VALinit(&vmin, TYPE_str, v);
+   pt->part.range.minvalue = SA_STRDUP(tr->sa, v);
+   pt->part.range.minlength = strLen(v);
store->table_api.column_find_string_end(cbat);
-   if (ok) {
-   v = store->table_api.column_find_string_start(tr, 
find_sql_column(ranges, "maximum"), rid, &cbat); 
-   ok = VALinit(&vmax, TYPE_str, v);
-   store->table_api.column_find_string_end(cbat);
-   }
-   if (ok) {
-   pt->with_nills = (bit) 
store->table_api.column_find_bte(tr, find_sql_column(ranges, "with_nulls"), 
rid);
-
-   pt->part.range.minvalue = SA_NEW_ARRAY(tr->sa, char, 
vmin.len);
-   pt->part.range.maxvalue = SA_NEW_ARRAY(tr->sa, char, 
vmax.len);
-   memcpy(pt->part.range.minvalue, VALget(&vmin), 
vmin.len);
-   memcpy(pt->part.range.maxvalue, VALget(&vmax), 
vmax.len);
-   pt->part.range.minlength = vmin.len;
-   pt->part.range.maxlength = vmax.len;
-   }
-   VALclear(&vmin);
-   VALclear(&vmax);
-   if (!ok) {
-   store->table_api.rids_destroy(rs);
-   return -1;
-   }
+   v = store->table_api.column_find_string_start(tr, 
find_sql_column(ranges, "maximum"), rid, &cbat);
+   pt->part.range.maxvalue = SA_STRDUP(tr->sa, v);
+   pt->part.range.maxlength = strLen(v);
+   store->table_api.column_find_string_end(cbat);
}
store->table_api.rids_destroy(rs);
return 0;
@@ -584,7 +566,6 @@ load_value_partition(sql_trans *tr, sql_
list *vals = NULL;
oid rid;
rids *rs = store->table_api.rids_select(tr, find_sql_column(values, 
"table_id"), &pt->member, &pt->member, NULL);
-   int i = 0;
 
vals = SA_LIST(tr->sa, (fdestroy) &part_value_destroy);
if (!vals) {
@@ -593,33 +574,19 @@ load_value_partition(sql_trans *tr, sql_
}
 
for (rid = store->table_api.rids_next(rs); !is_oid_nil(rid); rid = 
store->table_api.rids_next(rs)) {
-   sql_part_value* nextv;
-   ValRecord vvalue;
-   ptr ok, cbat;
+   ptr cbat;
str v;
 
-   vvalue = (ValRecord) {.vtype = TYPE_void,};
v = store->table_api.column_find_string_start(tr, 
find_sql_column(values, "value"), rid, &cbat);
-   ok = VALinit(&vvalue, TYPE_str, v);
+   if (strNil(v)) { /* check for null value */
+   pt->with_nills = true;
+   } else {
+   sql_part_value *nextv = SA_ZNEW(tr->sa, sql_part_value);
+   nextv->value = SA_STRDUP(tr->sa, v);
+   nextv->length = strLen(v);
+   list_append(vals, nextv);
+   }
store->table_api.column_find_string_end(cbat);
-   if (ok) {
-   if (VALisnil(&vvalue)) { /* check for null value */
-   pt->with_nills = true;
-   } else {
-   nextv = SA_ZNEW(tr->sa, sql_part_value);
-   nextv->value = SA_NEW_ARRAY(tr->sa, char, 
vvalue.len);
-   memcpy(nextv->value, VALget(&vvalue), 
vvalue.len);
-   nextv->length = vvalue.len;
-   list_append(vals, nextv);
-   }
-   }
-   VALclear(&vvalue);
-   if (!ok) {
-   store->table_api.rids_destroy(rs);
-   list_destroy2(vals, tr->store);
-   return -i - 1;
-   }
-   i++;
}
store->table_api.rids_destroy(rs

MonetDB: default - Clear the right bits.

2021-03-04 Thread Sjoerd Mullender
Changeset: 3eee8a447cce for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3eee8a447cce
Modified Files:
gdk/gdk_batop.c
Branch: default
Log Message:

Clear the right bits.


diffs (12 lines):

diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -2436,7 +2436,7 @@ BATconstant(oid hseq, int tailtype, cons
memset(p, 0xFF, 4 * ((n + 31) / 32));
if (n & 31) {
uint32_t *m = p;
-   m[n / 32] &= ~((1U << (n % 32)) - 1);
+   m[n / 32] &= (1U << (n % 32)) - 1;
}
} else
memset(p, 0x00, 4 * ((n + 31) / 32));
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: Oct2020 - Plugging embedded python leaks

2021-03-04 Thread Pedro Ferreira
Changeset: 6f2834d3a3a1 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6f2834d3a3a1
Modified Files:
sql/backends/monet5/UDF/pyapi3/connection3.c
sql/backends/monet5/UDF/pyapi3/emit3.c
Branch: Oct2020
Log Message:

Plugging embedded python leaks


diffs (32 lines):

diff --git a/sql/backends/monet5/UDF/pyapi3/connection3.c 
b/sql/backends/monet5/UDF/pyapi3/connection3.c
--- a/sql/backends/monet5/UDF/pyapi3/connection3.c
+++ b/sql/backends/monet5/UDF/pyapi3/connection3.c
@@ -41,6 +41,7 @@ static PyObject *_connection_execute(Py_
if (res != MAL_SUCCEED) {
PyErr_Format(PyExc_Exception, "SQL Query Failed: %s",
 (res ? 
getExceptionMessage(res) : ""));
+   freeException(res);
return NULL;
}
 
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
@@ -204,7 +204,7 @@ PyObject *PyEmit_Emit(PyEmitObject *self
// insert NULL values up until the 
current entry
for (ai = 0; ai < self->nvals; ai++) {
if 
(BUNappend(self->cols[self->ncols].b,
- 
ATOMnil(self->cols[self->ncols].b->ttype),
+ 
ATOMnilptr(self->cols[self->ncols].b->ttype),
  
false) != GDK_SUCCEED) {
msg = 
GDKstrdup("BUNappend failed.");
goto wrapup;
@@ -368,7 +368,7 @@ PyObject *PyEmit_Emit(PyEmitObject *self
}
for (ai = 0; ai < (size_t)el_count; ai++) {
if (BUNappend(self->cols[i].b,
- 
ATOMnil(self->cols[i].b->ttype),
+ 
ATOMnilptr(self->cols[i].b->ttype),
  false) != 
GDK_SUCCEED) {
goto wrapup;
}
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Merged with Oct2020

2021-03-04 Thread Pedro Ferreira
Changeset: 55872aff17d0 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=55872aff17d0
Modified Files:
sql/test/emptydb/Tests/check.stable.out
sql/test/emptydb/Tests/check.stable.out.32bit
sql/test/emptydb/Tests/check.stable.out.int128
Branch: default
Log Message:

Merged with Oct2020


diffs (32 lines):

diff --git a/sql/backends/monet5/UDF/pyapi3/connection3.c 
b/sql/backends/monet5/UDF/pyapi3/connection3.c
--- a/sql/backends/monet5/UDF/pyapi3/connection3.c
+++ b/sql/backends/monet5/UDF/pyapi3/connection3.c
@@ -41,6 +41,7 @@ static PyObject *_connection_execute(Py_
if (res != MAL_SUCCEED) {
PyErr_Format(PyExc_Exception, "SQL Query Failed: %s",
 (res ? 
getExceptionMessage(res) : ""));
+   freeException(res);
return NULL;
}
 
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
@@ -204,7 +204,7 @@ PyObject *PyEmit_Emit(PyEmitObject *self
// insert NULL values up until the 
current entry
for (ai = 0; ai < self->nvals; ai++) {
if 
(BUNappend(self->cols[self->ncols].b,
- 
ATOMnil(self->cols[self->ncols].b->ttype),
+ 
ATOMnilptr(self->cols[self->ncols].b->ttype),
  
false) != GDK_SUCCEED) {
msg = 
GDKstrdup("BUNappend failed.");
goto wrapup;
@@ -368,7 +368,7 @@ PyObject *PyEmit_Emit(PyEmitObject *self
}
for (ai = 0; ai < (size_t)el_count; ai++) {
if (BUNappend(self->cols[i].b,
- 
ATOMnil(self->cols[i].b->ttype),
+ 
ATOMnilptr(self->cols[i].b->ttype),
  false) != 
GDK_SUCCEED) {
goto wrapup;
}
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Describe pcre path chosen on tracer

2021-03-04 Thread Pedro Ferreira
Changeset: b106bdb4d963 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b106bdb4d963
Modified Files:
monetdb5/modules/mal/pcre.c
Branch: default
Log Message:

Describe pcre path chosen on tracer


diffs (83 lines):

diff --git a/monetdb5/modules/mal/pcre.c b/monetdb5/modules/mal/pcre.c
--- a/monetdb5/modules/mal/pcre.c
+++ b/monetdb5/modules/mal/pcre.c
@@ -1331,13 +1331,16 @@ PCRElike4(bit *ret, const str *s, const 
 {
str res = MAL_SUCCEED;
char *ppat = NULL;
-   bool use_re = false, use_strcmp = false, isnull = false;
+   bool use_re = false, use_strcmp = false, empty = false;
struct RE *re = NULL;
 
-   if ((res = choose_like_path(&ppat, &use_re, &use_strcmp, &isnull, pat, 
esc)) != MAL_SUCCEED)
+   if ((res = choose_like_path(&ppat, &use_re, &use_strcmp, &empty, pat, 
esc)) != MAL_SUCCEED)
return res;
 
-   if (strNil(*s) || isnull) {
+   MT_thread_setalgorithm(empty ? "pcrelike: trivially empty" : use_strcmp 
? "pcrelike: pattern matching using strcmp" :
+  use_re ? "pcrelike: pattern 
matching using RE" : "pcrelike: pattern matching using pcre");
+
+   if (strNil(*s) || empty) {
*ret = bit_nil;
} else if (use_re) {
if (use_strcmp) {
@@ -1625,7 +1628,7 @@ BATPCRElike3(Client cntxt, MalBlkPtr mb,
str msg = MAL_SUCCEED, input = NULL, pat = NULL;
BAT *b = NULL, *pbn = NULL, *bn = NULL;
char *ppat = NULL;
-   bool use_re = false, use_strcmp = false, allnulls = false, isensitive = 
(bool) *isens, anti = (bool) *not, has_nil = false,
+   bool use_re = false, use_strcmp = false, empty = false, isensitive = 
(bool) *isens, anti = (bool) *not, has_nil = false,
 input_is_a_bat = isaBatType(getArgType(mb, pci, 1)), 
pattern_is_a_bat = isaBatType(getArgType(mb, pci, 2));
bat *r = getArgReference_bat(stk, pci, 0);
BUN q = 0;
@@ -1675,7 +1678,7 @@ BATPCRElike3(Client cntxt, MalBlkPtr mb,
for (BUN p = 0; p < q; p++) {
const str next_input = b ? BUNtail(bi, p) : input, np = 
BUNtail(pi, p);
 
-   if ((msg = choose_like_path(&ppat, &use_re, 
&use_strcmp, &allnulls, &np, esc)) != MAL_SUCCEED)
+   if ((msg = choose_like_path(&ppat, &use_re, 
&use_strcmp, &empty, &np, esc)) != MAL_SUCCEED)
goto bailout;
 
if (use_re) {
@@ -1683,7 +1686,7 @@ BATPCRElike3(Client cntxt, MalBlkPtr mb,
goto bailout;
ret[p] = re_like_proj_apply(next_input, 
re_simple, wpat, np, isensitive, anti, use_strcmp);
re_like_clean(&re_simple, &wpat);
-   } else if (allnulls) {
+   } else if (empty) {
ret[p] = bit_nil;
} else {
if ((msg = pcre_like_build(&re, &ex, ppat, 
isensitive, 1)) != MAL_SUCCEED)
@@ -1699,9 +1702,12 @@ BATPCRElike3(Client cntxt, MalBlkPtr mb,
} else {
bi = bat_iterator(b);
pat = *getArgReference_str(stk, pci, 2);
-   if ((msg = choose_like_path(&ppat, &use_re, &use_strcmp, 
&allnulls, &pat, esc)) != MAL_SUCCEED)
+   if ((msg = choose_like_path(&ppat, &use_re, &use_strcmp, 
&empty, &pat, esc)) != MAL_SUCCEED)
goto bailout;
 
+   MT_thread_setalgorithm(empty ? "pcrelike: trivially empty" : 
use_strcmp ? "pcrelike: pattern matching using strcmp" :
+  use_re ? "pcrelike: 
pattern matching using RE" : "pcrelike: pattern matching using pcre");
+
if (use_re) {
if ((msg = re_like_build(&re_simple, &wpat, pat, 
isensitive, use_strcmp, (unsigned char) **esc)) != MAL_SUCCEED)
goto bailout;
@@ -1710,7 +1716,7 @@ BATPCRElike3(Client cntxt, MalBlkPtr mb,
ret[p] = re_like_proj_apply(s, re_simple, wpat, 
pat, isensitive, anti, use_strcmp);
has_nil |= is_bit_nil(ret[p]);
}
-   } else if (allnulls) {
+   } else if (empty) {
for (BUN p = 0; p < q; p++)
ret[p] = bit_nil;
has_nil = true;
@@ -2053,6 +2059,9 @@ PCRElikeselect2(bat *ret, const bat *bid
if ((msg = choose_like_path(&ppat, &use_re, &use_strcmp, &empty, pat, 
esc)) != MAL_SUCCEED)
goto bailout;
 
+   MT_thread_setalgorithm(empty ? "pcrelike: trivially empty" : use_strcmp 
? "pcrelike: pattern matching using strcmp" :
+  use_re ? "pcrelike: pattern 
matching using RE" : "pcrelike: pattern matching u

MonetDB: default - only write last 'int' with candidates if needed.

2021-03-04 Thread Niels Nes
Changeset: 5f178592a46e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5f178592a46e
Modified Files:
sql/storage/bat/bat_storage.c
Branch: default
Log Message:

only write last 'int' with candidates if needed.


diffs (13 lines):

diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c
--- a/sql/storage/bat/bat_storage.c
+++ b/sql/storage/bat/bat_storage.c
@@ -3046,7 +3046,8 @@ segments2cands(segment *s, sql_trans *tr
assert(lnr==0);
}
}
-   *dst=cur;
+   if (pos%32)
+   *dst=cur;
BATsetcount(b, nr);
if (!(bn = BATmaskedcands(start, nr, b, true))) {
BBPreclaim(b);
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Allocate less when possible

2021-03-04 Thread Pedro Ferreira
Changeset: ff5e572e630d for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=ff5e572e630d
Modified Files:
sql/backends/monet5/sql_user.c
sql/storage/store.c
Branch: default
Log Message:

Allocate less when possible


diffs (90 lines):

diff --git a/sql/backends/monet5/sql_user.c b/sql/backends/monet5/sql_user.c
--- a/sql/backends/monet5/sql_user.c
+++ b/sql/backends/monet5/sql_user.c
@@ -520,51 +520,37 @@ str
 monet5_user_get_def_schema(mvc *m, int user)
 {
oid rid;
-   sqlid schema_id = 0;
+   sqlid schema_id = int_nil;
sql_schema *sys = NULL;
sql_table *user_info = NULL;
-   sql_column *users_name = NULL;
-   sql_column *users_schema = NULL;
sql_table *schemas = NULL;
-   sql_column *schemas_name = NULL;
-   sql_column *schemas_id = NULL;
sql_table *auths = NULL;
-   sql_column *auths_id = NULL;
-   sql_column *auths_name = NULL;
str username = NULL;
str schema = NULL;
+   sqlstore *store = m->session->tr->store;
+   ptr cbat;
 
sys = find_sql_schema(m->session->tr, "sys");
auths = find_sql_table(m->session->tr, sys, "auths");
-   auths_id = find_sql_column(auths, "id");
-   auths_name = find_sql_column(auths, "name");
-   sqlstore *store = m->session->tr->store;
-   rid = store->table_api.column_find_row(m->session->tr, auths_id, &user, 
NULL);
+   user_info = find_sql_table(m->session->tr, sys, "db_user_info");
+   schemas = find_sql_table(m->session->tr, sys, "schemas");
+
+   rid = store->table_api.column_find_row(m->session->tr, 
find_sql_column(auths, "id"), &user, NULL);
if (is_oid_nil(rid))
return NULL;
-   username = store->table_api.column_find_value(m->session->tr, 
auths_name, rid);
-
-   user_info = find_sql_table(m->session->tr, sys, "db_user_info");
-   users_name = find_sql_column(user_info, "name");
-   users_schema = find_sql_column(user_info, "default_schema");
-   rid = store->table_api.column_find_row(m->session->tr, users_name, 
username, NULL);
-   if (!is_oid_nil(rid))
-   schema_id = store->table_api.column_find_sqlid(m->session->tr, 
users_schema, rid);
-
-   _DELETE(username);
+   username = store->table_api.column_find_string_start(m->session->tr, 
find_sql_column(auths, "name"), rid, &cbat);
+   rid = store->table_api.column_find_row(m->session->tr, 
find_sql_column(user_info, "name"), username, NULL);
+   store->table_api.column_find_string_end(cbat);
 
-   schemas = find_sql_table(m->session->tr, sys, "schemas");
-   schemas_name = find_sql_column(schemas, "name");
-   schemas_id = find_sql_column(schemas, "id");
-
-   rid = store->table_api.column_find_row(m->session->tr, schemas_id, 
&schema_id, NULL);
-   if (!is_oid_nil(rid)) {
-   schema = store->table_api.column_find_value(m->session->tr, 
schemas_name, rid);
-   }
-   if (schema) {
-   char *old = schema;
-   schema = sa_strdup(m->session->sa, schema);
-   _DELETE(old);
+   if (!is_oid_nil(rid))
+   schema_id = store->table_api.column_find_sqlid(m->session->tr, 
find_sql_column(user_info, "default_schema"), rid);
+   if (!is_int_nil(schema_id)) {
+   rid = store->table_api.column_find_row(m->session->tr, 
find_sql_column(schemas, "id"), &schema_id, NULL);
+   if (!is_oid_nil(rid)) {
+   str sname = 
store->table_api.column_find_string_start(m->session->tr, 
find_sql_column(schemas, "name"), rid, &cbat);
+   schema = sa_strdup(m->session->sa, sname);
+   store->table_api.column_find_string_end(cbat);
+   }
}
return schema;
 }
diff --git a/sql/storage/store.c b/sql/storage/store.c
--- a/sql/storage/store.c
+++ b/sql/storage/store.c
@@ -5297,11 +5297,7 @@ sql_trans_dist_count( sql_trans *tr, sql
sql_column *stats_column_id = find_sql_column(stats, 
"column_id");
oid rid = store->table_api.column_find_row(tr, 
stats_column_id, &col->base.id, NULL);
if (!is_oid_nil(rid)) {
-   sql_column *stats_unique = 
find_sql_column(stats, "unique");
-   void *v = 
store->table_api.column_find_value(tr, stats_unique, rid);
-
-   col->dcount = *(size_t*)v;
-   _DELETE(v);
+   col->dcount = (size_t) 
store->table_api.column_find_lng(tr, find_sql_column(stats, "unique"), rid);
} else { /* sample and put in statistics */
col->dcount = store->storage_api.dcount_col(tr, 
col);
}
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailm

MonetDB: default - Fix searching candidate list index for masked...

2021-03-04 Thread Sjoerd Mullender
Changeset: 845be12bf070 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=845be12bf070
Modified Files:
gdk/gdk_cand.c
Branch: default
Log Message:

Fix searching candidate list index for masked candidates.


diffs (16 lines):

diff --git a/gdk/gdk_cand.c b/gdk/gdk_cand.c
--- a/gdk/gdk_cand.c
+++ b/gdk/gdk_cand.c
@@ -982,10 +982,8 @@ canditer_search(struct canditer *ci, oid
o %= 32;
if (p == ci->nvals - 1 && o >= ci->lastbit)
return next ? ci->ncand : BUN_NONE;
-   if (ci->mask[p] & (1U << o))
-   return count_mask_bits(ci, 0, p);
-   if (next)
-   return count_mask_bits(ci, 0, p) + 1;
+   if (next || ci->mask[p] & (1U << o))
+   return count_mask_bits(ci, 0, p) + (o == 0 ? 0 : 
candmask_pop(ci->mask[p] << (32 - o))) + !(ci->mask[p] & (1U << o));
break;
}
return BUN_NONE;
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Improved upgrades.

2021-03-04 Thread Sjoerd Mullender
Changeset: 641437fda2a0 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=641437fda2a0
Modified Files:
sql/storage/bat/bat_logger.c
Branch: default
Log Message:

Improved upgrades.


diffs (277 lines):

diff --git a/sql/storage/bat/bat_logger.c b/sql/storage/bat/bat_logger.c
--- a/sql/storage/bat/bat_logger.c
+++ b/sql/storage/bat/bat_logger.c
@@ -1652,8 +1652,8 @@ bl_postversion(void *Store, old_logger *
return GDK_FAIL;
if (BATsetaccess(sem, BAT_READ) != GDK_SUCCEED ||
BUNappend(lg->catalog_id, &(int) {2162}, false) 
!= GDK_SUCCEED ||
-   BUNappend(old_lg->add, &sem->batCacheid, false) 
!= GDK_SUCCEED ||
-   BUNappend(lg->catalog_bid, &sem->batCacheid, 
false) != GDK_SUCCEED) {
+   BUNappend(lg->catalog_bid, &sem->batCacheid, 
false) != GDK_SUCCEED ||
+   BUNappend(old_lg->add, &sem->batCacheid, false) 
!= GDK_SUCCEED) {
bat_destroy(sem);
return GDK_FAIL;
}
@@ -1677,13 +1677,13 @@ bl_postversion(void *Store, old_logger *
tabins_first = false;
}
 
-   BAT *func_tid;
+   BAT *del_funcs = temp_descriptor(logger_find_bat(lg, 2016));
{
/* move sql.degrees, sql.radians, sql.like and 
sql.ilike functions
 * from 09_like.sql and 10_math.sql script to sql_types 
list */
-   BAT *del_funcs = temp_descriptor(logger_find_bat(lg, 
2016));
BAT *func_func = temp_descriptor(logger_find_bat(lg, 
2018));
BAT *func_schem = temp_descriptor(logger_find_bat(lg, 
2026));
+   BAT *func_tid;
BAT *cands;
if (del_funcs == NULL || func_func == NULL || 
func_schem == NULL) {
bat_destroy(del_funcs);
@@ -1691,59 +1691,62 @@ bl_postversion(void *Store, old_logger *
bat_destroy(func_schem);
return GDK_FAIL;
}
-   gdk_return rc = BATsort(&b, NULL, NULL, del_funcs, 
NULL, NULL, false, false, false);
-   if (rc != GDK_SUCCEED) {
-   bat_destroy(del_funcs);
-   bat_destroy(func_func);
-   bat_destroy(func_schem);
-   return rc;
-   }
-   func_tid = BATnegcands(BATcount(func_func), b);
-   bat_destroy(b);
+   func_tid = BATmaskedcands(0, BATcount(del_funcs), 
del_funcs, false);
if (func_tid == NULL) {
bat_destroy(del_funcs);
bat_destroy(func_func);
bat_destroy(func_schem);
return GDK_FAIL;
}
+   /* select * from sys.functions where schema_id = 2000; 
*/
b = BATselect(func_schem, func_tid, &(int) {2000}, 
NULL, true, true, false);
bat_destroy(func_schem);
+   bat_destroy(func_tid);
cands = b;
if (cands == NULL) {
bat_destroy(del_funcs);
bat_destroy(func_func);
-   bat_destroy(func_tid);
return GDK_FAIL;
}
 
-   const char *funcs[] = {
-   "degrees",
-   "radians",
-   "like",
-   "ilike",
-   NULL,
-   };
-   for (int i = 0; funcs[i]; i++) {
-   if ((b = BATselect(func_func, cands, funcs[i], 
NULL, true, true, false)) == NULL ||
-   BATappend(del_funcs, b, NULL, true) != 
GDK_SUCCEED) {
-   bat_destroy(del_funcs);
-   bat_destroy(func_func);
-   bat_destroy(func_tid);
-   return GDK_FAIL;
-   }
-   bat_destroy(b);
+   BAT *funcs;
+   if ((funcs = COLnew(0, TYPE_str, 4, TRANSIENT)) == NULL 
||
+   BUNappend(funcs, "degrees", false) != 
GDK_SUCCEED ||
+   BUNappend(funcs, "ilike", false) != GDK_SUCCEED 
||
+  

MonetDB: default - Use unsigned to manipulate bits.

2021-03-04 Thread Sjoerd Mullender
Changeset: 5956e20097a8 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5956e20097a8
Modified Files:
sql/storage/bat/bat_storage.c
Branch: default
Log Message:

Use unsigned to manipulate bits.


diffs (36 lines):

diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c
--- a/sql/storage/bat/bat_storage.c
+++ b/sql/storage/bat/bat_storage.c
@@ -278,7 +278,7 @@ segments2cs(sql_trans *tr, segments *seg
if (BATcount(b) < s->start) {
msk nil = bit_nil;
for(BUN i=BATcount(b); istart; i++){
-   if (BUNappend(b, &nil, TRUE) != 
GDK_SUCCEED) {
+   if (BUNappend(b, &nil, true) != 
GDK_SUCCEED) {
bat_destroy(b);
return LOG_ERR;
}
@@ -2985,20 +2985,18 @@ static BAT *
 segments2cands(segment *s, sql_trans *tr, size_t start, size_t end)
 {
size_t nr = end - start, pos = 0;
-   int cur = 0;
+   uint32_t cur = 0;
BAT *b = COLnew(0, TYPE_msk, nr, TRANSIENT), *bn = NULL;
if (!b)
return NULL;
 
-   int *restrict dst = Tloc(b, 0);
+   uint32_t *restrict dst = Tloc(b, 0);
for( ; s; s=s->next) {
if (s->end < start)
continue;
if (s->start >= end)
break;
-   msk m = TRUE;
-   if (SEG_IS_DELETED(s, tr))
-   m = FALSE;
+   msk m = !(SEG_IS_DELETED(s, tr));
size_t lnr = s->end-s->start;
if (s->start < start)
lnr -= (start - s->start);
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Approved tests.

2021-03-04 Thread Sjoerd Mullender
Changeset: 2d887f343d80 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=2d887f343d80
Modified Files:
clients/Tests/MAL-signatures.stable.out
clients/Tests/MAL-signatures.stable.out.int128
Branch: default
Log Message:

Approved tests.


diffs (truncated from 45226 to 300 lines):

diff --git a/clients/Tests/MAL-signatures.stable.out 
b/clients/Tests/MAL-signatures.stable.out
--- a/clients/Tests/MAL-signatures.stable.out
+++ b/clients/Tests/MAL-signatures.stable.out
@@ -64,5875 +64,5875 @@ stdout of test 'MAL-signatures` in direc
 % .%1, .%1,.%1,.%1,.%1 # table_name
 % module,  function,   signature,  address,comment # name
 % clob,clob,   clob,   clob,   clob # type
-% 12,  28, 243,42, 0 # length
-[ "aggr",  "all",  "command aggr.all(:bat[:any_1]):any_1 ",
"SQLall;",  ""  ]
-[ "aggr",  "allnotequal",  "pattern aggr.allnotequal(:bat[:any_1], 
:bat[:any_1]):bit ","SQLallnotequal;",  ""  ]
-[ "aggr",  "anyequal", "pattern aggr.anyequal(:any_1, :any_1):bit ",   
"CMDvarEQ;",""  ]
-[ "aggr",  "anyequal", "pattern aggr.anyequal(:bat[:any_1], 
:bat[:any_1]):bit ",   "SQLanyequal;", ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:bte], :bat[:oid], 
:bat[:any_1]):bat[:dbl] ","AGGRavg13_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:dbl], :bat[:oid], 
:bat[:any_1]):bat[:dbl] ","AGGRavg13_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:flt], :bat[:oid], 
:bat[:any_1]):bat[:dbl] ","AGGRavg13_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:int], :bat[:oid], 
:bat[:any_1]):bat[:dbl] ","AGGRavg13_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:lng], :bat[:oid], 
:bat[:any_1]):bat[:dbl] ","AGGRavg13_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:sht], :bat[:oid], 
:bat[:any_1]):bat[:dbl] ","AGGRavg13_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:bte], :bat[:oid], :bat[:any_1], 
:int):bat[:dbl] ",  "AGGRavg14_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:dbl], :bat[:oid], :bat[:any_1], 
:int):bat[:dbl] ",  "AGGRavg14_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:flt], :bat[:oid], :bat[:any_1], 
:int):bat[:dbl] ",  "AGGRavg14_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:int], :bat[:oid], :bat[:any_1], 
:int):bat[:dbl] ",  "AGGRavg14_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:lng], :bat[:oid], :bat[:any_1], 
:int):bat[:dbl] ",  "AGGRavg14_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:sht], :bat[:oid], :bat[:any_1], 
:int):bat[:dbl] ",  "AGGRavg14_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:bte], :bat[:oid], :bat[:any_1]) 
(:bat[:dbl], :bat[:lng]) ", "AGGRavg23_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:dbl], :bat[:oid], :bat[:any_1]) 
(:bat[:dbl], :bat[:lng]) ", "AGGRavg23_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:flt], :bat[:oid], :bat[:any_1]) 
(:bat[:dbl], :bat[:lng]) ", "AGGRavg23_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:int], :bat[:oid], :bat[:any_1]) 
(:bat[:dbl], :bat[:lng]) ", "AGGRavg23_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:lng], :bat[:oid], :bat[:any_1]) 
(:bat[:dbl], :bat[:lng]) ", "AGGRavg23_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:sht], :bat[:oid], :bat[:any_1]) 
(:bat[:dbl], :bat[:lng]) ", "AGGRavg23_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:bte], :bat[:oid], :bat[:any_1], 
:int) (:bat[:dbl], :bat[:lng]) ",   "AGGRavg24_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:dbl], :bat[:oid], :bat[:any_1], 
:int) (:bat[:dbl], :bat[:lng]) ",   "AGGRavg24_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:flt], :bat[:oid], :bat[:any_1], 
:int) (:bat[:dbl], :bat[:lng]) ",   "AGGRavg24_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:int], :bat[:oid], :bat[:any_1], 
:int) (:bat[:dbl], :bat[:lng]) ",   "AGGRavg24_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:lng], :bat[:oid], :bat[:any_1], 
:int) (:bat[:dbl], :bat[:lng]) ",   "AGGRavg24_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:sht], :bat[:oid], :bat[:any_1], 
:int) (:bat[:dbl], :bat[:lng]) ",   "AGGRavg24_dbl;",   ""  ]
-[ "aggr",  "avg",  "pattern aggr.avg(:bat[:bte], :bat[:oid], :bit) (:bte, 
:lng, :lng) ",   "CMDBATavg3;",  ""  ]
-[ "aggr",  "avg",  "pattern aggr.avg(:bat[:int], :bat[:oid], :bit) (:int, 
:lng, :lng) ",   "CMDBATavg3;",  ""  ]
-[ "aggr",  "avg",  "pattern aggr.avg(:bat[:lng], :bat[:oid], 

MonetDB: string_imprints - Get the correct argument from the MAL...

2021-03-04 Thread Panagiotis Koutsourakis
Changeset: 0d8e5444d101 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=0d8e5444d101
Modified Files:
monetdb5/modules/mal/batExtensions.c
Branch: string_imprints
Log Message:

Get the correct argument from the MAL stack


diffs (12 lines):

diff --git a/monetdb5/modules/mal/batExtensions.c 
b/monetdb5/modules/mal/batExtensions.c
--- a/monetdb5/modules/mal/batExtensions.c
+++ b/monetdb5/modules/mal/batExtensions.c
@@ -409,7 +409,7 @@ PATstrimp_makeheader(Client cntxt, MalBl
(void)cntxt;
(void)mb;
 
-   bid = *getArgReference_bat(stk, pci, 2);
+   bid = *getArgReference_bat(stk, pci, 1);
if ((b = BATdescriptor(bid)) == NULL)
throw(MAL, "bat.strimpHeader", SQLSTATE(HY002) 
RUNTIME_OBJECT_MISSING);
 
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: string_imprints - Count byte pairs instead of unicode c...

2021-03-04 Thread Panagiotis Koutsourakis
Changeset: fbcd6ce89476 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=fbcd6ce89476
Modified Files:
gdk/gdk_strimps.c
Branch: string_imprints
Log Message:

Count byte pairs instead of unicode character pairs


diffs (83 lines):

diff --git a/gdk/gdk_strimps.c b/gdk/gdk_strimps.c
--- a/gdk/gdk_strimps.c
+++ b/gdk/gdk_strimps.c
@@ -13,33 +13,33 @@
 /* This counts how many unicode codepoints the given string
  * contains.
  */
-static size_t
-GDKstrimp_strlen(const uint8_t *s)
-{
-   size_t ret = 0;
-   size_t i;
-   int m,n;
-   uint8_t c;
+/* static size_t */
+/* GDKstrimp_strlen(const uint8_t *s) */
+/* { */
+/* size_t ret = 0; */
+/* size_t i; */
+/* int m,n; */
+/* uint8_t c; */
 
-   i = 0;
-   while((c = *(s + i)) != 0) {
-   if (c < 0x80)
-   i++;
-   else {
-   for (n = 0, m=0x40; c & m; n++, m >>= 1)
-   ;
-   /* n is now the number of 10xx bytes that should
-  follow. */
-   if (n == 0 || n >= 4)
-   /* TODO: handle invalid utf-8 */
-   {}
-   i += n+1;
-   }
-   ret++;
-   }
+/* i = 0; */
+/* while((c = *(s + i)) != 0) { */
+/* if (c < 0x80) */
+/* i++; */
+/* else { */
+/* for (n = 0, m=0x40; c & m; n++, m >>= 1) */
+/* ; */
+/* /\* n is now the number of 10xx bytes that should */
+/*follow. *\/ */
+/* if (n == 0 || n >= 4) */
+/* /\* TODO: handle invalid utf-8 *\/ */
+/* {} */
+/* i += n+1; */
+/* } */
+/* ret++; */
+/* } */
 
-   return ret;
-}
+/* return ret; */
+/* } */
 
 /* Given a BAT return the number of digrams in it. The observation is
  * that the number of digrams is the number of characters - 1:
@@ -55,7 +55,7 @@ GDKstrimp_ndigrams(BAT *b, size_t *n)
// lng t0;
BUN i;
BATiter bi;
-   uint8_t *s;
+   char *s;
// GDKtracer_set_component_level("ALGO", "DEBUG");
// struct canditer ci;
 
@@ -66,8 +66,9 @@ GDKstrimp_ndigrams(BAT *b, size_t *n)
bi = bat_iterator(b);
*n = 0;
for (i = 0; i < b->batCount; i++) {
-   s = (uint8_t *)BUNtail(bi, i);
-*n += GDKstrimp_strlen(s) - 1;
+   s = (char *)BUNtail(bi, i);
+// *n += GDKstrimp_strlen(s) - 1;
+   *n += strlen(s) - 1;
// TRC_DEBUG(ALGO, "s["LLFMT"]=%s\n", i, s);
}
 
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: string_imprints - Add documentation and move things arr...

2021-03-04 Thread Panagiotis Koutsourakis
Changeset: e695149dd3ce for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e695149dd3ce
Modified Files:
gdk/gdk_strimps.c
Branch: string_imprints
Log Message:

Add documentation and move things arround


diffs (115 lines):

diff --git a/gdk/gdk_strimps.c b/gdk/gdk_strimps.c
--- a/gdk/gdk_strimps.c
+++ b/gdk/gdk_strimps.c
@@ -94,48 +94,7 @@ GDKstrimp_ndigrams(BAT *b, size_t *n)
((TPE *) _a)[_j] = _t;  \
} while(0)
 
-static StrimpHeader *
-make_header(StrimpHeader *h, uint64_t* hist, size_t hist_size)
-{
-   lng t0 = 0;
-   size_t i;
-   uint64_t max_counts[STRIMP_SIZE] = {0};
-   const size_t cmin_max = STRIMP_SIZE - 1;
-   size_t hidx;
-
-   TRC_DEBUG_IF(ALGO) t0 = GDKusec();
-
-   for(i = 0; i < STRIMP_SIZE; i++)
-   h->bytepairs[i] = 0;
-
-   for(i = 0; i < hist_size; i++) {
-   if (max_counts[cmin_max] < hist[i]) {
-   max_counts[cmin_max] = hist[i];
-   h->bytepairs[cmin_max] = i;
-for(hidx = cmin_max; hidx > 0 && max_counts[hidx] > 
max_counts[hidx-1]; hidx--) {
-   swp(max_counts, hidx, hidx-1, uint64_t);
-   swp(h->bytepairs, hidx, hidx-1, uint16_t);
-   }
-   }
-   }
-
-   for(i = 0; i < STRIMP_SIZE; i++) {
-   TRC_DEBUG(ALGO, "%u %u: %lu", indexToPair1(h->bytepairs[i]), 
indexToPair2(h->bytepairs[i]), max_counts[i]);
-   }
-
-   TRC_DEBUG_ENDIF(ALGO, LLFMT "usec\n", GDKusec() - t0);
-
-   return h;
-}
-
-
-/* static uint64_t */
-/* add_to_header(size_t idx, uint64_t count) */
-/* { */
-/* while */
-/* return GDK_SUCCEED; */
-/* } */
-/* Construct a histogram of pairs of bytes.
+/* Construct a histogram of pairs of bytes in the input BAT.
  *
  * Return the histogram in hist and the number of non-zero bins in
  * count.
@@ -194,8 +153,59 @@ GDKstrimp_make_histogram(BAT *b, uint64_
return GDK_SUCCEED;
 }
 
-gdk_return
-GDKstrimp_make_header(BAT *b)
+/* Given a histogram find the indices of the 64 largest counts.
+ *
+ * We make one scan of histogram and every time we find a count that is
+ * greater than the current minimum of the 64, we bubble it up in the
+ * header until we find a count that is greater. We carry the index in
+ * the histogram because this is the information we are actually
+ * interested in keeping.
+ *
+ * At the end of this process we have the indices of 64 largest counts
+ * in the histogram. This process is O(n) in time since we are doing
+ * constant work (at most 63 comparisons and swaps) for each item in the
+ * histogram and as such is (theoretically) more efficient than sorting
+ * (O(nlog n))and taking the 64 largest elements. This depends on the
+ * size of the histogram n. For some small n sorting might be more
+ * efficient, but for such inputs the difference should not be
+ * noticeable.
+ *
+ * In the current implementation each index is a DataPair value that is
+ * constructed by pairToIndex from 2 consecutive bytes in the input.
+ */
+static StrimpHeader *
+make_header(StrimpHeader *h, uint64_t* hist, size_t hist_size)
+{
+   lng t0 = 0;
+   size_t i;
+   uint64_t max_counts[STRIMP_HEADER_SIZE] = {0};
+   const size_t cmin_max = STRIMP_HEADER_SIZE - 1;
+   size_t hidx;
+
+   TRC_DEBUG_IF(ALGO) t0 = GDKusec();
+
+   for(i = 0; i < STRIMP_HEADER_SIZE; i++)
+   h->bytepairs[i] = 0;
+
+   for(i = 0; i < hist_size; i++) {
+   if (max_counts[cmin_max] < hist[i]) {
+   max_counts[cmin_max] = hist[i];
+   h->bytepairs[cmin_max] = i;
+for(hidx = cmin_max; hidx > 0 && max_counts[hidx] > 
max_counts[hidx-1]; hidx--) {
+   swp(max_counts, hidx, hidx-1, uint64_t);
+   swp(h->bytepairs, hidx, hidx-1, DataPair);
+   }
+   }
+   }
+
+   for(i = 0; i < STRIMP_HEADER_SIZE; i++) {
+   TRC_DEBUG(ALGO, "%u %u: %lu", indexToPair1(h->bytepairs[i]), 
indexToPair2(h->bytepairs[i]), max_counts[i]);
+   }
+
+   TRC_DEBUG(ALGO, LLFMT " usec\n", GDKusec() - t0);
+
+   return h;
+}
 {
uint64_t hist[STRIMP_HISTSIZE] = {0};
size_t nbins = 0;
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: string_imprints - Small changes

2021-03-04 Thread Panagiotis Koutsourakis
Changeset: 1ef057324896 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=1ef057324896
Modified Files:
gdk/gdk_strimps.c
Branch: string_imprints
Log Message:

Small changes


diffs (21 lines):

diff --git a/gdk/gdk_strimps.c b/gdk/gdk_strimps.c
--- a/gdk/gdk_strimps.c
+++ b/gdk/gdk_strimps.c
@@ -84,7 +84,7 @@ GDKstrimp_ndigrams(BAT *b, size_t *n)
  */
 #define isIgnored(x) (isspace((x)) || isdigit((x)) || ispunct((x)))
 #define isNotIgnored(x) (!isIgnored(x))
-#define pairToIndex(b1, b2) (((uint8_t)b1)<<8 | ((uint8_t)b2))
+#define pairToIndex(b1, b2) (DataPair)(((uint8_t)b1)<<8 | ((uint8_t)b2))
 #define indexToPair1(idx) (idx & 0xff00) >> 8
 #define indexToPair2(idx) (idx & 0xff)
 #define swp(_a, _i, _j, TPE)   \
@@ -148,7 +148,7 @@ GDKstrimp_make_histogram(BAT *b, uint64_
}
}
 
-   TRC_DEBUG_ENDIF(ALGO, LLFMT "usec\n", GDKusec() - t0);
+   TRC_DEBUG(ALGO, LLFMT " usec\n", GDKusec() - t0);
GDKtracer_flush_buffer();
return GDK_SUCCEED;
 }
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: string_imprints - Add a wrapper that allocates space fo...

2021-03-04 Thread Panagiotis Koutsourakis
Changeset: e09bb9a38502 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e09bb9a38502
Modified Files:
gdk/gdk_strimps.c
Branch: string_imprints
Log Message:

Add a wrapper that allocates space for the header


diffs (32 lines):

diff --git a/gdk/gdk_strimps.c b/gdk/gdk_strimps.c
--- a/gdk/gdk_strimps.c
+++ b/gdk/gdk_strimps.c
@@ -206,17 +206,24 @@ make_header(StrimpHeader *h, uint64_t* h
 
return h;
 }
+
+static StrimpHeader *
+create_header(BAT *b)
 {
uint64_t hist[STRIMP_HISTSIZE] = {0};
size_t nbins = 0;
-   StrimpHeader header;
+   StrimpHeader *header;
+   if ((header = (StrimpHeader*)GDKmalloc(sizeof(StrimpHeader))) == NULL)
+   return NULL;
+
if(GDKstrimp_make_histogram(b, hist, STRIMP_HISTSIZE, &nbins) != 
GDK_SUCCEED) {
-   return GDK_FAIL;
+   GDKfree(header);
+   return NULL;
}
 
-   make_header(&header, hist, STRIMP_HISTSIZE);
+   make_header(header, hist, STRIMP_HISTSIZE);
 
-   return GDK_SUCCEED;
+   return header;
 }
 
 
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: string_imprints - Some utility functions

2021-03-04 Thread Panagiotis Koutsourakis
Changeset: a13846692aaa for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a13846692aaa
Modified Files:
gdk/gdk_strimps.c
Branch: string_imprints
Log Message:

Some utility functions

- lookup the index of a pair in the header
- construct a bitstring for a given string encoding the presence or
  absence of the pairs in the header

These should probably be inlined.


diffs (68 lines):

diff --git a/gdk/gdk_strimps.c b/gdk/gdk_strimps.c
--- a/gdk/gdk_strimps.c
+++ b/gdk/gdk_strimps.c
@@ -227,33 +227,43 @@ create_header(BAT *b)
 }
 
 
-/* static uint8_t */
-/* lookup_index(StrimpHeader *h, uint16_t n) */
-/* { */
-/* size_t i; */
-/* for(i = 0; i < STRIMP_SIZE; i++) */
-/* if(h->bytepairs[i] == n) */
-/* return i; */
+/* Given a strimp h and a DataPair p, return the index i for which
+ *
+ * h[i] == p
+ *
+ * Returns 0 if p is not in h.
+ *
+ * TODO: Should this be inlined somehow? (probably yes)
+ */
+static uint8_t
+lookup_index(StrimpHeader *h, DataPair n)
+{
+   size_t i;
+   for(i = 0; i < STRIMP_HEADER_SIZE; i++)
+   if(h->bytepairs[i] == n)
+   return i;
 
-/* return 0; */
-/* } */
+   return 0;
+}
 
 
 /* Given a strimp header and a string compute the bitstring of which
  * digrams(byte pairs) are present in the string. The strimp header is a
  * map from digram(byte pair) to index in the strimp.
+ *
+ * This should probably be inlined.
  */
-/* static uint64_t */
-/* GDKstrimp_make_bitstring(str s, StrimpHeader *h) */
-/* { */
-/* uint64_t ret = 0; */
-/* uint8_t pair_idx; */
-/* char *it; */
+static uint64_t
+GDKstrimp_make_bitstring(const str s, StrimpHeader *h)
+{
+   uint64_t ret = 0;
+   uint8_t pair_idx;
+   char *it;
 
-/* for(it = s; *it != 0 && *(it+1) != 0; it++) { */
-/* pair_idx = lookup_index(h, pairToIndex(*it, *(it+1))); */
-/* ret |= 0x1 << pair_idx; */
-/* } */
+   for(it = s; *it != 0 && *(it+1) != 0; it++) {
+   pair_idx = lookup_index(h, pairToIndex(*it, *(it+1)));
+   ret |= 0x1 << pair_idx;
+   }
 
-/* return ret; */
-/* } */
+   return ret;
+}
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: string_imprints - Functions to construct the string imp...

2021-03-04 Thread Panagiotis Koutsourakis
Changeset: 6ab7ac7f1321 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6ab7ac7f1321
Modified Files:
gdk/gdk.h
gdk/gdk_private.h
gdk/gdk_strimps.c
gdk/gdk_strimps.h
Branch: string_imprints
Log Message:

Functions to construct the string imprint for a given BAT


diffs (153 lines):

diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -701,6 +701,7 @@ typedef struct {
Hash *hash; /* hash table */
Imprints *imprints; /* column imprints index */
Heap *orderidx; /* order oid index */
+   Heap *strimps;  /* string imprint index  */
 
PROPrec *props; /* list of dynamic properties stored in the bat 
descriptor */
 } COLrec;
@@ -772,6 +773,7 @@ typedef struct BATiter {
 #define thash  T.hash
 #define timprints  T.imprints
 #define tprops T.props
+#define tstrimps   T.strimps
 
 
 
diff --git a/gdk/gdk_private.h b/gdk/gdk_private.h
--- a/gdk/gdk_private.h
+++ b/gdk/gdk_private.h
@@ -25,7 +25,8 @@ enum heaptype {
varheap,
hashheap,
imprintsheap,
-   orderidxheap
+   orderidxheap,
+   strimpheap
 };
 
 #ifdef GDKLIBRARY_OLDDATE
diff --git a/gdk/gdk_strimps.c b/gdk/gdk_strimps.c
--- a/gdk/gdk_strimps.c
+++ b/gdk/gdk_strimps.c
@@ -267,3 +267,85 @@ GDKstrimp_make_bitstring(const str s, St
 
return ret;
 }
+
+/* Create the heap for a string imprint. Returns NULL on failure. */
+static Heap *
+createStrimpheap(BAT *b, StrimpHeader *h)
+{
+   Heap *r = NULL;
+   uint64_t *d;
+   size_t i,j;
+   const char *nme;
+
+   nme = GDKinmemory(b->theap.farmid) ? ":memory:" : 
BBP_physical(b->batCacheid);
+   if ((r = GDKzalloc(sizeof(Heap))) == NULL ||
+   (r->farmid = BBPselectfarm(b->batRole, b->ttype, strimpheap)) < 0 ||
+   strconcat_len(r->filename, sizeof(r->filename),
+ nme, ".strimp", NULL) >= sizeof(r->filename) ||
+   HEAPalloc(r, BATcount(b) + STRIMP_OFFSET, sizeof(uint64_t)) != 
GDK_SUCCEED) {
+   GDKfree(r);
+   return NULL;
+   }
+   r->free = STRIMP_OFFSET * sizeof(uint64_t);
+
+   d = (uint64_t *)r->base;
+   /* This loop assumes that we are working with byte pairs
+* (i.e. the type of the header is uint16_t). TODO: generalize.
+*/
+   for(i = 0; i < STRIMP_HEADER_SIZE; i += 4) {
+   *d = 0;
+   for(j = 0; j < 4; j++) {
+   *d <<= 16;
+   *d |= h->bytepairs[i + j];
+   }
+   }
+   return r;
+}
+
+/* Create */
+gdk_return
+GDKstrimp_create_strimp(BAT *b)
+{
+   lng t0 = 0;
+   BATiter bi;
+   BUN i;
+   str s;
+   StrimpHeader *head;
+   Heap *h;
+   uint64_t *dh;
+
+   assert(b->ttype == TYPE_str);
+   TRC_DEBUG_IF(ALGO) t0 = GDKusec();
+
+   if ((head = create_header(b)) == NULL) {
+   return GDK_FAIL;
+   }
+
+   if ((h = createStrimpheap(b, head)) == NULL) {
+   GDKfree(head);
+   return GDK_FAIL;
+   }
+   dh = (uint64_t *)h->base + h->free;
+
+   bi = bat_iterator(b);
+   for (i = 0; i < b->batCount; i++) {
+   s = (str)BUNtvar(bi, i);
+   if (!strNil(s))
+   *dh++ = GDKstrimp_make_bitstring(s, head);
+   else
+   *dh++ = 0; /* no pairs in nil values */
+
+   }
+
+   /* After we have computed the strimp, attempt to write it back
+* to the BAT.
+*/
+   MT_lock_set(&b->batIdxLock);
+   b->tstrimps = h;
+   b->batDirtydesc = true;
+   /* persistStrimp(b) */
+   MT_lock_unset(&b->batIdxLock);
+
+   TRC_DEBUG(ALGO, "strimp creation took " LLFMT " usec\n", GDKusec()-t0);
+   return GDK_SUCCEED;
+}
diff --git a/gdk/gdk_strimps.h b/gdk/gdk_strimps.h
--- a/gdk/gdk_strimps.h
+++ b/gdk/gdk_strimps.h
@@ -11,19 +11,25 @@
 
 #include 
 
+
+#define STRIMP_VERSION (uint64_t)1
 /* Count the occurences of pairs of bytes. This is a compromise between
  * just handling ASCII and full UTF-8 support.
  */
 #define STRIMP_HISTSIZE 256*256
-#define STRIMP_SIZE 64
+#define STRIMP_HEADER_SIZE 64
+#define STRIMP_OFFSET 1 + STRIMP_HEADER_SIZE*sizeof(DataPair)/sizeof(uint64_t) 
/* version + header */
 
+
+typedef uint16_t DataPair;
 typedef struct {
// TODO: find a better name for this
-   uint16_t bytepairs[STRIMP_SIZE];
+   DataPair bytepairs[STRIMP_HEADER_SIZE];
 } StrimpHeader;
 
 gdk_export gdk_return GDKstrimp_ndigrams(BAT *b, size_t *n); // Remove?
 gdk_export gdk_return GDKstrimp_make_histogram(BAT *b, uint64_t *hist, size_t 
hist_size, size_t *nbins); // make static
 // gdk_export gdk_return GDKstrimp_make_header(StrimpHeader *h, uint64_t 
*hist, size_t hist_size); // make static
-gdk_export gdk_return GDKstrimp_make_header(BAT *b);
+//gdk_export gdk_return GDKstrimp_

MonetDB: string_imprints - Add some documentation

2021-03-04 Thread Panagiotis Koutsourakis
Changeset: d0711db453cd for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d0711db453cd
Modified Files:
gdk/gdk_strimps.c
Branch: string_imprints
Log Message:

Add some documentation


diffs (105 lines):

diff --git a/gdk/gdk_strimps.c b/gdk/gdk_strimps.c
--- a/gdk/gdk_strimps.c
+++ b/gdk/gdk_strimps.c
@@ -6,6 +6,40 @@
  * Copyright 1997 - July 2008 CWI, August 2008 - 2021 MonetDB B.V.
  */
 
+
+/* A string imprint is an index that can be used as a prefilter in LIKE
+ * queries. It has 2 components:
+ *
+ * - a header of 64 string element pairs (bytes in the current
+ *   implementation but maybe unicode chars might make more sense).
+ *
+ * - a 64 bit mask for each item in the BAT that encodes the presence or
+ *   absence of each element of the header in the specific item.
+ *
+ * A string imprint is stored in a new Heap in the BAT.
+ *
+ * In the current (byte pair) implementation the first 136 bytes
+ * (i.e. the first 17 64 bit quantities) in the Heap are as follows:
+ *
+ * |   Version Number  |   -
+ * | byte pair 01 | byte pair 02 | byte pair 03 | byte pair 04 | |
+ * | byte pair 05 | byte pair 06 | byte pair 07 | byte pair 08 | |  17 64 
bit quantities
+ * [...] |
+ * | byte pair 61 | byte pair 62 | byte pair 63 | byte pair 64 |   -
+ *
+ * The bitmasks for each string in the BAT follow after this.
+ *
+ * Strimp creation goes as follows:
+ *
+ * - Construct a histogram of the element (byte or character) pairs for
+ *   all the strings in the BAT.
+ *
+ * - Take the 64 most frequent pairs as the Strimp Header.
+ *
+ * - For each string in the bat construct a 64 bit mask that encodes the
+ *   presence or absence of each member of the header in the string.
+ */
+
 #include "monetdb_config.h"
 #include "gdk.h"
 #include "gdk_private.h"
@@ -13,33 +47,35 @@
 /* This counts how many unicode codepoints the given string
  * contains.
  */
-/* static size_t */
-/* GDKstrimp_strlen(const uint8_t *s) */
-/* { */
-/* size_t ret = 0; */
-/* size_t i; */
-/* int m,n; */
-/* uint8_t c; */
+#if 0
+static size_t
+GDKstrimp_strlen(const uint8_t *s)
+{
+   size_t ret = 0;
+   size_t i;
+   int m,n;
+   uint8_t c;
 
-/* i = 0; */
-/* while((c = *(s + i)) != 0) { */
-/* if (c < 0x80) */
-/* i++; */
-/* else { */
-/* for (n = 0, m=0x40; c & m; n++, m >>= 1) */
-/* ; */
-/* /\* n is now the number of 10xx bytes that should */
-/*follow. *\/ */
-/* if (n == 0 || n >= 4) */
-/* /\* TODO: handle invalid utf-8 *\/ */
-/* {} */
-/* i += n+1; */
-/* } */
-/* ret++; */
-/* } */
+   i = 0;
+   while((c = *(s + i)) != 0) {
+   if (c < 0x80)
+   i++;
+   else {
+   for (n = 0, m=0x40; c & m; n++, m >>= 1)
+   ;
+   /* n is now the number of 10xx bytes that should
+  follow. */
+   if (n == 0 || n >= 4)
+   /* TODO: handle invalid utf-8 */
+   {}
+   i += n+1;
+   }
+   ret++;
+   }
 
-/* return ret; */
-/* } */
+   return ret;
+}
+#endif
 
 /* Given a BAT return the number of digrams in it. The observation is
  * that the number of digrams is the number of characters - 1:
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: string_imprints - Expose strimp construction to MAL

2021-03-04 Thread Panagiotis Koutsourakis
Changeset: 532b3fb7b9ff for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=532b3fb7b9ff
Modified Files:
monetdb5/modules/mal/batExtensions.c
Branch: string_imprints
Log Message:

Expose strimp construction to MAL


diffs (33 lines):

diff --git a/monetdb5/modules/mal/batExtensions.c 
b/monetdb5/modules/mal/batExtensions.c
--- a/monetdb5/modules/mal/batExtensions.c
+++ b/monetdb5/modules/mal/batExtensions.c
@@ -402,7 +402,7 @@ PATstrimp_makehist(Client cntxt, MalBlkP
 }
 
 static str
-PATstrimp_makeheader(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+PATstrimp(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
 {
bat bid;
BAT *b;
@@ -413,9 +413,10 @@ PATstrimp_makeheader(Client cntxt, MalBl
if ((b = BATdescriptor(bid)) == NULL)
throw(MAL, "bat.strimpHeader", SQLSTATE(HY002) 
RUNTIME_OBJECT_MISSING);
 
-   if(GDKstrimp_make_header(b) != GDK_SUCCEED)
+   if(GDKstrimp_create_strimp(b) != GDK_SUCCEED)
throw(MAL, "bat.strimpHistogram", SQLSTATE(HY002) 
OPERATION_FAILED);
 
+   // *getArgReference_lng(stk, pci, 0) = 0;
return MAL_SUCCEED;
 }
 
@@ -452,7 +453,7 @@ mel_func batExtensions_init_funcs[] = {
  /* String imprints */
  pattern("bat", "strimpNDigrams", PATstrimp_ndigrams, false, "count digrams in 
a string bat", args(1,2,arg("",lng),batarg("b",str))),
  pattern("bat", "strimpHistogram", PATstrimp_makehist, false, "make a 
histogram of all the byte pairs in a BAT", args(2,3,arg("",lng), 
batarg("",lng),batarg("b",str))),
- pattern("bat", "strimpHeader", PATstrimp_makeheader, false, "construct the 
strimp header from a BAT", args(1,2,arg("",void),batarg("b",str))),
+ pattern("bat", "strimp", PATstrimp, false, "construct the strimp a BAT", 
args(1,2,arg("",void),batarg("b",str))),
  { .imp=NULL }
 };
 #include "mal_import.h"
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Packing SQL optimizers into a single AST iter...

2021-03-04 Thread Pedro Ferreira
Changeset: 9518f0f0b844 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9518f0f0b844
Modified Files:
sql/server/rel_optimizer.c
Branch: default
Log Message:

Packing SQL optimizers into a single AST iteration


diffs (truncated from 494 to 300 lines):

diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c
--- a/sql/server/rel_optimizer.c
+++ b/sql/server/rel_optimizer.c
@@ -4079,7 +4079,7 @@ exps_uses_any(list *exps, list *l)
  * into
  * groupby ( [ union all( groupby( a, [gbe], [ count, sum] ), [ groupby( 
b, [gbe], [ count, sum] )) , [gbe], [sum, sum] )
  */
-static sql_rel *
+static inline sql_rel *
 rel_push_aggr_down(visitor *v, sql_rel *rel)
 {
if (rel->op == op_groupby && rel->l) {
@@ -4373,7 +4373,7 @@ gen_push_groupby_down(mvc *sql, sql_rel 
  * project(join(groupby (A)[a.i],[a.i]), Dict)[a.i==dict.i])[dict.n]
  *
  */
-static sql_rel *
+static inline sql_rel *
 rel_push_groupby_down(visitor *v, sql_rel *rel)
 {
sql_rel *p = rel->l;
@@ -5737,7 +5737,7 @@ score_gbe(visitor *v, sql_rel *rel, sql_
 }
 
 /* reorder group by expressions */
-static sql_rel *
+static inline sql_rel *
 rel_groupby_order(visitor *v, sql_rel *rel)
 {
int *scores = NULL;
@@ -5782,7 +5782,7 @@ rel_groupby_order(visitor *v, sql_rel *r
  * The reduced group by and (derived) aggr expressions are restored via
  * extra (new) aggregate columns.
  */
-static sql_rel *
+static inline sql_rel *
 rel_reduce_groupby_exps(visitor *v, sql_rel *rel)
 {
list *gbe = rel->r;
@@ -6060,7 +6060,7 @@ rel_groupby_distinct2(visitor *v, sql_re
  * groupby(R) [e,f,a,b] [ a, b, aggr3 c, aggr4 d]
  * ) [e,f]( aggr1 a distinct, aggr2 b distinct, aggr3_phase2 c, aggr4_phase2 d)
  */
-static sql_rel *
+static inline sql_rel *
 rel_groupby_distinct(visitor *v, sql_rel *rel)
 {
node *n;
@@ -6158,16 +6158,29 @@ rel_groupby_distinct(visitor *v, sql_rel
return rel;
 }
 
+/* pack grouby optimizers into a single function to void iterations in the AST 
*/
+static sql_rel *
+rel_optimize_group_by(visitor *v, sql_rel *rel)
+{
+   if (!is_groupby(rel->op))
+   return rel;
+
+   rel = rel_push_aggr_down(v, rel);
+   rel = rel_push_groupby_down(v, rel);
+   rel = rel_groupby_order(v, rel);
+   rel = rel_reduce_groupby_exps(v, rel);
+   rel = rel_groupby_distinct(v, rel);
+   return rel;
+}
+
 static sql_exp *split_aggr_and_project(mvc *sql, list *aexps, sql_exp *e);
 
 static void
 list_split_aggr_and_project(mvc *sql, list *aexps, list *exps)
 {
-   node *n;
-
-   if (!exps)
+   if (list_empty(exps))
return ;
-   for(n = exps->h; n; n = n->next)
+   for(node *n = exps->h; n; n = n->next)
n->data = split_aggr_and_project(sql, aexps, n->data);
 }
 
@@ -7533,13 +7546,14 @@ score_se(visitor *v, sql_rel *rel, sql_e
return score;
 }
 
-static sql_rel *
+static inline sql_rel *
 rel_select_order(visitor *v, sql_rel *rel)
 {
int *scores = NULL;
sql_exp **exps = NULL;
 
-   if (is_select(rel->op) && list_length(rel->exps) > 1) {
+   assert(is_select(rel->op));
+   if (list_length(rel->exps) > 1) {
node *n;
int i, nexps = list_length(rel->exps);
scores = SA_NEW_ARRAY(v->sql->ta, int, nexps);
@@ -7558,87 +7572,95 @@ rel_select_order(visitor *v, sql_rel *re
return rel;
 }
 
-static sql_rel *
+static inline sql_rel *
 rel_simplify_like_select(visitor *v, sql_rel *rel)
 {
-   if (is_select(rel->op) && rel->exps) {
-   node *n;
-   list *exps;
-   int needed = 0;
-
-   for (n = rel->exps->h; n && !needed; n = n->next) {
-   sql_exp *e = n->data;
-   list *l = e->l;
+   list *exps;
+   int needed = 0;
+
+   assert(is_select(rel->op) && !list_empty(rel->exps));
+   for (node *n = rel->exps->h; n && !needed; n = n->next) {
+   sql_exp *e = n->data;
+   list *l = e->l;
+   list *r = e->r;
+
+   if (e->type == e_cmp && e->flag == cmp_filter && 
strcmp(((sql_subfunc*)e->f)->func->base.name, "like") == 0 && list_length(l) == 
1 && list_length(r) <= 2 && !is_anti(e))
+   needed = 1;
+   }
+
+   if (!needed)
+   return rel;
+
+   exps = sa_list(v->sql->sa);
+   if (exps == NULL)
+   return NULL;
+   for (node *n = rel->exps->h; n; n = n->next) {
+   sql_exp *e = n->data;
+   list *l = e->l;
+   list *r = e->r;
+
+   if (e->type == e_cmp && e->flag == cmp_filter && 
strcmp(((sql_subfunc*)e->f)->func->base.name, "like") == 0 && list_length(l) == 
1 && list_length(r) <= 2 && !is_anti(e)) {
list *r = e->r;
-
-   if (e->type == e_cmp && e->flag == cmp_filter && 
strcmp(((sql_subfunc*)e->f)->func->base.n

MonetDB: default - fixed unaligned result of multiplex fallback ...

2021-03-04 Thread Niels Nes
Changeset: e471415e7fe4 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=e471415e7fe4
Modified Files:
monetdb5/modules/mal/batExtensions.c
monetdb5/optimizer/opt_multiplex.c
Branch: default
Log Message:

fixed unaligned result of multiplex fallback code


diffs (83 lines):

diff --git a/monetdb5/modules/mal/batExtensions.c 
b/monetdb5/modules/mal/batExtensions.c
--- a/monetdb5/modules/mal/batExtensions.c
+++ b/monetdb5/modules/mal/batExtensions.c
@@ -65,6 +65,25 @@ CMDBATnew(Client cntxt, MalBlkPtr m, Mal
 }
 
 static str
+CMDBATdup(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+{
+   BAT *b, *i;
+   bat *ret= getArgReference_bat(stk, pci, 0);
+   int tt = getArgType(mb, pci, 1);
+   bat input = *getArgReference_bat(stk, pci, 2);
+
+   (void)cntxt;
+   if ((i = BATdescriptor(input)) == NULL)
+   throw(MAL, "bat.new", INTERNAL_BAT_ACCESS);
+   b = COLnew(i->hseqbase, tt, BATcount(i), TRANSIENT);
+   BBPunfix(i->batCacheid);
+   if (b == 0)
+   throw(MAL,"bat.new", SQLSTATE(HY013) MAL_MALLOC_FAIL);
+   BBPkeepref(*ret = b->batCacheid);
+   return MAL_SUCCEED;
+}
+
+static str
 CMDBATsingle(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
 {
BAT *b;
@@ -344,6 +363,7 @@ mel_func batExtensions_init_funcs[] = {
  pattern("bat", "new", CMDBATnew, false, "", args(1,4, 
batargany("",1),argany("tt",1),arg("size",lng),arg("persist",bit))),
  pattern("bat", "new", CMDBATnew, false, "", args(1,4, 
batargany("",1),argany("tt",1),arg("size",int),arg("persist",bit))),
  pattern("bat", "new", CMDBATnew, false, "Creates a new empty transient BAT, 
with tail-types as indicated.", args(1,3, 
batargany("",1),argany("tt",1),arg("size",lng))),
+ pattern("bat", "new", CMDBATdup, false, "Creates a new empty transient BAT, 
with tail-type tt and hseqbase and size from the input bat argument.", 
args(1,3, batargany("",1), argany("tt",1),batargany("i",2))),
  pattern("bat", "single", CMDBATsingle, false, "Create a BAT with a single 
elemenet", args(1,2, batargany("",1),argany("val",1))),
  pattern("bat", "partition", CMDBATpartition, false, "Create a serie of slices 
over the BAT argument. The BUNs are distributed evenly.", args(1,2, 
batvarargany("",1),batargany("b",1))),
  pattern("bat", "partition", CMDBATpartition2, false, "Create the n-th slice 
over the BAT broken into several pieces.", args(1,4, 
batargany("",1),batargany("b",1),arg("pieces",int),arg("n",int))),
diff --git a/monetdb5/optimizer/opt_multiplex.c 
b/monetdb5/optimizer/opt_multiplex.c
--- a/monetdb5/optimizer/opt_multiplex.c
+++ b/monetdb5/optimizer/opt_multiplex.c
@@ -17,7 +17,7 @@
  * The call optimizer.multiplex(MOD,FCN,A1,...An) introduces the following code
  * structure:
  *
- * resB:= bat.new(A1);
+ * resB:= bat.new(restype, A1);
  * barrier (h,t1):= iterator.new(A1);
  * t2:= algebra.fetch(A2,h)
  * ...
@@ -41,8 +41,6 @@ OPTexpandMultiplex(Client cntxt, MalBlkP
int tt;
int bat = (getModuleId(pci) == batmalRef) ;
 
-   //if ( optimizerIsApplied(mb,"multiplex"))
-   //return 0;
(void) cntxt;
(void) stk;
for (i = 0; i < pci->retc; i++) {
@@ -93,13 +91,15 @@ OPTexpandMultiplex(Client cntxt, MalBlkP
 
/* resB := new(refBat) */
for (i = 0; i < pci->retc; i++) {
-   q = newFcnCall(mb, batRef, newRef);
+   q = newFcnCallArgs(mb, batRef, newRef, 2);
resB[i] = getArg(q, 0);
 
tt = getBatType(getArgType(mb, pci, i));
 
setVarType(mb, getArg(q, 0), newBatType(tt));
q = pushType(mb, q, tt);
+   q = pushArgument(mb, q, iter);
+   assert(q->argc==3);
}
 
/* barrier (h,r) := iterator.new(refBat); */
@@ -185,7 +185,6 @@ OPTexpandMultiplex(Client cntxt, MalBlkP
 str
 OPTmultiplexSimple(Client cntxt, MalBlkPtr mb)
 {
-   //MalBlkPtr mb= cntxt->curprg->def;
int i, doit=0;
InstrPtr p;
str msg = MAL_SUCCEED;
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - merged

2021-03-04 Thread Niels Nes
Changeset: cdaf5fa57a7c for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=cdaf5fa57a7c
Branch: default
Log Message:

merged


diffs (truncated from 46139 to 300 lines):

diff --git a/clients/Tests/MAL-signatures.stable.out 
b/clients/Tests/MAL-signatures.stable.out
--- a/clients/Tests/MAL-signatures.stable.out
+++ b/clients/Tests/MAL-signatures.stable.out
@@ -64,5875 +64,5875 @@ stdout of test 'MAL-signatures` in direc
 % .%1, .%1,.%1,.%1,.%1 # table_name
 % module,  function,   signature,  address,comment # name
 % clob,clob,   clob,   clob,   clob # type
-% 12,  28, 243,42, 0 # length
-[ "aggr",  "all",  "command aggr.all(:bat[:any_1]):any_1 ",
"SQLall;",  ""  ]
-[ "aggr",  "allnotequal",  "pattern aggr.allnotequal(:bat[:any_1], 
:bat[:any_1]):bit ","SQLallnotequal;",  ""  ]
-[ "aggr",  "anyequal", "pattern aggr.anyequal(:any_1, :any_1):bit ",   
"CMDvarEQ;",""  ]
-[ "aggr",  "anyequal", "pattern aggr.anyequal(:bat[:any_1], 
:bat[:any_1]):bit ",   "SQLanyequal;", ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:bte], :bat[:oid], 
:bat[:any_1]):bat[:dbl] ","AGGRavg13_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:dbl], :bat[:oid], 
:bat[:any_1]):bat[:dbl] ","AGGRavg13_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:flt], :bat[:oid], 
:bat[:any_1]):bat[:dbl] ","AGGRavg13_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:int], :bat[:oid], 
:bat[:any_1]):bat[:dbl] ","AGGRavg13_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:lng], :bat[:oid], 
:bat[:any_1]):bat[:dbl] ","AGGRavg13_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:sht], :bat[:oid], 
:bat[:any_1]):bat[:dbl] ","AGGRavg13_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:bte], :bat[:oid], :bat[:any_1], 
:int):bat[:dbl] ",  "AGGRavg14_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:dbl], :bat[:oid], :bat[:any_1], 
:int):bat[:dbl] ",  "AGGRavg14_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:flt], :bat[:oid], :bat[:any_1], 
:int):bat[:dbl] ",  "AGGRavg14_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:int], :bat[:oid], :bat[:any_1], 
:int):bat[:dbl] ",  "AGGRavg14_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:lng], :bat[:oid], :bat[:any_1], 
:int):bat[:dbl] ",  "AGGRavg14_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:sht], :bat[:oid], :bat[:any_1], 
:int):bat[:dbl] ",  "AGGRavg14_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:bte], :bat[:oid], :bat[:any_1]) 
(:bat[:dbl], :bat[:lng]) ", "AGGRavg23_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:dbl], :bat[:oid], :bat[:any_1]) 
(:bat[:dbl], :bat[:lng]) ", "AGGRavg23_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:flt], :bat[:oid], :bat[:any_1]) 
(:bat[:dbl], :bat[:lng]) ", "AGGRavg23_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:int], :bat[:oid], :bat[:any_1]) 
(:bat[:dbl], :bat[:lng]) ", "AGGRavg23_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:lng], :bat[:oid], :bat[:any_1]) 
(:bat[:dbl], :bat[:lng]) ", "AGGRavg23_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:sht], :bat[:oid], :bat[:any_1]) 
(:bat[:dbl], :bat[:lng]) ", "AGGRavg23_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:bte], :bat[:oid], :bat[:any_1], 
:int) (:bat[:dbl], :bat[:lng]) ",   "AGGRavg24_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:dbl], :bat[:oid], :bat[:any_1], 
:int) (:bat[:dbl], :bat[:lng]) ",   "AGGRavg24_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:flt], :bat[:oid], :bat[:any_1], 
:int) (:bat[:dbl], :bat[:lng]) ",   "AGGRavg24_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:int], :bat[:oid], :bat[:any_1], 
:int) (:bat[:dbl], :bat[:lng]) ",   "AGGRavg24_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:lng], :bat[:oid], :bat[:any_1], 
:int) (:bat[:dbl], :bat[:lng]) ",   "AGGRavg24_dbl;",   ""  ]
-[ "aggr",  "avg",  "command aggr.avg(:bat[:sht], :bat[:oid], :bat[:any_1], 
:int) (:bat[:dbl], :bat[:lng]) ",   "AGGRavg24_dbl;",   ""  ]
-[ "aggr",  "avg",  "pattern aggr.avg(:bat[:bte], :bat[:oid], :bit) (:bte, 
:lng, :lng) ",   "CMDBATavg3;",  ""  ]
-[ "aggr",  "avg",  "pattern aggr.avg(:bat[:int], :bat[:oid], :bit) (:int, 
:lng, :lng) ",   "CMDBATavg3;",  ""  ]
-[ "aggr",  "avg",  "pattern aggr.avg(:bat[:lng], :bat[:oid], :bit) (:lng, 
:lng, :lng) ",   "CMDBATavg3;",  ""  ]
-[ "aggr",  "avg",  "pattern aggr.avg(:bat[:sht], :bat[:oid], :bit)

monetdb-java: default - Correcting typos in documentation text. ...

2021-03-04 Thread Martin van Dinther
Changeset: 3dfcd06fd8ba for monetdb-java
URL: https://dev.monetdb.org/hg/monetdb-java?cmd=changeset;node=3dfcd06fd8ba
Modified Files:
src/main/java/org/monetdb/jdbc/MonetBlob.java
src/main/java/org/monetdb/jdbc/MonetCallableStatement.java
src/main/java/org/monetdb/jdbc/MonetClob.java
src/main/java/org/monetdb/jdbc/MonetConnection.java
src/main/java/org/monetdb/jdbc/MonetDataSource.java
src/main/java/org/monetdb/jdbc/MonetDriver.java.in
src/main/java/org/monetdb/jdbc/MonetPreparedStatement.java
src/main/java/org/monetdb/jdbc/MonetResultSet.java
src/main/java/org/monetdb/jdbc/MonetSavepoint.java
src/main/java/org/monetdb/jdbc/MonetStatement.java
src/main/java/org/monetdb/jdbc/MonetWrapper.java
src/main/java/org/monetdb/util/Exporter.java
Branch: default
Log Message:

Correcting typos in documentation text. Also improved the readability of the 
generated javadoc documents.


diffs (truncated from 341 to 300 lines):

diff --git a/src/main/java/org/monetdb/jdbc/MonetBlob.java 
b/src/main/java/org/monetdb/jdbc/MonetBlob.java
--- a/src/main/java/org/monetdb/jdbc/MonetBlob.java
+++ b/src/main/java/org/monetdb/jdbc/MonetBlob.java
@@ -16,14 +16,16 @@ import java.sql.SQLException;
 import java.sql.SQLFeatureNotSupportedException;
 
 /**
+ *
  * The MonetBlob class implements the {@link java.sql.Blob} interface.
  *
  * Because MonetDB/SQL currently has no support for streams, this class is a
- * shallow wrapper of a byte[].  It is more or less supplied to
- * enable an application that depends on it to run.  It may be obvious
+ * shallow wrapper of a byte[]. It is more or less supplied to
+ * enable an application that depends on it to run. It may be obvious
  * that it is a real resource expensive workaround that contradicts the
  * benefits for a Blob: avoidance of huge resource consumption.
  * Use of this class is highly discouraged.
+ *
  *
  * @author Fabian Groffen
  */
diff --git a/src/main/java/org/monetdb/jdbc/MonetCallableStatement.java 
b/src/main/java/org/monetdb/jdbc/MonetCallableStatement.java
--- a/src/main/java/org/monetdb/jdbc/MonetCallableStatement.java
+++ b/src/main/java/org/monetdb/jdbc/MonetCallableStatement.java
@@ -31,6 +31,7 @@ import java.util.Calendar;
 import java.util.Map;
 
 /**
+ *
  * A {@link CallableStatement} suitable for the MonetDB database.
  *
  * The interface used to execute SQL stored procedures.
@@ -39,15 +40,13 @@ import java.util.Map;
  * If used, the result parameter must be registered as an OUT parameter 
(MonetDB does not support this).
  * The other parameters can be used for input, output or both. Parameters are 
referred to sequentially, by number, with the first parameter being 1.
  *
- * 
  *  { call procedure-name [ (arg1, arg2, ...) ] }
  *  { ?= call procedure-name [ (arg1, arg2, ...) ] }
- * 
  *
  * IN parameter values are set using the set methods inherited from 
PreparedStatement.
  * The type of all OUT parameters must be registered prior to executing the 
stored procedure;
  * their values are retrieved after execution via the get methods provided 
here.
- * Note: MonetDB does not support OUT or INOUT parameters. Only input 
parameters are supported.
+ * Note: MonetDB does not support OUT or INOUT parameters. Only input 
parameters are supported.
  *
  * A CallableStatement can return one ResultSet object or multiple ResultSet 
objects.
  * Multiple ResultSet objects are handled using operations inherited from 
Statement.
@@ -62,6 +61,7 @@ import java.util.Map;
  * - all registerOutParameter(parameterIndex/parameterName, int sqlType, ...) 
methods
  * - wasNull() method
  * because output parameters in stored procedures are not supported by MonetDB.
+ *
  *
  * @author Martin van Dinther
  * @version 1.1
diff --git a/src/main/java/org/monetdb/jdbc/MonetClob.java 
b/src/main/java/org/monetdb/jdbc/MonetClob.java
--- a/src/main/java/org/monetdb/jdbc/MonetClob.java
+++ b/src/main/java/org/monetdb/jdbc/MonetClob.java
@@ -16,14 +16,16 @@ import java.sql.SQLException;
 import java.sql.SQLFeatureNotSupportedException;
 
 /**
+ *
  * The MonetClob class implements the {@link java.sql.Clob} interface.
  *
  * Because MonetDB/SQL currently has no support for streams, this class is a
- * shallow wrapper of a {@link StringBuilder}.  It is more or less supplied to
- * enable an application that depends on it to run.  It may be obvious
+ * shallow wrapper of a {@link StringBuilder}. It is more or less supplied to
+ * enable an application that depends on it to run. It may be obvious
  * that it is a real resource expensive workaround that contradicts the
  * sole reason for a Clob: avoidance of huge resource consumption.
  * Use of this class is highly discouraged.
+ *
  *
  * @author Fabian Groffen
  */
diff --git a/src/main/java/org/monetdb/jdbc/MonetConnection.java 
b/src/main/java/org/monetdb/jdbc/MonetConnection.java
--- a/src/main/java/org/monetdb/jdbc/MonetConnection.j

MonetDB: default - add MONETDBE_VERSION

2021-03-04 Thread Niels Nes
Changeset: 7260180c35e8 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7260180c35e8
Modified Files:
tools/monetdbe/monetdbe.h
Branch: default
Log Message:

add MONETDBE_VERSION


diffs (12 lines):

diff --git a/tools/monetdbe/monetdbe.h b/tools/monetdbe/monetdbe.h
--- a/tools/monetdbe/monetdbe.h
+++ b/tools/monetdbe/monetdbe.h
@@ -11,6 +11,8 @@
 
 #include "monetdb_config.h"
 
+#define MONETDBE_VERSION 1.0.0
+
 #ifdef __cplusplus
 extern "C" {
 #endif
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Pack more optimizers

2021-03-04 Thread Pedro Ferreira
Changeset: 54b5078dff77 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=54b5078dff77
Modified Files:
sql/server/rel_optimizer.c
Branch: default
Log Message:

Pack more optimizers


diffs (146 lines):

diff --git a/sql/server/rel_optimizer.c b/sql/server/rel_optimizer.c
--- a/sql/server/rel_optimizer.c
+++ b/sql/server/rel_optimizer.c
@@ -7442,64 +7442,59 @@ find_index(sql_allocator *sa, sql_rel *r
return NULL;
 }
 
-static sql_rel *
+static inline sql_rel *
 rel_use_index(visitor *v, sql_rel *rel)
 {
-   if (rel->l && (is_select(rel->op) || is_join(rel->op))) {
-   list *exps = NULL;
-   sql_idx *i = find_index(v->sql->sa, rel, rel->l, &exps);
-   int left = 1;
-
-   if (!i && is_join(rel->op)) {
-   left = 0;
-   i = find_index(v->sql->sa, rel, rel->r, &exps);
-   }
-
-   if (i) {
-   prop *p;
-   node *n;
-   int single_table = 1;
-   sql_exp *re = NULL;
-
-   for( n = exps->h; n && single_table; n = n->next) {
+   list *exps = NULL;
+   sql_idx *i = find_index(v->sql->sa, rel, rel->l, &exps);
+   int left = 1;
+
+   assert(is_select(rel->op) || is_join(rel->op));
+   if (!i && is_join(rel->op)) {
+   left = 0;
+   i = find_index(v->sql->sa, rel, rel->r, &exps);
+   }
+
+   if (i) {
+   prop *p;
+   node *n;
+   int single_table = 1;
+   sql_exp *re = NULL;
+
+   for( n = exps->h; n && single_table; n = n->next) {
+   sql_exp *e = n->data;
+   sql_exp *nre = e->r;
+
+   if (is_join(rel->op) && ((left && !rel_find_exp(rel->l, 
e->l)) || (!left && !rel_find_exp(rel->r, e->l
+   nre = e->l;
+   single_table = (!re || (exp_relname(nre) && 
exp_relname(re) && strcmp(exp_relname(nre), exp_relname(re)) == 0));
+   re = nre;
+   }
+   if (single_table) { /* add PROP_HASHCOL to all column exps */
+   for( n = exps->h; n; n = n->next) {
sql_exp *e = n->data;
-   sql_exp *nre = e->r;
-
-   if (is_join(rel->op) &&
-   ((left && !rel_find_exp(rel->l, e->l)) 
||
-   (!left && !rel_find_exp(rel->r, e->l
-   nre = e->l;
-   single_table = (!re || (exp_relname(nre) && 
exp_relname(re) && strcmp(exp_relname(nre), exp_relname(re)) == 0));
-   re = nre;
-   }
-   if (single_table) { /* add PROP_HASHCOL to all column 
exps */
-   for( n = exps->h; n; n = n->next) {
-   sql_exp *e = n->data;
-   int anti = is_anti(e), semantics = 
is_semantics(e);
-
-   /* swapped ? */
-   if (is_join(rel->op) &&
-   ((left && !rel_find_exp(rel->l, 
e->l)) ||
-   (!left && !rel_find_exp(rel->r, 
e->l
-   n->data = e = 
exp_compare(v->sql->sa, e->r, e->l, cmp_equal);
-   if (anti) set_anti(e);
-   if (semantics) set_semantics(e);
-   p = find_prop(e->p, PROP_HASHCOL);
-   if (!p)
-   e->p = p = 
prop_create(v->sql->sa, PROP_HASHCOL, e->p);
-   p->value = i;
-   }
-   }
-   /* add the remaining exps to the new exp list */
-   if (list_length(rel->exps) > list_length(exps)) {
-   for( n = rel->exps->h; n; n = n->next) {
-   sql_exp *e = n->data;
-   if (!list_find(exps, e, (fcmp)&exp_cmp))
-   list_append(exps, e);
-   }
-   }
-   rel->exps = exps;
-   }
+   int anti = is_anti(e), semantics = 
is_semantics(e);
+
+   /* swapped ? */
+   if (is_join(rel->op) && ((left && 
!rel_find_exp(rel->l, e->l)) || (!left && !rel_find_exp(rel->r, e->l
+   n->data = e = exp_compare(v->sql

monetdb-java: default - Avoid using table names called t1 in tes...

2021-03-04 Thread Martin van Dinther
Changeset: 64789c018991 for monetdb-java
URL: https://dev.monetdb.org/hg/monetdb-java?cmd=changeset;node=64789c018991
Modified Files:
tests/JDBC_API_Tester.java
Branch: default
Log Message:

Avoid using table names called t1 in tests, make them more unique.


diffs (truncated from 325 to 300 lines):

diff --git a/tests/JDBC_API_Tester.java b/tests/JDBC_API_Tester.java
--- a/tests/JDBC_API_Tester.java
+++ b/tests/JDBC_API_Tester.java
@@ -3160,99 +3160,99 @@ final public class JDBC_API_Tester {
sb.append("0. 
true\t").append(con3.getAutoCommit()).append("\n");
 
// test the creation of a table with concurrent clients
-   sb.append("1.1. create table t1 using client 1...\n");
-   stmt1.executeUpdate("CREATE TABLE t1 ( id int, name 
varchar(1024) )");
+   sb.append("1.1. create table t1504657 using client 
1...\n");
+   stmt1.executeUpdate("CREATE TABLE t1504657 ( id int, 
name varchar(1024) )");
sb.append("passed :)\n");
 
sb.append("1.2. check table existence in client 
2...\n");
-   rs2 = stmt2.executeQuery("SELECT name FROM tables where 
name LIKE 't1'");
+   rs2 = stmt2.executeQuery("SELECT name FROM tables where 
name LIKE 't1504657'");
while (rs2.next())
sb.append(rs2.getString("name")).append("\n");
sb.append("passed :)\n");
 
sb.append("1.3. check table existence in client 
3...\n");
-   rs3 = stmt3.executeQuery("SELECT name FROM tables where 
name LIKE 't1'");
+   rs3 = stmt3.executeQuery("SELECT name FROM tables where 
name LIKE 't1504657'");
while (rs3.next())
sb.append(rs3.getString("name")).append("\n");
sb.append("passed :)\n");
 
// test the insertion of values with concurrent clients
-   sb.append("2 insert into t1 using client 1...\n");
-   stmt1.executeUpdate("INSERT INTO t1 values( 1, 
'monetdb' )");
+   sb.append("2 insert into t1504657 using client 1...\n");
+   stmt1.executeUpdate("INSERT INTO t1504657 values( 1, 
'monetdb' )");
sb.append("passed :)\n");
-   stmt1.executeUpdate("INSERT INTO t1 values( 2, 'monet' 
)");
+   stmt1.executeUpdate("INSERT INTO t1504657 values( 2, 
'monet' )");
sb.append("passed :)\n");
-   stmt1.executeUpdate("INSERT INTO t1 values( 3, 'mon' 
)");
+   stmt1.executeUpdate("INSERT INTO t1504657 values( 3, 
'mon' )");
sb.append("passed :)\n");
 
sb.append("2.1. check table status with client 1...\n");
-   rs1 = stmt1.executeQuery("SELECT * FROM t1");
+   rs1 = stmt1.executeQuery("SELECT * FROM t1504657");
while (rs1.next())
sb.append(rs1.getInt("id")).append(", 
").append(rs1.getString("name")).append("\n");
sb.append("passed :)\n");
 
sb.append("2.2. check table status with client 2...\n");
-   rs2 = stmt2.executeQuery("SELECT * FROM t1");
+   rs2 = stmt2.executeQuery("SELECT * FROM t1504657");
while (rs2.next())
sb.append(rs2.getInt("id")).append(", 
").append(rs2.getString("name")).append("\n");
sb.append("passed :)\n");
 
sb.append("2.3. check table status with client 3...\n");
-   rs3 = stmt3.executeQuery("SELECT * FROM t1");
+   rs3 = stmt3.executeQuery("SELECT * FROM t1504657");
while (rs3.next())
sb.append(rs3.getInt("id")).append(", 
").append(rs3.getString("name")).append("\n");
sb.append("passed :)\n");
 
// test the insertion of values with concurrent clients
-   sb.append("3 insert into t1 using client 2...\n");
-   stmt2.executeUpdate("INSERT INTO t1 values( 4, 
'monetdb' )");
+   sb.append("3 insert into t1504657 using client 2...\n");
+   stmt2.executeUpdate("INSERT INTO t1504657 values( 4, 
'monetdb' )");
sb.append("passed :)\n");
-   stmt2.executeUpdate("INSERT INTO t1 values( 5, 'monet' 
)");
+   stmt2.executeUpdate("INSERT INTO t1504657 values( 5, 
'monet' )");
sb.append("passed :)\n");
-   stmt2.executeUpdate("INSERT INT

MonetDB: default - Avoid double run over the typechecker.

2021-03-04 Thread martin kersten
Changeset: 8bcdfc7cc56f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8bcdfc7cc56f
Modified Files:
monetdb5/optimizer/opt_mergetable.c
Branch: default
Log Message:

Avoid double run over the typechecker.


diffs (13 lines):

diff --git a/monetdb5/optimizer/opt_mergetable.c 
b/monetdb5/optimizer/opt_mergetable.c
--- a/monetdb5/optimizer/opt_mergetable.c
+++ b/monetdb5/optimizer/opt_mergetable.c
@@ -2346,9 +2346,6 @@ OPTmergetableImplementation(Client cntxt
pushInstruction(mb, cp);
}
(void) stk;
-   msg = chkTypes(cntxt->usermodule,mb, TRUE);
-   if( msg)
-   goto cleanup;
 
if ( mb->errors == MAL_SUCCEED) {
for(i=0; ihttps://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - No need to typecheck the optimizer instructions

2021-03-04 Thread martin kersten
Changeset: 69ad278379cf for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=69ad278379cf
Modified Files:
monetdb5/optimizer/opt_pipes.c
Branch: default
Log Message:

No need to typecheck the optimizer instructions


diffs (12 lines):

diff --git a/monetdb5/optimizer/opt_pipes.c b/monetdb5/optimizer/opt_pipes.c
--- a/monetdb5/optimizer/opt_pipes.c
+++ b/monetdb5/optimizer/opt_pipes.c
@@ -553,7 +553,7 @@ addOptimizerPipe(Client cntxt, MalBlkPtr
throw(MAL, "optimizer.addOptimizerPipe", 
SQLSTATE(HY013) MAL_MALLOC_FAIL);
for (k = 0; k < p->argc; k++)
getArg(p, k) = cloneVariable(mb, pipes[i].mb, 
getArg(p, k));
-   typeChecker(cntxt->usermodule, mb, p, j, FALSE);
+   // Not needed at this place 
typeChecker(cntxt->usermodule, mb, p, j, FALSE);
pushInstruction(mb, p);
}
}
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Postpone name generation until you need it

2021-03-04 Thread martin kersten
Changeset: a8d44f599588 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=a8d44f599588
Modified Files:
monetdb5/mal/mal_function.c
Branch: default
Log Message:

Postpone name generation until you need it


diffs (194 lines):

diff --git a/monetdb5/mal/mal_function.c b/monetdb5/mal/mal_function.c
--- a/monetdb5/mal/mal_function.c
+++ b/monetdb5/mal/mal_function.c
@@ -94,17 +94,15 @@ chkFlow(MalBlkPtr mb)
 {   int i,j,k, v,lastInstruction;
int  pc[DEPTH];
int  var[DEPTH];
-   char buf[IDLENGTH * 2 +2];
InstrPtr stmt[DEPTH];
int btop=0;
int endseen=0, retseen=0, yieldseen=0;
-   InstrPtr p;
+   InstrPtr p, sig;
str msg = MAL_SUCCEED;
 
if ( mb->errors != MAL_SUCCEED)
return mb->errors ;
-   p = getInstrPtr(mb, 0);
-   snprintf(buf, IDLENGTH * 2 +2, "%s.%s", getModuleId(p), 
getFunctionId(p));
+   sig = getInstrPtr(mb, 0);
lastInstruction = mb->stop-1;
for(i= 0; istop; i++){
p= getInstrPtr(mb,i);
@@ -114,23 +112,23 @@ chkFlow(MalBlkPtr mb)
case BARRIERsymbol:
case CATCHsymbol:
if(btop== DEPTH)
-   throw(MAL,buf,"Too many nested MAL blocks");
+   throw(MAL,"%s.%s Too many nested MAL blocks", 
getModuleId(sig), getFunctionId(sig));
pc[btop]= i;
v= var[btop]= getDestVar(p);
stmt[btop]=p;
 
for(j=btop-1;j>=0;j--)
if( v==var[j])
-   throw(MAL,buf, "recursive %s[%d] shields %s[%d]", 
getVarName(mb,v), pc[j], getFcnName(mb),pc[i]);
+   throw(MAL,"%s.%s recursive %s[%d] shields %s[%d]", 
getModuleId(sig), getFunctionId(sig), getVarName(mb,v), pc[j], 
getFcnName(mb),pc[i]);
 
btop++;
break;
case EXITsymbol:
v= getDestVar(p);
if( btop>0 && var[btop-1] != v)
-   throw(MAL, buf, "exit-label '%s' doesnot match 
'%s'", getVarName(mb,v), getVarName(mb,var[btop-1]));
+   throw(MAL, "%s.%s exit-label '%s' doesnot match 
'%s'", getModuleId(sig), getFunctionId(sig), getVarName(mb,v), 
getVarName(mb,var[btop-1]));
if(btop==0)
-   throw(MAL,buf, "exit-label '%s' without 
begin-label", getVarName(mb,v));
+   throw(MAL,"%s.%s exit-label '%s' without 
begin-label",  getModuleId(sig), getFunctionId(sig), getVarName(mb,v));
/* search the matching block */
for(j=btop-1;j>=0;j--)
if( var[j]==v) break;
@@ -156,13 +154,13 @@ chkFlow(MalBlkPtr mb)
if( var[j]==v) break;
if(j<0){
str nme=getVarName(mb,v);
-   throw(MAL,buf, "label '%s' not in guarded block", 
nme);
+   throw(MAL, "%s.%s label '%s' not in guarded block", 
getModuleId(sig), getFunctionId(sig), nme);
}
break;
case YIELDsymbol:
{ InstrPtr ps= getInstrPtr(mb,0);
if( ps->token != FACTORYsymbol){
-   throw(MAL, buf, "yield misplaced!");
+   throw(MAL, "%s.%s yield misplaced!",  
getModuleId(sig), getFunctionId(sig));
}
yieldseen= TRUE;
 }
@@ -174,13 +172,13 @@ chkFlow(MalBlkPtr mb)
if (p->barrier == RETURNsymbol)
yieldseen = FALSE;/* always end 
with a return */
if (ps->retc != p->retc) {
-   throw(MAL, buf, "invalid return 
target!");
+   throw(MAL, "%s.%s invalid return 
target!",  getModuleId(sig), getFunctionId(sig));
} else
if (ps->typechk == TYPE_RESOLVED)
for (e = 0; e < p->retc; e++) {
if (resolveType(getArgType(mb, 
ps, e), getArgType(mb, p, e)) < 0) {
str tpname = 
getTypeName(getArgType(mb, p, e));
-   msg = 
createException(MAL, buf, "%s type mismatch at type '%s'\n",
+   msg = 
createException(MAL, "%s.%s %s type mismatch at type '%s'\n", getModuleId(p), 
getFunctionId(p),

(p->barrier == RETURNsymbol ? "RETURN" : "YIELD"), tpname);

MonetDB: default - Postpone name generation

2021-03-04 Thread martin kersten
Changeset: 6247a8eaa9da for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=6247a8eaa9da
Modified Files:
monetdb5/optimizer/opt_wrapper.c
Branch: default
Log Message:

Postpone name generation


diffs (63 lines):

diff --git a/monetdb5/optimizer/opt_wrapper.c b/monetdb5/optimizer/opt_wrapper.c
--- a/monetdb5/optimizer/opt_wrapper.c
+++ b/monetdb5/optimizer/opt_wrapper.c
@@ -104,7 +104,6 @@ str OPTwrapper (Client cntxt, MalBlkPtr 
const char *fcnnme = "(NONE)";
Symbol s= NULL;
int i;
-   char optimizer[256];
str msg = MAL_SUCCEED;
lng clk;
 
@@ -116,7 +115,7 @@ str OPTwrapper (Client cntxt, MalBlkPtr 
 
if( mb->errors)
throw(MAL, "opt_wrapper", SQLSTATE(42000) "MAL block contains 
errors");
-   snprintf(optimizer,256,"%s", fcnnme = getFunctionId(p));
+   fcnnme = getFunctionId(p);
 
if( p && p->argc > 1 ){
if( getArgType(mb,p,1) != TYPE_str ||
@@ -124,7 +123,7 @@ str OPTwrapper (Client cntxt, MalBlkPtr 
!isVarConstant(mb,getArg(p,1)) ||
!isVarConstant(mb,getArg(p,2))
)
-   throw(MAL, optimizer, SQLSTATE(42000) ILLARG_CONSTANTS);
+   throw(MAL, getFunctionId(p), SQLSTATE(42000) 
ILLARG_CONSTANTS);
 
if( stk != 0){
modnme= *getArgReference_str(stk,p,1);
@@ -137,28 +136,28 @@ str OPTwrapper (Client cntxt, MalBlkPtr 
s= findSymbol(cntxt->usermodule, 
putName(modnme),putName(fcnnme));
 
if( s == NULL)
-   throw(MAL, optimizer, SQLSTATE(HY002) 
RUNTIME_OBJECT_UNDEFINED ":%s.%s", modnme, fcnnme);
+   throw(MAL, getFunctionId(p), SQLSTATE(HY002) 
RUNTIME_OBJECT_UNDEFINED "%s.%s", modnme, fcnnme);
mb = s->def;
stk= 0;
} else if( p )
removeInstruction(mb, p);
 
for (i=0; codes[i].nme; i++)
-   if (strcmp(codes[i].nme, optimizer) == 0){
+   if (strcmp(codes[i].nme, getFunctionId(p)) == 0){
clk = GDKusec();
msg = (str)(*(codes[i].fcn))(cntxt, mb, stk, 0);
codes[i].timing += GDKusec() - clk;
codes[i].calls++;
if (msg) {
-   throw(MAL, optimizer, SQLSTATE(42000) "Error in 
optimizer %s: %s", optimizer, msg);
+   throw(MAL, getFunctionId(p), SQLSTATE(42000) 
"Error in optimizer %s: %s", getFunctionId(p), msg);
}
break;
}
if (codes[i].nme == 0)
-   throw(MAL, optimizer, SQLSTATE(HY002) "Optimizer implementation 
'%s' missing", fcnnme);
+   throw(MAL, fcnnme,  SQLSTATE(HY002) "Optimizer implementation 
'%s' missing", fcnnme);
 
if ( mb->errors)
-   throw(MAL, optimizer, SQLSTATE(42000) PROGRAM_GENERAL ":%s.%s 
%s", modnme, fcnnme, mb->errors);
+   throw(MAL, fcnnme, SQLSTATE(42000) PROGRAM_GENERAL "%s.%s %s", 
modnme, fcnnme, mb->errors);
return MAL_SUCCEED;
 }
 
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Minor code upgrade

2021-03-04 Thread martin kersten
Changeset: 4c584b865796 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4c584b865796
Modified Files:
monetdb5/optimizer/opt_garbageCollector.c
Branch: default
Log Message:

Minor code upgrade


diffs (64 lines):

diff --git a/monetdb5/optimizer/opt_garbageCollector.c 
b/monetdb5/optimizer/opt_garbageCollector.c
--- a/monetdb5/optimizer/opt_garbageCollector.c
+++ b/monetdb5/optimizer/opt_garbageCollector.c
@@ -32,7 +32,9 @@ OPTgarbageCollectorImplementation(Client
char buf[1024];
lng usec = GDKusec();
str msg = MAL_SUCCEED;
+#ifndef NDEBUG
int *used;
+#endif
 
(void) pci;
(void) stk;
@@ -59,7 +61,9 @@ OPTgarbageCollectorImplementation(Client
 
// Actual garbage collection stuff, just mark them for re-assessment
vlimit = mb->vtop;
+#ifndef NDEBUG
used = (int *) GDKzalloc(vlimit * sizeof(int));
+#endif
p = NULL;
for (i = 0; i < limit; i++) {
p = getInstrPtr(mb, i);
@@ -67,13 +71,15 @@ OPTgarbageCollectorImplementation(Client
p->typechk = TYPE_UNKNOWN;
/* Set the program counter to ease profiling */
p->pc = i;
-   if ( i > 0 && getModuleId(p) != languageRef && getModuleId(p) 
!= querylogRef && getModuleId(p) != sqlRef && !p->barrier)
+#ifndef NDEBUG
+   if ( i > 1 && getModuleId(p) != languageRef && getModuleId(p) 
!= querylogRef && getModuleId(p) != sqlRef && !p->barrier)
for( j=0; j< p->retc; j++)
used[getArg(p,j)] = i;
if ( getModuleId(p) != languageRef && getFunctionId(p) != 
passRef){
for(j= p->retc ; j< p->argc; j++)
used[getArg(p,j)] = 0;
}
+#endif
if ( p->token == ENDsymbol)
break;
}
@@ -83,21 +89,19 @@ OPTgarbageCollectorImplementation(Client
GDKfree(used);
throw(MAL, "optimizer.garbagecollector", SQLSTATE(42000) 
"Incorrect MAL plan encountered");
}
+#ifndef NDEBUG
/* Leave a message behind when we have created variables and not used 
them */
for(i=0; i< vlimit; i++)
if( used[i]){
p = getInstrPtr(mb, used[i]);
if( p){
-#ifdef NDEBUG
-   snprintf(buf,1024,"Unused variable %s", getVarName(mb, 
i));
-#else
str msg = instruction2str(mb, NULL, p, LIST_MAL_ALL);
snprintf(buf,1024,"Unused variable %s: %s", 
getVarName(mb, i), msg);
GDKfree(msg);
-#endif
newComment(mb,buf);
}
}
+#endif
GDKfree(used);
getInstrPtr(mb,0)->gc |= GARBAGECONTROL;
 
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Fix compilation issues

2021-03-04 Thread martin kersten
Changeset: 83b2a6a1660a for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=83b2a6a1660a
Modified Files:
monetdb5/optimizer/opt_garbageCollector.c
Branch: default
Log Message:

Fix compilation issues


diffs (29 lines):

diff --git a/monetdb5/optimizer/opt_garbageCollector.c 
b/monetdb5/optimizer/opt_garbageCollector.c
--- a/monetdb5/optimizer/opt_garbageCollector.c
+++ b/monetdb5/optimizer/opt_garbageCollector.c
@@ -26,13 +26,14 @@
 str
 OPTgarbageCollectorImplementation(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci)
 {
-   int i, j, limit, vlimit;
+   int i, limit, vlimit;
InstrPtr p;
int actions = 0;
char buf[1024];
lng usec = GDKusec();
str msg = MAL_SUCCEED;
 #ifndef NDEBUG
+   int j;
int *used;
 #endif
 
@@ -101,8 +102,8 @@ OPTgarbageCollectorImplementation(Client
newComment(mb,buf);
}
}
+   GDKfree(used);
 #endif
-   GDKfree(used);
getInstrPtr(mb,0)->gc |= GARBAGECONTROL;
 
/* leave a consistent scope admin behind */
___
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list


MonetDB: default - Fix exception throwing

2021-03-04 Thread martin kersten
Changeset: 7ec62ee432f9 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7ec62ee432f9
Modified Files:
monetdb5/mal/mal_function.c
Branch: default
Log Message:

Fix exception throwing


diffs (123 lines):

diff --git a/monetdb5/mal/mal_function.c b/monetdb5/mal/mal_function.c
--- a/monetdb5/mal/mal_function.c
+++ b/monetdb5/mal/mal_function.c
@@ -112,23 +112,23 @@ chkFlow(MalBlkPtr mb)
case BARRIERsymbol:
case CATCHsymbol:
if(btop== DEPTH)
-   throw(MAL,"%s.%s Too many nested MAL blocks", 
getModuleId(sig), getFunctionId(sig));
+   throw(MAL,"chkFlow", "%s.%s Too many nested MAL 
blocks", getModuleId(sig), getFunctionId(sig));
pc[btop]= i;
v= var[btop]= getDestVar(p);
stmt[btop]=p;
 
for(j=btop-1;j>=0;j--)
if( v==var[j])
-   throw(MAL,"%s.%s recursive %s[%d] shields %s[%d]", 
getModuleId(sig), getFunctionId(sig), getVarName(mb,v), pc[j], 
getFcnName(mb),pc[i]);
+   throw(MAL,"chkFlow", "%s.%s recursive %s[%d] 
shields %s[%d]", getModuleId(sig), getFunctionId(sig), getVarName(mb,v), pc[j], 
getFcnName(mb),pc[i]);
 
btop++;
break;
case EXITsymbol:
v= getDestVar(p);
if( btop>0 && var[btop-1] != v)
-   throw(MAL, "%s.%s exit-label '%s' doesnot match 
'%s'", getModuleId(sig), getFunctionId(sig), getVarName(mb,v), 
getVarName(mb,var[btop-1]));
+   throw(MAL,"chkFlow",  "%s.%s exit-label '%s' 
doesnot match '%s'", getModuleId(sig), getFunctionId(sig), getVarName(mb,v), 
getVarName(mb,var[btop-1]));
if(btop==0)
-   throw(MAL,"%s.%s exit-label '%s' without 
begin-label",  getModuleId(sig), getFunctionId(sig), getVarName(mb,v));
+   throw(MAL,"chkFlow", "%s.%s exit-label '%s' without 
begin-label",  getModuleId(sig), getFunctionId(sig), getVarName(mb,v));
/* search the matching block */
for(j=btop-1;j>=0;j--)
if( var[j]==v) break;
@@ -154,13 +154,13 @@ chkFlow(MalBlkPtr mb)
if( var[j]==v) break;
if(j<0){
str nme=getVarName(mb,v);
-   throw(MAL, "%s.%s label '%s' not in guarded block", 
getModuleId(sig), getFunctionId(sig), nme);
+   throw(MAL,"chkFlow",  "%s.%s label '%s' not in 
guarded block", getModuleId(sig), getFunctionId(sig), nme);
}
break;
case YIELDsymbol:
{ InstrPtr ps= getInstrPtr(mb,0);
if( ps->token != FACTORYsymbol){
-   throw(MAL, "%s.%s yield misplaced!",  
getModuleId(sig), getFunctionId(sig));
+   throw(MAL,"chkFlow",  "%s.%s yield misplaced!",  
getModuleId(sig), getFunctionId(sig));
}
yieldseen= TRUE;
 }
@@ -172,7 +172,7 @@ chkFlow(MalBlkPtr mb)
if (p->barrier == RETURNsymbol)
yieldseen = FALSE;/* always end 
with a return */
if (ps->retc != p->retc) {
-   throw(MAL, "%s.%s invalid return 
target!",  getModuleId(sig), getFunctionId(sig));
+   throw(MAL,"chkFlow",  "%s.%s invalid 
return target!",  getModuleId(sig), getFunctionId(sig));
} else
if (ps->typechk == TYPE_RESOLVED)
for (e = 0; e < p->retc; e++) {
@@ -209,20 +209,20 @@ chkFlow(MalBlkPtr mb)
}
 
if(lastInstruction < mb->stop-1 )
-   throw(MAL, "%s.%s instructions after END", getModuleId(sig), 
getFunctionId(sig));
+   throw(MAL,"chkFlow",  "%s.%s instructions after END", 
getModuleId(sig), getFunctionId(sig));
 
if( endseen && btop  > 0)
-   throw(MAL, "%s.%s barrier '%s' without exit in %s[%d]", 
getModuleId(sig), getFunctionId(sig), i, getVarName(mb,var[btop - 
1]),getFcnName(mb),i);
+   throw(MAL,"chkFlow",  "barrier '%s' without exit in 
%s[%d]", getVarName(mb,var[btop - 1]), getFcnName(mb), i);
p= getInstrPtr(mb,0);
if( !isaSignature(p))
-   throw( MAL, "%s.%s signature missing",  getModuleId(sig), 
getFunctionId(sig));
+   throw( MAL,"chkFlow",  "%s.%s signature missing",  
getModuleId(sig), getFunctionId(sig));
if( retseen == 0){
if( getArgType(mb,p,0)!= TY