Changeset: 57e3815f3d63 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=57e3815f3d63
Modified Files:
        monetdb5/mal/Tests/blkjoin.mal
        monetdb5/modules/kernel/algebra.c
        monetdb5/modules/kernel/algebra.h
        monetdb5/modules/kernel/algebra.mal
        monetdb5/modules/kernel/bat5.mal
        monetdb5/modules/mal/mat.c
        monetdb5/modules/mal/mat.h
        monetdb5/modules/mal/mat.mal
        monetdb5/optimizer/opt_cluster.c
        monetdb5/optimizer/opt_emptySet.c
        monetdb5/optimizer/opt_mapreduce.c
        monetdb5/optimizer/opt_prelude.c
        monetdb5/optimizer/opt_prelude.h
        monetdb5/optimizer/opt_support.c
Branch: default
Log Message:

Rename sort operations, headless cleanup


diffs (truncated from 406 to 300 lines):

diff --git a/monetdb5/mal/Tests/blkjoin.mal b/monetdb5/mal/Tests/blkjoin.mal
--- a/monetdb5/mal/Tests/blkjoin.mal
+++ b/monetdb5/mal/Tests/blkjoin.mal
@@ -150,7 +150,7 @@ lb2:= nil;
 #bat.save(rb2);
 ## what if you sort first
 #t0:= alarm.usec();
-#s1 := algebra.sortTail(lb2);
+#s1 := algebra.sort(lb2);
 #t1:= alarm.usec();
 #d0:= t1-t0;
 #d1:= d0;
@@ -158,7 +158,7 @@ lb2:= nil;
 #lb2 := nil;
 #bat.save(s1);
 #t0:= alarm.usec();
-#s2 := algebra.sortTail(rb2);
+#s2 := algebra.sort(rb2);
 #t1:= alarm.usec();
 #d0:= t1-t0;
 #d1:= d1+d0;
diff --git a/monetdb5/modules/kernel/algebra.c 
b/monetdb5/modules/kernel/algebra.c
--- a/monetdb5/modules/kernel/algebra.c
+++ b/monetdb5/modules/kernel/algebra.c
@@ -1444,101 +1444,6 @@ ALGtsort_rev(bat *result, const bat *bid
 }
 
 str
