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

📄 batifthen.c

📁 一个内存数据库的源代码这是服务器端还有客户端
💻 C
📖 第 1 页 / 共 5 页
字号:
#line 361 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"#include "mal_config.h"#include "batifthen.h"#line 100 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"batifthen_export str CMDifThen_int(int *ret, int *bid, int *tid);strCMDifThen_int(int *ret, int *bid, int *tid) {	BAT *b, *tb, *bn;	int nilval=  (int) int_nil, *val;	BUN p,q;	size_t xx;	#line 63 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"	if( (b= BATdescriptor(*bid)) == NULL ){ ;		 throw(MAL, "batcalc.ifThen", "cannot access descriptor");   }#line 108 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"	#line 63 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"	if( (tb= BATdescriptor(*tid)) == NULL ){ BBPreleaseref(b->batCacheid);		 throw(MAL, "batcalc.ifThen", "cannot access descriptor");   }#line 109 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"	#line 84 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"	if( BATcount(b) != BATcount(tb) )	throw(MAL, "batcalc.CMDifThen", "requires bats of identical size");#line 110 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"	if( BAThvoid(b))		bn= BATnew(TYPE_oid,TYPE_int,BATcount(b));	else{		bn= BATnew(b->htype,TYPE_int,BATcount(b));	}	if( bn == 0 )		throw(MAL, "batcalc.ifThen","Can not create BAT");	bn->hsorted= b->hsorted;	bn->tsorted= b->tsorted;	BATloopFast(b, p, q, xx) {		bit *t= (bit*) BUNtail(b,p);		if( *(bit *) t == bit_nil) 			BUNfastins(bn, BUNhead(b,p), (ptr) & nilval);		else if( *(bit *) t ) {			val = (int*) BUNtail(tb,BUNptr(tb,BUNindex(b,p)));			BUNfastins(bn, BUNhead(b,p), val);		}	}	BBPreleaseref(tb->batCacheid);	#line 87 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"    if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ);    *ret= bn->batCacheid;    BBPkeepref(*ret);    BBPreleaseref(b->batCacheid);    return MAL_SUCCEED;#line 131 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"}batifthen_export str CMDifThenCst_int(int *ret, int *bid, int *tid);str CMDifThenCst_int(int *ret, int *bid, int *tid){	BAT *b, *bn;	int nilval= (int) int_nil;	BUN p,q;	size_t xx;	#line 63 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"	if( (b= BATdescriptor(*bid)) == NULL ){ ;		 throw(MAL, "batcalc.ifThen", "cannot access descriptor");   }#line 141 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"	#line 63 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"    if (BAThvoid(b)) {        bn = BATnew(TYPE_void, TYPE_int, BATcount(b));        BATseqbase(bn, b->hseqbase);    } else        bn = BATnew(b->htype, TYPE_int, BATcount(b));	if( bn== NULL) {				throw(MAL, "batcalc.ifThen", "can not create bat");	}    bn->hsorted = b->hsorted;    bn->tsorted = b->tsorted;#line 142 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"	if( BAThvoid(b))		bn= BATnew(TYPE_oid,TYPE_int,BATcount(b));	else		bn= BATnew(b->htype,TYPE_int,BATcount(b));	if( bn == 0 )		throw(MAL, "batcalc.ifThen","Can not create BAT");	bn->hsorted= b->hsorted;	bn->tsorted= b->tsorted;	BATloopFast(b, p, q, xx) {		ptr t = BUNtail(b,p);		if( *(bit*) t== bit_nil) 			BUNfastins(bn,BUNhead(b,p), (ptr) & nilval);		else if( *(bit*) t ) 			BUNfastins(bn,BUNhead(b,p),(ptr) tid);	}	#line 87 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"    if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ);    *ret= bn->batCacheid;    BBPkeepref(*ret);    BBPreleaseref(b->batCacheid);    return MAL_SUCCEED;#line 159 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"}batifthen_export str CMDifThenElseCst_int(int *ret, int *bid, int *tid, int *eid);str CMDifThenElseCst_int(int *ret, int *bid, int *tid, int *eid){	BAT *b, *bn;	int nilval= (int) int_nil;	#line 63 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"	if( (b= BATdescriptor(*bid)) == NULL ){ ;		 throw(MAL, "batcalc.ifThenElse", "cannot access descriptor");   }#line 166 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"	#line 63 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"    if (BAThvoid(b)) {        bn = BATnew(TYPE_void, TYPE_int, BATcount(b));        BATseqbase(bn, b->hseqbase);    } else        bn = BATnew(b->htype, TYPE_int, BATcount(b));	if( bn== NULL) {				throw(MAL, "batcalc.ifThenElse", "can not create bat");	}    bn->hsorted = b->hsorted;    bn->tsorted = b->tsorted;#line 167 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"	if( b->htype == TYPE_void && !ATOMvarsized(b->ttype)){		BUN p,q;		int *o;		size_t xx= BUNsize(b);		o= (int*) BUNtail(bn,BUNfirst(bn));		p= BUNtail(b,BUNfirst(b));		q= BUNtail(b,BUNlast(b));		while(p<q){			if( *(bit*) p== bit_nil) 				*o++ = (int) int_nil;			else if( *(bit*) p ) 				*o++ = *tid;			else				*o++ = *eid;			p += xx; 		}		(bn)->batBuns->free += BATcount(b)*sizeof(int);		BATsetcount(bn, BATcount(b));	} else {		BUN p,q;		size_t xx;		BATloopFast(b, p, q, xx) {			bit t = *(bit*)BUNtail(b,p);			if( t== bit_nil) 				BUNfastins(bn, BUNhead(b,p), (ptr) & nilval);			else if( t ) 				BUNfastins(bn, BUNhead(b,p), (ptr) tid);			else				BUNfastins(bn, BUNhead(b,p), (ptr) eid);		}	}	#line 87 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"    if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ);    *ret= bn->batCacheid;    BBPkeepref(*ret);    BBPreleaseref(b->batCacheid);    return MAL_SUCCEED;#line 202 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"}batifthen_export str CMDifThenElse_int(int *ret, int *bid, int *tid, int *eid);strCMDifThenElse_int(int *ret, int *bid, int *tid, int *eid){	BAT *b, *tb, *eb, *bn;	int nilval= (int) int_nil;	#line 63 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"	if( (b= BATdescriptor(*bid)) == NULL ){ ;		 throw(MAL, "batcalc.ifThenElse", "cannot access descriptor");   }#line 212 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"	#line 63 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"	if( (tb= BATdescriptor(*tid)) == NULL ){ BBPreleaseref(b->batCacheid);;		 throw(MAL, "batcalc.ifThenElse", "cannot access descriptor");   }#line 213 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"	#line 63 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"	if( (eb= BATdescriptor(*eid)) == NULL ){  BBPreleaseref(b->batCacheid); BBPreleaseref(tb->batCacheid);;		 throw(MAL, "batcalc.ifThenElse", "cannot access descriptor");   }#line 214 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"	#line 84 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"	if( BATcount(b) != BATcount(tb) )	throw(MAL, "batcalc.ifThenElse", "requires bats of identical size");#line 215 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"	#line 84 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"	if( BATcount(b) != BATcount(eb) )	throw(MAL, "batcalc.ifThenElse", "requires bats of identical size");#line 216 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"	#line 63 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"    if (BAThvoid(b)) {        bn = BATnew(TYPE_void, TYPE_int, BATcount(b));        BATseqbase(bn, b->hseqbase);    } else        bn = BATnew(b->htype, TYPE_int, BATcount(b));	if( bn== NULL) {				throw(MAL, "batcalc.ifThenElse", "can not create bat");	}    bn->hsorted = b->hsorted;    bn->tsorted = b->tsorted;#line 217 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"	if( b->htype == TYPE_void && !ATOMvarsized(b->ttype)){		BUN p,q;		int *o, *t,*e;		size_t px = BUNsize(b);		size_t tx = BUNsize(tb);		size_t ex = BUNsize(eb);		o= (int*) BUNtail(bn,BUNfirst(bn));		p= BUNtail(b,BUNfirst(b));		q= BUNtail(b,BUNlast(b));		t= (int*) BUNtail(tb,BUNfirst(tb));		e= (int*) BUNtail(eb,BUNfirst(eb));		while(p<q){			if( *(bit*) p== bit_nil) 				*o++ = (int) int_nil;			else if( *(bit*) p ) 				*o++ = *t;			else *o++ = *e;			p+= px;  t+=tx; e+=ex;		}		(bn)->batBuns->free += BATcount(b)*sizeof(int);		BATsetcount(bn, BATcount(b));	} else {		BUN p,q;		size_t xx;		BATloopFast(b, p, q, xx) {			bit t = *(bit*) BUNtail(b,p);			int idx = BUNindex(b, p);			if( t== bit_nil) 				BUNfastins(bn, BUNhead(b,p), (ptr) &nilval);			else if( t ) 				BUNfastins(bn, BUNhead(b,p), BUNtail(tb, BUNptr(tb, idx)));			else				BUNfastins(bn, BUNhead(b,p), BUNtail(eb, BUNptr(eb, idx)));		}	}	BBPreleaseref(tb->batCacheid);	BBPreleaseref(eb->batCacheid);	#line 87 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"    if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ);    *ret= bn->batCacheid;    BBPkeepref(*ret);    BBPreleaseref(b->batCacheid);    return MAL_SUCCEED;#line 258 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"}batifthen_export str CMDifThenElseCst1_int(int *ret, int *bid, int *val, int *eid);strCMDifThenElseCst1_int(int *ret, int *bid, int *val, int *eid){	BAT *b, *eb, *bn;	int nilval= (int) int_nil;	#line 63 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"	if( (b= BATdescriptor(*bid)) == NULL ){ ;		 throw(MAL, "batcalc.ifThenElse", "cannot access descriptor");   }#line 268 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"	#line 63 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"	if( (eb= BATdescriptor(*eid)) == NULL ){  BBPreleaseref(b->batCacheid);;		 throw(MAL, "batcalc.ifThenElse", "cannot access descriptor");   }#line 269 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"	#line 84 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"	if( BATcount(b) != BATcount(eb) )	throw(MAL, "batcalc.ifThenElse", "requires bats of identical size");#line 270 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"	#line 63 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"    if (BAThvoid(b)) {        bn = BATnew(TYPE_void, TYPE_int, BATcount(b));        BATseqbase(bn, b->hseqbase);    } else        bn = BATnew(b->htype, TYPE_int, BATcount(b));	if( bn== NULL) {				throw(MAL, "batcalc.ifThenElse", "can not create bat");	}    bn->hsorted = b->hsorted;    bn->tsorted = b->tsorted;#line 271 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"	if( b->htype == TYPE_void && !ATOMvarsized(b->ttype)){		BUN p,q;		int *o,*e;		size_t px= BUNsize(b);		size_t ex= BUNsize(eb);		o= (int*) BUNtail(bn,BUNfirst(bn));		p= BUNtail(b,BUNfirst(b));		q= BUNtail(b,BUNlast(b));		e= (int*) BUNtail(eb,BUNfirst(eb));		while(p<q){			if( *(bit*) p== bit_nil) 				*o++ = (int) int_nil;			else if( *(bit*) p ) 				*o++ = *val;			else *o++ = *e;			p+=px;  e+=ex;		}		(bn)->batBuns->free += BATcount(b)*sizeof(int);		BATsetcount(bn, BATcount(b));	} else {		BUN p,q;		size_t xx;		BATloopFast(b, p, q, xx) {			bit t = *(bit*) BUNtail(b,p);			int idx = BUNindex(b, p);			if( t== bit_nil) 				BUNfastins(bn, BUNhead(b,p), (ptr) &nilval);			else if( t ) 				BUNfastins(bn, BUNhead(b,p), (ptr) val);			else				BUNfastins(bn, BUNhead(b,p), BUNtail(eb, BUNptr(eb, idx)));		}	}	BBPreleaseref(eb->batCacheid);	#line 87 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"    if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ);    *ret= bn->batCacheid;    BBPkeepref(*ret);    BBPreleaseref(b->batCacheid);    return MAL_SUCCEED;#line 308 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/batifthen.mx"}batifthen_export str CMDifThenElseCst2_int(int *ret, int *bid, int *tid, int *val);strCMDifThenElseCst2_int(int *ret, int *bid, int *tid, int *val){	BAT *b, *tb, *bn;

⌨️ 快捷键说明

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