Changeset: 361ec35fb22f for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=361ec35fb22f
Modified Files:
gdk/Makefile.ag
gdk/gdk.h
gdk/gdk_inspect.c
gdk/gdk_scanselect.mx
gdk/gdk_scanselect_defs.mx
gdk/gdk_scanselect_defs_bte.mx
gdk/gdk_scanselect_defs_chr.mx
gdk/gdk_scanselect_defs_dbl.mx
gdk/gdk_scanselect_defs_fix.mx
gdk/gdk_scanselect_defs_flt.mx
gdk/gdk_scanselect_defs_int.mx
gdk/gdk_scanselect_defs_lng.mx
gdk/gdk_scanselect_defs_sht.mx
gdk/gdk_scanselect_defs_str.mx
gdk/gdk_scanselect_defs_var.mx
monetdb5/mal/mal_atom.c
monetdb5/mal/mal_box.c
monetdb5/mal/mal_dataflow.c
monetdb5/mal/mal_debugger.c
monetdb5/mal/mal_interpreter.c
monetdb5/mal/mal_listing.c
monetdb5/mal/mal_profiler.c
monetdb5/modules/atoms/str.c
monetdb5/modules/atoms/str.h
monetdb5/modules/kernel/calc.c.mx
monetdb5/modules/kernel/calc.h.mx
monetdb5/modules/kernel/colifthen.c.mx
monetdb5/modules/kernel/colmmath.c.mx
monetdb5/modules/kernel/colmmath.h.mx
monetdb5/modules/kernel/colstr.c
monetdb5/modules/kernel/column.c.mx
monetdb5/modules/kernel/column.h.mx
Branch: headless
Log Message:
Recompiling
After two weeks, the gdk layer allows for compilation again
This is a fix to many compile errors, hitherto invisible
diffs (truncated from 4402 to 300 lines):
diff --git a/gdk/Makefile.ag b/gdk/Makefile.ag
--- a/gdk/Makefile.ag
+++ b/gdk/Makefile.ag
@@ -19,26 +19,14 @@
INCLUDES = ../common/options ../common/stream ../common/utils
$(valgrind_CFLAGS)
-gdk_scanselect_CFLAGS = $(NO_INLINE_CFLAGS)
# gdk_relop.mx
-EXTRA_DIST = gdk_scanselect_defs.mx gdk.h gdk_cbp.h gdk_col.h gdk_delta.h
gdk_logger.h gdk_posix.h gdk_qsort_impl.h gdk_ssort_impl.h gdk_storage.h
gdk_system.h gdk_tm.h gdk_utils.h gdk_setop.h
+EXTRA_DIST = gdk.h gdk_cbp.h gdk_col.h gdk_delta.h gdk_logger.h gdk_posix.h
gdk_qsort_impl.h gdk_ssort_impl.h gdk_storage.h gdk_system.h gdk_tm.h
gdk_utils.h gdk_setop.h
lib_gdk = {
VERSION = $(GDK_VERSION)
NAME = bat
SOURCES = \
-# gdk_scanselect_defs_chr.mx \
-# gdk_scanselect_defs_bte.mx \
-# gdk_scanselect_defs_sht.mx \
-# gdk_scanselect_defs_int.mx \
-# gdk_scanselect_defs_flt.mx \
-# gdk_scanselect_defs_dbl.mx \
-# gdk_scanselect_defs_lng.mx \
-# gdk_scanselect_defs_str.mx \
-# gdk_scanselect_defs_fix.mx \
-# gdk_scanselect_defs_var.mx \
-# gdk_scanselect.mx \
gdk_batop.c \
gdk_search.c \
gdk_setop.c gdk_utils.c gdk_atoms.c \
@@ -51,6 +39,7 @@
# gdk_rangejoin.mx \
gdk_posix.c \
# gdk_logger.c bat.feps bat1.feps bat2.feps \
+ gdk_inspect.c \
libbat.rc
LIBS = ../common/options/libmoptions \
../common/stream/libstream \
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -3372,6 +3372,12 @@
#define ILLEGALVALUE ((ptr)-1L)
#define MAXPARAMS 32
+gdk_export lng COLgetDiskSize(COL *b);
+gdk_export lng COLgetMemorySize(COL *b);
+gdk_export lng COLgetTotalDiskSpace();
+gdk_export int COLinfo(COL *b, COL **bpx, COL **bvx);
+
+gdk_export ptr COLget(COL *b, oid o);
#endif /* _GDK_H_ */
/*
* @iftex
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -46,7 +46,6 @@
*/
#include "monetdb_config.h"
#include "gdk.h"
-#include "gdk_scanselect.h"
/*
* @+ COL insert/delete/replace
@@ -637,27 +636,125 @@
* the result (as (nil @{<,=,>@} ANY) = bit(nil) != true).
*/
COL *
-COL_select_(COL *b, ptr tl, ptr th, bit li, bit hi, bit anti)
+COL_scanselect(COL *b, COL *s, COL *bn, ptr tl, ptr th, bit li, bit hi, int
equi, int anti, int lval, int hval, int lnil, int nocheck)
{
- int hval, lval, equi, t, lnil = 0;
+ COLiter bi;
+ int (*atomcmp)(ptr, ptr);
+ oid p, q;
+ int c;
+ ptr v;
+ ptr nil;
+
+ (void) nocheck;
+ assert(b != NULL);
+ assert(bn != NULL);
+ assert(bn->type == TYPE_oid);
+ assert(bn->count == 0);
+ assert(anti == 0 || anti == 1);
+ bi = col_iterator(b);
+ atomcmp = COLatoms[b->type].atomCmp;
+ nil = b->nonil ? NULL : COLatoms[b->type].atomNull;
+ assert(!lnil || nil != NULL);
+ if (s) {
+ COLiter si = col_iterator(s);
+ oid o;
+
+ COLloop(s, p, q) {
+ o = * (oid *) BUNhead(si, p);
+ if (o < b->first || o >= b->first + b->count)
+ continue;
+ v = BUNhead(bi, o);
+ /* this IF statement is identical to the one below */
+ if (equi && lnil) {
+ /* this is the only way to match NILs */
+ if (atomcmp(nil, v) != 0)
+ continue;
+ } else {
+ if (nil && atomcmp(nil, v) == 0)
+ continue;
+ c = lval ? atomcmp(tl, v) : -1;
+ c = li ? c >= 0 : c > 0;
+ if (anti == c)
+ continue;
+ c = hval ? atomcmp(v, th) : 1;
+ c = hi ? c <= 0 : c < 0;
+ if (anti == c)
+ continue;
+ }
+ bunfastins_oid(bn, &o);
+ }
+ if (bn->count > 1) {
+ COLkey(bn, COLiskey(s));
+ bn->sorted = COLisordered(s);
+ bn->revsorted = s->revsorted;
+ } else {
+ COLkey(bn, TRUE);
+ bn->sorted = 1;
+ bn->revsorted = 1;
+ }
+ } else {
+ COLloop(b, p, q) {
+ v = BUNhead(bi, p);
+ /* this IF statement is identical to the one above */
+ if (equi && lnil) {
+ /* this is the only way to match NILs */
+ if (atomcmp(nil, v) != 0)
+ continue;
+ } else {
+ if (nil && atomcmp(nil, v) == 0)
+ continue;
+ c = lval ? atomcmp(tl, v) : -1;
+ c = li ? c >= 0 : c > 0;
+ if (anti == c)
+ continue;
+ c = hval ? atomcmp(v, th) : 1;
+ c = hi ? c <= 0 : c < 0;
+ if (anti == c)
+ continue;
+ }
+ bunfastins_oid(bn, &p);
+ }
+ COLkey(bn, TRUE);
+ bn->sorted = TRUE;
+ bn->revsorted = bn->count <= 1;
+ }
+ return bn;
+ bunins_failed:
+ CBPreclaim(bn);
+ return NULL;
+}
+
+COL *
+COLsubselect(COL *b, COL *s, ptr tl, ptr th, bit li, bit hi, bit anti)
+{
+ int hval, lval, equi, t, lnil;
oid offset, batcnt, estimate = 0;
ptr nil;
COL *bn;
oid p, q;
+ assert(li == 0 || li == 1);
+ assert(hi == 0 || hi == 1);
+
COLcheck(b, "COLselect");
COLcheck(tl, "COLselect: tl value required");
/*
* @-
* Examine type, and values for lower- and higher-bound.
*/
- batcnt = COLcount(b);
+ /* if tl==nil and th==NULL and anti==0, return all nils (only
+ * way to get nils);
+ * if tl==nil and th==nil, return all but nils;
+ * if tl==nil (and th!=NULL), no lower bound;
+ * if th==NULL or tl==th, point (equi) select;
+ * if th==nil, no upper bound. */
t = b->type;
nil = ATOMnilptr(t);
lnil = ATOMcmp(t, tl, nil) == 0;
lval = !lnil || (th == NULL);
- equi = ((th == NULL) || (lval && !ATOMcmp(t, tl, th)));
+ equi = ((th == NULL) || (lval && ATOMcmp(t, tl, th) == 0));
if (equi) {
+ assert(lval);
if (th == NULL)
hi = li;
th = tl;
@@ -665,7 +762,7 @@
} else {
hval = ATOMcmp(t, th, nil) != 0;
}
- if (nequi) {
+ if (anti) {
if (!lval != !hval) {
/* one of the end points is nil and the other
* isn't: swap sub-ranges */
@@ -677,7 +774,7 @@
tv = tl;
tl = th;
th = tv;
- nequi = 0;
+ anti = 0;
equi = 0;
} else if (!lval && !hval) {
/* antiselect for nil-nil range: all non-nil
@@ -690,13 +787,15 @@
* select for nil-nil range (i.e. everything
* but nil) */
equi = 0;
- nequi = 0;
+ anti = 0;
lval = 0;
hval = 0;
} else
equi = 0;
}
+ assert(!equi || (lval && hval)); /* if equi set, then so are both lval
and hval */
+
if (hval && ((ATOMcmp(t, tl, th) > 0) || (equi && !(li && hi)))) {
/* empty range */
ALGODEBUG THRprintf(GDKout, "#COL_select_(b=%s): empty
range;\n", COLgetId(b));
@@ -708,23 +807,25 @@
bn->seqbase = b->first;
return bn;
}
- if (equi && lval && hval && b->nonil && lnil)
+ if (equi && lnil && b->nonil)
return COLnewdensecol(0);
+ batcnt = COLcount(b);
+
/*
* @- Slice Implementations
* When the result is a dense slice of the COL, we can optimize.
* A slice does not need to copy the COL selected on, it can just
* give back a 'view' on the memory of the existing COL. See COLslice().
*/
- if (b->sorted) {
+ if (s == NULL && b->sorted) {
oid high = batcnt;
oid low = 0;
if (COLdense(b)) {
/* Selections on voids are positional. */
if (hval) {
- oid h = (*(oid *) th) + (hi ? 1 : 0);
+ oid h = (*(oid *) th) + hi;
if (h > b->seqbase)
h -= b->seqbase;
@@ -736,7 +837,7 @@
}
if (lval) {
if (*(oid *) tl != oid_nil) {
- oid l = (*(oid *) tl) + (li ? 0 : 1);
+ oid l = (*(oid *) tl) + li;
if (l > b->seqbase)
l -= b->seqbase;
@@ -811,6 +912,8 @@
*/
if (COLiskey(b)) {
estimate = 1;
+ } else if (s) {
+ estimate = COLcount(s);
} else if (batcnt > 100000) {
oid _lo = batcnt / 2, _hi = _lo + 105;
COL *tmp1;
@@ -821,7 +924,7 @@
COL *tmp2;
ALGODEBUG THRprintf(GDKout, "#COL_select_(b=%s):
sampling: tmp2 = COL_select_(tmp1=%s, tl, th, tail);\n", COLgetId(b),
COLgetId(tmp1));
- tmp2 = COL_select_(tmp1, tl, th, li, hi, anti);
+ tmp2 = COLsubselect(tmp1, NULL, tl, th, li, hi, anti);
if (tmp2) {
/* reserve 105% of what has been estimated */
estimate = (oid) ((((lng) COLcount(tmp2)) *
(lng) batcnt) / LL_CONSTANT(100));
@@ -840,26 +943,23 @@
if (bn) {
int nocheck = (estimate >= batcnt);
- if (equi && b->hash) {
- ALGODEBUG THRprintf(GDKout, "#COL_select_(b=%s):
COL_hashselect(b=%s, bn=%s, tl); (using existing hash-table)\n", COLgetId(b),
COLgetId(b), COLgetId(bn));
-
- bn = COL_hashselect(b, bn, tl);
- } else if (equi &&
- b->persistence == PERSISTENT &&
- (size_t) ATOMsize(b->type) > sizeof(oid) / 4 &&
- estimate < batcnt / 100 &&
- batcnt * (ATOMsize(b->type) + 2 * sizeof(oid)) <
(GDK_mem_maxsize / 2) /* MT_npages() * MT_pagesize() / (GDKnr_threads ?
GDKnr_threads : 1) */ ) {
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list