Changeset: 60515626d60f for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=60515626d60f
Modified Files:
monetdb5/modules/atoms/mtime.c
sql/backends/monet5/sql_cast.c
sql/backends/monet5/sql_round_impl.h
sql/backends/monet5/sql_time.c
Branch: clean-candidates
Log Message:
Use right candidate list type. Also added missing dense case
diffs (truncated from 418 to 300 lines):
diff --git a/monetdb5/modules/atoms/mtime.c b/monetdb5/modules/atoms/mtime.c
--- a/monetdb5/modules/atoms/mtime.c
+++ b/monetdb5/modules/atoms/mtime.c
@@ -167,13 +167,13 @@ NAME##_bulk(Client cntxt, MalBlkPtr mb,
INIT_OUTPUT(dst, bn);
\
if (ci.tpe == cand_dense) {
\
for (BUN i = 0; i < n; i++) {
\
- oid p = (BUN) (canditer_next_dense(&ci) - off);
\
+ oid p = (canditer_next_dense(&ci) - off);
\
FUNC_CALL(FUNC, dst[i], GET_NEXT_SRC(src1, p))
\
nils |= is_##OUTTYPE##_nil(dst[i]);
\
}
\
} else {
\
for (BUN i = 0; i < n; i++) {
\
- oid p = (BUN) (canditer_next(&ci) - off);
\
+ oid p = (canditer_next(&ci) - off);
\
FUNC_CALL(FUNC, dst[i], GET_NEXT_SRC(src1, p))
\
nils |= is_##OUTTYPE##_nil(dst[i]);
\
}
\
@@ -274,16 +274,16 @@ NAME##_bulk(Client cntxt, MalBlkPtr mb,
INIT_OUTPUT(dst, bn);
\
if (ci1.tpe == cand_dense && ci2.tpe == cand_dense) {
\
for (BUN i = 0; i < n; i++) {
\
- oid p1 = (BUN) (canditer_next_dense(&ci1) - off1);
\
- oid p2 = (BUN) (canditer_next_dense(&ci2) - off2);
\
+ oid p1 = (canditer_next_dense(&ci1) - off1);
\
+ oid p2 = (canditer_next_dense(&ci2) - off2);
\
FUNC_CALL(FUNC, res, GET_NEXT_SRC1(src1, p1),
GET_NEXT_SRC2(src2, p2)) \
APPEND_NEXT(MALFUNC);
\
nils |= is_##OUTTYPE##_nil(res);
\
}
\
} else {
\
for (BUN i = 0; i < n; i++) {
\
- oid p1 = (BUN) (canditer_next(&ci1) - off1);
\
- oid p2 = (BUN) (canditer_next(&ci2) - off2);
\
+ oid p1 = (canditer_next(&ci1) - off1);
\
+ oid p2 = (canditer_next(&ci2) - off2);
\
FUNC_CALL(FUNC, res, GET_NEXT_SRC1(src1, p1),
GET_NEXT_SRC2(src2, p2)) \
APPEND_NEXT(MALFUNC);
\
nils |= is_##OUTTYPE##_nil(res);
\
@@ -351,14 +351,14 @@ NAME##_bulk_p1(Client cntxt, MalBlkPtr m
INIT_OUTPUT(dst, bn);
\
if (ci2.tpe == cand_dense) {
\
for (BUN i = 0; i < n; i++) {
\
- oid p2 = (BUN) (canditer_next_dense(&ci2) - off2);
\
+ oid p2 = (canditer_next_dense(&ci2) - off2);
\
FUNC_CALL(FUNC, res, *src1, GET_NEXT_SRC2(src2, p2))
\
APPEND_NEXT(MALFUNC);
\
nils |= is_##OUTTYPE##_nil(res);
\
}
\
} else {
\
for (BUN i = 0; i < n; i++) {
\
- oid p2 = (BUN) (canditer_next(&ci2) - off2);
\
+ oid p2 = (canditer_next(&ci2) - off2);
\
FUNC_CALL(FUNC, res, *src1, GET_NEXT_SRC2(src2, p2))
\
APPEND_NEXT(MALFUNC);
\
nils |= is_##OUTTYPE##_nil(res);
\
@@ -422,14 +422,14 @@ NAME##_bulk_p2(Client cntxt, MalBlkPtr m
INIT_OUTPUT(dst, bn);
\
if (ci1.tpe == cand_dense) {
\
for (BUN i = 0; i < n; i++) {
\
- oid p1 = (BUN) (canditer_next_dense(&ci1) - off1);
\
+ oid p1 = (canditer_next_dense(&ci1) - off1);
\
FUNC_CALL(FUNC, res, GET_NEXT_SRC1(src1, p1), *src2)
\
APPEND_NEXT(MALFUNC);
\
nils |= is_##OUTTYPE##_nil(res);
\
}
\
} else {
\
for (BUN i = 0; i < n; i++) {
\
- oid p1 = (BUN) (canditer_next(&ci1) - off1);
\
+ oid p1 = (canditer_next(&ci1) - off1);
\
FUNC_CALL(FUNC, res, GET_NEXT_SRC1(src1, p1), *src2)
\
APPEND_NEXT(MALFUNC);
\
nils |= is_##OUTTYPE##_nil(res);
\
diff --git a/sql/backends/monet5/sql_cast.c b/sql/backends/monet5/sql_cast.c
--- a/sql/backends/monet5/sql_cast.c
+++ b/sql/backends/monet5/sql_cast.c
@@ -69,7 +69,7 @@ batstr_2_blob(bat *res, const bat *bid,
if (ci.tpe == cand_dense) {
for (BUN i = 0; i < q; i++) {
- BUN p = (BUN) (canditer_next_dense(&ci) - off);
+ oid p = (canditer_next_dense(&ci) - off);
str v = (str) BUNtvar(bi, p);
if ((msg = str_2_blob_imp(&r, &rlen, v)))
@@ -82,7 +82,7 @@ batstr_2_blob(bat *res, const bat *bid,
}
} else {
for (BUN i = 0; i < q; i++) {
- BUN p = (BUN) (canditer_next(&ci) - off);
+ oid p = (canditer_next(&ci) - off);
str v = (str) BUNtvar(bi, p);
if ((msg = str_2_blob_imp(&r, &rlen, v)))
@@ -266,7 +266,7 @@ SQLbatstr_cast(Client cntxt, MalBlkPtr m
if (ci.tpe == cand_dense) {
if (from_str) { /* string to string */
for (BUN i = 0; i < q; i++) {
- BUN p = (BUN) (canditer_next_dense(&ci) - off);
+ oid p = (canditer_next_dense(&ci) - off);
str v = (str) BUNtail(bi, p);
if (strNil(v)) {
@@ -286,7 +286,7 @@ SQLbatstr_cast(Client cntxt, MalBlkPtr m
}
} else { /* any other type to string */
for (BUN i = 0; i < q; i++) {
- BUN p = (BUN) (canditer_next_dense(&ci) - off);
+ oid p = (canditer_next_dense(&ci) - off);
ptr v = BUNtail(bi, p);
if ((msg = SQLstr_cast_any_type(&r, &rlen, m,
eclass, d1, s1, has_tz, v, tpe, digits)) != MAL_SUCCEED)
@@ -301,7 +301,7 @@ SQLbatstr_cast(Client cntxt, MalBlkPtr m
} else {
if (from_str) { /* string to string */
for (BUN i = 0; i < q; i++) {
- BUN p = (BUN) (canditer_next(&ci) - off);
+ oid p = (canditer_next(&ci) - off);
str v = (str) BUNtail(bi, p);
if (strNil(v)) {
@@ -321,7 +321,7 @@ SQLbatstr_cast(Client cntxt, MalBlkPtr m
}
} else { /* any other type to string */
for (BUN i = 0; i < q; i++) {
- BUN p = (BUN) (canditer_next(&ci) - off);
+ oid p = (canditer_next(&ci) - off);
ptr v = BUNtail(bi, p);
if ((msg = SQLstr_cast_any_type(&r, &rlen, m,
eclass, d1, s1, has_tz, v, tpe, digits)) != MAL_SUCCEED)
diff --git a/sql/backends/monet5/sql_round_impl.h
b/sql/backends/monet5/sql_round_impl.h
--- a/sql/backends/monet5/sql_round_impl.h
+++ b/sql/backends/monet5/sql_round_impl.h
@@ -398,15 +398,28 @@ batstr_2dec(Client cntxt, MalBlkPtr mb,
}
ret = (TYPE*) Tloc(res, 0);
- for (BUN i = 0 ; i < q ; i++) {
- BUN p = (BUN) (canditer_next(&ci) - off);
- const str next = BUNtail(bi, p);
+ if (ci.tpe == cand_dense) {
+ for (BUN i = 0; i < q; i++) {
+ oid p = (canditer_next_dense(&ci) - off);
+ const str next = BUNtail(bi, p);
- if (strNil(next)) {
- ret[i] = NIL(TYPE);
- nils = true;
- } else if ((msg = str_2dec_body(&(ret[i]), next, d, sk)))
- goto bailout;
+ if (strNil(next)) {
+ ret[i] = NIL(TYPE);
+ nils = true;
+ } else if ((msg = str_2dec_body(&(ret[i]), next, d,
sk)))
+ goto bailout;
+ }
+ } else {
+ for (BUN i = 0; i < q; i++) {
+ oid p = (canditer_next(&ci) - off);
+ const str next = BUNtail(bi, p);
+
+ if (strNil(next)) {
+ ret[i] = NIL(TYPE);
+ nils = true;
+ } else if ((msg = str_2dec_body(&(ret[i]), next, d,
sk)))
+ goto bailout;
+ }
}
bailout:
@@ -494,9 +507,10 @@ batdec2second_interval(Client cntxt, Mal
divider = scales[d];
}
+ /* the cast from decimal to interval is now deactivated. So adding the
canditer_next_dense case is not worth */
if (sc < 3) {
for (BUN i = 0 ; i < q ; i++) {
- BUN p = (BUN) (canditer_next(&ci) - off);
+ oid p = (canditer_next(&ci) - off);
if (ISNIL(TYPE)(src[p])) {
ret[i] = lng_nil;
nils = true;
@@ -508,7 +522,7 @@ batdec2second_interval(Client cntxt, Mal
}
} else if (sc > 3) {
for (BUN i = 0 ; i < q ; i++) {
- BUN p = (BUN) (canditer_next(&ci) - off);
+ oid p = (canditer_next(&ci) - off);
if (ISNIL(TYPE)(src[p])) {
ret[i] = lng_nil;
nils = true;
@@ -521,7 +535,7 @@ batdec2second_interval(Client cntxt, Mal
}
} else {
for (BUN i = 0 ; i < q ; i++) {
- BUN p = (BUN) (canditer_next(&ci) - off);
+ oid p = (canditer_next(&ci) - off);
if (ISNIL(TYPE)(src[p])) {
ret[i] = lng_nil;
nils = true;
diff --git a/sql/backends/monet5/sql_time.c b/sql/backends/monet5/sql_time.c
--- a/sql/backends/monet5/sql_time.c
+++ b/sql/backends/monet5/sql_time.c
@@ -77,7 +77,7 @@ daytime_2time_daytime(Client cntxt, MalB
daytime *restrict vals = (daytime*) Tloc(b, 0);
if (ci.tpe == cand_dense) {
for (BUN i = 0; i < q; i++) {
- BUN p = (BUN) (canditer_next_dense(&ci) - off);
+ oid p = (canditer_next_dense(&ci) - off);
daytime next = vals[p];
if (is_daytime_nil(next)) {
@@ -89,7 +89,7 @@ daytime_2time_daytime(Client cntxt, MalB
}
} else {
for (BUN i = 0 ; i < q ; i++) {
- BUN p = (BUN) (canditer_next(&ci) - off);
+ oid p = (canditer_next(&ci) - off);
daytime next = vals[p];
if (is_daytime_nil(next)) {
@@ -192,7 +192,7 @@ second_interval_2_daytime(Client cntxt,
lng *restrict vals = (lng*) Tloc(b, 0);
if (ci.tpe == cand_dense) {
for (BUN i = 0 ; i < q ; i++) {
- BUN p = (BUN) (canditer_next_dense(&ci) - off);
+ oid p = (canditer_next_dense(&ci) - off);
lng next = vals[p];
if (is_lng_nil(next)) {
@@ -204,7 +204,7 @@ second_interval_2_daytime(Client cntxt,
}
} else {
for (BUN i = 0 ; i < q ; i++) {
- BUN p = (BUN) (canditer_next(&ci) - off);
+ oid p = (canditer_next(&ci) - off);
lng next = vals[p];
if (is_lng_nil(next)) {
@@ -335,7 +335,7 @@ str_2time_daytimetz_internal(ptr out, pt
BATiter it = bat_iterator(b);
if (ci.tpe == cand_dense) {
for (BUN i = 0 ; i < q && !msg; i++) {
- BUN p = (BUN) (canditer_next_dense(&ci) - off);
+ oid p = (canditer_next_dense(&ci) - off);
str next = BUNtail(it, p);
if (strNil(next)) {
@@ -347,7 +347,7 @@ str_2time_daytimetz_internal(ptr out, pt
}
} else {
for (BUN i = 0 ; i < q && !msg; i++) {
- BUN p = (BUN) (canditer_next(&ci) - off);
+ oid p = (canditer_next(&ci) - off);
str next = BUNtail(it, p);
if (strNil(next)) {
@@ -476,7 +476,7 @@ timestamp_2_daytime(Client cntxt, MalBlk
timestamp *restrict vals = (timestamp*) Tloc(b, 0);
if (ci.tpe == cand_dense) {
for (BUN i = 0 ; i < q; i++) {
- BUN p = (BUN) (canditer_next_dense(&ci) - off);
+ oid p = (canditer_next_dense(&ci) - off);
timestamp next = vals[p];
if (is_timestamp_nil(next)) {
@@ -488,7 +488,7 @@ timestamp_2_daytime(Client cntxt, MalBlk
}
} else {
for (BUN i = 0 ; i < q; i++) {
- BUN p = (BUN) (canditer_next(&ci) - off);
+ oid p = (canditer_next(&ci) - off);
timestamp next = vals[p];
if (is_timestamp_nil(next)) {
@@ -562,13 +562,13 @@ date_2_timestamp(Client cntxt, MalBlkPtr
date *restrict vals = (date*) Tloc(b, 0);
if (ci.tpe == cand_dense) {
for (BUN i = 0 ; i < q; i++) {
- BUN p = (BUN) (canditer_next_dense(&ci) - off);
+ oid p = (canditer_next_dense(&ci) - off);
ret[i] = timestamp_fromdate(vals[p]);
nils |= is_timestamp_nil(ret[i]);
}
} else {
for (BUN i = 0 ; i < q; i++) {
- BUN p = (BUN) (canditer_next(&ci) - off);
+ oid p = (canditer_next(&ci) - off);
ret[i] = timestamp_fromdate(vals[p]);
nils |= is_timestamp_nil(ret[i]);
}
@@ -664,7 +664,7 @@ timestamp_2time_timestamp(Client cntxt,
timestamp *restrict vals = (timestamp*) Tloc(b, 0);
if (ci.tpe == cand_dense) {
for (BUN i = 0 ; i < q; i++) {
- BUN p = (BUN) (canditer_next_dense(&ci) - off);
+ oid p = (canditer_next_dense(&ci) - off);
timestamp next = vals[p];
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list