Changeset: 763039fd8af6 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=763039fd8af6 Modified Files: clients/Tests/MAL-signatures.stable.out clients/Tests/MAL-signatures.stable.out.int128 gdk/gdk_calc.c monetdb5/modules/mal/01_batcalc.mal monetdb5/modules/mal/01_batcalc.mal.sh monetdb5/modules/mal/01_calc.mal.sh Branch: msk-type Log Message:
Implemented (bat)calc.not for msk type. diffs (239 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 @@ -13378,6 +13378,9 @@ stdout of test 'MAL-signatures` in direc [ "batcalc", "ifthenelse", "pattern batcalc.ifthenelse(v:bit, b1:bat[:any_1], b2:bat[:any_1]):bat[:any_1] ", "CMDifthen;", "If-then-else operation to assemble a conditional result" ] [ "batcalc", "ifthenelse", "pattern batcalc.ifthenelse(v:bit, b1:bat[:any_1], v2:any_1):bat[:any_1] ", "CMDifthen;", "If-then-else operation to assemble a conditional result" ] [ "batcalc", "ifthenelse", "pattern batcalc.ifthenelse(v:bit, v1:any_1, b2:bat[:any_1]):bat[:any_1] ", "CMDifthen;", "If-then-else operation to assemble a conditional result" ] +[ "batcalc", "ifthenelse", "pattern batcalc.ifthenelse(v:msk, b1:bat[:any_1], b2:bat[:any_1]):bat[:any_1] ", "CMDifthen;", "If-then-else operation to assemble a conditional result" ] +[ "batcalc", "ifthenelse", "pattern batcalc.ifthenelse(v:msk, b1:bat[:any_1], v2:any_1):bat[:any_1] ", "CMDifthen;", "If-then-else operation to assemble a conditional result" ] +[ "batcalc", "ifthenelse", "pattern batcalc.ifthenelse(v:msk, v1:any_1, b2:bat[:any_1]):bat[:any_1] ", "CMDifthen;", "If-then-else operation to assemble a conditional result" ] [ "batcalc", "index", "command batcalc.index(v:bat[:str], u:bit):bat[:bte] ", "BATSTRindex_bte;", "Return the offsets as an index bat" ] [ "batcalc", "index", "command batcalc.index(v:bat[:str], u:bit):bat[:int] ", "BATSTRindex_int;", "Return the offsets as an index bat" ] [ "batcalc", "index", "command batcalc.index(v:bat[:str], u:bit):bat[:sht] ", "BATSTRindex_sht;", "Return the offsets as an index bat" ] @@ -15061,12 +15064,12 @@ stdout of test 'MAL-signatures` in direc [ "batcalc", "mul_noerror", "pattern batcalc.mul_noerror(v:sht, b:bat[:sht], s:bat[:msk], r:bat[:bit]):bat[:sht] ", "CMDbatMUL;", "Return V * B with candidates list, overflow causes NIL value" ] [ "batcalc", "mul_noerror", "pattern batcalc.mul_noerror(v:sht, b:bat[:sht], s:bat[:oid]):bat[:sht] ", "CMDbatMUL;", "Return V * B with candidates list, overflow causes NIL value" ] [ "batcalc", "mul_noerror", "pattern batcalc.mul_noerror(v:sht, b:bat[:sht], s:bat[:oid], r:bat[:bit]):bat[:sht] ", "CMDbatMUL;", "Return V * B with candidates list, overflow causes NIL value" ] -[ "batcalc", "not", "pattern batcalc.not(b:bat[:bit]):bat[:bit] ", "CMDbatNOT;", "Return the Boolean inverse" ] -[ "batcalc", "not", "pattern batcalc.not(b:bat[:bit], r:bat[:bit]):bat[:bit] ", "CMDbatNOT;", "Return the Boolean inverse" ] -[ "batcalc", "not", "pattern batcalc.not(b:bat[:bit], s:bat[:msk]):bat[:bit] ", "CMDbatNOT;", "Return the Boolean inverse with candidates list" ] -[ "batcalc", "not", "pattern batcalc.not(b:bat[:bit], s:bat[:msk], r:bat[:bit]):bat[:bit] ", "CMDbatNOT;", "Return the Boolean inverse with candidates list" ] -[ "batcalc", "not", "pattern batcalc.not(b:bat[:bit], s:bat[:oid]):bat[:bit] ", "CMDbatNOT;", "Return the Boolean inverse with candidates list" ] -[ "batcalc", "not", "pattern batcalc.not(b:bat[:bit], s:bat[:oid], r:bat[:bit]):bat[:bit] ", "CMDbatNOT;", "Return the Boolean inverse with candidates list" ] +[ "batcalc", "not", "pattern batcalc.not(b:bat[:bit]):bat[:bit] ", "CMDbatNOT;", "Unary bitwise not over the tail of the bat" ] +[ "batcalc", "not", "pattern batcalc.not(b:bat[:bit], r:bat[:bit]):bat[:bit] ", "CMDbatNOT;", "Unary bitwise not over the tail of the bat" ] +[ "batcalc", "not", "pattern batcalc.not(b:bat[:bit], s:bat[:msk]):bat[:bit] ", "CMDbatNOT;", "Unary bitwise not over the tail of the bat with candidates list" ] +[ "batcalc", "not", "pattern batcalc.not(b:bat[:bit], s:bat[:msk], r:bat[:bit]):bat[:bit] ", "CMDbatNOT;", "Unary bitwise not over the tail of the bat with candidates list" ] +[ "batcalc", "not", "pattern batcalc.not(b:bat[:bit], s:bat[:oid]):bat[:bit] ", "CMDbatNOT;", "Unary bitwise not over the tail of the bat with candidates list" ] +[ "batcalc", "not", "pattern batcalc.not(b:bat[:bit], s:bat[:oid], r:bat[:bit]):bat[:bit] ", "CMDbatNOT;", "Unary bitwise not over the tail of the bat with candidates list" ] [ "batcalc", "not", "pattern batcalc.not(b:bat[:bte]):bat[:bte] ", "CMDbatNOT;", "Unary bitwise not over the tail of the bat" ] [ "batcalc", "not", "pattern batcalc.not(b:bat[:bte], r:bat[:bit]):bat[:bte] ", "CMDbatNOT;", "Unary bitwise not over the tail of the bat" ] [ "batcalc", "not", "pattern batcalc.not(b:bat[:bte], s:bat[:msk]):bat[:bte] ", "CMDbatNOT;", "Unary bitwise not over the tail of the bat with candidates list" ] @@ -15085,6 +15088,12 @@ stdout of test 'MAL-signatures` in direc [ "batcalc", "not", "pattern batcalc.not(b:bat[:lng], s:bat[:msk], r:bat[:bit]):bat[:lng] ", "CMDbatNOT;", "Unary bitwise not over the tail of the bat with candidates list" ] [ "batcalc", "not", "pattern batcalc.not(b:bat[:lng], s:bat[:oid]):bat[:lng] ", "CMDbatNOT;", "Unary bitwise not over the tail of the bat with candidates list" ] [ "batcalc", "not", "pattern batcalc.not(b:bat[:lng], s:bat[:oid], r:bat[:bit]):bat[:lng] ", "CMDbatNOT;", "Unary bitwise not over the tail of the bat with candidates list" ] +[ "batcalc", "not", "pattern batcalc.not(b:bat[:msk]):bat[:msk] ", "CMDbatNOT;", "Return the Boolean inverse" ] +[ "batcalc", "not", "pattern batcalc.not(b:bat[:msk], r:bat[:bit]):bat[:msk] ", "CMDbatNOT;", "Return the Boolean inverse" ] +[ "batcalc", "not", "pattern batcalc.not(b:bat[:msk], s:bat[:msk]):bat[:msk] ", "CMDbatNOT;", "Return the Boolean inverse with candidates list" ] +[ "batcalc", "not", "pattern batcalc.not(b:bat[:msk], s:bat[:msk], r:bat[:bit]):bat[:msk] ", "CMDbatNOT;", "Return the Boolean inverse with candidates list" ] +[ "batcalc", "not", "pattern batcalc.not(b:bat[:msk], s:bat[:oid]):bat[:msk] ", "CMDbatNOT;", "Return the Boolean inverse with candidates list" ] +[ "batcalc", "not", "pattern batcalc.not(b:bat[:msk], s:bat[:oid], r:bat[:bit]):bat[:msk] ", "CMDbatNOT;", "Return the Boolean inverse with candidates list" ] [ "batcalc", "not", "pattern batcalc.not(b:bat[:sht]):bat[:sht] ", "CMDbatNOT;", "Unary bitwise not over the tail of the bat" ] [ "batcalc", "not", "pattern batcalc.not(b:bat[:sht], r:bat[:bit]):bat[:sht] ", "CMDbatNOT;", "Unary bitwise not over the tail of the bat" ] [ "batcalc", "not", "pattern batcalc.not(b:bat[:sht], s:bat[:msk]):bat[:sht] ", "CMDbatNOT;", "Unary bitwise not over the tail of the bat with candidates list" ] 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 @@ -19445,6 +19445,9 @@ stdout of test 'MAL-signatures` in direc [ "batcalc", "ifthenelse", "pattern batcalc.ifthenelse(v:bit, b1:bat[:any_1], b2:bat[:any_1]):bat[:any_1] ", "CMDifthen;", "If-then-else operation to assemble a conditional result" ] [ "batcalc", "ifthenelse", "pattern batcalc.ifthenelse(v:bit, b1:bat[:any_1], v2:any_1):bat[:any_1] ", "CMDifthen;", "If-then-else operation to assemble a conditional result" ] [ "batcalc", "ifthenelse", "pattern batcalc.ifthenelse(v:bit, v1:any_1, b2:bat[:any_1]):bat[:any_1] ", "CMDifthen;", "If-then-else operation to assemble a conditional result" ] +[ "batcalc", "ifthenelse", "pattern batcalc.ifthenelse(v:msk, b1:bat[:any_1], b2:bat[:any_1]):bat[:any_1] ", "CMDifthen;", "If-then-else operation to assemble a conditional result" ] +[ "batcalc", "ifthenelse", "pattern batcalc.ifthenelse(v:msk, b1:bat[:any_1], v2:any_1):bat[:any_1] ", "CMDifthen;", "If-then-else operation to assemble a conditional result" ] +[ "batcalc", "ifthenelse", "pattern batcalc.ifthenelse(v:msk, v1:any_1, b2:bat[:any_1]):bat[:any_1] ", "CMDifthen;", "If-then-else operation to assemble a conditional result" ] [ "batcalc", "index", "command batcalc.index(v:bat[:str], u:bit):bat[:bte] ", "BATSTRindex_bte;", "Return the offsets as an index bat" ] [ "batcalc", "index", "command batcalc.index(v:bat[:str], u:bit):bat[:int] ", "BATSTRindex_int;", "Return the offsets as an index bat" ] [ "batcalc", "index", "command batcalc.index(v:bat[:str], u:bit):bat[:sht] ", "BATSTRindex_sht;", "Return the offsets as an index bat" ] @@ -21928,12 +21931,12 @@ stdout of test 'MAL-signatures` in direc [ "batcalc", "mul_noerror", "pattern batcalc.mul_noerror(v:sht, b:bat[:sht], s:bat[:msk], r:bat[:bit]):bat[:sht] ", "CMDbatMUL;", "Return V * B with candidates list, overflow causes NIL value" ] [ "batcalc", "mul_noerror", "pattern batcalc.mul_noerror(v:sht, b:bat[:sht], s:bat[:oid]):bat[:sht] ", "CMDbatMUL;", "Return V * B with candidates list, overflow causes NIL value" ] [ "batcalc", "mul_noerror", "pattern batcalc.mul_noerror(v:sht, b:bat[:sht], s:bat[:oid], r:bat[:bit]):bat[:sht] ", "CMDbatMUL;", "Return V * B with candidates list, overflow causes NIL value" ] -[ "batcalc", "not", "pattern batcalc.not(b:bat[:bit]):bat[:bit] ", "CMDbatNOT;", "Return the Boolean inverse" ] -[ "batcalc", "not", "pattern batcalc.not(b:bat[:bit], r:bat[:bit]):bat[:bit] ", "CMDbatNOT;", "Return the Boolean inverse" ] -[ "batcalc", "not", "pattern batcalc.not(b:bat[:bit], s:bat[:msk]):bat[:bit] ", "CMDbatNOT;", "Return the Boolean inverse with candidates list" ] -[ "batcalc", "not", "pattern batcalc.not(b:bat[:bit], s:bat[:msk], r:bat[:bit]):bat[:bit] ", "CMDbatNOT;", "Return the Boolean inverse with candidates list" ] -[ "batcalc", "not", "pattern batcalc.not(b:bat[:bit], s:bat[:oid]):bat[:bit] ", "CMDbatNOT;", "Return the Boolean inverse with candidates list" ] -[ "batcalc", "not", "pattern batcalc.not(b:bat[:bit], s:bat[:oid], r:bat[:bit]):bat[:bit] ", "CMDbatNOT;", "Return the Boolean inverse with candidates list" ] +[ "batcalc", "not", "pattern batcalc.not(b:bat[:bit]):bat[:bit] ", "CMDbatNOT;", "Unary bitwise not over the tail of the bat" ] +[ "batcalc", "not", "pattern batcalc.not(b:bat[:bit], r:bat[:bit]):bat[:bit] ", "CMDbatNOT;", "Unary bitwise not over the tail of the bat" ] +[ "batcalc", "not", "pattern batcalc.not(b:bat[:bit], s:bat[:msk]):bat[:bit] ", "CMDbatNOT;", "Unary bitwise not over the tail of the bat with candidates list" ] +[ "batcalc", "not", "pattern batcalc.not(b:bat[:bit], s:bat[:msk], r:bat[:bit]):bat[:bit] ", "CMDbatNOT;", "Unary bitwise not over the tail of the bat with candidates list" ] +[ "batcalc", "not", "pattern batcalc.not(b:bat[:bit], s:bat[:oid]):bat[:bit] ", "CMDbatNOT;", "Unary bitwise not over the tail of the bat with candidates list" ] +[ "batcalc", "not", "pattern batcalc.not(b:bat[:bit], s:bat[:oid], r:bat[:bit]):bat[:bit] ", "CMDbatNOT;", "Unary bitwise not over the tail of the bat with candidates list" ] [ "batcalc", "not", "pattern batcalc.not(b:bat[:bte]):bat[:bte] ", "CMDbatNOT;", "Unary bitwise not over the tail of the bat" ] [ "batcalc", "not", "pattern batcalc.not(b:bat[:bte], r:bat[:bit]):bat[:bte] ", "CMDbatNOT;", "Unary bitwise not over the tail of the bat" ] [ "batcalc", "not", "pattern batcalc.not(b:bat[:bte], s:bat[:msk]):bat[:bte] ", "CMDbatNOT;", "Unary bitwise not over the tail of the bat with candidates list" ] @@ -21958,6 +21961,12 @@ stdout of test 'MAL-signatures` in direc [ "batcalc", "not", "pattern batcalc.not(b:bat[:lng], s:bat[:msk], r:bat[:bit]):bat[:lng] ", "CMDbatNOT;", "Unary bitwise not over the tail of the bat with candidates list" ] [ "batcalc", "not", "pattern batcalc.not(b:bat[:lng], s:bat[:oid]):bat[:lng] ", "CMDbatNOT;", "Unary bitwise not over the tail of the bat with candidates list" ] [ "batcalc", "not", "pattern batcalc.not(b:bat[:lng], s:bat[:oid], r:bat[:bit]):bat[:lng] ", "CMDbatNOT;", "Unary bitwise not over the tail of the bat with candidates list" ] +[ "batcalc", "not", "pattern batcalc.not(b:bat[:msk]):bat[:msk] ", "CMDbatNOT;", "Return the Boolean inverse" ] +[ "batcalc", "not", "pattern batcalc.not(b:bat[:msk], r:bat[:bit]):bat[:msk] ", "CMDbatNOT;", "Return the Boolean inverse" ] +[ "batcalc", "not", "pattern batcalc.not(b:bat[:msk], s:bat[:msk]):bat[:msk] ", "CMDbatNOT;", "Return the Boolean inverse with candidates list" ] +[ "batcalc", "not", "pattern batcalc.not(b:bat[:msk], s:bat[:msk], r:bat[:bit]):bat[:msk] ", "CMDbatNOT;", "Return the Boolean inverse with candidates list" ] +[ "batcalc", "not", "pattern batcalc.not(b:bat[:msk], s:bat[:oid]):bat[:msk] ", "CMDbatNOT;", "Return the Boolean inverse with candidates list" ] +[ "batcalc", "not", "pattern batcalc.not(b:bat[:msk], s:bat[:oid], r:bat[:bit]):bat[:msk] ", "CMDbatNOT;", "Return the Boolean inverse with candidates list" ] [ "batcalc", "not", "pattern batcalc.not(b:bat[:sht]):bat[:sht] ", "CMDbatNOT;", "Unary bitwise not over the tail of the bat" ] [ "batcalc", "not", "pattern batcalc.not(b:bat[:sht], r:bat[:bit]):bat[:sht] ", "CMDbatNOT;", "Unary bitwise not over the tail of the bat" ] [ "batcalc", "not", "pattern batcalc.not(b:bat[:sht], s:bat[:msk]):bat[:sht] ", "CMDbatNOT;", "Unary bitwise not over the tail of the bat with candidates list" ] diff --git a/gdk/gdk_calc.c b/gdk/gdk_calc.c --- a/gdk/gdk_calc.c +++ b/gdk/gdk_calc.c @@ -284,6 +284,28 @@ BATcalcnot(BAT *b, BAT *s, BAT *r) return NULL; switch (ATOMbasetype(b->ttype)) { + case TYPE_msk: + if (ci.tpe == cand_dense) { + const uint32_t *restrict src = Tloc(b, (ci.seq - b->hseqbase) / 32); + uint32_t *restrict dst = Tloc(bn, 0); + int bits = (ci.seq - b->hseqbase) % 32; + ncand = (ncand + 31) / 32; + if (bits == 0) { + for (i = 0; i < ncand; i++) + dst[i] = ~src[i]; + } else { + for (i = 0; i < ncand; i++) + dst[i] = (~src[i] >> bits) | ~(src[i + 1] >> (32 - bits)); + } + if (ci.ncand % 32 != 0) + dst[ci.ncand / 32] &= (1U << (ci.ncand % 32)) - 1; + } else { + for (i = 0; i < ci.ncand; i++) { + x = canditer_next(&ci) - b->hseqbase; + mskSetVal(bn, i, !mskGetVal(b, x)); + } + } + break; case TYPE_bte: if (b->ttype == TYPE_bit) { UNARY_2TYPE_FUNC(bit, bit, NOTBIT); @@ -311,7 +333,7 @@ BATcalcnot(BAT *b, BAT *s, BAT *r) return NULL; } - BATsetcount(bn, ncand); + BATsetcount(bn, ci.ncand); /* NOT reverses the order, but NILs mess it up */ bn->tsorted = nils == 0 && b->trevsorted; @@ -338,6 +360,9 @@ VARcalcnot(ValPtr ret, const ValRecord * { ret->vtype = v->vtype; switch (ATOMbasetype(v->vtype)) { + case TYPE_msk: + ret->val.mval = !v->val.mval; + break; case TYPE_bte: if (is_bit_nil(v->val.btval)) ret->val.btval = bit_nil; diff --git a/monetdb5/modules/mal/01_batcalc.mal b/monetdb5/modules/mal/01_batcalc.mal --- a/monetdb5/modules/mal/01_batcalc.mal +++ b/monetdb5/modules/mal/01_batcalc.mal @@ -162,24 +162,43 @@ address CMDbatISNOTNIL comment "Unary check for notnil over the tail of the bat with candidates list"; -pattern not(b:bat[:bit]) :bat[:bit] +pattern not(b:bat[:msk]) :bat[:msk] address CMDbatNOT comment "Return the Boolean inverse"; -pattern not(b:bat[:bit],s:bat[:oid]) :bat[:bit] +pattern not(b:bat[:msk],s:bat[:oid]) :bat[:msk] +address CMDbatNOT +comment "Return the Boolean inverse with candidates list"; +pattern not(b:bat[:msk],s:bat[:msk]) :bat[:msk] address CMDbatNOT comment "Return the Boolean inverse with candidates list"; -pattern not(b:bat[:bit],s:bat[:msk]) :bat[:bit] +pattern not(b:bat[:msk],r:bat[:bit]) :bat[:msk] +address CMDbatNOT +comment "Return the Boolean inverse"; +pattern not(b:bat[:msk],s:bat[:oid],r:bat[:bit]) :bat[:msk] +address CMDbatNOT +comment "Return the Boolean inverse with candidates list"; +pattern not(b:bat[:msk],s:bat[:msk],r:bat[:bit]) :bat[:msk] address CMDbatNOT comment "Return the Boolean inverse with candidates list"; + +pattern not(b:bat[:bit]) :bat[:bit] +address CMDbatNOT +comment "Unary bitwise not over the tail of the bat"; +pattern not(b:bat[:bit],s:bat[:oid]) :bat[:bit] +address CMDbatNOT +comment "Unary bitwise not over the tail of the bat with candidates list"; +pattern not(b:bat[:bit],s:bat[:msk]) :bat[:bit] +address CMDbatNOT +comment "Unary bitwise not over the tail of the bat with candidates list"; pattern not(b:bat[:bit],r:bat[:bit]) :bat[:bit] address CMDbatNOT -comment "Return the Boolean inverse"; +comment "Unary bitwise not over the tail of the bat"; pattern not(b:bat[:bit],s:bat[:oid],r:bat[:bit]) :bat[:bit] address CMDbatNOT -comment "Return the Boolean inverse with candidates list"; +comment "Unary bitwise not over the tail of the bat with candidates list"; pattern not(b:bat[:bit],s:bat[:msk],r:bat[:bit]) :bat[:bit] address CMDbatNOT -comment "Return the Boolean inverse with candidates list"; +comment "Unary bitwise not over the tail of the bat with candidates list"; pattern not(b:bat[:bte]) :bat[:bte] address CMDbatNOT @@ -45609,6 +45628,18 @@ pattern ifthenelse(v:bit, b1:bat[:any_1] address CMDifthen comment "If-then-else operation to assemble a conditional result"; +pattern ifthenelse(v:msk, b1:bat[:any_1], b2:bat[:any_1]) :bat[:any_1] +address CMDifthen +comment "If-then-else operation to assemble a conditional result"; + +pattern ifthenelse(v:msk, v1:any_1, b2:bat[:any_1]) :bat[:any_1] +address CMDifthen +comment "If-then-else operation to assemble a conditional result"; + +pattern ifthenelse(v:msk, b1:bat[:any_1], v2:any_1) :bat[:any_1] +address CMDifthen +comment "If-then-else operation to assemble a conditional result"; + pattern ifthenelse(b:bat[:bit], v1:any_1, v2:any_1) :bat[:any_1] address CMDifthen comment "If-then-else operation to assemble a conditional result"; diff --git a/monetdb5/modules/mal/01_batcalc.mal.sh b/monetdb5/modules/mal/01_batcalc.mal.sh --- a/monetdb5/modules/mal/01_batcalc.mal.sh +++ b/monetdb5/modules/mal/01_batcalc.mal.sh @@ -68,7 +68,7 @@ done echo com="Return the Boolean inverse" -for tp in bit ${integer[@]}; do +for tp in msk bit ${integer[@]}; do cat <<EOF pattern not(b:bat[:$tp]) :bat[:$tp] address CMDbatNOT diff --git a/monetdb5/modules/mal/01_calc.mal.sh b/monetdb5/modules/mal/01_calc.mal.sh --- a/monetdb5/modules/mal/01_calc.mal.sh +++ b/monetdb5/modules/mal/01_calc.mal.sh @@ -336,6 +336,10 @@ pattern ifthenelse(b:bit,t:any_1,f:any_1 address CALCswitchbit comment "If VALUE is true return MIDDLE else RIGHT"; +pattern ifthenelse(b:msk,t:any_1,f:any_1):any_1 +address CALCswitchbit +comment "If VALUE is true return MIDDLE else RIGHT"; + command length(s:str) :int address CMDstrlength comment "Length of STRING"; _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list