Changeset: 55c77dbc2d77 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=55c77dbc2d77
Modified Files:
clients/Tests/MAL-signatures.stable.out
clients/Tests/MAL-signatures.stable.out.int128
monetdb5/modules/atoms/blob.c
sql/backends/monet5/sql_statement.h
Branch: default
Log Message:
Blobs with candidate lists
diffs (187 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
@@ -777,7 +777,8 @@ stdout of test 'MAL-signatures` in direc
[ "batalgebra", "not_like", "pattern
batalgebra.not_like(X_1:bat[:str], X_2:bat[:str], X_3:str):bat[:bit] ",
"BATPCREnotlike;", "" ]
[ "batalgebra", "not_like", "pattern
batalgebra.not_like(X_1:bat[:str], X_2:str, X_3:str):bat[:bit] ",
"BATPCREnotlike;", "" ]
[ "batalgebra", "not_like", "pattern batalgebra.not_like(X_1:str,
X_2:bat[:str], X_3:str):bat[:bit] ", "BATPCREnotlike;", "" ]
-[ "batblob", "nitems", "command
batblob.nitems(X_1:bat[:blob]):bat[:int] ", "BLOBnitems_bulk;", "" ]
+[ "batblob", "nitems", "pattern
batblob.nitems(X_1:bat[:blob]):bat[:int] ", "BLOBnitems_bulk;", "" ]
+[ "batblob", "nitems", "pattern batblob.nitems(X_1:bat[:blob],
X_2:bat[:oid]):bat[:int] ", "BLOBnitems_bulk;", "" ]
[ "batcalc", "!=", "pattern batcalc.!=(X_1:any_1,
X_2:bat[:any_1]):bat[:bit] ", "CMDbatNE;", "" ]
[ "batcalc", "!=", "pattern batcalc.!=(X_1:any_1, X_2:bat[:any_1],
X_3:bat[:oid]):bat[:bit] ", "CMDbatNE;", "" ]
[ "batcalc", "!=", "pattern batcalc.!=(X_1:any_1, X_2:bat[:any_1],
X_3:bat[:oid], X_4:bit):bat[:bit] ", "CMDbatNE;", "" ]
diff --git a/clients/Tests/MAL-signatures.stable.out.int128
b/clients/Tests/MAL-signatures.stable.out.int128
--- a/clients/Tests/MAL-signatures.stable.out.int128
+++ b/clients/Tests/MAL-signatures.stable.out.int128
@@ -892,7 +892,8 @@ stdout of test 'MAL-signatures` in direc
[ "batalgebra", "not_like", "pattern
batalgebra.not_like(X_1:bat[:str], X_2:bat[:str], X_3:str):bat[:bit] ",
"BATPCREnotlike;", "" ]
[ "batalgebra", "not_like", "pattern
batalgebra.not_like(X_1:bat[:str], X_2:str, X_3:str):bat[:bit] ",
"BATPCREnotlike;", "" ]
[ "batalgebra", "not_like", "pattern batalgebra.not_like(X_1:str,
X_2:bat[:str], X_3:str):bat[:bit] ", "BATPCREnotlike;", "" ]
-[ "batblob", "nitems", "command
batblob.nitems(X_1:bat[:blob]):bat[:int] ", "BLOBnitems_bulk;", "" ]
+[ "batblob", "nitems", "pattern
batblob.nitems(X_1:bat[:blob]):bat[:int] ", "BLOBnitems_bulk;", "" ]
+[ "batblob", "nitems", "pattern batblob.nitems(X_1:bat[:blob],
X_2:bat[:oid]):bat[:int] ", "BLOBnitems_bulk;", "" ]
[ "batcalc", "!=", "pattern batcalc.!=(X_1:any_1,
X_2:bat[:any_1]):bat[:bit] ", "CMDbatNE;", "" ]
[ "batcalc", "!=", "pattern batcalc.!=(X_1:any_1, X_2:bat[:any_1],
X_3:bat[:oid]):bat[:bit] ", "CMDbatNE;", "" ]
[ "batcalc", "!=", "pattern batcalc.!=(X_1:any_1, X_2:bat[:any_1],
X_3:bat[:oid], X_4:bit):bat[:bit] ", "CMDbatNE;", "" ]
diff --git a/monetdb5/modules/atoms/blob.c b/monetdb5/modules/atoms/blob.c
--- a/monetdb5/modules/atoms/blob.c
+++ b/monetdb5/modules/atoms/blob.c
@@ -31,6 +31,8 @@
*/
#include "monetdb_config.h"
#include "blob.h"
+#include "mal_client.h"
+#include "mal_interpreter.h"
int TYPE_blob;
@@ -168,58 +170,94 @@ BLOBput(Heap *h, var_t *bun, const void
return *bun;
}
-static inline int
-blob_nitems(blob *b)
-{
- if (is_blob_nil(b))
- return int_nil;
- assert(b->nitems <INT_MAX);
- return (int) b->nitems;
-}
-
static str
BLOBnitems(int *ret, blob **b)
{
- *ret = blob_nitems(*b);
+ if (is_blob_nil(*b)) {
+ *ret = int_nil;
+ } else {
+ assert((*b)->nitems < INT_MAX);
+ *ret = (int) (*b)->nitems;
+ }
return MAL_SUCCEED;
}
static str
-BLOBnitems_bulk(bat *ret, const bat *bid)
+BLOBnitems_bulk(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
{
- BAT *b = NULL, *bn = NULL;
- BUN n, p, q;
- int *restrict dst;
+ BATiter bi;
+ BAT *bn = NULL, *b = NULL, *bs = NULL;
+ BUN q = 0;
+ int *restrict vals;
str msg = MAL_SUCCEED;
- BATiter bi;
+ bool nils = false;
+ struct canditer ci1 = {0};
+ oid off1;
+ bat *res = getArgReference_bat(stk, pci, 0), *bid =
getArgReference_bat(stk, pci, 1),
+ *sid1 = pci->argc == 3 ? getArgReference_bat(stk, pci, 2) :
NULL;
- if ((b = BATdescriptor(*bid)) == NULL) {
- msg = createException(MAL, "blob.nitems_bulk", SQLSTATE(HY002)
RUNTIME_OBJECT_MISSING);
+ (void) cntxt;
+ (void) mb;
+ if (!(b = BATdescriptor(*bid))) {
+ msg = createException(MAL, "blob.nitems_bulk", SQLSTATE(HY005)
RUNTIME_OBJECT_MISSING);
goto bailout;
}
- n = BATcount(b);
- if ((bn = COLnew(b->hseqbase, TYPE_int, n, TRANSIENT)) == NULL) {
+ if (sid1 && !is_bat_nil(*sid1) && !(bs = BATdescriptor(*sid1))) {
+ msg = createException(MAL, "blob.nitems_bulk", SQLSTATE(HY005)
RUNTIME_OBJECT_MISSING);
+ goto bailout;
+ }
+ q = canditer_init(&ci1, b, bs);
+ if (!(bn = COLnew(ci1.hseq, TYPE_int, q, TRANSIENT))) {
msg = createException(MAL, "blob.nitems_bulk", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
goto bailout;
}
- dst = Tloc(bn, 0);
+
+ off1 = b->hseqbase;
bi = bat_iterator(b);
- BATloop(b, p, q) {
- blob *restrict next = BUNtvar(bi, p);
- dst[p] = blob_nitems(next);
+ vals = Tloc(bn, 0);
+ if (ci1.tpe == cand_dense) {
+ for (BUN i = 0; i < q; i++) {
+ oid p1 = (canditer_next_dense(&ci1) - off1);
+ blob *b = (blob*) BUNtvar(bi, p1);
+
+ if (is_blob_nil(b)) {
+ vals[i] = int_nil;
+ nils = true;
+ } else {
+ assert((int) b->nitems < INT_MAX);
+ vals[i] = (int) b->nitems;
+ }
+ }
+ } else {
+ for (BUN i = 0; i < q; i++) {
+ oid p1 = (canditer_next(&ci1) - off1);
+ blob *b = (blob*) BUNtvar(bi, p1);
+
+ if (is_blob_nil(b)) {
+ vals[i] = int_nil;
+ nils = true;
+ } else {
+ assert((int) b->nitems < INT_MAX);
+ vals[i] = (int) b->nitems;
+ }
+ }
}
- bn->tnonil = b->tnonil;
- bn->tnil = b->tnil;
- BATsetcount(bn, n);
- bn->tsorted = bn->trevsorted = n < 2;
- bn->tkey = false;
+
bailout:
+ if (bn && !msg) {
+ BATsetcount(bn, q);
+ bn->tnil = nils;
+ bn->tnonil = !nils;
+ bn->tkey = BATcount(bn) <= 1;
+ bn->tsorted = BATcount(bn) <= 1;
+ bn->trevsorted = BATcount(bn) <= 1;
+ BBPkeepref(*res = bn->batCacheid);
+ } else if (bn)
+ BBPreclaim(bn);
if (b)
BBPunfix(b->batCacheid);
- if (msg && bn)
- BBPreclaim(bn);
- else if (bn)
- BBPkeepref(*ret = bn->batCacheid);
+ if (bs)
+ BBPunfix(bs->batCacheid);
return msg;
}
@@ -478,7 +516,8 @@ static mel_func blob_init_funcs[] = {
command("blob", "blob", BLOBblob_fromstr, false, "", args(1,2,
arg("",blob),arg("s",str))),
command("blob", "toblob", BLOBtoblob, false, "store a string as a blob.",
args(1,2, arg("",blob),arg("v",str))),
command("blob", "nitems", BLOBnitems, false, "get the number of bytes in this
blob.", args(1,2, arg("",int),arg("b",blob))),
- command("batblob", "nitems", BLOBnitems_bulk, false, "", args(1,2,
batarg("",int),batarg("b",blob))),
+ pattern("batblob", "nitems", BLOBnitems_bulk, false, "", args(1,2,
batarg("",int),batarg("b",blob))),
+ pattern("batblob", "nitems", BLOBnitems_bulk, false, "", args(1,3,
batarg("",int),batarg("b",blob),batarg("s",oid))),
command("blob", "prelude", BLOBprelude, false, "", args(1,1, arg("",void))),
command("calc", "blob", BLOBblob_blob, false, "", args(1,2,
arg("",blob),arg("b",blob))),
command("batcalc", "blob", BLOBblob_blob_bulk, false, "", args(1,3,
batarg("",blob),batarg("b",blob),batarg("s",oid))),
diff --git a/sql/backends/monet5/sql_statement.h
b/sql/backends/monet5/sql_statement.h
--- a/sql/backends/monet5/sql_statement.h
+++ b/sql/backends/monet5/sql_statement.h
@@ -133,7 +133,7 @@ typedef struct stmt {
/* which MAL modules can push candidates */
#define can_push_cands(sel, f) \
(sel && (strcmp(sql_func_mod(f->func), "calc") == 0 ||
strcmp(sql_func_mod(f->func), "mmath") == 0 || \
- strcmp(sql_func_mod(f->func), "mtime") == 0 || \
+ strcmp(sql_func_mod(f->func), "mtime") == 0 ||
strcmp(sql_func_mod(f->func), "blob") == 0 || \
(strcmp(sql_func_mod(f->func), "str") == 0 &&
batstr_func_has_candidates(sql_func_imp(f->func)))))
extern void create_merge_partitions_accumulator(backend *be);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list