⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 opt_costmodel.c

📁 一个内存数据库的源代码这是服务器端还有客户端
💻 C
📖 第 1 页 / 共 2 页
字号:
#line 85 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"#include "mal_config.h"#include "opt_costModel.h"static voidfixPropertySet(MalBlkPtr mb, int dst){	if (mb->var[dst]->props == 0)		mb->var[dst]->props = newPropertySet();}#define getVarRows(Y) (int*)getPropertyValue(mb->var[Y]->props,"rows")#define getVarSize(Y) (int*)getPropertyValue(mb->var[Y]->props,"size")#line 120 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"static voidOPTbackpropagate(MalBlkPtr mb, int i, int idx){	int *rows;	InstrPtr p;	for( ; i > 0; i--){		p= getInstrPtr(mb,i);		if( getFunctionId(p) == setWriteModeRef){			rows= getVarRows(getArg(p,1));			if( rows == NULL  || *rows) continue;			*rows = *getVarRows(idx);		} 	}}#line 144 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"static intOPTcostModelImplementation(MalBlkPtr mb, MalStkPtr stk, InstrPtr pci){	int i, *c1, *c2, k;	InstrPtr p;	str sortrevRef= putName("sortReverse",11);	str sortrevTailRef= putName("sortReverseTail",15);	str projectRef= putName("project",7);	(void) stk;	(void) pci;	for (i = 0; i < mb->stop; i++) {		p = getInstrPtr(mb, i);		if (getModuleId(p)==algebraRef) {			if (getFunctionId(p) == markTRef  || 				getFunctionId(p) == markHRef  ||				getFunctionId(p) == selectNotNilRef  ||				getFunctionId(p) == sortRef  ||				getFunctionId(p) == sortTailRef  ||				getFunctionId(p) == sortrevRef  ||				getFunctionId(p) == sortrevTailRef  ||				getFunctionId(p) == projectRef  ){				#line 113 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"		#line 100 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"{		c1 = getVarRows(getArg(p,1));		c2 = getVarRows(getArg(p,1));		if( c1 == NULL) continue;		if( c2 == NULL) continue;		k= ( *c1);		fixPropertySet(mb, getArg(p,0));		setProperty(getProps(mb,getArg(p,0)),"rows","=", TYPE_int, &k);#ifdef DEBUG_OPT_COSTMODEL		stream_printf(GDKout,"COST of 1 1 into 0: %d\n",k);		printInstruction(GDKout,mb,p,0);#endif}#line 113 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"#line 166 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"			} else			if(	getFunctionId(p) == unionRef ||				getFunctionId(p) == kunionRef) {				#line 115 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"		#line 100 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"{		c1 = getVarRows(getArg(p,1));		c2 = getVarRows(getArg(p,2));		if( c1 == NULL) continue;		if( c2 == NULL) continue;		k= ( *c1+*c2);		fixPropertySet(mb, getArg(p,0));		setProperty(getProps(mb,getArg(p,0)),"rows","=", TYPE_int, &k);#ifdef DEBUG_OPT_COSTMODEL		stream_printf(GDKout,"COST of 1 2 into 0: %d\n",k);		printInstruction(GDKout,mb,p,0);#endif}#line 115 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"#line 170 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"			} else if (getFunctionId(p)== kdifferenceRef) {				#line 115 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"		#line 100 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"{		c1 = getVarRows(getArg(p,1));		c2 = getVarRows(getArg(p, 2));		if( c1 == NULL) continue;		if( c2 == NULL) continue;		k= ( *c1==0? 0: *c2==0? *c1: *c1 - *c2 < 0 ? 1 : *c1 - *c2+1);		fixPropertySet(mb, getArg(p,0));		setProperty(getProps(mb,getArg(p,0)),"rows","=", TYPE_int, &k);#ifdef DEBUG_OPT_COSTMODEL		stream_printf(GDKout,"COST of 1  2 into 0: %d\n",k);		printInstruction(GDKout,mb,p,0);#endif}#line 115 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"#line 172 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"			} else if (getFunctionId(p) == joinRef ) {				/* assume 1-1 joins */				#line 115 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"		#line 100 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"{		c1 = getVarRows(getArg(p,1));		c2 = getVarRows(getArg(p, 2));		if( c1 == NULL) continue;		if( c2 == NULL) continue;		k= ( *c1 < *c2 ? *c1 : *c2);		fixPropertySet(mb, getArg(p,0));		setProperty(getProps(mb,getArg(p,0)),"rows","=", TYPE_int, &k);#ifdef DEBUG_OPT_COSTMODEL		stream_printf(GDKout,"COST of 1  2 into 0: %d\n",k);		printInstruction(GDKout,mb,p,0);#endif}#line 115 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"#line 175 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"			} else if (getFunctionId(p) == semijoinRef ) {				/* assume 1-1 semijoins */				#line 115 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"		#line 100 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"{		c1 = getVarRows(getArg(p,1));		c2 = getVarRows(getArg(p, 2));		if( c1 == NULL) continue;		if( c2 == NULL) continue;		k= ( *c1 < *c2 ? *c1 : *c2);		fixPropertySet(mb, getArg(p,0));		setProperty(getProps(mb,getArg(p,0)),"rows","=", TYPE_int, &k);#ifdef DEBUG_OPT_COSTMODEL		stream_printf(GDKout,"COST of 1  2 into 0: %d\n",k);		printInstruction(GDKout,mb,p,0);#endif}#line 115 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"#line 178 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"			} else if (getFunctionId(p) == selectRef ||				   getFunctionId(p) == uselectRef) {				#line 113 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"		#line 100 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"{		c1 = getVarRows(getArg(p,1));		c2 = getVarRows(getArg(p,1));		if( c1 == NULL) continue;		if( c2 == NULL) continue;		k= ( *c1 > 100 ? *c1 / 2 +1: *c1);		fixPropertySet(mb, getArg(p,0));		setProperty(getProps(mb,getArg(p,0)),"rows","=", TYPE_int, &k);#ifdef DEBUG_OPT_COSTMODEL		stream_printf(GDKout,"COST of 1 1 into 0: %d\n",k);		printInstruction(GDKout,mb,p,0);#endif}#line 113 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"#line 181 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"			} else if (getFunctionId(p) == crossRef) {				#line 115 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"		#line 100 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"{		c1 = getVarRows(getArg(p,1));		c2 = getVarRows(getArg(p, 2));		if( c1 == NULL) continue;		if( c2 == NULL) continue;		k= ( (log((double) *c1) + log((double) *c2) > log(INT_MAX) ? INT_MAX : *c1 * *c2 +1));		fixPropertySet(mb, getArg(p,0));		setProperty(getProps(mb,getArg(p,0)),"rows","=", TYPE_int, &k);#ifdef DEBUG_OPT_COSTMODEL		stream_printf(GDKout,"COST of 1  2 into 0: %d\n",k);		printInstruction(GDKout,mb,p,0);#endif}#line 115 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"#line 183 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"			} else if (getFunctionId(p) == tuniqueRef ) {				#line 113 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"		#line 100 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"{		c1 = getVarRows(getArg(p,1));		c2 = getVarRows(getArg(p,1));		if( c1 == NULL) continue;		if( c2 == NULL) continue;		k= ( *c1 < 50 ? *c1 : *c1 / 10+1);		fixPropertySet(mb, getArg(p,0));		setProperty(getProps(mb,getArg(p,0)),"rows","=", TYPE_int, &k);#ifdef DEBUG_OPT_COSTMODEL		stream_printf(GDKout,"COST of 1 1 into 0: %d\n",k);		printInstruction(GDKout,mb,p,0);#endif}#line 113 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"#line 185 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"			}		} else if (getModuleId(p) == batcalcRef) {			if( isaBatType(getArgType(mb,p,1)) )				#line 113 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"		#line 100 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"{		c1 = getVarRows(getArg(p,1));		c2 = getVarRows(getArg(p,1));		if( c1 == NULL) continue;		if( c2 == NULL) continue;		k= ( *c1);		fixPropertySet(mb, getArg(p,0));		setProperty(getProps(mb,getArg(p,0)),"rows","=", TYPE_int, &k);#ifdef DEBUG_OPT_COSTMODEL		stream_printf(GDKout,"COST of 1 1 into 0: %d\n",k);		printInstruction(GDKout,mb,p,0);#endif}#line 113 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"#line 189 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"			else				#line 113 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"		#line 100 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"{		c1 = getVarRows(getArg(p,2));		c2 = getVarRows(getArg(p,2));		if( c1 == NULL) continue;		if( c2 == NULL) continue;		k= ( *c2);		fixPropertySet(mb, getArg(p,0));		setProperty(getProps(mb,getArg(p,0)),"rows","=", TYPE_int, &k);#ifdef DEBUG_OPT_COSTMODEL		stream_printf(GDKout,"COST of 2 2 into 0: %d\n",k);		printInstruction(GDKout,mb,p,0);#endif}#line 113 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"#line 191 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"		} else if (getModuleId(p) == batRef) {			if (getFunctionId(p) == reverseRef ||			    getFunctionId(p) == setWriteModeRef  ||			    getFunctionId(p) == hashRef  ||			    getFunctionId(p) == mirrorRef) {				#line 113 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"		#line 100 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_costModel.mx"{		c1 = getVarRows(getArg(p,1));		c2 = getVarRows(getArg(p,1));		if( c1 == NULL) continue;		if( c2 == NULL) continue;		k= ( *c1);		fixPropertySet(mb, getArg(p,0));		setProperty(getProps(mb,getArg(p,0)),"rows","=", TYPE_int, &k);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -