Changeset: 4b0ee9d4f390 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=4b0ee9d4f390
Modified Files:
sql/backends/monet5/sql_fround.c
sql/backends/monet5/sql_fround_impl.h
sql/backends/monet5/sql_round.c
sql/backends/monet5/sql_round_impl.h
Branch: clean-candidates
Log Message:
Fix sorted property propagation and include less header files
diffs (232 lines):
diff --git a/sql/backends/monet5/sql_fround.c b/sql/backends/monet5/sql_fround.c
--- a/sql/backends/monet5/sql_fround.c
+++ b/sql/backends/monet5/sql_fround.c
@@ -8,17 +8,6 @@
#include "monetdb_config.h"
#include "sql.h"
-#include "sql_result.h"
-#include "sql_gencode.h"
-#include "sql_storage.h"
-#include "sql_scenario.h"
-#include "store_sequence.h"
-#include "sql_datetime.h"
-#include "rel_optimizer.h"
-#include "rel_distribute.h"
-#include "rel_select.h"
-#include "rel_exp.h"
-#include "rel_dump.h"
#include "mal_instruction.h"
#define CONCAT_2(a, b) a##b
@@ -34,15 +23,15 @@
#define STRING(a) #a
static void
-finalize_ouput_copy_sorted_property(bat *res, BAT *bn, BAT *b, str msg, bool
nils, BUN q)
+finalize_ouput_copy_sorted_property(bat *res, BAT *bn, BAT *b, str msg, bool
nils, BUN q, bool try_copy_sorted)
{
if (bn && !msg) {
BATsetcount(bn, q);
bn->tnil = nils;
bn->tnonil = !nils;
bn->tkey = BATcount(bn) <= 1;
- bn->tsorted = !b || b->tsorted;
- bn->trevsorted = !b || b->trevsorted;
+ bn->tsorted = ((try_copy_sorted && b->tsorted) || BATcount(bn)
<= 1);
+ bn->trevsorted = ((try_copy_sorted && b->trevsorted) ||
BATcount(bn) <= 1);
BBPkeepref(*res = bn->batCacheid);
} else if (bn)
BBPreclaim(bn);
diff --git a/sql/backends/monet5/sql_fround_impl.h
b/sql/backends/monet5/sql_fround_impl.h
--- a/sql/backends/monet5/sql_fround_impl.h
+++ b/sql/backends/monet5/sql_fround_impl.h
@@ -105,7 +105,7 @@ bat_dec_round_wrap(Client cntxt, MalBlkP
}
}
bailout:
- finalize_ouput_copy_sorted_property(res, bn, b, msg, nils, q);
+ finalize_ouput_copy_sorted_property(res, bn, b, msg, nils, q, true);
unfix_inputs(2, b, bs);
return msg;
}
@@ -179,7 +179,7 @@ bat_dec_round_wrap_cst(Client cntxt, Mal
}
bailout:
- finalize_ouput_copy_sorted_property(res, bn, NULL, msg, nils, q);
+ finalize_ouput_copy_sorted_property(res, bn, b, msg, nils, q, false);
unfix_inputs(2, b, bs);
return msg;
}
@@ -263,7 +263,7 @@ bat_dec_round_wrap_nocst(Client cntxt, M
}
bailout:
- finalize_ouput_copy_sorted_property(res, bn, left, msg, nils, q);
+ finalize_ouput_copy_sorted_property(res, bn, left, msg, nils, q, false);
unfix_inputs(4, left, lefts, right, rights);
return msg;
}
@@ -370,7 +370,7 @@ bat_round_wrap(Client cntxt, MalBlkPtr m
}
}
bailout:
- finalize_ouput_copy_sorted_property(res, bn, b, msg, nils, q);
+ finalize_ouput_copy_sorted_property(res, bn, b, msg, nils, q, true);
unfix_inputs(2, b, bs);
return msg;
}
@@ -445,7 +445,7 @@ bat_round_wrap_cst(Client cntxt, MalBlkP
}
bailout:
- finalize_ouput_copy_sorted_property(res, bn, NULL, msg, nils, q);
+ finalize_ouput_copy_sorted_property(res, bn, b, msg, nils, q, false);
unfix_inputs(2, b, bs);
return msg;
}
@@ -530,7 +530,7 @@ bat_round_wrap_nocst(Client cntxt, MalBl
}
bailout:
- finalize_ouput_copy_sorted_property(res, bn, left, msg, nils, q);
+ finalize_ouput_copy_sorted_property(res, bn, left, msg, nils, q, false);
unfix_inputs(4, left, lefts, right, rights);
return msg;
}
diff --git a/sql/backends/monet5/sql_round.c b/sql/backends/monet5/sql_round.c
--- a/sql/backends/monet5/sql_round.c
+++ b/sql/backends/monet5/sql_round.c
@@ -8,17 +8,6 @@
#include "monetdb_config.h"
#include "sql.h"
-#include "sql_result.h"
-#include "sql_gencode.h"
-#include "sql_storage.h"
-#include "sql_scenario.h"
-#include "store_sequence.h"
-#include "sql_datetime.h"
-#include "rel_optimizer.h"
-#include "rel_distribute.h"
-#include "rel_select.h"
-#include "rel_exp.h"
-#include "rel_dump.h"
#include "mal_instruction.h"
#define CONCAT_2(a, b) a##b
@@ -36,15 +25,15 @@
#define BIG lng /* a larger type */
static void
-finalize_ouput_copy_sorted_property(bat *res, BAT *bn, BAT *b, str msg, bool
nils, BUN q)
+finalize_ouput_copy_sorted_property(bat *res, BAT *bn, BAT *b, str msg, bool
nils, BUN q, bool try_copy_sorted)
{
if (bn && !msg) {
BATsetcount(bn, q);
bn->tnil = nils;
bn->tnonil = !nils;
bn->tkey = BATcount(bn) <= 1;
- bn->tsorted = !b || b->tsorted;
- bn->trevsorted = !b || b->trevsorted;
+ bn->tsorted = ((try_copy_sorted && b && b->tsorted) ||
BATcount(bn) <= 1);
+ bn->trevsorted = ((try_copy_sorted && b && b->trevsorted) ||
BATcount(bn) <= 1);
BBPkeepref(*res = bn->batCacheid);
} else if (bn)
BBPreclaim(bn);
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
@@ -116,7 +116,7 @@ bat_dec_round_wrap(Client cntxt, MalBlkP
}
}
bailout:
- finalize_ouput_copy_sorted_property(res, bn, b, msg, nils, q);
+ finalize_ouput_copy_sorted_property(res, bn, b, msg, nils, q, true);
unfix_inputs(2, b, bs);
return msg;
}
@@ -190,7 +190,7 @@ bat_dec_round_wrap_cst(Client cntxt, Mal
}
bailout:
- finalize_ouput_copy_sorted_property(res, bn, NULL, msg, nils, q);
+ finalize_ouput_copy_sorted_property(res, bn, b, msg, nils, q, false);
unfix_inputs(2, b, bs);
return msg;
}
@@ -274,7 +274,7 @@ bat_dec_round_wrap_nocst(Client cntxt, M
}
bailout:
- finalize_ouput_copy_sorted_property(res, bn, left, msg, nils, q);
+ finalize_ouput_copy_sorted_property(res, bn, left, msg, nils, q, false);
unfix_inputs(4, left, lefts, right, rights);
return msg;
}
@@ -387,7 +387,7 @@ bat_round_wrap(Client cntxt, MalBlkPtr m
}
bailout:
- finalize_ouput_copy_sorted_property(res, bn, b, msg, nils, q);
+ finalize_ouput_copy_sorted_property(res, bn, b, msg, nils, q, true);
unfix_inputs(2, b, bs);
return msg;
}
@@ -457,7 +457,7 @@ bat_round_wrap_cst(Client cntxt, MalBlkP
}
bailout:
- finalize_ouput_copy_sorted_property(res, bn, b, msg, nils, q);
+ finalize_ouput_copy_sorted_property(res, bn, b, msg, nils, q, false);
unfix_inputs(2, b, bs);
return msg;
}
@@ -537,7 +537,7 @@ bat_round_wrap_nocst(Client cntxt, MalBl
}
bailout:
- finalize_ouput_copy_sorted_property(res, bn, left, msg, nils, q);
+ finalize_ouput_copy_sorted_property(res, bn, left, msg, nils, q, false);
unfix_inputs(4, left, lefts, right, rights);
return msg;
}
@@ -717,17 +717,8 @@ batstr_2dec(Client cntxt, MalBlkPtr mb,
}
bailout:
+ finalize_ouput_copy_sorted_property(r, res, b, msg, nils, q, false);
unfix_inputs(2, b, s);
- if (res && !msg) {
- BATsetcount(res, q);
- res->tnil = nils;
- res->tnonil = !nils;
- res->tkey = BATcount(res) <= 1;
- res->tsorted = BATcount(res) <= 1;
- res->trevsorted = BATcount(res) <= 1;
- BBPkeepref(*r = res->batCacheid);
- } else if (res)
- BBPreclaim(res);
return msg;
}
@@ -845,17 +836,8 @@ batdec2second_interval(Client cntxt, Mal
}
bailout:
+ finalize_ouput_copy_sorted_property(r, res, b, msg, nils, q, false);
unfix_inputs(2, b, s);
- if (res && !msg) {
- BATsetcount(res, q);
- res->tnil = nils;
- res->tnonil = !nils;
- res->tkey = BATcount(res) <= 1;
- res->tsorted = BATcount(res) <= 1;
- res->trevsorted = BATcount(res) <= 1;
- BBPkeepref(*r = res->batCacheid);
- } else if (res)
- BBPreclaim(res);
return msg;
}
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list