-ALGhsort(bat *result, const bat *bid)
-{
-       BAT *b, *bn;
-
-       if ((b = BATdescriptor(*bid)) == NULL) {
-               throw(MAL, "algebra.hsort", RUNTIME_OBJECT_MISSING);
-       }
-       bn = BATsort(b);
-       if (bn) {
-               if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ);
-               *result = bn->batCacheid;
-               BBPkeepref(*result);
-               BBPunfix(b->batCacheid);
-               return MAL_SUCCEED;
-       }
-       BBPunfix(b->batCacheid);
-       throw(MAL, "algebra.hsort", GDK_EXCEPTION);
-}
-
-str
-ALGhsort_rev(bat *result, const bat *bid)
-{
-       BAT *b, *bn;
-
-       if ((b = BATdescriptor(*bid)) == NULL) {
-               throw(MAL, "algebra.tsort", RUNTIME_OBJECT_MISSING);
-       }
-       bn = BATsort_rev(b);
-       if (bn) {
-               if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ);
-               *result = bn->batCacheid;
-               BBPkeepref(*result);
-               BBPunfix(b->batCacheid);
-               return MAL_SUCCEED;
-       }
-       BBPunfix(b->batCacheid);
-       throw(MAL, "algebra.tsort", GDK_EXCEPTION);
-}
-str
-ALGhtsort(bat *result, const bat *lid)
-{
-       BAT *b, *bm = NULL, *bn = NULL;
-
-       if ((b = BATdescriptor(*lid)) == NULL) {
-               throw(MAL, "algebra.htsort", RUNTIME_OBJECT_MISSING);
-       }
-       bm = BATmirror(BATsort(BATmirror(b)));
-       if (bm) {
-               bn = BATssort(bm);
-               if (bn) {
-                       if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ);
-                       *result = bn->batCacheid;
-                       BBPkeepref(*result);
-                       BBPunfix(bm->batCacheid);
-                       BBPunfix(b->batCacheid);
-                       return MAL_SUCCEED;
-               }
-               BBPunfix(bm->batCacheid);
-               BBPunfix(b->batCacheid);
-               throw(MAL, "algebra.htsort", GDK_EXCEPTION);
-       }
-       BBPunfix(b->batCacheid);
-       throw(MAL, "algebra.htsort", GDK_EXCEPTION);
-}
-
-str
-ALGthsort(bat *result, const bat *lid)
-{
-       BAT *b, *bm = NULL, *bn = NULL;
-
-       if ((b = BATdescriptor(*lid)) == NULL) {
-               throw(MAL, "algebra.thsort", RUNTIME_OBJECT_MISSING);
-       }
-       bm = BATmirror(BATsort(b));
-       if (bm) {
-               bn = BATssort(bm);
-               if (bn) {
-                       bn = BATmirror(bn);
-                       if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ);
-                       *result = bn->batCacheid;
-                       BBPkeepref(*result);
-                       BBPunfix(bm->batCacheid);
-                       BBPunfix(b->batCacheid);
-                       return MAL_SUCCEED;
-               }
-               BBPunfix(bm->batCacheid);
-               BBPunfix(b->batCacheid);
-               throw(MAL, "algebra.thsort", GDK_EXCEPTION);
-       }
-       BBPunfix(b->batCacheid);
-       throw(MAL, "algebra.thsort", GDK_EXCEPTION);
-}
-
-
-str
 ALGsubsort33(bat *result, bat *norder, bat *ngroup, const bat *bid, const bat 
*order, const bat *group, const bit *reverse, const bit *stable)
 {
        BAT *bn = NULL, *on = NULL, *gn = NULL;
diff --git a/monetdb5/modules/kernel/algebra.h 
b/monetdb5/modules/kernel/algebra.h
--- a/monetdb5/modules/kernel/algebra.h
+++ b/monetdb5/modules/kernel/algebra.h
@@ -100,10 +100,6 @@ algebra_export str ALGsample(bat *result
 
 algebra_export str ALGtsort(bat *result, const bat *bid);
 algebra_export str ALGtsort_rev(bat *result, const bat *bid);
-algebra_export str ALGhsort(bat *result, const bat *bid);
-algebra_export str ALGhsort_rev(bat *result, const bat *bid);
-algebra_export str ALGhtsort(bat *result, const bat *lid);
-algebra_export str ALGthsort(bat *result, const bat *lid);
 algebra_export str ALGssort(bat *result, const bat *bid);
 algebra_export str ALGssort_rev(bat *result, const bat *bid);
 algebra_export str ALGsubsort11(bat *result, const bat *bid, const bit 
*reverse, const bit *stable);
diff --git a/monetdb5/modules/kernel/algebra.mal 
b/monetdb5/modules/kernel/algebra.mal
--- a/monetdb5/modules/kernel/algebra.mal
+++ b/monetdb5/modules/kernel/algebra.mal
@@ -84,30 +84,10 @@ address ALGuselect1
 comment "Value select, but returning only the
        head values. SEE ALSO:select(bat,val)";
 
-command revert( b:bat[:any_1,:any_2]) :bat[:any_1,:any_2]
-address ALGrevert
-comment "Returns a BAT copy with buns in reverse order";
-
 command groupby(gids:bat[:oid,:oid], cnts:bat[:oid,:wrd]) :bat[:oid,:oid]
 address ALGgroupby
 comment "Produces a new BAT with groups identified by the head column. The 
result contains tail times the head value, ie the tail contains the result 
group sizes.";
 
-
-# Sorted copy
-command sort( b:bat[:any_1,:any_2]) :bat[:any_1,:any_2]
-address ALGhsort
-comment "Returns a BAT copy sorted on the head column.";
-command sortReverse( b:bat[:any_1,:any_2]) :bat[:any_1,:any_2]
-address ALGhsort_rev
-comment "Returns a BAT copy reversely sorted on the head column.";
-
-command sortTail( b:bat[:any_1,:any_2]) :bat[:any_1,:any_2]
-address ALGtsort
-comment "Returns a BAT copy sorted on the tail column.";
-command sortReverseTail( b:bat[:any_1,:any_2]) :bat[:any_1,:any_2]
-address ALGtsort_rev
-comment "Returns a BAT copy reversely sorted on the tail column.";
-
 # Note that joins over void columns are handled as if they are oids.
 command antijoin(left:bat[:any_1,:any_2], right:bat[:any_2,:any_4])
        :bat[:any_1,:any_4]
@@ -200,6 +180,18 @@ address ALGrangejoin;
 
 #END OF HEADLESS PLANS
 
+command sort( b:bat[:oid,:any_2]) :bat[:oid,:any_2]
+address ALGtsort
+comment "Returns a BAT copy sorted on the tail column.";
+
+command sortReverse( b:bat[:oid,:any_2]) :bat[:oid,:any_2]
+address ALGtsort_rev
+comment "Returns a BAT copy reversely sorted on the tail column.";
+
+command revert( b:bat[:oid,:any_1]) :bat[:oid,:any_1]
+address ALGrevert
+comment "Returns a BAT copy with buns in reverse order";
+
 # BAT copying
 command copy( b:bat[:oid,:any_1]) :bat[:oid,:any_1]
 address ALGcopy
diff --git a/monetdb5/modules/kernel/bat5.mal b/monetdb5/modules/kernel/bat5.mal
--- a/monetdb5/modules/kernel/bat5.mal
+++ b/monetdb5/modules/kernel/bat5.mal
@@ -29,9 +29,9 @@ command mirror(b:bat[:any_1,:any_2]) :ba
 address BKCmirror
 comment "Returns the head-mirror image of a BAT (two head columns).";
 
-command revert(b:bat[:any_1,:any_2]) :bat[:any_1,:any_2] 
-address BKCrevert
-comment "Puts all BUNs in a BAT in reverse order.  (Belongs to the BAT 
sequence module)";
+#command revert(b:bat[:any_1,:any_2]) :bat[:any_1,:any_2] 
+#address BKCrevert
+#comment "Puts all BUNs in a BAT in reverse order.  (Belongs to the BAT 
sequence module)";
 
 command insert(b:bat[:oid,:any_1], h:oid, t:any_1) :bat[:oid,:any_1]
 address BKCinsert_bun
