Changeset: 97174f0e320d for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=97174f0e320d
Modified Files:
        gdk/gdk_select.c
        monetdb5/modules/mal/Tests/orderidx01.mal
Branch: leftmart
Log Message:

Sort cand list the fast way, and fix the tests io.prints


diffs (86 lines):

diff --git a/gdk/gdk_select.c b/gdk/gdk_select.c
--- a/gdk/gdk_select.c
+++ b/gdk/gdk_select.c
@@ -1539,11 +1539,15 @@ BATsubselect(BAT *b, BAT *s, const void 
                } else {
                        /* match: [low..high) */
                        if (s) {
-                               oid o = (oid) low + b->hseqbase;
-                               low = SORTfndfirst(s, &o) - BUNfirst(s);
-                               o = (oid) high + b->hseqbase;
-                               high = SORTfndfirst(s, &o) - BUNfirst(s);
-                               bn = doubleslice(s, 0, 0, low, high);
+                               if (use_orderidx) {
+                                       return GDK_FAIL; /* fail until fixed*/
+                               } else {
+                                       oid o = (oid) low + b->hseqbase;
+                                       low = SORTfndfirst(s, &o) - BUNfirst(s);
+                                       o = (oid) high + b->hseqbase;
+                                       high = SORTfndfirst(s, &o) - 
BUNfirst(s);
+                                       bn = doubleslice(s, 0, 0, low, high);
+                               }
                        } else {
                                if (use_orderidx) {
                                        BAT *order;
@@ -1552,7 +1556,15 @@ BATsubselect(BAT *b, BAT *s, const void 
                                                GDKerror("Runtime object (order 
index) not found");
                                        }
                                        bn = BATslice(order, low + 
order->hseqbase, high + order->hseqbase);
-                                       BATorder(BATmirror(bn));
+                                       /* output must be sorted */
+                                       GDKqsort((oid *) Tloc(bn, 
BUNfirst(bn)), NULL, NULL, (size_t) bn->batCount, sizeof(oid), 0, TYPE_oid);
+                                       bn->tsorted = 1;
+                                       bn->trevsorted = bn->batCount <= 1;
+                                       bn->tkey = 1;
+                                       bn->tseqbase = (bn->tdense = 
bn->batCount <= 1) != 0 ? BUNfirst(bn) : oid_nil;
+                                       bn->T->nil = 0;
+                                       bn->T->nonil = 1;
+
                                } else {
                                        bn = doublerange(0, 0,
                                                         low + b->hseqbase,
diff --git a/monetdb5/modules/mal/Tests/orderidx01.mal 
b/monetdb5/modules/mal/Tests/orderidx01.mal
--- a/monetdb5/modules/mal/Tests/orderidx01.mal
+++ b/monetdb5/modules/mal/Tests/orderidx01.mal
@@ -13,30 +13,32 @@ bat.append(bv,1674978691 );
 bat.append(bv,1863672321 );
 bat.append(bv,58690783 );
 
+io.print(bv);
+
 s0:= 
algebra.subselect(bv,nil:bat[:oid,:oid],nil:int,nil:int,false,false,false);
-io.print(s0,bv);
+io.print(s0);
 
 s1:= 
algebra.subselect(bv,nil:bat[:oid,:oid],nil:int,959217167,true,true,false);
-io.print(s1,bv);
+io.print(s1);
 
 s2:= 
algebra.subselect(bv,nil:bat[:oid,:oid],959217167,959217167,true,true,false);
-io.print(s2,bv);
+io.print(s2);
 
 s3:= 
algebra.subselect(bv,nil:bat[:oid,:oid],1863672321,nil:int,true,true,false);
-io.print(s3,bv);
+io.print(s3);
 
 # introduce an oid index, it should produce the same results
 bat.orderidx(bv,3);
 ord := bat.getorderidx(bv);
-io.print(ord,bv);
+io.print(ord);
 x0:= 
algebra.subselect(bv,nil:bat[:oid,:oid],nil:int,nil:int,false,false,false);
-io.print(x0,bv);
+io.print(x0);
 
 x1:= 
algebra.subselect(bv,nil:bat[:oid,:oid],nil:int,959217167,true,true,false);
-io.print(x1,bv);
+io.print(x1);
 
 x2:= 
algebra.subselect(bv,nil:bat[:oid,:oid],959217167,959217167,true,true,false);
-io.print(x2,bv);
+io.print(x2);
 
 x3:= 
algebra.subselect(bv,nil:bat[:oid,:oid],1863672321,nil:int,true,true,false);
-io.print(x3,bv);
+io.print(x3);
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to