Changeset: 9c933902dc41 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9c933902dc41
Modified Files:
clients/Tests/exports.stable.out
gdk/gdk.h
gdk/gdk_batop.c
sql/storage/restrict/restrict_table.c
Branch: default
Log Message:
Removed legacy functions BATsort, BATsort_rev, BATssort, BATssort_rev.
diffs (261 lines):
diff --git a/clients/Tests/exports.stable.out b/clients/Tests/exports.stable.out
--- a/clients/Tests/exports.stable.out
+++ b/clients/Tests/exports.stable.out
@@ -179,10 +179,6 @@ void BATsetcapacity(BAT *b, BUN cnt);
void BATsetcount(BAT *b, BUN cnt);
void BATsetprop(BAT *b, int idx, int type, void *v);
BAT *BATslice(BAT *b, BUN low, BUN high);
-BAT *BATsort(BAT *b);
-BAT *BATsort_rev(BAT *b);
-BAT *BATssort(BAT *b);
-BAT *BATssort_rev(BAT *b);
gdk_return BATsubbandjoin(BAT **r1p, BAT **r2p, BAT *l, BAT *r, BAT *sl, BAT
*sr, const void *c1, const void *c2, int li, int hi, BUN estimate);
gdk_return BATsubcross(BAT **r1p, BAT **r2p, BAT *l, BAT *r, BAT *sl, BAT *sr);
BAT *BATsubdiff(BAT *l, BAT *r, BAT *sl, BAT *sr, int nil_matches, BUN
estimate);
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -1596,10 +1596,6 @@ gdk_export gdk_return BATprintf(stream *
* @- BAT clustering
* @multitable @columnfractions 0.08 0.7
* @item BAT *
- * @tab BATsort (BAT *b)
- * @item BAT *
- * @tab BATsort_rev (BAT *b)
- * @item BAT *
* @tab BATrevert (BAT *b)
* @item int
* @tab BATordered (BAT *b)
@@ -1614,21 +1610,15 @@ gdk_export gdk_return BATprintf(stream *
* clusterings will allow that MonetDB's main-memory oriented
* algorithms work efficiently also in a disk-oriented context.
*
- * The BATsort functions return a copy of the input BAT, sorted in
- * ascending order on the head column. BATordered starts a check on
- * the head values to see if they are ordered. The result is returned
- * and stored in the hsorted field of the BAT. The BATrevert puts all
- * the live BUNs of a BAT in reverse order. It just reverses the
- * sequence, so this does not necessarily mean that they are sorted in
- * reverse order!
+ * BATordered starts a check on the head values to see if they are
+ * ordered. The result is returned and stored in the hsorted field of
+ * the BAT. The BATrevert puts all the live BUNs of a BAT in reverse
+ * order. It just reverses the sequence, so this does not necessarily
+ * mean that they are sorted in reverse order!
*/
-gdk_export BAT *BATsort(BAT *b);
-gdk_export BAT *BATsort_rev(BAT *b);
gdk_export gdk_return BATrevert(BAT *b);
gdk_export int BATordered(BAT *b);
gdk_export int BATordered_rev(BAT *b);
-gdk_export BAT *BATssort(BAT *b);
-gdk_export BAT *BATssort_rev(BAT *b);
gdk_export gdk_return BATsubsort(BAT **sorted, BAT **order, BAT **groups, BAT
*b, BAT *o, BAT *g, int reverse, int stable);
@@ -3047,13 +3037,12 @@ gdk_export void ALIGNsetH(BAT *b1, BAT *
/*
* @- loop over a BAT with ordered tail
- * Here we loop over a BAT with an ordered tail column (see for
- * instance BATsort). Again, 'p' and 'q' are iteration variables,
- * where 'p' points at the current BUN. 'tl' and 'th' are pointers to
- * atom corresponding to the minimum (included) and maximum (included)
- * bound in the selected range of BUNs. A nil-value means that there
- * is no bound. The 's' finally is an integer denoting the bunsize,
- * used for speed.
+ * Here we loop over a BAT with an ordered tail column. Again, 'p' and
+ * 'q' are iteration variables, where 'p' points at the current
+ * BUN. 'tl' and 'th' are pointers to atom corresponding to the
+ * minimum (included) and maximum (included) bound in the selected
+ * range of BUNs. A nil-value means that there is no bound. The 's'
+ * finally is an integer denoting the bunsize, used for speed.
*/
#define SORTloop(b, p, q, tl, th) \
if (!BATtordered(b)) \
@@ -3109,10 +3098,6 @@ gdk_export void BATsetprop(BAT *b, int i
* Interpretation of a NULL argument depends on the position, i.e. a
* domain lower or upper bound.
*
- * The operation BATsort sorts the BAT on the header and produces a
- * new BAT. A side effect is the clustering of the BAT store on the
- * sort key.
- *
* The BATjoin over R[A, B] and S[C, D] performs an equi-join over B
* and C. It results in a BAT over A and D. The BATouterjoin
* implements a left outerjoin over the BATs involved. The
@@ -3211,46 +3196,6 @@ gdk_export BAT *BATsample(BAT *b, BUN n)
(c)->dense ? "dense" : "oid" : \
ATOMname((c)->type))
-#define BATsort(b) \
- ({ \
- BAT *_b = (b); \
- HEADLESSDEBUG fprintf(stderr, \
- "#BATsort([%s,%s]#"BUNFMT") %s[%s:%d]\n", \
- _COL_TYPE(_b->H), _COL_TYPE(_b->T), BATcount(_b), \
- __func__, __FILE__, __LINE__); \
- BATsort(_b); \
- })
-
-#define BATsort_rev(b) \
- ({ \
- BAT *_b = (b); \
- HEADLESSDEBUG fprintf(stderr, \
- "#BATsort_rev([%s,%s]#"BUNFMT") %s[%s:%d]\n", \
- _COL_TYPE(_b->H), _COL_TYPE(_b->T), BATcount(_b), \
- __func__, __FILE__, __LINE__); \
- BATsort_rev(_b); \
- })
-
-#define BATssort(b) \
- ({ \
- BAT *_b = (b); \
- HEADLESSDEBUG fprintf(stderr, \
- "#BATssort([%s,%s]#"BUNFMT") %s[%s:%d]\n", \
- _COL_TYPE(_b->H), _COL_TYPE(_b->T), BATcount(_b), \
- __func__, __FILE__, __LINE__); \
- BATssort(_b); \
- })
-
-#define BATssort_rev(b)
\
- ({ \
- BAT *_b = (b); \
- HEADLESSDEBUG fprintf(stderr, \
- "#BATssort_rev([%s,%s]#"BUNFMT") %s[%s:%d]\n", \
- _COL_TYPE(_b->H), _COL_TYPE(_b->T), BATcount(_b), \
- __func__, __FILE__, __LINE__); \
- BATssort_rev(_b); \
- })
-
#define BATselect_(b, h, t, li, hi) \
({ \
BAT *_b = (b); \
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -1080,7 +1080,6 @@ BATslice(BAT *b, BUN l, BUN h)
/*
* BAT Sorting
- * BATsort returns a sorted copy.
*/
int
BATordered(BAT *b)
@@ -1127,102 +1126,6 @@ do_sort(void *h, void *t, const void *ba
return GDK_SUCCEED;
}
-/* Sort b according to stable and reverse, do it in-place if copy is
- * unset, otherwise do it on a copy */
-static BAT *
-BATorder_internal(BAT *b, int stable, int reverse, int copy, const char *func)
-{
- BATcheck(b, func, NULL);
- /* set some trivial properties (probably not necessary, but
- * it's cheap) */
- if (b->htype == TYPE_void) {
- b->hsorted = 1;
- b->hrevsorted = b->hseqbase == oid_nil || b->batCount <= 1;
- b->hkey |= b->hseqbase != oid_nil;
- } else if (b->batCount <= 1) {
- b->hsorted = b->hrevsorted = 1;
- }
- if (reverse ? b->hrevsorted : b->hsorted) {
- /* b is already ordered as desired, hence we return b
- * as is */
- return copy ? BATcopy(b, b->htype, b->ttype, FALSE, TRANSIENT)
: b;
- }
- if (copy) {
- /* now make a writable copy that we're going to sort
- * materialize any VOID columns while we're at it */
- b = BATcopy(b, BAThtype(b), BATttype(b), TRUE, TRANSIENT);
- } else if (b->ttype == TYPE_void && b->tseqbase != oid_nil) {
- /* materialize void-tail in-place */
- /* note, we don't need to materialize the head column:
- * if it is void, either we didn't get here (already
- * sorted correctly), or we will fall into BATrevert
- * below which does the materialization for us */
- if (BATmaterializet(b) != GDK_SUCCEED)
- return NULL;
- }
-
- if ((reverse ? b->hsorted : b->hrevsorted) && (!stable || b->hkey)) {
- /* b is ordered in the opposite direction, hence we
- * revert b (note that if requesting stable sort, the
- * column needs to be key) */
- return BATrevert(b) == GDK_SUCCEED ? b : NULL;
- }
- if (!(reverse ? b->hrevsorted : b->hsorted) &&
- do_sort(Hloc(b, BUNfirst(b)), Tloc(b, BUNfirst(b)),
- b->H->vheap ? b->H->vheap->base : NULL,
- BATcount(b), Hsize(b), Tsize(b), b->htype,
- reverse, stable) != GDK_SUCCEED) {
- if (copy)
- BBPreclaim(b);
- return NULL;
- }
- if (reverse) {
- b->hrevsorted = 1;
- b->hsorted = b->batCount <= 1;
- } else {
- b->hsorted = 1;
- b->hrevsorted = b->batCount <= 1;
- }
- b->tsorted = b->trevsorted = 0;
- HASHdestroy(b);
- IMPSdestroy(b);
- ALIGNdel(b, func, FALSE, NULL);
- b->hdense = 0;
- b->tdense = 0;
- b->batDirtydesc = b->H->heap.dirty = b->T->heap.dirty = TRUE;
-
- return b;
-}
-
-#undef BATsort
-#undef BATsort_rev
-#undef BATssort
-#undef BATssort_rev
-
-BAT *
-BATsort(BAT *b)
-{
- return BATorder_internal(b, 0, 0, 1, "BATsort");
-}
-
-BAT *
-BATsort_rev(BAT *b)
-{
- return BATorder_internal(b, 0, 1, 1, "BATsort_rev");
-}
-
-BAT *
-BATssort(BAT *b)
-{
- return BATorder_internal(b, 1, 0, 1, "BATssort");
-}
-
-BAT *
-BATssort_rev(BAT *b)
-{
- return BATorder_internal(b, 1, 1, 1, "BATssort_rev");
-}
-
/* subsort the bat b according to both o and g. The stable and
* reverse parameters indicate whether the sort should be stable or
* descending respectively. The parameter b is required, o and g are
diff --git a/sql/storage/restrict/restrict_table.c
b/sql/storage/restrict/restrict_table.c
--- a/sql/storage/restrict/restrict_table.c
+++ b/sql/storage/restrict/restrict_table.c
@@ -221,8 +221,8 @@ rids_orderby(sql_trans *tr, rids *r, sql
if (d)
bat_destroy(d);
bat_destroy(r->data);
- b = BATmirror(b);
- r->data = BATmirror(BATsort(b));
+ BATsubsort(&d, NULL, NULL, b, NULL, NULL, 0, 0);
+ r->data = d;
bat_destroy(b);
return r;
}
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list