[prev in list] [next in list] [prev in thread] [next in thread] 

List:       monetdb-checkins
Subject:    [Monetdb-checkins] MonetDB5/src/optimizer opt_replicator.mx, , 1.5,
From:       Milena Ivanova <mivanova () users ! sourceforge ! net>
Date:       2008-01-30 17:29:07
Message-ID: E1JKGkM-00046V-HZ () mail ! sourceforge ! net
[Download RAW message or body]

Update of /cvsroot/monetdb/MonetDB5/src/optimizer
In directory sc8-pr-cvs16.sourceforge.net:/tmp/cvs-serv11396/optimizer

Modified Files:
	opt_replicator.mx 
Log Message:
Collect statistics for executions of select


Index: opt_replicator.mx
===================================================================
RCS file: /cvsroot/monetdb/MonetDB5/src/optimizer/opt_replicator.mx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- opt_replicator.mx	29 Jan 2008 09:09:43 -0000	1.5
+++ opt_replicator.mx	30 Jan 2008 17:29:05 -0000	1.6
@@ -51,6 +51,15 @@
 pattern replicator.uselect(dst:bat[:any_1,:any_2],low:any_2,hgh:any_2):bat[:any_1,:any_2]
 address REPuselect
 comment "The overloaded uselect operator for replicated operations";
+
+command init():void
+address REPinit
+comment "Initialize replica table"
+
+command dump():void
+address REPdump
+comment "Dump summary of replica table for potential re-use benefits"
+
 @h
 #ifndef _OPT_REPLICATOR_
 #define _OPT_REPLICATOR_
@@ -62,12 +71,54 @@
 opt_export str REPuselect(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
 opt_export str REPprelude(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci);
 
+opt_export str REPinit(void);
+opt_export str REPdump(void);
+
 /* #define DEBUG_OPT_REPLICATOR  */
 @-
 @c
 #include "mal_config.h"
 #include "opt_replicator.h"
 
+typedef struct REPLICAREC {
+        bat srcbid, resbid;                /* partition BAT, back into BBP */
+
+        ValRecord low,hgh; /* selected tail range */
+        bit li, hi; 	/* inclusive bits */
+        size_t cnt;     /* how many tuples */
+	dbl cost;	/* how much time was spent to produce */
+	MalBlkPtr malblk; /* mal instruction block*/
+} *Replica, ReplicaRec;
+
+static Replica repltable = NULL;
+static int replsz = 0;  /* alloc. mem */
+static int replnr = 0;	/* number of replicas */
+
+static void assureSpace(){
+	if ( replsz == 0){
+		replsz = 16;
+		repltable = (ReplicaRec*)GDKzalloc((replsz)*sizeof(ReplicaRec));
+	}
+	else if( replnr == replsz){
+		replsz <<=1;
+		repltable = (ReplicaRec*) GDKrealloc((void*)repltable,
+				 sizeof(ReplicaRec) * replsz);
+	}
+}
+
+str
+REPinit(){
+	str msg= MAL_SUCCEED;
+
+        if ( repltable != NULL){
+		GDKfree(repltable);
+                replsz = replnr = 0;
+        }
+	assureSpace();
+	return msg;
+}
+
+
 static int
 OPTreplicatorImplementation(MalBlkPtr mb, MalStkPtr stk, InstrPtr p)
 {
@@ -148,6 +199,7 @@
 	bit t=TRUE,*li=&t,*hi=&t;
 	BAT *b;
 	lng cnt,clk;
+	Replica r;
 	str msg= MAL_SUCCEED;
 	
 	(void) mb;
@@ -165,11 +217,21 @@
 	clk= GDKusec()-clk;
 
 	/* time for the decision */
-	if ( (b=BATdescriptor(*bid)) == NULL)
+	if ( (b=BATdescriptor(*ret)) == NULL)
 		throw(MAL,"replicator.select","can not access BAT");
 	cnt= BATcount(b);
-	(void) cnt;
-	(void) clk;
+	/* keep stat */
+	assureSpace();
+	r = repltable + replnr;
+	r->srcbid = *bid;
+	r->resbid = *ret;
+	VALset(&r->low,b->ttype,(ValPtr) low);
+	VALset(&r->hgh,b->ttype,(ValPtr) hgh);
+	r->li = *li;
+	r->hi = *hi; 
+	r->cnt = cnt;
+	r->cost = clk;
+	replnr++;
 	BBPunfix(b->batCacheid);
 
 	return msg;


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Monetdb-checkins mailing list
Monetdb-checkins@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/monetdb-checkins
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic