Update of /cvsroot/monetdb/MonetDB4/src/modules/contrib
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv30304/src/modules/contrib
Modified Files:
Makefile.ag array.mx bat_cast.mx bat_mmath.mx iterator.mx
malalgebra.mx salgebra.mx txtsim.mx vector.mx
Log Message:
Merged GDK-2 branch into development branch.
Current changes were mostly started for
fixing the void concurrency problem
As a side action, the bun/bat layout was also changed.
We now have a split head and tail. This means many of the well known
macros are changed (ie BUN{h,t}{loc,var} BUN{head,tail})
BAT iteration now needs a special struct
BATiter which can be correctly created as
BATiter bi = bat_iterator(b);
TODO
1 some modules aren't ported (maybe be dropped as they aren't used)
2 some more bugs to find
Next improvements which are now possible
views based on 2 bats
(or a bat where head is real and the tail a view (or vs))
many more....
For a presentation about the changes, see
http://www.cwi.nl/~niels/download/gdk2.pdf
Index: salgebra.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB4/src/modules/contrib/salgebra.mx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- salgebra.mx 19 Apr 2007 01:48:31 -0000 1.5
+++ salgebra.mx 4 Oct 2007 10:35:12 -0000 1.6
@@ -177,10 +177,6 @@
\begin{verbatim}
TODO:
- * loading module in both server and client does not work
- it can hang in BBPtrim if you access
- ch_cache.info().find("batCacheid").print;
- in client and server and load module in both
* use of local_itoa implementation causes memory leak in info
\end{verbatim}
@@ -419,17 +415,18 @@
static str
clusterhashName(int batId)
{
+ BATiter sni = bat_iterator(salgebra_namecache);
BUN bun;
str result;
/* find ch in dictionary */
MT_set_lock(salgebra_cacheLock, "clusterhashName");
- if (!(bun = BUNfnd(salgebra_namecache, &batId))) {
+ if ((bun = BUNfnd(salgebra_namecache, &batId)) == BUN_NONE) {
MT_unset_lock(salgebra_cacheLock, "clusterhashName");
GDKwarning("Inconsistency in clusterhash repository...\n");
return NULL;
}
- result = (str) BUNtail(salgebra_namecache, bun);
+ result = (str) BUNtail(sni, bun);
MT_unset_lock(salgebra_cacheLock, "clusterhashName");
return result;
}
@@ -468,14 +465,14 @@
/* find ch in dictionary */
MT_set_lock(salgebra_cacheLock, "clusterhashByName");
- if (!(bun = BUNfnd(ncrev, chname))) {
+ if ((bun = BUNfnd(ncrev, chname) == BUN_NONE)) {
MT_unset_lock(salgebra_cacheLock, "clusterhashByName");
GDKwarning("Clusterhash does not exist.\n");
(void) clusterhashNil(res);
return GDK_FAIL;
}
- batId = *(int *) BUNtail(ncrev, bun);
- if (!(ch = (clusterhash *) BUNtail(salgebra_cache,
BUNfnd(salgebra_cache, &batId)))) {
+ batId = *(int *) Tloc(ncrev, bun);
+ if (!(ch = (clusterhash *) Tloc(salgebra_cache, BUNfnd(salgebra_cache,
&batId)))) {
MT_unset_lock(salgebra_cacheLock, "clusterhashByName");
GDKerror("clusterhashByName: Inconsistency in clusterhash
repository...\n");
(void) clusterhashNil(res);
@@ -630,7 +627,7 @@
int bid = ABS(batId);
BUN chbun = BUNfnd(salgebra_cache, &bid);
- return chbun ? TRUE : FALSE;
+ return (chbun != BUN_NONE) ? TRUE : FALSE;
}
/* pre: !isNil( ch ) */
@@ -639,11 +636,11 @@
[EMAIL PROTECTED]( clusterhash *ch ) {
int refCnt = 0;
int batId = ABS( ch->b );
- BUN chbun = NULL;
+ BUN chbun = BUN_NONE;
MT_set_lock( salgebra_refcntLock, "@1RefCnt" );
chbun = BUNfnd( salgebra_refcnt, &batId );
- ERRORcheck( !chbun, "Inconsistency in clusterhash repository...\n" );
- refCnt = @2*( (int *) BUNtail( salgebra_refcnt, chbun ) );
+ ERRORcheck(chbun == BUN_NONE, "Inconsistency in clusterhash
repository...\n");
+ refCnt = @2*( (int *) Tloc( salgebra_refcnt, chbun ) );
MT_unset_lock( salgebra_refcntLock, "@1RefCnt" );
return refCnt;
}
@@ -661,6 +658,7 @@
static int
salgebra_CHbuild(clusterhash *ch, BAT *b)
{
+ BATiter bi = bat_iterator(b);
Hash *h = NULL;
BAT *bt = NULL, *hv = NULL, *tv = NULL;
dict_entry *dict = NULL;
@@ -681,9 +679,9 @@
ch->bttype = BATttype(b);
/* build a hash if it does not yet exist */
bt = BATmirror(b);
- if (!(bt->hhash))
+ if (!(bt->H->hash))
BAThash(bt, 0);
- h = bt->hhash;
+ h = bt->H->hash;
ch->bhash = (Hash *) GDKmalloc(sizeof(Hash));
memcpy(ch->bhash, h, sizeof(Hash));
@@ -711,9 +709,8 @@
/* NOTE: htype == void;
the idea should however extend to other ordered types as well (?) */
hv = BATnew(TYPE_oid, TYPE_void, xx = BATcount(b));
- hv->batBuns->free = xx * sizeof(oid);
BATsetcount(hv, xx);
- hvs = (oid *) BUNfirst(hv);
+ hvs = (oid *)Hloc(hv, BUNfirst(hv));
/* Read the unique ch's from the hash (i.e., do a k-cluster-unique) */
for (cur = 0; cur < chlen; cur++) {
@@ -749,7 +746,7 @@
continue;
}
/* check if still perfect */
- tl = BUNtail(b, BUNptr(b, hb)); /* will be obsolete if
isPerfect */
+ tl = BUNtail(bi, hb);/* will be obsolete if isPerfect */
if (cc++ == 0) {
/* cache tail value of first bun */
cur_tl = tl;
@@ -812,14 +809,15 @@
Find matching buns using clusterhash ch.
Returns the number of matching values
- TODO: can we easily get the <hvs = BUNfirst> statement out of the loop?
+ TODO: can we easily get the <hvs = Hloc/BUNfirst> statement out of the loop?
*/
static int
salgebra_collect_matches_imperfect(oid *res, clusterhash *ch, hash_t bucket,
ptr v)
{
BAT *hv = BBPdescriptor(ch->hv), *tv = BBPdescriptor(ch->tv);
- oid *hvs = (oid *) BUNfirst(hv);
+ BATiter tvi = bat_iterator(tv);
+ oid *hvs = (oid *) Hloc(hv, BUNfirst(hv));
int i = 0, j = DICTentry(ch, bucket).s, n = DICTentry(ch, bucket).e - j
+ 1, nres = 0;
#ifdef DEBUG
@@ -829,7 +827,7 @@
return 0; /* no matches */
for (i = 0; i < n; i++) {
/* Inner loop over q; check tails since the hash is imperfect */
- if (!(ATOMcmp(ch->bttype, BUNhead(tv, BUNptr(tv, j + 1)), v))) {
+ if (!(ATOMcmp(ch->bttype, BUNhead(tvi, j + 1), v))) {
*res++ = hvs[j];
nres++;
}
@@ -842,7 +840,7 @@
salgebra_collect_matches_perfect(oid *res, clusterhash *ch, hash_t bucket)
{
BAT *hv = BBPdescriptor(ch->hv);
- oid *hvs = (oid *) BUNfirst(hv);
+ oid *hvs = (oid *)Hloc(hv, BUNfirst(hv));
int i = 0, j = DICTentry(ch, bucket).s, n = DICTentry(ch, bucket).e - j
+ 1;
#ifdef DEBUG
@@ -902,7 +900,7 @@
}
/* retrieve ch from the dictionary */
MT_set_lock(salgebra_cacheLock, "CMDclusterhash");
- ch = (clusterhash *) BUNtail(salgebra_cache, BUNfnd(salgebra_cache,
&batId));
+ ch = (clusterhash *) Tloc(salgebra_cache, BUNfnd(salgebra_cache,
&batId));
memcpy(res, ch, clusterhash_size());
MT_unset_lock(salgebra_cacheLock, "CMDclusterhash");
clusterhashFix(res);
@@ -951,7 +949,7 @@
MT_set_lock(salgebra_cacheLock, "rename");
ncrev = BATmirror(salgebra_namecache);
- if (BUNfnd(ncrev, name)) {
+ if (BUNfnd(ncrev, name) != BUN_NONE) {
GDKerror("salgebra_CMDrename: A clusterhash with name %s
already exists.\n", name);
MT_unset_lock(salgebra_cacheLock, "rename");
return GDK_FAIL;
@@ -973,10 +971,10 @@
@:CHECKnil(error,FAIL)@
nmaxres = DICTclustersize(ch, v);
result = BATnew(TYPE_oid, TYPE_void, nmaxres);
- result->batBuns->free = nmaxres * sizeof(oid);
BATsetcount(result, nmaxres);
- nres = salgebra_collect_matches((oid *) BUNfirst(result), ch, v);
- result->batBuns->free -= (nmaxres - nres) * sizeof(oid);
+ nres = salgebra_collect_matches((oid *) Hloc(result, BUNfirst(result)),
ch, v);
+ result->H->heap.free -= headsize(result,(nmaxres - nres));
+ result->T->heap.free -= tailsize(result,(nmaxres - nres));
result->batCount -= (nmaxres - nres);
*res = result;
return GDK_SUCCEED;
@@ -985,6 +983,7 @@
int
salgebra_CMDujoin(BAT **res, clusterhash *ch, BAT *b)
{
+ BATiter bi = bat_iterator(b);
BUN p, q;
BAT *result = NULL;
oid *matches = NULL;
@@ -996,19 +995,19 @@
/* determine result size if perfect hash */
BATloop(b, p, q)
- nmaxres += (DICTclustersize(ch, BUNhead(b, p)));
+ nmaxres += (DICTclustersize(ch, BUNhead(bi, p)));
/* create result BAT */
result = BATnew(TYPE_oid, TYPE_void, nmaxres);
result->hsorted = 0;
- result->batBuns->free = nmaxres * sizeof(oid);
BATsetcount(result, nmaxres);
/* construct result */
- matches = (oid *) BUNfirst(result);
+ matches = (oid *) Hloc(result, BUNfirst(result));
BATloop(b, p, q)
- nres += salgebra_collect_matches(&matches[nres], ch, BUNhead(b, p));
- result->batBuns->free -= (nmaxres - nres) * sizeof(oid);
+ nres += salgebra_collect_matches(&matches[nres], ch, BUNhead(bi,
p));
+ result->H->heap.free -= headsize(result, (nmaxres - nres));
+ result->T->heap.free -= tailsize(result, (nmaxres - nres));
result->batCount -= (nmaxres - nres);
/* return the result */
@@ -1019,6 +1018,7 @@
int
salgebra_CMDusortedjoin(BAT **res, clusterhash *ch, BAT *b)
{
+ BATiter bi = bat_iterator(b);
BUN p, q;
BAT *result = NULL, *hbuf = NULL;
oid *cur = NULL, *prev = NULL, *matches = NULL;
@@ -1030,30 +1030,29 @@
/* determine result size if perfect hash */
BATloop(b, p, q)
- nmaxres += (DICTclustersize(ch, BUNhead(b, p)));
+ nmaxres += (DICTclustersize(ch, BUNhead(bi, p)));
/* create result BAT, and a temporary buffer for mergesorting */
result = BATnew(TYPE_oid, TYPE_void, nmaxres);
- result->batBuns->free = nmaxres * sizeof(oid);
BATsetcount(result, nmaxres);
hbuf = BATnew(TYPE_oid, TYPE_void, nmaxres);
- hbuf->batBuns->free = nmaxres * sizeof(oid);
BATsetcount(hbuf, nmaxres);
/* construct sorted result */
- prev = (oid *) BUNfirst(result);
- matches = (oid *) BUNfirst(hbuf);
+ prev = (oid *) Hloc(result, BUNfirst(result));
+ matches = (oid *) Hloc(hbuf, BUNfirst(hbuf));
BATloop(b, p, q) {
cur = &prev[nres];
- ncur = salgebra_collect_matches(cur, ch, BUNhead(b, p));
+ ncur = salgebra_collect_matches(cur, ch, BUNhead(bi, p));
salgebra_mergesort_matches(matches, cur, ncur, prev, nres);
nres += ncur;
SWAPoidptr(&prev, &matches);
SWAPBATptr(&result, &hbuf);
}
BBPreclaim(hbuf);
- result->batBuns->free -= (nmaxres - nres) * sizeof(oid);
+ result->H->heap.free -= headsize(result, (nmaxres - nres));
+ result->T->heap.free -= tailsize(result, (nmaxres - nres));
result->batCount -= (nmaxres - nres);
/* return the result */
Index: vector.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB4/src/modules/contrib/vector.mx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- vector.mx 20 Feb 2007 11:32:11 -0000 1.3
+++ vector.mx 4 Oct 2007 10:35:14 -0000 1.4
@@ -989,8 +989,9 @@
@= varsized_meanvector_c
int [EMAIL PROTECTED](@2s **res, BAT *b, int *dim) {
+ BATiter bi = bat_iterator(b);
BUN p, q;
- int i, m;
+ int i;
if(b->ttype != [EMAIL PROTECTED]) {
GDKerror("[EMAIL PROTECTED]: BAT has wrong tail datatype (need
@1s). (%d) (%d) (%d)\n", b->ttype,[EMAIL PROTECTED], ATOMindex("dbls"));
@@ -999,8 +1000,8 @@
*res = @2screate(*dim);
for(i = 0; i < (*res)->dimension; i++) (*res)->data[i] = 0;
- BATloopFast(b, p, q, m) {
- @1s *val = (@1s *)BUNtvar(b, p);
+ BATloop(b, p, q) {
+ @1s *val = (@1s *)BUNtvar(bi, p);
for(i = 0; i < (*res)->dimension; i++) {
(*res)->data[i] += (@2)val->data[i];
}
@@ -1016,8 +1017,9 @@
@= fixedsize_meanvector_c
int [EMAIL PROTECTED]@3_meanvector(@[EMAIL PROTECTED] *res, BAT *b) {
+ BATiter bi = bat_iterator(b);
BUN p, q;
- int i, m;
+ int i;
if(b->ttype != [EMAIL PROTECTED]@3) {
GDKerror("[EMAIL PROTECTED]@3_meanvector]: BAT has wrong tail
datatype (need @[EMAIL PROTECTED]).\n");
@@ -1025,8 +1027,8 @@
}
for(i = 0; i < @3; i++) res->data[i] = 0;
- BATloopFast(b, p, q, m) {
- @[EMAIL PROTECTED] *val = (@[EMAIL PROTECTED] *)BUNtail(b, p);
+ BATloop(b, p, q) {
+ @[EMAIL PROTECTED] *val = (@[EMAIL PROTECTED] *)BUNtail(bi, p);
for(i = 0; i < @3; i++) {
res->data[i] += val->data[i];
}
@@ -1042,10 +1044,11 @@
@= varsized_aggregate_c
int [EMAIL PROTECTED]@2range(@1s **rval, BAT *vecs) {
- int i,xx, first = 1;
+ BATiter vecsi = bat_iterator(vecs);
+ int i,first = 1;
BUN p,q;
BUN firstbun = BUNfirst(vecs);
- @1s* vec = (@1s*)(BUNtvar(vecs, firstbun));
+ @1s* vec = (@1s*)(BUNtvar(vecsi, firstbun));
int dim = vec->dimension;
@@ -1058,9 +1061,9 @@
}
/* Compute aggregate */
- BATloopFast(vecs, p, q, xx) {
+ BATloop(vecs, p, q) {
if(first) { first = 0; continue; }
- vec = (@1s *)BUNtvar(vecs, p);
+ vec = (@1s *)BUNtvar(vecsi, p);
if(vec->dimension != dim) {
GDKerror( "[EMAIL PROTECTED]@2range]: Cannot compute @2range
for vectors of different lengths.\n");
return(GDK_FAIL);
@@ -1074,10 +1077,11 @@
@= fixedsize_aggregate_c
int [EMAIL PROTECTED]@[EMAIL PROTECTED](@[EMAIL PROTECTED] *rval, BAT
*vecs) {
- int i,xx, first = 1;
+ BATiter vecsi = bat_iterator(vecs);
+ int i,first = 1;
BUN p,q;
BUN firstbun = BUNfirst(vecs);
- @[EMAIL PROTECTED] *vec = (@[EMAIL PROTECTED] *)(BUNtloc(vecs,
firstbun));
+ @[EMAIL PROTECTED] *vec = (@[EMAIL PROTECTED] *)(BUNtloc(vecsi,
firstbun));
int dim = vec->dimension;
/* Make Copy... */
@@ -1088,9 +1092,9 @@
}
/* Compute aggregate */
- BATloopFast(vecs, p, q, xx) {
+ BATloop(vecs, p, q) {
if(first) { first = 0; continue; }
- vec = (@[EMAIL PROTECTED] *)BUNtvar(vecs, p);
+ vec = (@[EMAIL PROTECTED] *)BUNtvar(vecsi, p);
if(vec->dimension != dim) {
GDKerror( "[EMAIL PROTECTED]@[EMAIL PROTECTED]: Cannot compute
@3range for vectors of different lengths.\n");
return(GDK_FAIL);
Index: array.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB4/src/modules/contrib/array.mx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- array.mx 3 Jan 2007 12:23:33 -0000 1.2
+++ array.mx 4 Oct 2007 10:35:05 -0000 1.3
@@ -45,11 +45,11 @@
@= grid_hdefs
#define [EMAIL PROTECTED](b,s) {(b)=BATnew(TYPE_void,[EMAIL
PROTECTED],(size_t) (s)); \
BATseqbase((b),0); }
-#define [EMAIL PROTECTED](b,n) {(b)->batBuns->free+=(size_t)(n)*sizeof(@1);\
+#define [EMAIL PROTECTED](b,n) {(b)->T->heap.free+=(size_t)(n)*sizeof(@1);\
(b)->batCount+=(size_t)n;\
BATkey(BATmirror((b)),0); \
(b)->tsorted = 0; }
-#define [EMAIL PROTECTED](b) ((@1*)(BUNfirst((b))))
+#define [EMAIL PROTECTED](b) ((@1*)(Tloc(b,BUNfirst((b)))))
@h
@:grid_hdefs(int)@
@:grid_hdefs(lng)@
@@ -67,26 +67,25 @@
#include <time.h>
@= grid_impl
+array_export str [EMAIL PROTECTED](@1 *ret, @1 *groups, @1 *groupsize, @1
*clustersize, @1 *offset);
+array_export str [EMAIL PROTECTED](@1 *ret, @1 *groups, @1 *groupsize, @1
*clustersize, @1 *offset, @1 *shift);
+array_export str [EMAIL PROTECTED](@1 *ret, @1 *bid, @1 *groups, @1
*groupsize, @1 *clustersize, @1 *offset);
+array_export str [EMAIL PROTECTED](@1 *ret, @1 *bid, @1 *groups, @1
*groupsize, @1 *clustersize, @1 *offset, @1 *shift);
+
int
[EMAIL PROTECTED](BAT **out, @1 *groups, @1 *groupsize, @1 *clustersize, @1
*offset)
[EMAIL PROTECTED](BAT **out, @1 *groups, @1 *groupsize, @1 *clustersize, @1
*offset, @1 *shift)
{
register @1 *ptr;
@1 i = *groups;
@1 n = *groupsize + *offset;
@1 r = *clustersize;
@1 o = *offset;
+ @1 s = *shift;
#ifdef EXCESSIVE_DEBUGGING
fprintf(stderr, "[grid] (%d,%d,%d,%d)", i, n, r, o);
#endif
- [EMAIL PROTECTED](*out, (i * (n - o) * r));
- if (out == NULL) {
- GDKerror("grid: cannot create the bat (%ld BUNs)\n", (i * (n - o) * r));
- return GDK_FAIL;
- }
-
- [EMAIL PROTECTED](*out, (i * (n - o) * r));
ptr = [EMAIL PROTECTED](*out);
while (i--) {
@@ -96,7 +95,7 @@
register @1 ri = r;
while (ri--)
- (*(ptr ++)) = ni;
+ (*(ptr ++)) = ni * s;
ni++;
}
}
@@ -107,6 +106,48 @@
return GDK_SUCCEED;
}
+
+int
[EMAIL PROTECTED](BAT **out, @1 *groups, @1 *groupsize, @1 *clustersize, @1
*offset)
+{
+ @1 i = *groups;
+ @1 n = *groupsize + *offset;
+ @1 r = *clustersize;
+ @1 o = *offset;
+ @1 s = 1;
+
+#ifdef EXCESSIVE_DEBUGGING
+ fprintf(stderr, "[grid] (%d,%d,%d,%d)", i, n, r, o);
+#endif
+
+ [EMAIL PROTECTED](*out, (i * (n - o) * r));
+ if (out == NULL) {
+ GDKerror("grid: cannot create the bat (%ld BUNs)\n", (i * (n -
o) * r));
+ return GDK_FAIL;
+ }
+ [EMAIL PROTECTED](*out, (i * (n - o) * r));
+ return [EMAIL PROTECTED](out, groups, groupsize, clustersize, offset,
&s);
+}
+
+int
[EMAIL PROTECTED](BAT **out, @1 *groups, @1 *groupsize, @1 *clustersize, @1
*offset, @1 *shift)
+{
+ @1 i = *groups;
+ @1 n = *groupsize + *offset;
+ @1 r = *clustersize;
+ @1 o = *offset;
+
+#ifdef EXCESSIVE_DEBUGGING
+ fprintf(stderr, "[grid] (%d,%d,%d,%d)", i, n, r, o);
+#endif
+
+ [EMAIL PROTECTED](*out, (i * (n - o) * r));
+ if (*out == 0)
+ return GDK_FAIL;
+ [EMAIL PROTECTED](*out, (i * (n - o) * r));
+ return [EMAIL PROTECTED](out, groups, groupsize, clustersize, offset,
shift);
+}
+
@c
@:grid_impl(int)@
@:grid_impl(lng)@
@@ -121,6 +162,7 @@
int
print_array(BAT *val, ...)
{
+ BATiter vali = bat_iterator(val);
va_list ap;
BAT *tmp, *batptr[MAX_ARRAY_DIM];
int *minvector;
@@ -188,26 +230,27 @@
/* And fetch additional indices (for a given oid) */
/* building the full M-D structure (of oid's). */
{
+ BATiter b0i = bat_iterator(batptr[0]);
register BUN p, q;
p = BUNfirst(batptr[0]);
q = BUNlast(batptr[0]);
while (p < q) {
- register oid *o = (oid *) BUNhead(batptr[0], p);
+ register oid *o = (oid *) BUNhead(b0i, p);
register int offset;
- offset = *((int *) BUNtail(batptr[0], p)) -
minvector[0];
+ offset = *((int *) BUNtail(b0i, p)) - minvector[0];
for (i = 1; i < dims; i++) {
register BUN p = BUNfnd(batptr[i], o);
- if (p == NULL) {
+ if (p == BUN_NONE) {
GDKerror("print_array: Index %d missing
for oid %d.\n", i, *o);
goto exit_err_full;
}
- offset = (offset * lenvector[i]) + ((*((int *)
p)) - minvector[i]);
+ offset = (offset * lenvector[i]) + ((*((int *)
Tloc(batptr[i],p))) - minvector[i]);
}
arrayindex[offset] = *o;
- p = BUNnext(batptr[0], p);
+ p++;
}
}
@@ -246,14 +289,14 @@
{
register BUN p = BUNfnd(val, &arrayindex[offset]);
- if (p == NULL) {
+ if (p == BUN_NONE) {
GDKerror("print_array: Value missing for oid
%d.\n", arrayindex[offset]);
goto exit_err_full;
}
#ifdef EXCESSIVE_DEBUGGING
fprintf(stderr, "[EMAIL PROTECTED]",
arrayindex[offset]);
#endif
- ATOMprint(type_id, BUNtail(val, p), st);
+ ATOMprint(type_id, BUNtail(vali, p), st);
if (stream_errnr(st))
goto exit_err_full;
}
Index: iterator.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB4/src/modules/contrib/iterator.mx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- iterator.mx 20 Feb 2007 11:32:10 -0000 1.3
+++ iterator.mx 4 Oct 2007 10:35:08 -0000 1.4
@@ -227,7 +227,7 @@
ITERinit(ITER *input, str name, NEXTfcn next, FREEfcn freefcn, GUESSfcn guess,
BAT *b, BAT *h, BAT *t)
{
ITER *it = (ITER *) GDKmalloc(sizeof(ITER));
- BAT *v = VIEWcreate_(b, TRUE);
+ BAT *v = VIEWcreate_(b, b, TRUE);
oid hseq = BAThdense(v) ? v->hseqbase - chunksize : oid_nil;
oid tseq = BATtdense(v) ? v->tseqbase - chunksize : oid_nil;
Index: malalgebra.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB4/src/modules/contrib/malalgebra.mx,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- malalgebra.mx 18 May 2007 16:46:56 -0000 1.4
+++ malalgebra.mx 4 Oct 2007 10:35:11 -0000 1.5
@@ -167,8 +167,8 @@
static BAT *
BATmalhashjoin(BAT *l, BAT *r)
{
- size_t lsize = l->batBuns->size + (l->hheap ? l->hheap->size : 0) +
(l->theap ? l->theap->size : 0);
- size_t rsize = r->batBuns->size + (r->hheap ? r->hheap->size : 0) +
(r->theap ? r->theap->size : 0);
+ size_t lsize = l->H->heap.size + l->T->heap.size + (l->hheap ?
l->hheap->size : 0) + (l->theap ? l->theap->size : 0);
+ size_t rsize = r->H->heap.size + r->T->heap.size + (r->hheap ?
r->hheap->size : 0) + (r->theap ? r->theap->size : 0);
if (rsize < lsize) {
return BATmirror(BAThashjoin(BATmirror(r), BATmirror(l),
oid_nil));
@@ -267,19 +267,19 @@
@= sumcmd
int [EMAIL PROTECTED](BAT **ret, BAT *b ) {
+ BATiter bi = bat_iterator(b);
BAT *bn = BATnew(b->htype, BATttype(b), BATcount(b));
BUN p, q;
- int xx;
oid cur;
@1 sum = 0;
bn->hsorted = b->hsorted;
bn->tsorted = 0;
if (BATcount(b))
- cur = *(oid*)BUNhead(b,BUNfirst(b));
- BATloopFast(b, p, q, xx) {
- oid *h = (oid*) BUNhead(b,p);
- @1 *t = (@1*) BUNtail(b,p);
+ cur = *(oid*)BUNhead(bi,BUNfirst(b));
+ BATloop(b, p, q) {
+ oid *h = (oid*) BUNhead(bi,p);
+ @1 *t = (@1*) BUNtail(bi,p);
if (cur != *h){
BUNfastins(bn, &cur, &sum );
Index: bat_mmath.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB4/src/modules/contrib/bat_mmath.mx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- bat_mmath.mx 20 Feb 2007 11:32:10 -0000 1.3
+++ bat_mmath.mx 4 Oct 2007 10:35:08 -0000 1.4
@@ -80,9 +80,8 @@
int
[EMAIL PROTECTED]@2(BAT **ret, BAT *b)
{
- REGISTER chr *bp, *bq;
- REGISTER @1 *bnp;
- REGISTER int bs = BUNsize(b);
+ @1 *bp, *bq;
+ @1 *bnp;
BAT *bn;
ALGODEBUG THRprintf(GDKout, "[EMAIL
PROTECTED]@2(b=%s);\n",BATgetId(b));
@@ -93,19 +92,17 @@
bn = BATnew(TYPE_void, b->ttype, BATcount(b));
BATseqbase(bn,b->hseqbase);
bn->tsorted = 0;
- bq = (chr*)BUNtloc(b,BUNlast(b));
- bp = (chr*)BUNtloc(b,BUNfirst(b));
- bnp = (@1*)BUNtloc(bn,BUNlast(bn));
- for (; bp < bq; bp+=bs) {
+ bq = (@1*)Tloc(b,BUNlast(b));
+ bp = (@1*)Tloc(b,BUNfirst(b));
+ bnp = (@1*)Tloc(bn,BUNlast(bn));
+ for (; bp < bq; bp++) {
REGISTER @1 bv = *(@1*)bp;
if (bv != @1_nil) {
bv = @2(bv);
}
- *bnp = bv;
- bnp++;
+ *bnp++ = bv;
}
- bn->batBuns->free = (BUN)bnp - bn->batBuns->base;
- BATsetcount(bn, bn->batBuns->free/BUNsize(bn));
+ BATsetcount(bn, ((char*)bnp - bn->T->heap.base)/Tsize(bn));
if (!bn->batDirty) bn->batDirty = TRUE;
*ret = bn;
@@ -116,7 +113,7 @@
int
[EMAIL PROTECTED]@2(BAT **ret, BAT *l, BAT *r)
{
- REGISTER @1 *bnp;
+ @1 *bnp, *lp, *lq, *rp;
BAT *bn;
ALGODEBUG THRprintf(GDKout, "[EMAIL
PROTECTED]@2(l=%s,r=%s);\n",BATgetId(l),BATgetId(r));
@@ -127,81 +124,20 @@
BATseqbase(bn,l->hseqbase);
bn->tsorted = 0;
- if ((BUNsize(l)==sizeof(@1))&&(BUNsize(r)==sizeof(@1))) {
- REGISTER @1 *lp, *lq, *rp;
- REGISTER int cnt = 4096/(int)sizeof(@1);
- @1* lbuf = GDKmalloc(2*cnt*sizeof(@1));
- @1* rbuf = lbuf+cnt;
-
- lq = (@1*)BUNtloc(l,BUNlast(l));
- lp = (@1*)BUNtloc(l,BUNfirst(l));
- rp = (@1*)BUNtloc(r,BUNfirst(r));
- bnp = (@1*)BUNtloc(bn,BUNlast(bn));
- for (; lp < lq; lp+=cnt, rp+=cnt) {
- /* 0 <= cnt <= 4096, so cast to int is safe */
- REGISTER int x = (int) (lq - lp < cnt ? lq - lp : cnt);
- REGISTER int y = x*(int)sizeof(@1);
- REGISTER int i;
- memcpy(lbuf,lp,y);
- memcpy(rbuf,rp,y);
- for (i=0; i<x; i++) {
- if ((lbuf[i] != @1_nil) && (rbuf[i] != @1_nil))
{
- *bnp = @2(lbuf[i], rbuf[i]);
- } else {
- *bnp = @1_nil;
- }
- bnp++;
- }
- }
- GDKfree(lbuf);
- } else if ((BUNsize(l)==BUNsize(r))) {
- REGISTER chr *lp, *lq, *rp;
- REGISTER int bs = BUNsize(l);
- REGISTER int sze = (4096/bs)*bs;
- chr* lbuf = GDKmalloc(2*sze);
- chr* rbuf = lbuf+sze;
-
- lq = (chr*)BUNtloc(l,BUNlast(l));
- lp = (chr*)BUNtloc(l,BUNfirst(l));
- rp = (chr*)BUNtloc(r,BUNfirst(r));
- bnp = (@1*)BUNtloc(bn,BUNlast(bn));
- for (; lp < lq; lp+=sze, rp+=sze) {
- /* 0 <= sze <= 4096, so cast to int is safe */
- REGISTER int z = (int) (lq - lp < sze ? lq - lp : sze);
- REGISTER chr *lbp=lbuf, *lbq=lbuf+z, *rbp=rbuf;
- memcpy(lbuf,lp,z);
- memcpy(rbuf,rp,z);
- for (; lbp < lbq; lbp+=bs, rbp+=bs) {
- if ((*(@1*)lbp != @1_nil) && (*(@1*)rbp !=
@1_nil)) {
- *bnp = @2(*(@1*)lbp, *(@1*)rbp);
- } else {
- *bnp = @1_nil;
- }
- bnp++;
- }
- }
- GDKfree(lbuf);
- } else {
- REGISTER chr *lp, *lq, *rp;
- REGISTER int ls = BUNsize(l);
- REGISTER int rs = BUNsize(r);
-
- lq = (chr*)BUNtloc(l,BUNlast(l));
- lp = (chr*)BUNtloc(l,BUNfirst(l));
- rp = (chr*)BUNtloc(r,BUNfirst(r));
- bnp = (@1*)BUNtloc(bn,BUNlast(bn));
- for (; lp < lq; lp+=ls, rp+=rs) {
- if ((*(@1*)lp != @1_nil) && (*(@1*)rp != @1_nil)) {
- *bnp = @2(*(@1*)lp, *(@1*)rp);
- } else {
- *bnp = @1_nil;
- }
- bnp++;
+ lq = (@1*)Tloc(l,BUNlast(l));
+ lp = (@1*)Tloc(l,BUNfirst(l));
+ rp = (@1*)Tloc(r,BUNfirst(r));
+ bnp = (@1*)Tloc(bn,BUNlast(bn));
+ for (; lp < lq; lp++, rp++) {
+ if ((*lp != @1_nil) && (*rp != @1_nil)) {
+ *bnp = @2(*lp, *rp);
+ } else {
+ *bnp = @1_nil;
}
+ bnp++;
}
- bn->batBuns->free = (BUN)bnp - bn->batBuns->base;
- BATsetcount(bn, bn->batBuns->free/BUNsize(bn));
+ BATsetcount(bn, ((char*)bnp - bn->T->heap.base)/Tsize(bn));
if (!bn->batDirty) bn->batDirty = TRUE;
*ret = bn;
@@ -210,10 +146,8 @@
int
[EMAIL PROTECTED]@2(BAT **ret, @1 *v, BAT *b)
{
- REGISTER chr *bp, *bq;
- REGISTER @1 *bnp;
- REGISTER @1 vv = (((*v)[EMAIL PROTECTED])?(*v):@1_nil);
- REGISTER int bs = BUNsize(b);
+ @1 *bp, *bq, *bnp;
+ @1 vv = (((*v)[EMAIL PROTECTED])?(*v):@1_nil);
BAT *bn;
ALGODEBUG THRprintf(GDKout, "[EMAIL
PROTECTED]@2(v,b=%s);\n",BATgetId(b));
@@ -224,12 +158,12 @@
bn = BATnew(TYPE_void, b->ttype, BATcount(b));
BATseqbase(bn,b->hseqbase);
bn->tsorted = 0;
- bq = (chr*)BUNtloc(b,BUNlast(b));
- bp = (chr*)BUNtloc(b,BUNfirst(b));
- bnp = (@1*)BUNtloc(bn,BUNlast(bn));
+ bq = (@1*)Tloc(b,BUNlast(b));
+ bp = (@1*)Tloc(b,BUNfirst(b));
+ bnp = (@1*)Tloc(bn,BUNlast(bn));
if (vv != @1_nil) {
- for (; bp < bq; bp+=bs) {
- REGISTER @1 bv = *(@1*)bp;
+ for (; bp < bq; bp++) {
+ @1 bv = *(@1*)bp;
if (bv != @1_nil) {
bv = @2(vv,bv);
}
@@ -237,13 +171,12 @@
bnp++;
}
} else {
- for (; bp < bq; bp+=bs) {
+ for (; bp < bq; bp++) {
*bnp = vv;
bnp++;
}
}
- bn->batBuns->free = (BUN)bnp - bn->batBuns->base;
- BATsetcount(bn, bn->batBuns->free/BUNsize(bn));
+ BATsetcount(bn, ((char*)bnp - bn->T->heap.base)/Tsize(bn));
if (!bn->batDirty) bn->batDirty = TRUE;
*ret = bn;
@@ -252,10 +185,8 @@
int
[EMAIL PROTECTED]@2(BAT **ret, BAT *b, @1 *v)
{
- REGISTER chr *bp, *bq;
- REGISTER @1 *bnp;
- REGISTER @1 vv = (((*v)[EMAIL PROTECTED])?(*v):@1_nil);
- REGISTER int bs = BUNsize(b);
+ @1 *bp, *bq, *bnp;
+ @1 vv = (((*v)[EMAIL PROTECTED])?(*v):@1_nil);
BAT *bn;
ALGODEBUG THRprintf(GDKout, "[EMAIL
PROTECTED]@2(v,b=%s);\n",BATgetId(b));
@@ -265,12 +196,12 @@
bn = BATnew(TYPE_void, b->ttype, BATcount(b));
BATseqbase(bn,b->hseqbase);
bn->tsorted = 0;
- bq = (chr*)BUNtloc(b,BUNlast(b));
- bp = (chr*)BUNtloc(b,BUNfirst(b));
- bnp = (@1*)BUNtloc(bn,BUNlast(bn));
+ bq = (@1*)Tloc(b,BUNlast(b));
+ bp = (@1*)Tloc(b,BUNfirst(b));
+ bnp = (@1*)Tloc(bn,BUNlast(bn));
if (vv != @1_nil) {
- for (; bp < bq; bp+=bs) {
- REGISTER @1 bv = *(@1*)bp;
+ for (; bp < bq; bp++) {
+ @1 bv = *(@1*)bp;
if (bv != @1_nil) {
bv = @2(bv,vv);
}
@@ -278,13 +209,12 @@
bnp++;
}
} else {
- for (; bp < bq; bp+=bs) {
+ for (; bp < bq; bp++) {
*bnp = vv;
bnp++;
}
}
- bn->batBuns->free = (BUN)bnp - bn->batBuns->base;
- BATsetcount(bn, bn->batBuns->free/BUNsize(bn));
+ BATsetcount(bn, ((char*)bnp - bn->T->heap.base)/Tsize(bn));
if (!bn->batDirty) bn->batDirty = TRUE;
*ret = bn;
Index: Makefile.ag
===================================================================
RCS file: /cvsroot/monetdb/MonetDB4/src/modules/contrib/Makefile.ag,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- Makefile.ag 12 Sep 2007 10:54:28 -0000 1.6
+++ Makefile.ag 4 Oct 2007 10:35:04 -0000 1.7
@@ -23,47 +23,33 @@
DIR = pkglibdir
SEP = _
SOURCES = \
- bitset.mx bitvector.mx iterator.mx malalgebra.mx \
- mel.mx oo7.mx uchr.mx qt.mx salgebra.mx vector.mx \
- wisc.mx ddbench.mx \
+ bitset.mx malalgebra.mx \
+ mel.mx uchr.mx salgebra.mx vector.mx \
+ wisc.mx \
bat_mmath.mx bat_cast.mx array.mx color.mx \
image.mx txtsim.mx
- HEADERS = h proto.h m
- #SCRIPTS = mil ""
- LIBS = $(MONETDB_LIBS) -lstream -lbat \
- ../../monet/libmonet ../plain/lib_algebra \
- $(SOCKET_LIBS) $(Z_LIBS) $(BZ_LIBS) \
- $(MALLOC_LIBS) $(PTHREAD_LIBS) $(DL_LIBS) $(MATH_LIBS)
-}
-LIB_mprof = {
- DIR = pkglibdir
- SEP = _
- COND = NOT_WIN32
- SOURCES = mprof.mx
+ # bitvector.mx ddbench.mx iterator.mx oo7.mx qt.mx
HEADERS = h proto.h m
+ #SCRIPTS = mil ""
LIBS = $(MONETDB_LIBS) -lstream -lbat \
../../monet/libmonet ../plain/lib_algebra \
$(SOCKET_LIBS) $(Z_LIBS) $(BZ_LIBS) \
$(MALLOC_LIBS) $(PTHREAD_LIBS) $(DL_LIBS) $(MATH_LIBS)
}
-headers_mprof = {
- HEADERS = mil
- DIR = pkglibdir
- COND = NOT_WIN32
- SOURCES = mprof.mx
-}
+# mprof.mx
headers_mil = {
HEADERS = mil
DIR = pkglibdir
SOURCES = \
- bitset.mx bitvector.mx iterator.mx malalgebra.mx \
- mel.mx oo7.mx uchr.mx qt.mx salgebra.mx vector.mx \
- wisc.mx ddbench.mx \
+ bitset.mx malalgebra.mx \
+ mel.mx uchr.mx salgebra.mx vector.mx \
+ wisc.mx \
bat_mmath.mx bat_cast.mx array.mx color.mx \
image.mx txtsim.mx
+ # bitvector.mx ddbench.mx iterator.mx oo7.mx qt.mx
}
EXTRA_DIST_DIR = Tests
Index: txtsim.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB4/src/modules/contrib/txtsim.mx,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- txtsim.mx 20 Feb 2007 11:32:11 -0000 1.3
+++ txtsim.mx 4 Oct 2007 10:35:14 -0000 1.4
@@ -899,10 +899,10 @@
unsigned int i, j;
BAT *bn;
- oid *qbuf = (oid *) BUNtloc(qgram, BUNfirst(qgram));
- int *ibuf = (int *) BUNtloc(id, BUNfirst(id));
- int *pbuf = (int *) BUNtloc(pos, BUNfirst(pos));
- int *lbuf = (int *) BUNtloc(len, BUNfirst(len));
+ oid *qbuf = (oid *) Tloc(qgram, BUNfirst(qgram));
+ int *ibuf = (int *) Tloc(id, BUNfirst(id));
+ int *pbuf = (int *) Tloc(pos, BUNfirst(pos));
+ int *lbuf = (int *) Tloc(len, BUNfirst(len));
ERRORcheck((qgram->ttype != TYPE_oid), "CMDqgramselfjoin: tail of BAT
qgram must be oid.\n");
ERRORcheck((id->ttype != TYPE_int), "CMDqgramselfjoin: tail of BAT id
must be int.\n");
@@ -916,11 +916,11 @@
ERRORcheck((ALIGNsynced(qgram, pos) == 0), "CMDqgramselfjoin: qgram and
pos are not synced");
ERRORcheck((ALIGNsynced(qgram, len) == 0), "CMDqgramselfjoin: qgram and
len are not synced");
- ERRORcheck((BUNsize(qgram) != ATOMsize(qgram->ttype)),
"CMDqgramselfjoin: qgram is not a true void bat");
- ERRORcheck((BUNsize(id) != ATOMsize(id->ttype)), "CMDqgramselfjoin: id
is not a true void bat");
+ ERRORcheck((Tsize(qgram) != ATOMsize(qgram->ttype)), "CMDqgramselfjoin:
qgram is not a true void bat");
+ ERRORcheck((Tsize(id) != ATOMsize(id->ttype)), "CMDqgramselfjoin: id is
not a true void bat");
- ERRORcheck((BUNsize(pos) != ATOMsize(pos->ttype)), "CMDqgramselfjoin:
pos is not a true void bat");
- ERRORcheck((BUNsize(len) != ATOMsize(len->ttype)), "CMDqgramselfjoin:
len is not a true void bat");
+ ERRORcheck((Tsize(pos) != ATOMsize(pos->ttype)), "CMDqgramselfjoin: pos
is not a true void bat");
+ ERRORcheck((Tsize(len) != ATOMsize(len->ttype)), "CMDqgramselfjoin: len
is not a true void bat");
*res = bn = BATnew(TYPE_int, TYPE_int, n);
Index: bat_cast.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB4/src/modules/contrib/bat_cast.mx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- bat_cast.mx 3 Jan 2007 12:23:34 -0000 1.2
+++ bat_cast.mx 4 Oct 2007 10:35:07 -0000 1.3
@@ -55,9 +55,8 @@
@c
@= implementation
int [EMAIL PROTECTED]@2(BAT **ret, BAT *b) {
- REGISTER chr *bp, *bq;
- REGISTER @2 *bnp;
- REGISTER int bs = BUNsize(b);
+ @1 *bp, *bq;
+ @2 *bnp;
BAT *bn;
ALGODEBUG THRprintf(GDKout, "[EMAIL
PROTECTED]@2(b=%s);\n",BATgetId(b));
@@ -67,16 +66,15 @@
bn = BATnew(TYPE_void, [EMAIL PROTECTED], BATcount(b));
BATseqbase(bn,b->hseqbase);
bn->tsorted = 0;
- bq = (chr*)BUNtloc(b,BUNlast(b));
- bp = (chr*)BUNtloc(b,BUNfirst(b));
- bnp = (@2*)BUNtloc(bn,BUNlast(bn));
- for (; bp < bq; bp+=bs) {
+ bq = (@1*)Tloc(b,BUNlast(b));
+ bp = (@1*)Tloc(b,BUNfirst(b));
+ bnp = (@2*)Tloc(bn,BUNlast(bn));
+ for (; bp < bq; bp++) {
REGISTER @1 bv = *(@1*)bp;
*bnp = (bv != @1_nil) ? (@2)bv : @2_nil;
bnp++;
}
- bn->batBuns->free = (BUN)bnp - bn->batBuns->base;
- BATsetcount(bn, bn->batBuns->free/BUNsize(bn));
+ BATsetcount(bn, ((char*)bnp - bn->T->heap.base)/Tsize(bn));
if (!bn->batDirty) bn->batDirty = TRUE;
*ret = bn;
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Monetdb-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins