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

📄 algebra.c

📁 一个内存数据库的源代码这是服务器端还有客户端
💻 C
📖 第 1 页 / 共 5 页
字号:
#line 797 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"#include "mal_config.h"#include "algebra.h"#line 829 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"#line 801 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"ptr BATmin(BAT *b, ptr aggr) {		int t;		size_t s;		ptr v, x;		BATcheck(b, "BATmin");		s = BATcount(b);		t = b->ttype;		if (BATtvoid(b)) {			#line 954 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"	v = (s == 0)?ATOMnilptr(t):BUNtail(b, BUNfirst(b));	#line 947 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"	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);	}#line 955 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"#line 810 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"		} else {			switch(ATOMstorage(t)) {			case TYPE_chr: #line 954 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"	v = (s == 0)?ATOMnilptr(t):BUNtail(b, BUNfirst(b));	#line 924 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"	if (s > 0 && !(BATtordered(b)&1)) {		char* nil = BATatoms[t].atomNull;		BUN p,q;		int xx;		BATloopFast(b, p, q, xx) {			x = (ptr) BUNtloc(b, p);			if (simple_CMP(x, nil, chr) == 0) {				v = nil;				break;			}			if (simple_LT(x, v, chr)) {				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);   }#line 955 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"#line 813 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx" break;			case TYPE_sht: #line 954 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"	v = (s == 0)?ATOMnilptr(t):BUNtail(b, BUNfirst(b));	#line 924 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"	if (s > 0 && !(BATtordered(b)&1)) {		char* nil = BATatoms[t].atomNull;		BUN p,q;		int xx;		BATloopFast(b, p, q, xx) {			x = (ptr) BUNtloc(b, p);			if (simple_CMP(x, nil, sht) == 0) {				v = nil;				break;			}			if (simple_LT(x, v, sht)) {				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);   }#line 955 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"#line 814 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx" break;			case TYPE_int: #line 954 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"	v = (s == 0)?ATOMnilptr(t):BUNtail(b, BUNfirst(b));	#line 924 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"	if (s > 0 && !(BATtordered(b)&1)) {		char* nil = BATatoms[t].atomNull;		BUN p,q;		int xx;		BATloopFast(b, p, q, xx) {			x = (ptr) BUNtloc(b, p);			if (simple_CMP(x, nil, int) == 0) {				v = nil;				break;			}			if (simple_LT(x, v, int)) {				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);   }#line 955 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"#line 815 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx" break;			case TYPE_flt: #line 954 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"	v = (s == 0)?ATOMnilptr(t):BUNtail(b, BUNfirst(b));	#line 924 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"	if (s > 0 && !(BATtordered(b)&1)) {		char* nil = BATatoms[t].atomNull;		BUN p,q;		int xx;		BATloopFast(b, p, q, xx) {			x = (ptr) BUNtloc(b, p);			if (simple_CMP(x, nil, flt) == 0) {				v = nil;				break;			}			if (simple_LT(x, v, flt)) {				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);   }#line 955 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"#line 816 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx" break;			case TYPE_dbl: #line 954 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"	v = (s == 0)?ATOMnilptr(t):BUNtail(b, BUNfirst(b));	#line 924 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"	if (s > 0 && !(BATtordered(b)&1)) {		char* nil = BATatoms[t].atomNull;		BUN p,q;		int xx;		BATloopFast(b, p, q, xx) {			x = (ptr) BUNtloc(b, p);			if (simple_CMP(x, nil, dbl) == 0) {				v = nil;				break;			}			if (simple_LT(x, v, dbl)) {				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);   }#line 955 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"#line 817 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx" break;			case TYPE_lng: #line 954 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"	v = (s == 0)?ATOMnilptr(t):BUNtail(b, BUNfirst(b));	#line 924 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"	if (s > 0 && !(BATtordered(b)&1)) {		char* nil = BATatoms[t].atomNull;		BUN p,q;		int xx;		BATloopFast(b, p, q, xx) {			x = (ptr) BUNtloc(b, p);			if (simple_CMP(x, nil, lng) == 0) {				v = nil;				break;			}			if (simple_LT(x, v, lng)) {				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);   }#line 955 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"#line 818 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx" break;			default:if (b->tvarsized) {						   #line 954 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"	v = (s == 0)?ATOMnilptr(t):BUNtail(b, BUNfirst(b));	#line 924 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"	if (s > 0 && !(BATtordered(b)&1)) {		char* nil = BATatoms[t].atomNull;		BUN p,q;		int xx;		BATloopFast(b, p, q, xx) {			x = (ptr) BUNtvar(b, p);			if (atom_CMP(x, nil, t) == 0) {				v = nil;				break;			}			if (atom_LT(x, v, t)) {				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);   }#line 955 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"#line 820 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx" break;					 } else {						   #line 954 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"	v = (s == 0)?ATOMnilptr(t):BUNtail(b, BUNfirst(b));	#line 924 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"	if (s > 0 && !(BATtordered(b)&1)) {		char* nil = BATatoms[t].atomNull;		BUN p,q;		int xx;		BATloopFast(b, p, q, xx) {			x = (ptr) BUNtloc(b, p);			if (atom_CMP(x, nil, t) == 0) {				v = nil;				break;			}			if (atom_LT(x, v, t)) {				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);   }#line 955 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"#line 822 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx" break;			}		}		}		return x;}#line 829 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"#line 801 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"ptr BATmax(BAT *b, ptr aggr) {		int t;		size_t s;		ptr v, x;		BATcheck(b, "BATmax");		s = BATcount(b);		t = b->ttype;		if (BATtvoid(b)) {			#line 957 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"	v = (s == 0)?ATOMnilptr(t):BUNtail(b, BUNlast(b)-BUNsize(b));	#line 947 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"	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);	}#line 958 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"#line 810 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"		} else {			switch(ATOMstorage(t)) {			case TYPE_chr: #line 957 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"	v = (s == 0)?ATOMnilptr(t):BUNtail(b, BUNlast(b)-BUNsize(b));	#line 924 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"	if (s > 0 && !(BATtordered(b)&1)) {		char* nil = BATatoms[t].atomNull;		BUN p,q;		int xx;		BATloopFast(b, p, q, xx) {			x = (ptr) BUNtloc(b, p);			if (simple_CMP(x, nil, chr) == 0) {				v = nil;				break;			}			if (simple_GT(x, v, chr)) {				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);   }#line 958 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"#line 813 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx" break;			case TYPE_sht: #line 957 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"	v = (s == 0)?ATOMnilptr(t):BUNtail(b, BUNlast(b)-BUNsize(b));	#line 924 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"	if (s > 0 && !(BATtordered(b)&1)) {		char* nil = BATatoms[t].atomNull;		BUN p,q;		int xx;		BATloopFast(b, p, q, xx) {			x = (ptr) BUNtloc(b, p);			if (simple_CMP(x, nil, sht) == 0) {				v = nil;				break;			}			if (simple_GT(x, v, sht)) {				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);   }#line 958 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"#line 814 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx" break;			case TYPE_int: #line 957 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"	v = (s == 0)?ATOMnilptr(t):BUNtail(b, BUNlast(b)-BUNsize(b));	#line 924 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"	if (s > 0 && !(BATtordered(b)&1)) {		char* nil = BATatoms[t].atomNull;		BUN p,q;		int xx;		BATloopFast(b, p, q, xx) {			x = (ptr) BUNtloc(b, p);			if (simple_CMP(x, nil, int) == 0) {				v = nil;				break;			}			if (simple_GT(x, v, int)) {				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);   }#line 958 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"#line 815 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx" break;			case TYPE_flt: #line 957 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"	v = (s == 0)?ATOMnilptr(t):BUNtail(b, BUNlast(b)-BUNsize(b));	#line 924 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"	if (s > 0 && !(BATtordered(b)&1)) {		char* nil = BATatoms[t].atomNull;		BUN p,q;		int xx;		BATloopFast(b, p, q, xx) {			x = (ptr) BUNtloc(b, p);			if (simple_CMP(x, nil, flt) == 0) {				v = nil;				break;			}			if (simple_GT(x, v, flt)) {				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);   }#line 958 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"#line 816 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx" break;			case TYPE_dbl: #line 957 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"	v = (s == 0)?ATOMnilptr(t):BUNtail(b, BUNlast(b)-BUNsize(b));	#line 924 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"	if (s > 0 && !(BATtordered(b)&1)) {		char* nil = BATatoms[t].atomNull;		BUN p,q;		int xx;		BATloopFast(b, p, q, xx) {			x = (ptr) BUNtloc(b, p);			if (simple_CMP(x, nil, dbl) == 0) {				v = nil;				break;			}			if (simple_GT(x, v, dbl)) {				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);   }#line 958 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx"#line 817 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/algebra.mx" break;

⌨️ 快捷键说明

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