Update of /cvsroot/monetdb/sql/src/backends/monet5
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv23380

Modified Files:
      Tag: Nov2009
        sql.mx 
Log Message:
Prepared the code for faster execution. Scales[0] seems to be a 1 for
consistency reasons with the rest. Remaining cast operations
should also be dealt with. Moreover, upcast in some cases can re-use
space, e.g. lng-dec2-dbl. [tobedone]


Index: sql.mx
===================================================================
RCS file: /cvsroot/monetdb/sql/src/backends/monet5/sql.mx,v
retrieving revision 1.358.2.1
retrieving revision 1.358.2.2
diff -u -d -r1.358.2.1 -r1.358.2.2
--- sql.mx      19 Oct 2009 18:00:51 -0000      1.358.2.1
+++ sql.mx      20 Oct 2009 21:19:12 -0000      1.358.2.2
@@ -2718,7 +2718,7 @@
 }
 
 lng scales[20] = {
-       LL_CONSTANT(0),
+       LL_CONSTANT(1),
        LL_CONSTANT(10),
        LL_CONSTANT(100),
        LL_CONSTANT(1000),
@@ -3234,8 +3234,9 @@
        BBPunfix(b->batCacheid);
        return msg;
 }
-...@c
-
+...@-
+The simple cast up operations in some cases
+could re-use the storage space as well.
 @= numcastup
 @:simpleupcast(@1,@2)@
 
@@ -3304,26 +3305,37 @@
 
 str b...@2_dec2_@1( int *res, int *s1, int *bid )
 {
-       BAT *b, *dst;
+       BAT *b, *bn;
        BATiter bi;
-       BUN p,q;
+       @2 *p,*q;
        char *msg = NULL;
+       int scale = *s1;
+       @1 *o;
 
        if( (b = BATdescriptor(*bid)) == NULL ){
                throw(SQL, "batca...@2_dec2_@1", "Cannot access descriptor");
        }
        bi = bat_iterator(b);
-       dst = BATnew(b->htype, ty...@1, BATcount(b));
-       BATseqbase(dst, b->hseqbase);
-       BATloop(b,p,q) {
-               @2 *v = (@2*)BUNtail(bi,p);
-               @1 r;
-               msg = @2_de...@1( &r, s1, v );
-               if (msg)
-                       break;
-               BUNins(dst, BUNhead(bi,p), &r, FALSE);
+       bn = BATnew(b->htype, ty...@1, BATcount(b));
+       BATseqbase(bn, b->hseqbase);
+       o = (@1*) Tloc(bn,BUNfirst(bn));
+       p = (@2*) Tloc(b, BUNfirst(b));
+       q = (@2*) Tloc(b, BUNlast(b));
+       if ( b->T->nonil){
+               for (; p<q; p++)
+                       *o = (@1) ((*p +  (*p<0)?-5:5) / scales[scale]);
+       } else{
+               if (*p == @2_nil) 
+                       *o = @1_nil;
+               else
+                       *o = (@1) ((*p +  (*p<0)?-5:5) / scales[scale]);
        }
-       BBPkeepref( *res = dst->batCacheid);
+       BATsetcount(bn, BATcount(b));
+    bn->tsorted = 0;
+    BATkey(BATmirror(bn),FALSE);
+    if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ);
+
+       BBPkeepref( *res = bn->batCacheid);
        BBPunfix(b->batCacheid);
        return msg;
 }


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Monetdb-sql-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/monetdb-sql-checkins

Reply via email to