Changeset: 95ab8167a332 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB/rev/95ab8167a332
Modified Files:
        gdk/gdk_batop.c
Branch: Mar2025
Log Message:

When appending a bat to a sorted bat, maybe invest in sorted check.
If we don't know whether the to-be-appended is sorted, and the first
value would maintain sortedness of the result, check whether the new bat
is sorted so that we know whether the result is sorted.


diffs (30 lines):

diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -946,6 +946,26 @@ BATappend2(BAT *b, BAT *n, BAT *s, bool 
                int xx = ATOMcmp(b->ttype,
                                 BUNtail(ni, ci.seq - hseq),
                                 BUNtail(bi, last));
+               if (b->tsorted && !ni.sorted && ni.nosorted == 0 && xx >= 0) {
+                       /* b is currently sorted; we don't know whether
+                        * n is sorted; first value of n is at least as
+                        * large as last value of b: we invest in an
+                        * order check of n to see whether the result is
+                        * still sorted */
+                       (void) BATordered(n);
+                       bat_iterator_end(&ni);
+                       ni = bat_iterator(n);
+               }
+               if (b->trevsorted && !ni.revsorted && ni.norevsorted == 0 && xx 
<= 0) {
+                       /* b is currently reverse sorted; we don't know
+                        * whether n is reverse sorted; first value of n
+                        * is at most as large as last value of b: we
+                        * invest in an order check of n to see whether
+                        * the result is still reverse sorted */
+                       (void) BATordered_rev(n);
+                       bat_iterator_end(&ni);
+                       ni = bat_iterator(n);
+               }
                if (b->tsorted && (!ni.sorted || xx < 0)) {
                        b->tsorted = false;
                        b->tnosorted = 0;
_______________________________________________
checkin-list mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to