Changeset: bc5a0fe5481b for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=bc5a0fe5481b
Added Files:
gdk/gdk_batop.c
Removed Files:
gdk/gdk_batop.mx
Modified Files:
gdk/Makefile.ag
Branch: default
Log Message:
De-mx gdk_batop. Biggest change: BATins only allows (v)oid-headed inputs.
diffs (truncated from 545 to 300 lines):
diff --git a/gdk/Makefile.ag b/gdk/Makefile.ag
--- a/gdk/Makefile.ag
+++ b/gdk/Makefile.ag
@@ -34,7 +34,7 @@ lib_gdk = {
gdk_scanselect_defs_str.mx \
gdk_scanselect_defs_fix.mx \
gdk_scanselect_defs_var.mx \
- gdk_scanselect.mx gdk.h gdk_batop.mx \
+ gdk_scanselect.mx gdk.h gdk_batop.c \
gdk_search.mx gdk_tm.c gdk_align.c gdk_bbp.c gdk_bbp.h \
gdk_heap.c gdk_setop.mx gdk_utils.c gdk_utils.h gdk_atoms.c
gdk_atoms.h \
gdk_qsort.c gdk_qsort_impl.h gdk_ssort.c gdk_ssort_impl.h \
diff --git a/gdk/gdk_batop.mx b/gdk/gdk_batop.c
rename from gdk/gdk_batop.mx
rename to gdk/gdk_batop.c
--- a/gdk/gdk_batop.mx
+++ b/gdk/gdk_batop.c
@@ -1,25 +1,22 @@
-@/
-The contents of this file are subject to the MonetDB Public License
-Version 1.1 (the "License"); you may not use this file except in
-compliance with the License. You may obtain a copy of the License at
-http://www.monetdb.org/Legal/MonetDBLicense
+/*
+ * The contents of this file are subject to the MonetDB Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.monetdb.org/Legal/MonetDBLicense
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the MonetDB Database System.
+ *
+ * The Initial Developer of the Original Code is CWI.
+ * Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
+ * Copyright August 2008-2012 MonetDB B.V.
+ * All Rights Reserved.
+ */
-Software distributed under the License is distributed on an "AS IS"
-basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
-License for the specific language governing rights and limitations
-under the License.
-
-The Original Code is the MonetDB Database System.
-
-The Initial Developer of the Original Code is CWI.
-Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
-Copyright August 2008-2012 MonetDB B.V.
-All Rights Reserved.
-@
-
-@f gdk_batop
-
-@c
/*
* @a M. L. Kersten, P. Boncz, S. Manegold, N. Nes
* @* Common BAT Operations
@@ -69,157 +66,138 @@ All Rights Reserved.
static BAT *
insert_string_bat(BAT *b, BAT *n, int append)
{
- BATiter ni; /* iterators */
- int ht, tt; /* head and tail types */
- size_t hoff = ~(size_t) 0, toff = ~(size_t) 0; /* head and tail
offsets */
+ BATiter ni; /* iterator */
+ int tt; /* tail type */
+ size_t toff = ~(size_t) 0; /* tail offset */
BUN p, q; /* loop variables */
oid o = 0; /* in case we're appending */
ptr hp, tp; /* head and tail value pointers */
- unsigned char hbv, tbv; /* head and tail value-as-bte */
- unsigned short hsv, tsv; /* head and tail value-as-sht */
+ unsigned char tbv; /* tail value-as-bte */
+ unsigned short tsv; /* tail value-as-sht */
#if SIZEOF_VAR_T == 8
- unsigned int hiv, tiv; /* head and tail value-as-int */
+ unsigned int tiv; /* tail value-as-int */
#endif
- var_t hvv, tvv; /* head and tail value-as-var_t */
var_t v; /* value */
- int nhw, ntw, bhw, btw; /* shortcuts for {b,n}->{H,T}->width */
+ int ntw, btw; /* shortcuts for {b,n}->t->width */
- assert(!append || b->H->type == TYPE_void || b->H->type == TYPE_oid);
+ assert(b->H->type == TYPE_void || b->H->type == TYPE_oid);
if (n->batCount == 0)
return b;
ni = bat_iterator(n);
- bhw = b->H->width;
btw = b->T->width;
- nhw = n->H->width;
ntw = n->T->width;
hp = NULL;
tp = NULL;
-@= prep_strapp
- @1t = b->@1type;
- if (@1t == TYPE_str &&
- (!GDK_ELIMDOUBLES(b->@2->vheap) || b->batCount == 0) &&
- !GDK_ELIMDOUBLES(n->@2->vheap) &&
- b->@2->vheap->hashash == n->@2->vheap->hashash &&
+ if (b->H->type != TYPE_void) {
+ hp = &o;
+ o = MAXoid(b);
+ }
+ tt = b->ttype;
+ if (tt == TYPE_str &&
+ (!GDK_ELIMDOUBLES(b->T->vheap) || b->batCount == 0) &&
+ !GDK_ELIMDOUBLES(n->T->vheap) &&
+ b->T->vheap->hashash == n->T->vheap->hashash &&
/* if needs to be kept unique, take slow path */
- (b->@1key & BOUND2BTRUE) == 0 &&
+ (b->tkey & BOUND2BTRUE) == 0 &&
/* if view, only copy if significant part of parent is used */
- (VIEW@1parent(n) == 0 ||
- BATcapacity(BBP_cache(VIEW@1parent(n))) < 2 * BATcount(n))) {
+ (VIEWtparent(n) == 0 ||
+ BATcapacity(BBP_cache(VIEWtparent(n))) < 2 * BATcount(n))) {
/* append string heaps */
- @1off = b->batCount == 0 ? 0 : b->@2->vheap->free;
+ toff = b->batCount == 0 ? 0 : b->T->vheap->free;
/* make sure we get alignment right */
- @1off = (@1off + GDK_VARALIGN - 1) & ~(GDK_VARALIGN - 1);
- assert(((@1off >> GDK_VARSHIFT) << GDK_VARSHIFT) == @1off);
- if (HEAPextend(b->@2->vheap, @1off + n->@2->vheap->size) < 0) {
- @1off = ~ (size_t) 0;
+ toff = (toff + GDK_VARALIGN - 1) & ~(GDK_VARALIGN - 1);
+ assert(((toff >> GDK_VARSHIFT) << GDK_VARSHIFT) == toff);
+ if (HEAPextend(b->T->vheap, toff + n->T->vheap->size) < 0) {
+ toff = ~ (size_t) 0;
goto bunins_failed;
}
- memcpy(b->@2->vheap->base + @1off, n->@2->vheap->base,
n->@2->vheap->size);
- b->@2->vheap->free = @1off + n->@2->vheap->free;
+ memcpy(b->T->vheap->base + toff, n->T->vheap->base,
n->T->vheap->size);
+ b->T->vheap->free = toff + n->T->vheap->free;
/* flush double-elimination hash table */
- memset(b->@2->vheap->base, 0, GDK_STRHASHSIZE);
- if (b->@2->width < SIZEOF_VAR_T &&
- ((size_t) 1 << 8 * b->@2->width) < (b->@2->width <= 2 ?
(b->@2->vheap->size >> GDK_VARSHIFT) - GDK_VAROFFSET : (b->@2->vheap->size >>
GDK_VARSHIFT))) {
+ memset(b->T->vheap->base, 0, GDK_STRHASHSIZE);
+ if (b->T->width < SIZEOF_VAR_T &&
+ ((size_t) 1 << 8 * b->T->width) < (b->T->width <= 2 ?
(b->T->vheap->size >> GDK_VARSHIFT) - GDK_VAROFFSET : (b->T->vheap->size >>
GDK_VARSHIFT))) {
/* offsets aren't going to fit */
- if (GDKupgradevarheap(b->@2, (var_t)
(b->@2->vheap->size >> GDK_VARSHIFT), 0) == GDK_FAIL) {
- @1off = ~ (size_t) 0;
+ if (GDKupgradevarheap(b->T, (var_t) (b->T->vheap->size
>> GDK_VARSHIFT), 0) == GDK_FAIL) {
+ toff = ~ (size_t) 0;
goto bunins_failed;
}
- b@1w = b->@2->width;
+ btw = b->T->width;
}
- switch (b@1w) {
+ switch (btw) {
case 1:
- @1t = TYPE_bte;
+ tt = TYPE_bte;
break;
case 2:
- @1t = TYPE_sht;
+ tt = TYPE_sht;
break;
#if SIZEOF_VAR_T == 8
case 4:
- @1t = TYPE_int;
+ tt = TYPE_int;
break;
#endif
default:
- @1t = TYPE_var;
+ tt = TYPE_var;
break;
}
- b->@2->varsized = 0;
- n->@2->varsized = 0;
- b->@2->type = @1t;
+ b->T->varsized = 0;
+ n->T->varsized = 0;
+ b->T->type = tt;
}
-@
-@c
- if (!append) {
- @:prep_strapp(h,H)@
- } else if (b->H->type != TYPE_void) {
- hp = &o;
- o = MAXoid(b);
- }
- @:prep_strapp(t,T)@
BATloop(n, p, q) {
-@= read_strapp
- @1p = b->@2->type ? BUN@3(ni, p) : NULL;
- if (@1off != ~ (size_t) 0) {
- assert(@1p != NULL);
- switch (n@1w) {
+ if (!append)
+ hp = b->H->type ? BUNhloc(ni, p) : NULL;
+
+ tp = b->T->type ? BUNtail(ni, p) : NULL;
+ if (toff != ~ (size_t) 0) {
+ assert(tp != NULL);
+ switch (ntw) {
case 1:
- v = (var_t) * (unsigned char *) @1p +
GDK_VAROFFSET;
+ v = (var_t) * (unsigned char *) tp +
GDK_VAROFFSET;
break;
case 2:
- v = (var_t) * (unsigned short *) @1p +
GDK_VAROFFSET;
+ v = (var_t) * (unsigned short *) tp +
GDK_VAROFFSET;
break;
#if SIZEOF_VAR_T == 8
case 4:
- v = (var_t) * (unsigned int *) @1p;
+ v = (var_t) * (unsigned int *) tp;
break;
#endif
default:
- v = * (var_t *) @1p;
+ v = * (var_t *) tp;
break;
}
- v = (var_t) ((((size_t) v << GDK_VARSHIFT) + @1off) >>
GDK_VARSHIFT);
+ v = (var_t) ((((size_t) v << GDK_VARSHIFT) + toff) >>
GDK_VARSHIFT);
assert(v >= GDK_VAROFFSET);
- assert(((size_t) v << GDK_VARSHIFT) <
b->@2->vheap->free);
- switch (b@1w) {
+ assert(((size_t) v << GDK_VARSHIFT) <
b->T->vheap->free);
+ switch (btw) {
case 1:
assert(v - GDK_VAROFFSET < ((var_t) 1 << 8));
- @1bv = (unsigned char) (v - GDK_VAROFFSET);
- @1p = (ptr) &@1bv;
+ tbv = (unsigned char) (v - GDK_VAROFFSET);
+ tp = (ptr) &tbv;
break;
case 2:
assert(v - GDK_VAROFFSET < ((var_t) 1 << 16));
- @1sv = (unsigned short) (v - GDK_VAROFFSET);
- @1p = (ptr) &@1sv;
+ tsv = (unsigned short) (v - GDK_VAROFFSET);
+ tp = (ptr) &tsv;
break;
#if SIZEOF_VAR_T == 8
case 4:
assert(v < ((var_t) 1 << 32));
- @1iv = (unsigned int) v;
- @1p = (ptr) &@1iv;
+ tiv = (unsigned int) v;
+ tp = (ptr) &tiv;
break;
#endif
default:
- @1vv = v;
- @1p = (ptr) &@1vv;
+ tp = (ptr) &v;
break;
}
}
-@
-@c
- if (!append) {
- @:read_strapp(h,H,head)@
- }
- @:read_strapp(t,T,tail)@
bunfastins(b, hp, tp);
if (append)
o++;
}
- if (hoff != ~(size_t) 0) {
- b->H->varsized = 1;
- n->H->varsized = 1;
- b->H->type = TYPE_str;
- }
if (toff != ~(size_t) 0) {
b->T->varsized = 1;
n->T->varsized = 1;
@@ -227,11 +205,6 @@ insert_string_bat(BAT *b, BAT *n, int ap
}
return b;
bunins_failed:
- if (hoff != ~(size_t) 0) {
- b->H->varsized = 1;
- n->H->varsized = 1;
- b->H->type = TYPE_str;
- }
if (toff != ~(size_t) 0) {
b->T->varsized = 1;
n->T->varsized = 1;
@@ -251,6 +224,10 @@ BATins(BAT *b, BAT *n, bit force)
if (b == NULL || n == NULL || BATcount(n) == 0) {
return b;
}
+ if (b->htype != TYPE_void && b->htype != TYPE_oid) {
+ GDKerror("BATins: input must be (V)OID headed\n");
+ return NULL;
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list