Changeset: 3d5d2ba2feb5 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=3d5d2ba2feb5
Modified Files:
gdk/gdk_aggr.c
gdk/gdk_bat.c
gdk/gdk_batop.c
gdk/gdk_group.c
gdk/gdk_select.c
gdk/gdk_setop.c
Branch: Oct2014
Log Message:
Set more properties where we can easily do so.
diffs (221 lines):
diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c
--- a/gdk/gdk_aggr.c
+++ b/gdk/gdk_aggr.c
@@ -1348,6 +1348,8 @@ BATgroupavg(BAT **bnp, BAT **cntsp, BAT
(*cntsp)->tkey = BATcount(*cntsp) <= 1;
(*cntsp)->tsorted = BATcount(*cntsp) <= 1;
(*cntsp)->trevsorted = BATcount(*cntsp) <= 1;
+ (*cntsp)->T->nil = 0;
+ (*cntsp)->T->nonil = 1;
}
BATsetcount(bn, ngrp);
BATseqbase(bn, min);
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -967,35 +967,35 @@ BATcopy(BAT *b, int ht, int tt, int writ
if (ATOMtype(ht) == ATOMtype(b->htype)) {
ALIGNsetH(bn, b);
} else if (ATOMtype(ATOMstorage(ht)) ==
ATOMtype(ATOMstorage(b->htype))) {
- bn->hsorted = b->hsorted || (cnt <= 1 &&
BATatoms[b->htype].linear);
- bn->hrevsorted = b->hrevsorted || (cnt <= 1 &&
BATatoms[b->htype].linear);
+ bn->hsorted = b->hsorted;
+ bn->hrevsorted = b->hrevsorted;
bn->hdense = b->hdense && ATOMtype(bn->htype) == TYPE_oid;
if (b->hkey)
BATkey(bn, TRUE);
bn->H->nonil = b->H->nonil;
} else {
- bn->hsorted = bn->hrevsorted = (cnt <= 1 &&
BATatoms[b->htype].linear);
+ bn->hsorted = bn->hrevsorted = 0; /* set based on count later */
bn->hdense = bn->H->nonil = 0;
}
if (ATOMtype(tt) == ATOMtype(b->ttype)) {
ALIGNsetT(bn, b);
} else if (ATOMtype(ATOMstorage(tt)) ==
ATOMtype(ATOMstorage(b->ttype))) {
- bn->tsorted = b->tsorted || (cnt <= 1 &&
BATatoms[b->ttype].linear);
- bn->trevsorted = b->trevsorted || (cnt <= 1 &&
BATatoms[b->ttype].linear);
+ bn->tsorted = b->tsorted;
+ bn->trevsorted = b->trevsorted;
bn->tdense = b->tdense && ATOMtype(bn->ttype) == TYPE_oid;
if (b->tkey)
BATkey(BATmirror(bn), TRUE);
bn->T->nonil = b->T->nonil;
} else {
- bn->tsorted = bn->trevsorted = (cnt <= 1 &&
BATatoms[b->ttype].linear);
+ bn->tsorted = bn->trevsorted = 0; /* set based on count later */
bn->tdense = bn->T->nonil = 0;
}
if (BATcount(bn) <= 1) {
- bn->hsorted = 1;
- bn->hrevsorted = 1;
+ bn->hsorted = BATatoms[b->htype].linear;
+ bn->hrevsorted = BATatoms[b->htype].linear;
bn->hkey = 1;
- bn->tsorted = 1;
- bn->trevsorted = 1;
+ bn->tsorted = BATatoms[b->ttype].linear;
+ bn->trevsorted = BATatoms[b->ttype].linear;
bn->tkey = 1;
}
if (writable != TRUE)
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -893,10 +893,10 @@ BATslice(BAT *b, BUN l, BUN h)
}
}
if (bn->batCount <= 1) {
- bn->hsorted = 1;
- bn->tsorted = 1;
- bn->hrevsorted = 1;
- bn->trevsorted = 1;
+ bn->hsorted = BATatoms[b->htype].linear;
+ bn->tsorted = BATatoms[b->ttype].linear;
+ bn->hrevsorted = BATatoms[b->htype].linear;
+ bn->trevsorted = BATatoms[b->ttype].linear;
BATkey(bn, 1);
BATkey(BATmirror(bn), 1);
} else {
@@ -1207,7 +1207,7 @@ BATsubsort(BAT **sorted, BAT **order, BA
if (order) {
/* prepare order bat */
if (o) {
- /* make copy of input so that we can refine it
+ /* make copy of input so that we can refine it;
* copy can be read-only if we take the shortcut
* below in the case g is "key" */
on = BATcopy(o, TYPE_void, TYPE_oid,
@@ -1226,10 +1226,12 @@ BATsubsort(BAT **sorted, BAT **order, BA
grps[p] = p;
BATsetcount(on, BATcount(bn));
on->tkey = 1;
+ on->T->nil = 0;
+ on->T->nonil = 1;
}
BATseqbase(on, 0);
- on->tsorted = on->trevsorted = 0;
- on->tdense = 0;
+ on->tsorted = on->trevsorted = 0; /* it won't be sorted */
+ on->tdense = 0; /* and hence not dense */
*order = on;
}
if (g) {
@@ -1241,8 +1243,24 @@ BATsubsort(BAT **sorted, BAT **order, BA
} else {
BBPunfix(bn->batCacheid);
}
- if (order)
+ if (order) {
*order = on;
+ if (o) {
+ /* we can inherit sortedness
+ * after all */
+ on->tsorted = o->tsorted;
+ on->trevsorted = o->trevsorted;
+ } else {
+ /* we didn't rearrange, so
+ * still sorted */
+ on->tsorted = 1;
+ on->trevsorted = 0;
+ }
+ if (BATcount(on) <= 1) {
+ on->tsorted = 1;
+ on->trevsorted = 1;
+ }
+ }
if (groups) {
gn = BATcopy(g, TYPE_void, g->ttype, 0,
TRANSIENT);
if (gn == NULL)
diff --git a/gdk/gdk_group.c b/gdk/gdk_group.c
--- a/gdk/gdk_group.c
+++ b/gdk/gdk_group.c
@@ -857,9 +857,15 @@ BATgroup_internal(BAT **groups, BAT **ex
if (histo) {
BATsetcount(hn, (BUN) ngrp);
BATseqbase(hn, 0);
- hn->tkey = 0;
- hn->tsorted = 0;
- hn->trevsorted = 0;
+ if (BATcount(hn) <= 1) {
+ hn->tkey = 1;
+ hn->tsorted = 1;
+ hn->trevsorted = 1;
+ } else {
+ hn->tkey = 0;
+ hn->tsorted = 0;
+ hn->trevsorted = 0;
+ }
hn->T->nonil = 1;
hn->T->nil = 0;
*histo = hn;
diff --git a/gdk/gdk_select.c b/gdk/gdk_select.c
--- a/gdk/gdk_select.c
+++ b/gdk/gdk_select.c
@@ -122,6 +122,8 @@ doublerange(oid l1, oid h1, oid l2, oid
bn->tkey = 1;
bn->tsorted = 1;
bn->trevsorted = BATcount(bn) <= 1;
+ bn->T->nil = 0;
+ bn->T->nonil = 1;
return bn;
}
@@ -155,6 +157,8 @@ doubleslice(BAT *b, BUN l1, BUN h1, BUN
bn->tkey = 1;
bn->tsorted = 1;
bn->trevsorted = BATcount(bn) <= 1;
+ bn->T->nil = 0;
+ bn->T->nonil = 1;
return virtualize(bn);
}
@@ -208,14 +212,9 @@ BAT_hashselect(BAT *b, BAT *s, BAT *bn,
if (bn->batCount == 1)
bn->tseqbase = *(oid *) Tloc(bn, BUNfirst(bn));
/* temporarily set head to nil so that BATorder doesn't materialize */
- bn->hseqbase = oid_nil;
- bn->hkey = 0;
- bn->hsorted = bn->hrevsorted = 1;
+ BATseqbase(bn, oid_nil);
bn = BATmirror(BATorder(BATmirror(bn)));
- bn->hseqbase = 0;
- bn->hkey = 1;
- bn->hsorted = 1;
- bn->hrevsorted = bn->batCount <= 1;
+ BATseqbase(bn, 0);
return bn;
}
diff --git a/gdk/gdk_setop.c b/gdk/gdk_setop.c
--- a/gdk/gdk_setop.c
+++ b/gdk/gdk_setop.c
@@ -473,16 +473,20 @@ diff_intersect(BAT *l, BAT *r, int diff)
BATcount(bn) == BATcount(r)) {
ALIGNsetH(bn, r);
}
- bn->hsorted = BAThordered(l);
- bn->hrevsorted = BAThrevordered(l);
- bn->tsorted = BATtordered(l);
- bn->trevsorted = BATtrevordered(l);
- if (BATcount(bn)) {
+ if (BATcount(bn) <= 1) {
+ bn->hsorted = 1;
+ bn->hrevsorted = 1;
+ bn->tsorted = 1;
+ bn->trevsorted = 1;
+ BATkey(bn, TRUE);
+ BATkey(BATmirror(bn), TRUE);
+ } else {
+ bn->hsorted = BAThordered(l);
+ bn->hrevsorted = BAThrevordered(l);
+ bn->tsorted = BATtordered(l);
+ bn->trevsorted = BATtrevordered(l);
BATkey(bn, BAThkey(l));
BATkey(BATmirror(bn), BATtkey(l));
- } else {
- BATkey(bn, TRUE);
- BATkey(BATmirror(bn), TRUE);
}
bn->H->nonil = l->H->nonil;
bn->T->nonil = l->T->nonil;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list