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

📄 algebra.mx

📁 一个内存数据库的源代码这是服务器端还有客户端
💻 MX
📖 第 1 页 / 共 5 页
字号:
intCMDmin_@1(@1* result, BAT *b){	return BATmin(b, result)?GDK_SUCCEED:GDK_FAIL;}intCMDmax_@1(@1* result, BAT *b){	return BATmax(b, result)?GDK_SUCCEED:GDK_FAIL;}@= atomaggr	if (s > 0 && !(BATtordered(b)&1)) {		char* nil = BATatoms[t].atomNull;		BUN p,q;		int xx;		BATloopFast(b, p, q, xx) {			x = (ptr) BUNt@2(b, p);			if (@3_CMP(x, nil, @4) == 0) {				v = nil;				break;			}			if (@3_@5(x, v, @4)) {				v = x;			}		}	}	if (aggr) {	   memcpy(aggr, x=v, ATOMsize(t));	} else {	   /* alloc new space and copy the atom into it */	   s = ATOMlen(t, v);	   memcpy(x = (ptr) GDKmalloc(s), v, s);   }@= voidaggr	if (aggr) {		*(oid *) aggr = *(oid *) (x=v);	} else {		/* alloc new space and copy the atom into it */		memcpy(x = (ptr) GDKmalloc(sizeof(oid)), v, s);	}@= aggrmin	v = (s == 0)?ATOMnilptr(t):BUNtail(b, BUNfirst(b));	@:@5aggr(@1,@2,@3,@4,LT)@@= aggrmax	v = (s == 0)?ATOMnilptr(t):BUNtail(b, BUNlast(b)-BUNsize(b));	@:@5aggr(@1,@2,@3,@4,GT)@@c@:sum_implementation(sht,sht,0)@@:sum_implementation(sht,int,0)@@:sum_implementation(sht,lng,0)@@:sum_implementation(sht,dbl,0)@@:sum_implementation(int,int,0)@@:sum_implementation(int,lng,0)@@:sum_implementation(int,dbl,0)@@:sum_implementation(lng,lng,0)@@:sum_implementation(lng,dbl,0)@@:sum_implementation(flt,flt,0.0)@@:sum_implementation(flt,dbl,0.0)@@:sum_implementation(dbl,dbl,0.0)@@:prod_implementation(sht,sht,1)@@:prod_implementation(sht,int,1)@@:prod_implementation(sht,lng,1)@@:prod_implementation(int,int,1)@@:prod_implementation(int,lng,1)@@:prod_implementation(lng,lng,1)@@:prod_implementation(flt,flt,1.0)@@:prod_implementation(flt,dbl,1.0)@@:prod_implementation(dbl,dbl,1.0)@@:avg_implementation(sht)@@:avg_implementation(int)@@:avg_implementation(lng)@@:avg_implementation(flt)@@:avg_implementation(dbl)@@:aggregate_implementation(sht)@@:aggregate_implementation(int)@@:aggregate_implementation(flt)@@:aggregate_implementation(dbl)@@:aggregate_implementation(lng)@intCMDminany(ptr result, BAT *b){	if (!ATOMlinear(b->ttype))		return GDKerror("CMDminANY: atom '%s' cannot be ordered linearly\n", ATOMname(b->ttype));	if (ATOMvarsized(b->ttype)) {			*(ptr *) result = BATmin(b, NULL);			return (result)?GDK_SUCCEED:GDK_FAIL;	}	if (BATmin(b, result)) {		if (b->ttype == TYPE_bat)			*(BAT **) result = BATdescriptor(*(bat *) result);		return GDK_SUCCEED;	}	return GDK_FAIL;}intCMDmaxany(ptr result, BAT *b){	if (!ATOMlinear(b->ttype))		return GDKerror("CMDmaxANY: atom '%s' cannot be ordered linearly\n", ATOMname(b->ttype));	if (ATOMvarsized(b->ttype)) {			*(ptr *) result = BATmax(b, NULL);			return (result)?GDK_SUCCEED:GDK_FAIL;	}	if (BATmax(b, result)) {		if (b->ttype == TYPE_bat)			*(BAT **) result = BATdescriptor(*(bat *) result);		return GDK_SUCCEED;	}	return GDK_FAIL;}@* Command Implementations in CThis module contains just a wrapper implementations; since all describedoperations are part of the GDK kernel.@cintCMDselect1(BAT **result, BAT *b, ptr value){	ptr v = (b->ttype == TYPE_bat) ? (ptr) &((BAT *) value)->batCacheid : value;	return (*result = BATselect(b, v, 0)) ? GDK_SUCCEED : GDK_FAIL;}intCMDuselect1(BAT **result, BAT *b, ptr value){	ptr v = (b->ttype == TYPE_bat) ? (ptr) &((BAT *) value)->batCacheid : value;	return (*result = BATuselect(b, v, 0)) ? GDK_SUCCEED : GDK_FAIL;}intCMDselect(BAT **result, BAT *b, ptr low, ptr high){	ptr l = (b->ttype == TYPE_bat) ? (ptr) &((BAT *) low )->batCacheid : low ;	ptr h = (b->ttype == TYPE_bat) ? (ptr) &((BAT *) high)->batCacheid : high;	if (b->ttype == TYPE_bat && l != h ) {		GDKerror("CMDselect: range-selects on type BAT are not supported\n");		return GDK_FAIL;	}	return (*result = BATselect(b, l, h)) ? GDK_SUCCEED : GDK_FAIL;}intCMDuselect(BAT **result, BAT *b, ptr low, ptr high){	ptr l = (b->ttype == TYPE_bat) ? (ptr) &((BAT *) low )->batCacheid : low ;	ptr h = (b->ttype == TYPE_bat) ? (ptr) &((BAT *) high)->batCacheid : high;	if (b->ttype == TYPE_bat && l != h ) {		GDKerror("CMDuselect: range-selects on type BAT are not supported\n");		return GDK_FAIL;	}	return (*result = BATuselect(b, l, h)) ? GDK_SUCCEED : GDK_FAIL;}intCMDselect_(BAT **result, BAT *b, ptr low, ptr high, bit *l_in, bit *h_in){	int tt = b->ttype;	ptr nil = ATOMnilptr(tt);	ptr l = (b->ttype == TYPE_bat) ? (ptr) &((BAT *) low )->batCacheid : low ;	ptr h = (b->ttype == TYPE_bat) ? (ptr) &((BAT *) high)->batCacheid : high;	if (b->ttype == TYPE_bat && l != h ) {		GDKerror("CMDselect: range-selects on type BAT are not supported\n");		return GDK_FAIL;	}	if (*l_in == bit_nil && ATOMcmp(tt, l, nil)) {		GDKerror("CMDselect: flag 'l_in' must not be NIL, unless boundary 'low' is NIL\n");		return GDK_FAIL;	}	if (*h_in == bit_nil && ATOMcmp(tt, h, nil)) {		GDKerror("CMDselect: flag 'h_in' must not be NIL, unless boundary 'high' is NIL\n");		return GDK_FAIL;	}	return (*result = BATselect_(b, l, h, *l_in, *h_in)) ? GDK_SUCCEED : GDK_FAIL;}intCMDuselect_(BAT **result, BAT *b, ptr low, ptr high, bit *l_in, bit *h_in){	int tt = b->ttype;	ptr nil = ATOMnilptr(tt);	ptr l = (b->ttype == TYPE_bat) ? (ptr) &((BAT *) low )->batCacheid : low ;	ptr h = (b->ttype == TYPE_bat) ? (ptr) &((BAT *) high)->batCacheid : high;	if (b->ttype == TYPE_bat && l != h ) {		GDKerror("CMDuselect: range-selects on type BAT are not supported\n");		return GDK_FAIL;	}	if (*l_in == bit_nil && ATOMcmp(tt, l, nil)) {		GDKerror("CMDuselect: flag 'l_in' must not be NIL, unless boundary 'low' is NIL\n");		return GDK_FAIL;	}	if (*h_in == bit_nil && ATOMcmp(tt, h, nil)) {		GDKerror("CMDuselect: flag 'h_in' must not be NIL, unless boundary 'high' is NIL\n");		return GDK_FAIL;	}	return (*result = BATuselect_(b, l, h, *l_in, *h_in)) ? GDK_SUCCEED : GDK_FAIL;}intCMDfragment(BAT **result, BAT *b, ptr hlow, ptr hhigh, ptr tlow, ptr thigh){	return (*result = BATrestrict(b, hlow, hhigh, tlow, thigh)) ? GDK_SUCCEED : GDK_FAIL;}intCMDthetajoin(BAT **result, BAT *left, BAT *right, int *mode, lng *estimate){	return (*result = BATthetajoin(left, right, *mode, (*estimate == lng_nil) ? oid_nil : (size_t) * estimate)) ? GDK_SUCCEED : GDK_FAIL;}intCMDbandjoin(BAT **result, BAT *left, BAT *right, ptr minus, ptr plus){	return (*result = BATbandjoin(left, right, minus, plus)) ? GDK_SUCCEED : GDK_FAIL;}@-Let cut this text down with some Mx macro's@= unaryintCMD@1(BAT **result, BAT *b){	return (*result = @2(b))?GDK_SUCCEED:GDK_FAIL;}@= unaryintintCMD@1(int *result, BAT *b){	*result = @2(b);	return GDK_SUCCEED;}@= binaryintCMD@1(BAT **result, BAT *left, BAT* right){	return (*result = @2(left, right))?GDK_SUCCEED:GDK_FAIL;}@= binaryestimateintCMD@1(BAT **result, BAT *left, BAT* right, lng *estimate){	return (*result = @2(left, right, *estimate==lng_nil?(size_t)oid_nil:(size_t)*estimate))?GDK_SUCCEED:GDK_FAIL;}@= binaryintintCMD@1(BAT **result, BAT* b, int *param){	return (*result = @2(b, *param))?GDK_SUCCEED:GDK_FAIL;}@c#define BATtdiff(l,r) BATmirror(BATkdiff(BATmirror(l),BATmirror(r)))#define BATtintersect(l,r) BATmirror(BATkintersect(BATmirror(l),BATmirror(r)))#define BATtsort(b) BATmirror(BATsort(BATmirror(b)))#define BATtsort_rev(b) BATmirror(BATsort_rev(BATmirror(b)))#define BAThistogram_rev(b) BAThistogram(BATmirror(b))#define BATmark_default(b) BATmark(b,OIDnew(BATcount(b)))#define BATtmark_default(b) BATmirror(BATmark(BATmirror(b),OIDnew(BATcount(b))))#define BAThmark_default(b) BATmirror(BATmark(b,OIDnew(BATcount(b))))#define BATwcopy(b) BATcopy(b, b->htype, b->ttype, 1)#define BATrcopy(b) BATcopy(b, b->htype, b->ttype, 2)@:unaryint(count,BATcount)@@:unary(histogram,BAThistogram)@@:unary(histogram_rev,BAThistogram_rev)@@:unary(sort,BATsort)@@:unary(sort_rev,BATsort_rev)@@:unary(tsort,BATtsort)@@:unary(tsort_rev,BATtsort_rev)@@:unary(ssort,BATssort)@@:unary(ssort_rev,BATssort_rev)@@:unary(number,BATnumber)@@:unary(copy,BATwcopy)@@:unary(rcopy,BATrcopy)@@:unary(kunique,BATkunique)@@:unary(sunique,BATsunique)@@:unary(mark_default,BATmark_default)@@:unary(tmark_default,BATtmark_default)@@:unary(hmark_default,BAThmark_default)@@:binary(semijoin,BATsemijoin)@@:binary(cross,BATcross)@@:binary(antijoin,BATantijoin)@@:binaryestimate(join,BATjoin)@@:binaryestimate(fetchjoin,BATfetchjoin)@@:binaryestimate(leftjoin,BATleftjoin)@@:binaryestimate(leftfetchjoin,BATleftfetchjoin)@@:binaryestimate(outerjoin,BATouterjoin)@@:binary(sunion,BATsunion)@@:binary(kunion,BATkunion)@@:binary(sintersect,BATsintersect)@@:binary(kintersect,BATkintersect)@@:binary(tintersect,BATtintersect)@@:binary(sdiff,BATsdiff)@@:binary(kdiff,BATkdiff)@@:binary(tdiff,BATtdiff)@@:binaryint(sample,BATsample)@intCMDtunique(BAT **result, BAT* b){	oid id = oid_nil;	BAT *v = BATconst(BATmirror(b), TYPE_oid, &id);	*result = BATkunique(v);	BBPreclaim(v);	return *result?GDK_SUCCEED:GDK_FAIL;}intCMDcount_nil(int *result, BAT *b, bit *ignore_nils){	if (*ignore_nils)		*result = (int) BATcount_no_nil(b);	else		*result = (int) BATcount(b);	return GDK_SUCCEED;}intCMDgroup(BAT **result, BAT *b, int *start, int *incr, int *grpsize){	return (*result = BATgroup(b, *start, *incr, *grpsize)) ? GDK_SUCCEED : GDK_FAIL;}intCMDgen_group(BAT **result, BAT *b ){	BUN u, v;	int xx;	int htpe = (b->htype == TYPE_void)?TYPE_oid:b->htype;	BAT *r = BATnew(htpe, TYPE_void, BATcount(b)*2);	if (b->hvarsized) {		BATloopFast(b, u, v, xx) {			int i, sz = *(int*)BUNtloc(b, u);			for(i = 0; i < sz; i++) {			if (BUNfastins(r, BUNhvar(b, u), NULL) == NULL) {				BBPreclaim(r);				return GDK_FAIL;			}			}		}	} else {		BATloopFast(b, u, v, xx) {			int i, sz = *(int*)BUNtloc(b, u);			for(i = 0; i < sz; i++) {			if (BUNfastins(r, BUNhloc(b, u), NULL) == NULL) {				BBPreclaim(r);				return GDK_FAIL;			}			}		}	}	r -> hsorted = BAThordered(b);	r -> tsorted = BATtordered(b);	*result = r;	return GDK_SUCCEED;}intCMDproject(BAT **res, BAT *b, ptr p, int t){	return (*res = BATconst(b, t, p)) ? GDK_SUCCEED : GDK_FAIL;}intCMDmark(BAT **res, BAT *b, oid *base){	return (*res = BATmark(b, *base)) ? GDK_SUCCEED : GDK_FAIL;}intCMDtmark(BAT **res, BAT *b, oid *base){	return (*res = BATmirror(BATmark(BATmirror(b), *base))) ? GDK_SUCCEED : GDK_FAIL;}intCMDhmark(BAT **res, BAT *b, oid *base){	return (*res = BATmirror(BATmark(b, *base))) ? GDK_SUCCEED : GDK_FAIL;}intCMDhashsplit(BAT **res, BAT *b, int *nfrag){	return (*res = BAThashsplit(b, *nfrag, FALSE)) ? GDK_SUCCEED : GDK_FAIL;}intCMDuhashsplit(BAT **res, BAT *b, int *nfrag){	return (*res = BAThashsplit(b, *nfrag, TRUE)) ? GDK_SUCCEED : GDK_FAIL;}intCMDrangesplit(BAT **res, BAT *b, int *nfrag){	return (*res = BATrangesplit(b, *nfrag, FALSE)) ? GDK_SUCCEED : GDK_FAIL;}intCMDurangesplit(BAT **res, BAT *b, int *nfrag){	return (*res = BATrangesplit(b, *nfrag, TRUE)) ? GDK_SUCCEED : GDK_FAIL;}@- Substring SelectThe string pattern matching routine has been added. It should bedynamically linked.A simple string matcher is included. It should be refined later on@cINLINE intlike(char *x, char *y, int ylen){	char *r;	if (x == (char *) NULL) {		return 0;	}	for (r = x + strlen(x) - ylen; x <= r; x++) {		int ok = 1;		char *s = x;		char *q;		for (q = y; *q; q++, s++)			if (*q != tolower(*s)) {				ok = 0;				break;			}		if (ok)			return 1;	}	return 0;}intCMDlike(BAT **ret, BAT *b, str s){	BAT *c = BATnew(BAThtype(b), TYPE_str, BATcount(b) / 10);	str t = GDKstrdup(s);	BUN u, v;	int xx, yy = 0;

⌨️ 快捷键说明

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