Changeset: 948110104856 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/948110104856
Modified Files:
clients/Tests/MAL-signatures.stable.out
clients/Tests/MAL-signatures.stable.out.int128
monetdb5/modules/atoms/uuid.c
monetdb5/modules/kernel/batmmath.c
Branch: default
Log Message:
Added cardinality input version for batmmath.rand and batuuid.new functions
diffs (156 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
@@ -6042,6 +6042,7 @@
[ "batmmath", "radians", "pattern batmmath.radians(X_0:bat[:flt],
X_1:bat[:oid]):bat[:flt] ", "CMDscience_bat_radians;", "" ]
[ "batmmath", "rand", "unsafe pattern batmmath.rand(X_0:bat[:int]):bat[:int]
", "CMDscience_bat_randintarg;", "" ]
[ "batmmath", "rand", "unsafe pattern batmmath.rand(X_0:bat[:int],
X_1:bat[:oid]):bat[:int] ", "CMDscience_bat_randintarg;", "" ]
+[ "batmmath", "rand", "unsafe pattern batmmath.rand(X_0:lng):bat[:int] ",
"CMDscience_bat_randintarg;", "" ]
[ "batmmath", "sin", "pattern batmmath.sin(X_0:bat[:dbl]):bat[:dbl] ",
"CMDscience_bat_sin;", "" ]
[ "batmmath", "sin", "pattern batmmath.sin(X_0:bat[:dbl],
X_1:bat[:oid]):bat[:dbl] ", "CMDscience_bat_sin;", "" ]
[ "batmmath", "sin", "pattern batmmath.sin(X_0:bat[:flt]):bat[:flt] ",
"CMDscience_bat_sin;", "" ]
@@ -6607,7 +6608,8 @@
[ "batstr", "unicodeAt", "pattern batstr.unicodeAt(X_0:bat[:str],
X_1:int, X_2:bat[:oid]):bat[:int] ", "STRbatWChrAtcst;", "get a unicode
character (as an int) from a string position." ]
[ "battxtsim", "similarity", "command battxtsim.similarity(X_0:bat[:str],
X_1:bat[:str]):bat[:dbl] ", "fstrcmp0_impl_bulk;", "Normalized edit
distance between two strings" ]
[ "batuuid", "isaUUID", "command
batuuid.isaUUID(X_0:bat[:str]):bat[:bit] ", "UUIDisaUUID_bulk;", "Test a
string for a UUID format" ]
-[ "batuuid", "new", "command batuuid.new(X_0:bat[:int]):bat[:uuid] ",
"UUIDgenerateUuidInt_bulk;", "Generate a new uuid (dummy version for side
effect free multiplex loop)" ]
+[ "batuuid", "new", "pattern batuuid.new(X_0:bat[:int]):bat[:uuid] ",
"UUIDgenerateUuidInt_bulk;", "Generate a new uuid (dummy version for side
effect free multiplex loop)" ]
+[ "batuuid", "new", "pattern batuuid.new(X_0:lng):bat[:uuid] ",
"UUIDgenerateUuidInt_bulk;", "Generate a new uuid (dummy version for side
effect free multiplex loop)" ]
[ "batxml", "attribute", "command batxml.attribute(X_0:str,
X_1:bat[:str]):bat[:xml] ", "BATXMLattribute;", "Construct an attribute
value pair." ]
[ "batxml", "comment", "command
batxml.comment(X_0:bat[:str]):bat[:xml] ", "BATXMLcomment;", "Create
an XML comment element." ]
[ "batxml", "concat", "command batxml.concat(X_0:bat[:xml],
X_1:bat[:xml]):bat[:xml] ", "BATXMLconcat;", "Concatenate the XML
values." ]
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
@@ -8572,6 +8572,7 @@
[ "batmmath", "radians", "pattern batmmath.radians(X_0:bat[:flt],
X_1:bat[:oid]):bat[:flt] ", "CMDscience_bat_radians;", "" ]
[ "batmmath", "rand", "unsafe pattern batmmath.rand(X_0:bat[:int]):bat[:int]
", "CMDscience_bat_randintarg;", "" ]
[ "batmmath", "rand", "unsafe pattern batmmath.rand(X_0:bat[:int],
X_1:bat[:oid]):bat[:int] ", "CMDscience_bat_randintarg;", "" ]
+[ "batmmath", "rand", "unsafe pattern batmmath.rand(X_0:lng):bat[:int] ",
"CMDscience_bat_randintarg;", "" ]
[ "batmmath", "sin", "pattern batmmath.sin(X_0:bat[:dbl]):bat[:dbl] ",
"CMDscience_bat_sin;", "" ]
[ "batmmath", "sin", "pattern batmmath.sin(X_0:bat[:dbl],
X_1:bat[:oid]):bat[:dbl] ", "CMDscience_bat_sin;", "" ]
[ "batmmath", "sin", "pattern batmmath.sin(X_0:bat[:flt]):bat[:flt] ",
"CMDscience_bat_sin;", "" ]
@@ -9166,7 +9167,8 @@
[ "batstr", "unicodeAt", "pattern batstr.unicodeAt(X_0:bat[:str],
X_1:int, X_2:bat[:oid]):bat[:int] ", "STRbatWChrAtcst;", "get a unicode
character (as an int) from a string position." ]
[ "battxtsim", "similarity", "command battxtsim.similarity(X_0:bat[:str],
X_1:bat[:str]):bat[:dbl] ", "fstrcmp0_impl_bulk;", "Normalized edit
distance between two strings" ]
[ "batuuid", "isaUUID", "command
batuuid.isaUUID(X_0:bat[:str]):bat[:bit] ", "UUIDisaUUID_bulk;", "Test a
string for a UUID format" ]
-[ "batuuid", "new", "command batuuid.new(X_0:bat[:int]):bat[:uuid] ",
"UUIDgenerateUuidInt_bulk;", "Generate a new uuid (dummy version for side
effect free multiplex loop)" ]
+[ "batuuid", "new", "pattern batuuid.new(X_0:bat[:int]):bat[:uuid] ",
"UUIDgenerateUuidInt_bulk;", "Generate a new uuid (dummy version for side
effect free multiplex loop)" ]
+[ "batuuid", "new", "pattern batuuid.new(X_0:lng):bat[:uuid] ",
"UUIDgenerateUuidInt_bulk;", "Generate a new uuid (dummy version for side
effect free multiplex loop)" ]
[ "batxml", "attribute", "command batxml.attribute(X_0:str,
X_1:bat[:str]):bat[:xml] ", "BATXMLattribute;", "Construct an attribute
value pair." ]
[ "batxml", "comment", "command
batxml.comment(X_0:bat[:str]):bat[:xml] ", "BATXMLcomment;", "Create
an XML comment element." ]
[ "batxml", "concat", "command batxml.concat(X_0:bat[:xml],
X_1:bat[:xml]):bat[:xml] ", "BATXMLconcat;", "Concatenate the XML
values." ]
diff --git a/monetdb5/modules/atoms/uuid.c b/monetdb5/modules/atoms/uuid.c
--- a/monetdb5/modules/atoms/uuid.c
+++ b/monetdb5/modules/atoms/uuid.c
@@ -19,7 +19,7 @@
#endif
#include "mal.h"
#include "mal_exception.h"
-#include "mal_atom.h" /* for malAtomSize */
+#include "mal_interpreter.h"
#if !defined(HAVE_UUID) && !defined(HAVE_GETENTROPY) && defined(HAVE_RAND_S)
static inline bool
@@ -109,19 +109,27 @@ isaUUID(const char *s)
}
static str
-UUIDgenerateUuidInt_bulk(bat *ret, const bat *bid)
+UUIDgenerateUuidInt_bulk(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr
pci)
{
BAT *b = NULL, *bn = NULL;
BUN n = 0;
str msg = MAL_SUCCEED;
uuid *restrict bnt = NULL;
+ bat *ret = getArgReference_bat(stk, pci, 0);
- if ((b = BBPquickdesc(*bid)) == NULL) {
- msg = createException(MAL, "uuid.generateuuidint_bulk",
SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
- goto bailout;
+ (void) cntxt;
+ if (isaBatType(getArgType(mb, pci, 1))) {
+ bat *bid = getArgReference_bat(stk, pci, 1);
+ if (!(b = BBPquickdesc(*bid))) {
+ msg = createException(MAL, "uuid.generateuuidint_bulk",
SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
+ goto bailout;
+ }
+ n = BATcount(b);
+ } else {
+ n = (BUN) *getArgReference_lng(stk, pci, 1);
}
- n = BATcount(b);
- if ((bn = COLnew(b->hseqbase, TYPE_uuid, n, TRANSIENT)) == NULL) {
+
+ if ((bn = COLnew(b ? b->hseqbase : 0, TYPE_uuid, n, TRANSIENT)) ==
NULL) {
msg = createException(MAL, "uuid.generateuuidint_bulk",
SQLSTATE(HY013) MAL_MALLOC_FAIL);
goto bailout;
}
@@ -454,7 +462,8 @@ bailout:
mel_func uuid_init_funcs[] = {
command("uuid", "new", UUIDgenerateUuid, true, "Generate a new uuid",
args(1,1, arg("",uuid))),
command("uuid", "new", UUIDgenerateUuidInt, false, "Generate a new uuid
(dummy version for side effect free multiplex loop)", args(1,2,
arg("",uuid),arg("d",int))),
- command("batuuid", "new", UUIDgenerateUuidInt_bulk, false, "Generate a new
uuid (dummy version for side effect free multiplex loop)", args(1,2,
batarg("",uuid),batarg("d",int))),
+ pattern("batuuid", "new", UUIDgenerateUuidInt_bulk, false, "Generate a new
uuid (dummy version for side effect free multiplex loop)", args(1,2,
batarg("",uuid),batarg("d",int))),
+ pattern("batuuid", "new", UUIDgenerateUuidInt_bulk, false, "Generate a new
uuid (dummy version for side effect free multiplex loop)", args(1,2,
batarg("",uuid),arg("card",lng))), /* version with cardinality input */
command("uuid", "uuid", UUIDstr2uuid, false, "Coerce a string to a uuid,
validating its format", args(1,2, arg("",uuid),arg("s",str))),
command("uuid", "str", UUIDuuid2str, false, "Coerce a uuid to its string
type", args(1,2, arg("",str),arg("u",uuid))),
command("uuid", "isaUUID", UUIDisaUUID, false, "Test a string for a UUID
format", args(1,2, arg("",bit),arg("u",str))),
diff --git a/monetdb5/modules/kernel/batmmath.c
b/monetdb5/modules/kernel/batmmath.c
--- a/monetdb5/modules/kernel/batmmath.c
+++ b/monetdb5/modules/kernel/batmmath.c
@@ -385,20 +385,26 @@ CMDscience_bat_randintarg(Client cntxt,
int *restrict vals;
str msg = MAL_SUCCEED;
struct canditer ci = {0};
- bat *res = getArgReference_bat(stk, pci, 0), *bid =
getArgReference_bat(stk, pci, 1),
- *sid = pci->argc == 3 ? getArgReference_bat(stk, pci, 2) : NULL;
+ bat *res = getArgReference_bat(stk, pci, 0);
(void) cntxt;
- (void) mb;
- if (!(b = BBPquickdesc(*bid))) {
- msg = createException(MAL, "batmmath.rand", SQLSTATE(HY002)
RUNTIME_OBJECT_MISSING);
- goto bailout;
+ if (isaBatType(getArgType(mb, pci, 1))) {
+ bat *bid = getArgReference_bat(stk, pci, 1), *sid = pci->argc
== 3 ? getArgReference_bat(stk, pci, 2) : NULL;
+ if (!(b = BBPquickdesc(*bid))) {
+ msg = createException(MAL, "batmmath.rand",
SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
+ goto bailout;
+ }
+ if (sid && !is_bat_nil(*sid) && !(bs = BATdescriptor(*sid))) {
+ msg = createException(MAL, "batmmath.rand",
SQLSTATE(HY002) RUNTIME_OBJECT_MISSING);
+ goto bailout;
+ }
+ q = canditer_init(&ci, b, bs);
+ if (bs)
+ BBPunfix(bs->batCacheid);
+ } else {
+ q = (BUN) *getArgReference_lng(stk, pci, 1);
}
- if (sid && !is_bat_nil(*sid) && !(bs = BATdescriptor(*sid))) {
- msg = createException(MAL, "batmmath.rand", SQLSTATE(HY002)
RUNTIME_OBJECT_MISSING);
- goto bailout;
- }
- q = canditer_init(&ci, b, bs);
+
if (!(bn = COLnew(ci.hseq, TYPE_int, q, TRANSIENT))) {
msg = createException(MAL, "batmmath.rand", SQLSTATE(HY013)
MAL_MALLOC_FAIL);
goto bailout;
@@ -416,8 +422,6 @@ CMDscience_bat_randintarg(Client cntxt,
#endif
bailout:
- if (bs)
- BBPunfix(bs->batCacheid);
if (bn && !msg) {
BATsetcount(bn, q);
bn->tnil = false;
@@ -581,6 +585,7 @@ mel_func batmmath_init_funcs[] = {
pattern("batmmath", "pow", CMDscience_bat_pow, false, "", args(1,4,
batarg("",flt),arg("x",flt),batarg("y",flt),batarg("s",oid))),
pattern("batmmath", "rand", CMDscience_bat_randintarg, true, "", args(1,2,
batarg("",int),batarg("v",int))),
pattern("batmmath", "rand", CMDscience_bat_randintarg, true, "", args(1,3,
batarg("",int),batarg("v",int),batarg("s",oid))),
+ pattern("batmmath", "rand", CMDscience_bat_randintarg, true, "", args(1,2,
batarg("",int),arg("card",lng))), /* version with cardinality input */
{ .imp=NULL }
};
#include "mal_import.h"
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list