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

📄 opt_accessmode.c

📁 一个内存数据库的源代码这是服务器端还有客户端
💻 C
字号:
#line 52 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_accessmode.mx"#include "mal_config.h"#include "opt_accessmode.h"#include "mal_interpreter.h"static intOPTaccessmodeImplementation(MalBlkPtr mb, MalStkPtr stk, InstrPtr p){	int i, j, k;	int actions = 0;	InstrPtr *candidate;	int *writeable;	int top=0;	(void) stk;	candidate= (InstrPtr*) alloca(sizeof(InstrPtr) * mb->stop);	writeable= (int*) alloca(sizeof(int) * mb->vtop);	memset((char *)writeable,0, sizeof(int)*mb->vtop);	for(i=0; i<mb->stop; i++){		p= getInstrPtr(mb,i);		if( getFunctionId(p)== setWriteModeRef && getModuleId(p)== batRef ){			if( writeable[getArg(p,1)] ){				writeable[getArg(p,0)]= writeable[getArg(p,1)];				p->token= ASSIGNsymbol;				setModuleId(p,NULL);				setFunctionId(p,NULL);				p->argc=2;			} else{				candidate[top++] = p;				writeable[getArg(p,0)]= getArg(p,0);			}		} else		if( getModuleId(p)== batRef &&			( getFunctionId(p) == insertRef ||			  getFunctionId(p) == deleteRef ||			  getFunctionId(p) == appendRef ) ){				for(j=k=0; j<top;j++)				if( getArg(p,1) != getArg(candidate[j],0) )					candidate[k++]= candidate[j];				top= k;		}	}	/* now remove all candidates */	for( j=0; j<top; j++){		p= candidate[j];		/* turn it into an alias */		setModuleId(p,NULL);		setFunctionId(p,NULL);		p->token= ASSIGNsymbol;		p->argc= 2;		p->fcn= NULL;		actions++;	} #ifdef DEBUG_OPT_MODES	stream_printf(GDKout,"OPTIMIZE MODES\n");	printFunction(GDKout,mb,LIST_MAL_ALL);#endif	return actions;}#line 115 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_accessmode.mx"#line 113 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_accessmode.mx"/* #define _DEBUG_OPTIMIZER_*/str OPTaccessmode(MalBlkPtr mb, MalStkPtr stk, InstrPtr p){	str modnme;	str fcnnme;	Module  scope=NULL;	Symbol s= NULL;	lng clk= GDKusec();	int actions = 0;	optimizerInit();	if( p )		removeInstruction(mb, p);#ifdef _DEBUG_OPTIMIZER_	stream_printf(GDKout,"apply accessmode\n");	printFunction(GDKout,mb,LIST_MAL_ALL);#endif	if( p && p->argc > 1 && getFunctionId(p) != multiplexRef){#ifdef _DEBUG_OPTIMIZER_		stream_printf(GDKout,"locate function accessmode\n");#endif		if( getArgType(mb,p,1) != TYPE_str ||			getArgType(mb,p,2) != TYPE_str ||			!isConstant(mb,getArg(p,1)) ||			!isConstant(mb,getArg(p,2))		) {			char buf[1024];			snprintf(buf,1024, "Optimizer requires constant string arguments\n");			throw(MAL, "optimizer.accessmode",buf);		}		if( stk != 0){			modnme= (str)getArgValue(stk,p,1);			fcnnme= (str)getArgValue(stk,p,2);		} else {			modnme= getArgDefault(mb,p,1);			fcnnme= getArgDefault(mb,p,2);		}		scope = findModule(MCgetClient()->nspace,putName(modnme,strlen(modnme)) );		if( scope)			s= findSymbolInModule(scope,putName(fcnnme,strlen(fcnnme)));		if( s == NULL) {			char buf[1024];			snprintf(buf,1024, "Could not find %s.%s\n",modnme,fcnnme);			throw(MAL, "optimizer.accessmode",buf);		}#ifdef _DEBUG_OPTIMIZER_		stream_printf(GDKout,"accessmode %s %d\n",modnme,fcnnme);#endif		mb = s->def;		stk= 0;	} 	if( mb->errors )		return MAL_SUCCEED;	addtoMalBlkHistory(mb);	actions= OPTaccessmodeImplementation(mb,stk,p);#ifdef _DEBUG_OPTIMIZER_	stream_printf(GDKout,"finished accessmode %d\n",actions);	printFunction(GDKout,mb,LIST_MAL_ALL);#endif    optimizerCheck(mb, "optimizer.accessmode", actions, GDKusec() - clk,OPT_CHECK_ALL);	return MAL_SUCCEED;}#line 115 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_accessmode.mx"#line 117 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/optimizer/opt_accessmode.mx"

⌨️ 快捷键说明

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