diff --git a/monetdb5/modules/mal/mat.c b/monetdb5/modules/mal/mat.c
--- a/monetdb5/modules/mal/mat.c
+++ b/monetdb5/modules/mal/mat.c
@@ -1756,7 +1756,7 @@ MATsort_bte( BAT **map, BAT **bats, int 
 }
 
 static str
-MATsort(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci, int rev)
+MATsortInternal(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci, int 
rev)
 {
        bat *res_id = getArgReference_bat(stk,pci,0); /* result sorted */
        bat *map_id = getArgReference_bat(stk,pci,1); /* result map */
@@ -1768,7 +1768,7 @@ MATsort(Client cntxt, MalBlkPtr mb, MalS
 
        (void) cntxt; (void) mb; (void) stk; 
        if( bats == NULL)
-               throw(SQL, "mat.sortTail",MAL_MALLOC_FAIL);
+               throw(SQL, "mat.sort",MAL_MALLOC_FAIL);
        for (i=2; i<pci->argc; i++) {
                bat id = *getArgReference_bat(stk,pci,i);
                bats[i-2] = BATdescriptor(id);
@@ -1818,18 +1818,18 @@ error:
                return MAL_SUCCEED;
        }
        if (map) BBPunfix(map->batCacheid);
-       throw(SQL, "mat.sortTail","Cannot access descriptor");
+       throw(SQL, "mat.sort","Cannot access descriptor");
 }
 
 str
-MATsortTail(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+MATsort(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
 {
-       return MATsort( cntxt, mb, stk, pci, 0);
+       return MATsortInternal( cntxt, mb, stk, pci, 0);
 }
 
 str
-MATsortReverseTail(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
+MATsortReverse(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
 {
-       return MATsort( cntxt, mb, stk, pci, 1);
+       return MATsortInternal( cntxt, mb, stk, pci, 1);
 }
 
diff --git a/monetdb5/modules/mal/mat.h b/monetdb5/modules/mal/mat.h
--- a/monetdb5/modules/mal/mat.h
+++ b/monetdb5/modules/mal/mat.h
@@ -46,8 +46,8 @@ mat_export str MAThasMoreElements(Client
 mat_export str MATinfo(bat *ret, str *grp, str *elm);
 mat_export str MATprint(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr p);
 mat_export str MATproject(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci);
-mat_export str MATsortReverseTail(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
-mat_export str MATsortTail(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci);
+mat_export str MATsortReverse(Client cntxt, MalBlkPtr mb, MalStkPtr stk, 
InstrPtr pci);
+mat_export str MATsort(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr 
pci);
 
 
 #endif /* _MAT_H */
diff --git a/monetdb5/modules/mal/mat.mal b/monetdb5/modules/mal/mat.mal
--- a/monetdb5/modules/mal/mat.mal
+++ b/monetdb5/modules/mal/mat.mal
@@ -62,9 +62,9 @@ pattern project(map:bat[:oid,:bte], b:ba
 address MATproject
 comment "project using the map bat (contains which bat to use in scan order)";
 
-pattern sortTail(b:bat[:oid,:any_2]...)
+pattern sort(b:bat[:oid,:any_2]...)
        (sorted:bat[:oid,:any_2], map:bat[:oid,:bte]) 
-address MATsortTail
+address MATsort
 comment "Returns a BAT copy sorted on the head column.";
 
 pattern sortReverseTail(b:bat[:oid,:any_2]...)
diff --git a/monetdb5/optimizer/opt_cluster.c b/monetdb5/optimizer/opt_cluster.c
--- a/monetdb5/optimizer/opt_cluster.c
+++ b/monetdb5/optimizer/opt_cluster.c
@@ -332,8 +332,8 @@ cluster_orderby(MalBlkPtr mb)
 
                if (state == ORDERBY_NONE && 
                    getModuleId(q) == algebraRef &&
-                       (getFunctionId(q) == sortTailRef ||
-                        getFunctionId(q) == sortReverseTailRef) &&
+                       (getFunctionId(q) == sortRef ||
+                        getFunctionId(q) == sortReverseRef) &&
                    q->argc == 2) {
                        state = ORDERBY_SORT;
                        o = getArg(q,0);
diff --git a/monetdb5/optimizer/opt_emptySet.c 
b/monetdb5/optimizer/opt_emptySet.c
--- a/monetdb5/optimizer/opt_emptySet.c
+++ b/monetdb5/optimizer/opt_emptySet.c
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to