Changeset: 91116f6f1186 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=91116f6f1186
Modified Files:
monetdb5/mal/Tests/tst017.mal
monetdb5/modules/kernel/Makefile.ag
monetdb5/modules/kernel/algebra.c.mx
monetdb5/modules/kernel/algebra.h.mx
monetdb5/modules/kernel/algebra.mal.mx
monetdb5/modules/mal/mal_init.mal
testing/Mtest.py.in
Branch: headless
Log Message:
Algebra first conversion
The algebra.mx file has been reduced and converted to columns.
There is no guarantee it will work.
diffs (truncated from 3070 to 300 lines):
diff --git a/monetdb5/mal/Tests/tst017.mal b/monetdb5/mal/Tests/tst017.mal
--- a/monetdb5/mal/Tests/tst017.mal
+++ b/monetdb5/mal/Tests/tst017.mal
@@ -2,7 +2,7 @@
b := column.new(nil:int);
aa_a := column.append(b,2);
ba_a := column.append(b,3);
- z := bbp.getLRefCount(b);
+ z := cbp.getLRefCount(b);
io.print(z);
- b := algebra.join(b,b);
- io.print(b);
+ (l,r) := algebra.join(b,b);
+ io.print(l,r));
diff --git a/monetdb5/modules/kernel/Makefile.ag
b/monetdb5/modules/kernel/Makefile.ag
--- a/monetdb5/modules/kernel/Makefile.ag
+++ b/monetdb5/modules/kernel/Makefile.ag
@@ -39,7 +39,8 @@
# aggr_bge_sum.mx \
# aggr.mx \
alarm.c \
-# algebra.mx \
+ algebra.h.mx \
+ algebra.c.mx \
# array.mx \
# group.mx \
# logger.c \
@@ -76,7 +77,7 @@
SOURCES = calc.mal.mx \
# aggr.mx \
alarm.mal \
- algebra.mx \
+ algebra.mal.mx \
# array.mx \
colcolor.mal.mx \
colcast.mal.mx \
@@ -96,8 +97,8 @@
unix.mal
}
-EXTRA_DIST = aggr_ri.mx colcolor.mal lock.mal lock.h sema.h sema.mal unix.mal
alarm.h alarm.mal\
- microbenchmark.mal microbenchmark.h
+EXTRA_DIST = algebra.h aggr_ri.mx lock.h sema.h alarm.h
+# microbenchmark.h
# logger.h \
EXTRA_DIST_DIR = Tests
diff --git a/monetdb5/modules/kernel/algebra.c.mx
b/monetdb5/modules/kernel/algebra.c.mx
--- a/monetdb5/modules/kernel/algebra.c.mx
+++ b/monetdb5/modules/kernel/algebra.c.mx
@@ -18,6 +18,7 @@
*/
@f algebra
+@c
/* Author(s) Peter Boncz, Martin Kersten, Niels Nes
* BAT Algebra
* This modules contains the most common algebraic BAT manipulation
@@ -36,20 +37,19 @@
* and we have to de-reference them before entering the gdk library.
* This calls for knowlegde on the underlying BAT typs`s
*/
-@= derefStr
-{int _tpe= ATOMstorage(@1->@2type);
- if( _tpe >= TYPE_str )
- { if(@3== 0 || *(str*)@3==0) @3 = (str)str_nil;
- else @3 = *(str *)@3;
+#define derefStr(X,Y) \
+{int _tpe= ATOMstorage(COLtype(X)); \
+ if( _tpe >= TYPE_str ) \
+ { if( (Y) == 0 || *(str*) (Y) ==0) (Y) = (str)str_nil; \
+ else (Y) = *(str *) (Y); \
}}
-@c
#include "monetdb_config.h"
#include "algebra.h"
#include "gdk_rangejoin.h"
#include <math.h>
-/* BAT sum operation
+/* Column sum operation
* The sum aggregate only works for int and float fields.
* The routines below assumes that the caller knows what type
* is large enough to prevent overflow.
@@ -58,66 +58,43 @@
* is large enough to prevent overflow.
*/
-@= aggrmax
- if (s > 0 && !(BATordered(b)&1)) {
- if (b->nonil) {
- COLforloop(b,o) {
- x = (ptr) BUNt@2(bi, p);
- if (@3_GT(x, v, @4)) {
- v = x;
- }
- }
- } else {
- COLforloop(b,o) {
- x = (ptr) BUNt@2(bi, p);
- if (@3_CMP(x, nil, @4) == 0) {
- v = nil;
- break;
- }
- if (@3_GT(x, v, @4)) {
- v = x;
- }
- }
- }
- }
-@c
/*
* The result of COLmin is stored in the area pointed at by aggr
* It should be large enough to hold the value returned.
*/
#define minloop(TYPE, TYPE_NIL) \
- v = &((TYPE*) lbase)[0]; \
+{ TYPE *lbase = (TYPE*) COLbase(b); \
+ TYPE v = lbase[0]; \
if (COLordered(b) & 1 ) { \
- *(TYPE*) aggr = *(TYPE*) v; \
+ *(TYPE*) aggr = lbase[COLfirst(b)]; \
break; \
} \
if (b->nonil) { \
COLforloop(b,o) \
- if ( ((TYPE*)lbase)[o] < *(TYPE*)v ) \
- v = &((TYPE*)lbase)[o]; \
+ if ( lbase[o] < v ) \
+ *(TYPE*)aggr = lbase[o]; \
} else \
COLforloop(b,o) { \
- if ( ((TYPE*)lbase)[o] == TYPE_NIL) { \
- v = &TYPE_NIL; \
+ if ( lbase[o] == TYPE_NIL) { \
+ *(TYPE*)aggr = TYPE_NIL; \
break; \
} \
- if ( ((TYPE*)lbase)[o] < v*(TYPE*)v ) \
- v = &((TYPE*)lbase)[o]; \
- } \
- memcpy(aggr, v, ATOMsize(t));
+ if ( lbase[o] < v ) \
+ *(TYPE*)aggr = lbase[o]; \
+ } }
+
void
COLmin(COL *b, ptr aggr)
{
int t;
- oid o;
- ptr v;
+ oid o = 0;
str s;
assert(aggr);
t = COLtype(b);
if ( COLcount(b) == 0) {
memcpy(aggr, ATOMnilptr(t), ATOMsize(t));
- return aggr;
+ return;
}
COLaccessBegin(b,USE_HEAP,MMAP_SEQUENTIAL);
@@ -141,7 +118,7 @@
minloop(lng,lng_nil);
break;
case TYPE_str:
- v = (ptr) COLget_str(b,o);
+ { str v = (ptr) COLget_str(b,o);
if (b->nonil)
COLforloop(b,o) {
s= COLget_str(b,o);
@@ -159,41 +136,37 @@
v = s;
}
*(str*) aggr = GDKstrdup((str)v);
- break;
- default:
- /* all others are represented in the heap */
+ }
}
COLaccessEnd(b,USE_HEAP,MMAP_SEQUENTIAL);
- return aggr;
}
#define maxloop(TYPE, TYPE_NIL) \
- v = &((TYPE*) lbase)[0]; \
+{ TYPE *lbase = (TYPE*) COLbase(b); \
+ TYPE v = lbase[0]; \
if (COLordered(b) & 1 ) { \
- *(TYPE*) aggr = *(TYPE*) v; \
+ *(TYPE*) aggr = lbase[COLfirst(b)]; \
break; \
} \
if (b->nonil) { \
COLforloop(b,o) \
- if ( ((TYPE*)lbase)[o] > *(TYPE*)v ) \
- v = &((TYPE*)lbase)[o]; \
+ if ( lbase[o] > v ) \
+ *(TYPE*) aggr = lbase[o]; \
} else \
COLforloop(b,o) { \
- if ( ((TYPE*)lbase)[o] == TYPE_NIL) { \
- v = &TYPE_NIL; \
+ if ( lbase[o] == TYPE_NIL) { \
+ *(TYPE*) aggr = TYPE_NIL; \
break; \
} \
- if ( ((TYPE*)lbase)[o] > v*(TYPE*)v ) \
- v = &((TYPE*)lbase)[o]; \
- } \
- memcpy(aggr, v, ATOMsize(t));
+ if ( lbase[o] > v ) \
+ *(TYPE*) aggr = lbase[o]; \
+ } }
ptr
COLmax(COL *b, ptr aggr)
{
int t;
- oid o;
- ptr v;
+ oid o = 0;
str s;
assert(aggr);
@@ -224,7 +197,7 @@
maxloop(lng,lng_nil);
break;
case TYPE_str:
- v = (ptr) COLget_str(b,o);
+ { str v = (ptr) COLget_str(b,o);
if (b->nonil)
COLforloop(b,o) {
s= COLget_str(b,o);
@@ -234,300 +207,18 @@
else
COLforloop(b,o) {
s= COLget_str(b,o);
- if ( strcmp(s,nil) == 0){
- v = (ptr) nil;
+ if ( strcmp(s,str_nil) == 0){
+ v = (ptr) str_nil;
break;
}
if ( strcmp(s,(str) v) > 0)
v = (ptr) s;
}
*(str*) aggr = GDKstrdup((str)v);
- break;
- default:
- /* all others are represented in the heap */
+ }
}
COLaccessEnd(b,USE_HEAP,MMAP_SEQUENTIAL);
-}
-
-@* Command Implementations in C
-This module contains just a wrapper implementations; since all described
-operations are part of the GDK kernel.
-
-@c
-int
-CMDselect1(BAT **result, BAT *b, ptr value)
-{
- ptr v = (b->ttype == TYPE_bat) ? (ptr) &((BAT *) value)->cacheid :
value;
-
- return (*result = COLselect(b, v, 0)) ? GDK_SUCCEED : GDK_FAIL;
-}
-
-int
-CMDuselect1(BAT **result, BAT *b, ptr value)
-{
- ptr v = (b->ttype == TYPE_bat) ? (ptr) &((BAT *) value)->cacheid :
value;
-
- return (*result = COLuselect(b, v, 0)) ? GDK_SUCCEED : GDK_FAIL;
-}
-
-int
-CMDantiuselect1(BAT **result, BAT *b, ptr value)
-{
- ptr v = (b->ttype == TYPE_bat) ? (ptr) &((BAT *) value)->cacheid :
value;
-
- return (*result = BATantiuselect_(b, v, NULL, TRUE, TRUE)) ?
GDK_SUCCEED : GDK_FAIL;
-}
-
-int
-CMDselect(BAT **result, BAT *b, ptr low, ptr high)
-{
- ptr l = (b->ttype == TYPE_bat) ? (ptr) &((BAT *) low )->cacheid : low ;
- ptr h = (b->ttype == TYPE_bat) ? (ptr) &((BAT *) high)->cacheid : high;
-
- if (b->ttype == TYPE_bat && l != h ) {
- GDKerror("CMDselect: range-selects on type BAT are not
supported\n");
- return GDK_FAIL;
- }
- return (*result = COLselect(b, l, h)) ? GDK_SUCCEED : GDK_FAIL;
-}
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list