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

📄 algebra.mx

📁 一个内存数据库的源代码这是服务器端还有客户端
💻 MX
📖 第 1 页 / 共 5 页
字号:
@:ALGprod_implementation(flt,flt,1.0)@@:ALGprod_implementation(flt,dbl,1.0)@@:ALGprod_implementation(dbl,dbl,1.0)@@= avg_implstr ALGavg_@1(dbl *res, int *bid) {	BAT *b;	if( (b= BATdescriptor(*bid)) == NULL ){		 throw(MAL, "algebra.prod", "Cannot access descriptor");	}	CMDavg_@1(res,b);	BBPreleaseref(b->batCacheid);	return MAL_SUCCEED;}@c@:avg_impl(sht)@@:avg_impl(int)@@:avg_impl(lng)@@:avg_impl(flt)@@:avg_impl(dbl)@@-@= ALGaggregate_implementationalgebra_export str ALGmin_@1(@1* res, int *bid) ;str ALGmin_@1(@1* res, int *bid) {	BAT *b;	if( (b= BATdescriptor(*bid)) == NULL ){		 throw(MAL, "algebra.min", "Cannot access descriptor");	}	if( CMDmin_@1(res,b)) {		BBPreleaseref(b->batCacheid);		return MAL_SUCCEED;	}	BBPreleaseref(b->batCacheid);	throw(MAL, "algebra.min", "GDKerror");}algebra_export str ALGmax_@1(@1* res, int *bid) ;str ALGmax_@1(@1* res, int *bid) {	BAT *b;	if( (b= BATdescriptor(*bid)) == NULL ){		 throw(MAL, "algebra.min", "Cannot access descriptor");	}	if( CMDmax_@1(res,b)) {		BBPreleaseref(b->batCacheid);		return MAL_SUCCEED;	}	BBPreleaseref(b->batCacheid);	throw(MAL, "algebra.max", "GDKerror");}@c@:ALGaggregate_implementation(sht)@@:ALGaggregate_implementation(int)@@:ALGaggregate_implementation(flt)@@:ALGaggregate_implementation(dbl)@@:ALGaggregate_implementation(lng)@algebra_export str ALGminany(ptr result, int *bid);strALGminany(ptr result, int *bid){	BAT *b;	if ((b = BATdescriptor(*bid)) == NULL) {		throw(MAL, "algebra.min", "Cannot access descriptor");	}	if (CMDminany(result, b) == GDK_SUCCEED) {		BBPreleaseref(b->batCacheid);		return MAL_SUCCEED;	}	BBPreleaseref(b->batCacheid);	throw(MAL, "algebra.min", "GDKerror");}algebra_export str ALGmaxany(ptr result, int *bid);strALGmaxany(ptr result, int *bid){	BAT *b;	if ((b = BATdescriptor(*bid)) == NULL) {		throw(MAL, "algebra.min", "Cannot access descriptor");	}	if (CMDmaxany(result, b) == GDK_SUCCEED) {		BBPreleaseref(b->batCacheid);		return MAL_SUCCEED;	}	BBPreleaseref(b->batCacheid);	throw(MAL, "algebra.max", "GDKerror");}algebra_export str ALGtopN(int *res, int *bid, lng *top);strALGtopN(int *res, int *bid, lng *top){	BAT *b;	b = BATdescriptor(*bid);	if (b == NULL) {		throw(MAL, "algebra.top", "Cannot access descriptor");	}	/* TOP N works inplace, ie deletes ... */	(void) BATtopN(b, (size_t) *top);	*res = b->batCacheid;	BBPkeepref(b->batCacheid);	return MAL_SUCCEED;}algebra_export str ALGgroupby(int *res, int *bid);strALGgroupby(int *res, int *bid){	BAT *b,*bn;	b = BATdescriptor(*bid);	if (b == NULL) {		throw(MAL, "algebra.groupby", "Cannot access descriptor");	}	if( CMDgen_group(&bn,b) == GDK_FAIL){		BBPreleaseref(b->batCacheid);		throw(MAL, "algebra.groupby","unknown error");	}	if( bn){		*res = bn->batCacheid;		if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ);		BBPkeepref(bn->batCacheid);	}	BBPreleaseref(b->batCacheid);	return MAL_SUCCEED;}algebra_export str ALGcard(lng *result, int *bid);strALGcard(lng *result, int *bid){	BAT *b, *bn;	if ((b = BATdescriptor(*bid)) == NULL) {		throw(MAL, "algebra.card", "Cannot access descriptor");	}	bn = (BAT *) BATkunique(BATmirror(b));	if (bn == NULL) {		throw(MAL, "algebra.card", "GDKerror");	}	*result = BATcount(bn);	BBPunfix(bn->batCacheid);	BBPreleaseref(b->batCacheid);	return MAL_SUCCEED;}algebra_export str ALGBATminimum(ptr *result, int *bid);strALGBATminimum(ptr *result, int *bid){	BAT *b;	if ((b = BATdescriptor(*bid)) == NULL) {		throw(MAL, "algebra.min", "Cannot access descriptor");	}	BATmin(b, result);	BBPreleaseref(b->batCacheid);	return MAL_SUCCEED;}algebra_export str ALGBATmaximum(ptr *result, int *bid);strALGBATmaximum(ptr *result, int *bid){	BAT *b;	if ((b = BATdescriptor(*bid)) == NULL) {		throw(MAL, "algebra.max", "Cannot access descriptor");	}	BATmax(b, result);	BBPreleaseref(b->batCacheid);	return MAL_SUCCEED;}algebra_export str ALGselect1(int *result, int *bid, ptr value);strALGselect1(int *result, int *bid, ptr value){	BAT *b, *bn = NULL;	if ((b = BATdescriptor(*bid)) == NULL) {		throw(MAL, "algebra.select", "Cannot access descriptor");	}	@:derefStr(b,t,value)@	CMDselect1(&bn, b, value);	BBPreleaseref(b->batCacheid);	if (bn) {		if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ);		*result = bn->batCacheid;		BBPkeepref(*result);		return MAL_SUCCEED;	}	throw(MAL, "algebra.select", "GDKerror");}algebra_export str ALGselect1Head(int *result, int *bid, ptr value);strALGselect1Head(int *result, int *bid, ptr value){	BAT *b, *bn = NULL;	if ((b = BATdescriptor(*bid)) == NULL) {		throw(MAL, "algebra.select", "Cannot access descriptor");	}	b = BATmirror(b);	@:derefStr(b,t,value)@	CMDselect1(&bn, b, value);	bn = BATmirror(bn);	BBPreleaseref(b->batCacheid);	if (bn) {		if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ);		*result = bn->batCacheid;		BBPkeepref(*result);		return MAL_SUCCEED;	}	throw(MAL, "algebra.select", "GDKerror");}algebra_export str ALGuselect1(int *result, int *bid, ptr value);strALGuselect1(int *result, int *bid, ptr value){	BAT *b, *bn = NULL;	if ((b = BATdescriptor(*bid)) == NULL) {		throw(MAL, "algebra.uselect", "Cannot access descriptor");	}	@:derefStr(b,t,value)@	CMDuselect1(&bn, b, value);	BBPreleaseref(b->batCacheid);	if (bn) {		if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ);		*result = bn->batCacheid;		BBPkeepref(*result);		return MAL_SUCCEED;	}	throw(MAL, "algebra.uselect", "GDKerror");}algebra_export str ALGselect(int *result, int *bid, ptr low, ptr high);strALGselect(int *result, int *bid, ptr low, ptr high){	BAT *b, *bn = NULL;	if ((b = BATdescriptor(*bid)) == NULL) {		throw(MAL, "algebra.select", "Cannot access descriptor");	}	@:derefStr(b,t,low)@	@:derefStr(b,t,high)@	CMDselect(&bn, b, low, high);	BBPreleaseref(b->batCacheid);	if (bn) {		if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ);		*result = bn->batCacheid;		BBPkeepref(*result);		return MAL_SUCCEED;	}	throw(MAL, "algebra.select", "GDKerror");}algebra_export str ALGselectNotNil(int *result, int *bid);strALGselectNotNil(int *result, int *bid){	BAT *b, *bn = NULL;	ptr low,high;	bit bound=FALSE;	if ((b = BATdescriptor(*bid)) == NULL) 		throw(MAL, "algebra.selectNotNil", "Cannot access descriptor");	if( BATcount_no_nil(b) != BATcount(b) ){		low=high= ATOMnilptr(b->ttype);		CMDselect_(&bn, b, low, high, &bound, &bound);		BBPreleaseref(b->batCacheid);		if (bn) {			if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ);			*result = bn->batCacheid;			BBPkeepref(*result);			return MAL_SUCCEED;		}		throw(MAL, "algebra.select", "GDKerror");	}	/* just pass on the result */	*result = b->batCacheid;	BBPkeepref(*result);	return MAL_SUCCEED;}algebra_export str ALGselectHead(int *result, int *bid, ptr low, ptr high);strALGselectHead(int *result, int *bid, ptr low, ptr high){	BAT *b, *bn = NULL;	if ((b = BATdescriptor(*bid)) == NULL) {		throw(MAL, "algebra.select", "Cannot access descriptor");	}	b = BATmirror(b);	@:derefStr(b,t,low)@	@:derefStr(b,t,high)@	CMDselect(&bn, b, low, high);	bn = BATmirror(bn);	BBPreleaseref(b->batCacheid);	if (bn) {		if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ);		*result = bn->batCacheid;		BBPkeepref(*result);		return MAL_SUCCEED;	}	throw(MAL, "algebra.select", "GDKerror");}algebra_export str ALGuselect(int *result, int *bid, ptr low, ptr high);strALGuselect(int *result, int *bid, ptr low, ptr high){	BAT *b, *bn = NULL;	if ((b = BATdescriptor(*bid)) == NULL) {		throw(MAL, "algebra.uselect", "Cannot access descriptor");	}	@:derefStr(b,t,low);@	@:derefStr(b,t,high);@	CMDuselect(&bn, b, low, high);	BBPreleaseref(b->batCacheid);	if (bn) {		if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ);		*result = bn->batCacheid;		BBPkeepref(*result);		return MAL_SUCCEED;	}	throw(MAL, "algebra.uselect", "GDKerror");}algebra_export str ALGselectInclusive(int *result, int *bid, ptr low, ptr high, bit *lin, bit *rin);strALGselectInclusive(int *result, int *bid, ptr low, ptr high, bit *lin, bit *rin){	BAT *b, *bn = NULL;	if ((b = BATdescriptor(*bid)) == NULL) {		throw(MAL, "algebra.select", "Cannot access descriptor");	}	@:derefStr(b,t,low)@	@:derefStr(b,t,high)@	CMDselect_(&bn, b, low, high, lin, rin);	BBPreleaseref(b->batCacheid);	if (bn) {		if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ);		*result = bn->batCacheid;		BBPkeepref(*result);		return MAL_SUCCEED;	}	throw(MAL, "algebra.select", "GDKerror");}algebra_export str ALGselectInclusiveHead(int *result, int *bid, ptr low, ptr high, bit *lin, bit *rin);strALGselectInclusiveHead(int *result, int *bid, ptr low, ptr high, bit *lin, bit *rin){	BAT *b, *bn = NULL;	if ((b = BATdescriptor(*bid)) == NULL) {		throw(MAL, "algebra.select", "Cannot access descriptor");	}	b = BATmirror(b);	@:derefStr(b,t,low)@	@:derefStr(b,t,high)@	CMDselect_(&bn, b, low, high, lin, rin);	bn = BATmirror(bn);	BBPreleaseref(b->batCacheid);	if (bn) {		if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ);		*result = bn->batCacheid;		BBPkeepref(*result);		return MAL_SUCCEED;	}	throw(MAL, "algebra.select", "GDKerror");}algebra_export str ALGuselectInclusive(int *result, int *bid, ptr low, ptr high, bit *lin, bit *rin);strALGuselectInclusive(int *result, int *bid, ptr low, ptr high, bit *lin, bit *rin){	BAT *b, *bn = NULL;	if ((b = BATdescriptor(*bid)) == NULL) {		throw(MAL, "algebra.select", "Cannot access descriptor");	}	@:derefStr(b,t,low);@	@:derefStr(b,t,high);@	CMDuselect_(&bn, b, low, high, lin, rin);	BBPreleaseref(b->batCacheid);	if (bn) {		if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ);		*result = bn->batCacheid;		BBPkeepref(*result);		return MAL_SUCCEED;	}	throw(MAL, "algebra.uselect", "GDKerror");}algebra_export str ALGfragment(int *result, int *bid, ptr hlow, ptr hhigh, ptr tlow, ptr thigh);strALGfragment(int *result, int *bid, ptr hlow, ptr hhigh, ptr tlow, ptr thigh){	BAT *b, *bn = NULL;	if ((b = BATdescriptor(*bid)) == NULL) {		throw(MAL, "algebra.fragment", "Cannot access descriptor");	}	@:derefStr(b,h,hlow);@	@:derefStr(b,h,hhigh);@	@:derefStr(b,t,tlow);@	@:derefStr(b,t,thigh);@	CMDfragment(&bn, b, hlow, hhigh, tlow, thigh);	BBPreleaseref(b->batCacheid);	if (bn) {		if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ);		*result = bn->batCacheid;		BBPkeepref(*result);		return MAL_SUCCEED;	}	throw(MAL, "algebra.fragment", "GDKerror");}algebra_export str ALGthetajoinEstimate(int *result, int *lid, int *rid, int *opc, lng *estimate);strALGthetajoinEstimate(int *result, int *lid, int *rid, int *opc, lng *estimate){	BAT *left, *right, *bn = NULL;	if ((left = BATdescriptor(*lid)) == NULL) {		throw(MAL, "algebra.thetajoin", "Cannot access descriptor");	}	if ((right = BATdescriptor(*rid)) == NULL) {		BBPreleaseref(left->batCacheid);		throw(MAL, "algebra.thetajoin", "Cannot access descriptor");	}	if( *opc == -3 ){		/* The NE case is not supported in the kernel */		BBPreleaseref(left->batCacheid);		BBPreleaseref(right->batCacheid);		throw(MAL, "algebra.thetajoin", "theta <> not yet supported");	} 	CMDthetajoin(&bn, left, right, opc, estimate);	BBPreleaseref(left->batCacheid);	BBPreleaseref(right->batCacheid);	if (bn) {		if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ);		*result = bn->batCacheid;		BBPkeep

⌨️ 快捷键说明

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