gdk_setop.c

来自「这个是内存数据库中的一个管理工具」· C语言 代码 · 共 2,964 行 · 第 1/5 页

C
2,964
字号
#line 84 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"#include "monetdb_config.h"#include "gdk.h"#include "gdk_setop.h"#line 195 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"BAT *BATins_kunique(BAT *bn, BAT *b){	bit unique = FALSE;	BATcheck(b, "BATins_kunique: src BAT");	BATcheck(bn, "BATins_kunique: dst BAT");	unique = (BATcount(bn)==0);	#line 154 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"	switch(ATOMstorage(b->htype)) {#ifndef NOEXPAND_CHR	case TYPE_chr:		#line 134 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"	{		int xx, (*cmp)(ptr, ptr) = BATatoms[b->ttype].atomCmp;		size_t zz;		BUN p, q, r;		if (BAThordered(b)&1) {			if (b->tvarsized) {				#line 92 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"	BATloopFast(b, p, q, xx) {		ptr h = BUNhloc(b,p);		ptr t = BUNtvar(b,p);		for (r = p + xx; (r < q) && (simple_CMP(h,BUNhloc(b,r),chr) == 0); r += xx) {			if (HITk(t, BUNtvar(b,r)))				goto nextlocvar_chr;		}		bunfastins(bn, h, t);  nextlocvar_chr:;	}#line 141 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"			} else {				#line 92 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"	BATloopFast(b, p, q, xx) {		ptr h = BUNhloc(b,p);		ptr t = BUNtloc(b,p);		for (r = p + xx; (r < q) && (simple_CMP(h,BUNhloc(b,r),chr) == 0); r += xx) {			if (HITk(t, BUNtloc(b,r)))				goto nextlocloc_chr;		}		bunfastins(bn, h, t);  nextlocloc_chr:;	}#line 143 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"			}		} else if (b->tvarsized) {			#line 103 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"	zz = BUNindex(bn, BUNfirst(bn));	if (!bn->hhash){		if (BAThash(bn, BATcapacity(bn)/2) == NULL) {			BBPreclaim(bn);			return NULL;		}	}	BATloopFast(b, p, q, xx) {		ptr h = BUNhloc(b,p);		ptr t = BUNtvar(b,p);		int ins = 1;		hash_t yy;		if (BATprepareHash(bn)) {			BBPreclaim(bn);			return NULL;		}		HASHloop_chr(bn, bn->hhash, yy, h, r) {			if (HITk(t, BUNtvar(bn,r))) {				ins=0;				break;			}		}		if (ins) {			bunfastins(bn, h, t);			if (bn->hhash)				HASHins_chr(bn->hhash, (hash_t) zz, h);			zz++;		}	}#line 146 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"		} else {			#line 103 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"	zz = BUNindex(bn, BUNfirst(bn));	if (!bn->hhash){		if (BAThash(bn, BATcapacity(bn)/2) == NULL) {			BBPreclaim(bn);			return NULL;		}	}	BATloopFast(b, p, q, xx) {		ptr h = BUNhloc(b,p);		ptr t = BUNtloc(b,p);		int ins = 1;		hash_t yy;		if (BATprepareHash(bn)) {			BBPreclaim(bn);			return NULL;		}		HASHloop_chr(bn, bn->hhash, yy, h, r) {			if (HITk(t, BUNtloc(bn,r))) {				ins=0;				break;			}		}		if (ins) {			bunfastins(bn, h, t);			if (bn->hhash)				HASHins_chr(bn->hhash, (hash_t) zz, h);			zz++;		}	}#line 148 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"		}		(void) cmp;		break;	}#line 157 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"#endif#ifndef NOEXPAND_BTE	case TYPE_bte:		#line 134 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"	{		int xx, (*cmp)(ptr, ptr) = BATatoms[b->ttype].atomCmp;		size_t zz;		BUN p, q, r;		if (BAThordered(b)&1) {			if (b->tvarsized) {				#line 92 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"	BATloopFast(b, p, q, xx) {		ptr h = BUNhloc(b,p);		ptr t = BUNtvar(b,p);		for (r = p + xx; (r < q) && (simple_CMP(h,BUNhloc(b,r),bte) == 0); r += xx) {			if (HITk(t, BUNtvar(b,r)))				goto nextlocvar_bte;		}		bunfastins(bn, h, t);  nextlocvar_bte:;	}#line 141 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"			} else {				#line 92 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"	BATloopFast(b, p, q, xx) {		ptr h = BUNhloc(b,p);		ptr t = BUNtloc(b,p);		for (r = p + xx; (r < q) && (simple_CMP(h,BUNhloc(b,r),bte) == 0); r += xx) {			if (HITk(t, BUNtloc(b,r)))				goto nextlocloc_bte;		}		bunfastins(bn, h, t);  nextlocloc_bte:;	}#line 143 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"			}		} else if (b->tvarsized) {			#line 103 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"	zz = BUNindex(bn, BUNfirst(bn));	if (!bn->hhash){		if (BAThash(bn, BATcapacity(bn)/2) == NULL) {			BBPreclaim(bn);			return NULL;		}	}	BATloopFast(b, p, q, xx) {		ptr h = BUNhloc(b,p);		ptr t = BUNtvar(b,p);		int ins = 1;		hash_t yy;		if (BATprepareHash(bn)) {			BBPreclaim(bn);			return NULL;		}		HASHloop_bte(bn, bn->hhash, yy, h, r) {			if (HITk(t, BUNtvar(bn,r))) {				ins=0;				break;			}		}		if (ins) {			bunfastins(bn, h, t);			if (bn->hhash)				HASHins_bte(bn->hhash, (hash_t) zz, h);			zz++;		}	}#line 146 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"		} else {			#line 103 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"	zz = BUNindex(bn, BUNfirst(bn));	if (!bn->hhash){		if (BAThash(bn, BATcapacity(bn)/2) == NULL) {			BBPreclaim(bn);			return NULL;		}	}	BATloopFast(b, p, q, xx) {		ptr h = BUNhloc(b,p);		ptr t = BUNtloc(b,p);		int ins = 1;		hash_t yy;		if (BATprepareHash(bn)) {			BBPreclaim(bn);			return NULL;		}		HASHloop_bte(bn, bn->hhash, yy, h, r) {			if (HITk(t, BUNtloc(bn,r))) {				ins=0;				break;			}		}		if (ins) {			bunfastins(bn, h, t);			if (bn->hhash)				HASHins_bte(bn->hhash, (hash_t) zz, h);			zz++;		}	}#line 148 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"		}		(void) cmp;		break;	}#line 161 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"#endif#ifndef NOEXPAND_SHT	case TYPE_sht:		#line 134 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"	{		int xx, (*cmp)(ptr, ptr) = BATatoms[b->ttype].atomCmp;		size_t zz;		BUN p, q, r;		if (BAThordered(b)&1) {			if (b->tvarsized) {				#line 92 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"	BATloopFast(b, p, q, xx) {		ptr h = BUNhloc(b,p);		ptr t = BUNtvar(b,p);		for (r = p + xx; (r < q) && (simple_CMP(h,BUNhloc(b,r),sht) == 0); r += xx) {			if (HITk(t, BUNtvar(b,r)))				goto nextlocvar_sht;		}		bunfastins(bn, h, t);  nextlocvar_sht:;	}#line 141 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"			} else {				#line 92 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"	BATloopFast(b, p, q, xx) {		ptr h = BUNhloc(b,p);		ptr t = BUNtloc(b,p);		for (r = p + xx; (r < q) && (simple_CMP(h,BUNhloc(b,r),sht) == 0); r += xx) {			if (HITk(t, BUNtloc(b,r)))				goto nextlocloc_sht;		}		bunfastins(bn, h, t);  nextlocloc_sht:;	}#line 143 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"			}		} else if (b->tvarsized) {			#line 103 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"	zz = BUNindex(bn, BUNfirst(bn));	if (!bn->hhash){		if (BAThash(bn, BATcapacity(bn)/2) == NULL) {			BBPreclaim(bn);			return NULL;		}	}	BATloopFast(b, p, q, xx) {		ptr h = BUNhloc(b,p);		ptr t = BUNtvar(b,p);		int ins = 1;		hash_t yy;		if (BATprepareHash(bn)) {			BBPreclaim(bn);			return NULL;		}		HASHloop_sht(bn, bn->hhash, yy, h, r) {			if (HITk(t, BUNtvar(bn,r))) {				ins=0;				break;			}		}		if (ins) {			bunfastins(bn, h, t);			if (bn->hhash)				HASHins_sht(bn->hhash, (hash_t) zz, h);			zz++;		}	}#line 146 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"		} else {			#line 103 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"	zz = BUNindex(bn, BUNfirst(bn));	if (!bn->hhash){		if (BAThash(bn, BATcapacity(bn)/2) == NULL) {			BBPreclaim(bn);			return NULL;		}	}	BATloopFast(b, p, q, xx) {		ptr h = BUNhloc(b,p);		ptr t = BUNtloc(b,p);		int ins = 1;		hash_t yy;		if (BATprepareHash(bn)) {			BBPreclaim(bn);			return NULL;		}		HASHloop_sht(bn, bn->hhash, yy, h, r) {			if (HITk(t, BUNtloc(bn,r))) {				ins=0;				break;			}		}		if (ins) {			bunfastins(bn, h, t);			if (bn->hhash)				HASHins_sht(bn->hhash, (hash_t) zz, h);			zz++;		}	}#line 148 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"		}		(void) cmp;		break;	}#line 165 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"#endif#ifndef NOEXPAND_INT	case TYPE_int:		#line 134 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"	{		int xx, (*cmp)(ptr, ptr) = BATatoms[b->ttype].atomCmp;		size_t zz;		BUN p, q, r;		if (BAThordered(b)&1) {			if (b->tvarsized) {				#line 92 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"	BATloopFast(b, p, q, xx) {		ptr h = BUNhloc(b,p);		ptr t = BUNtvar(b,p);		for (r = p + xx; (r < q) && (simple_CMP(h,BUNhloc(b,r),int) == 0); r += xx) {			if (HITk(t, BUNtvar(b,r)))				goto nextlocvar_int;		}		bunfastins(bn, h, t);  nextlocvar_int:;	}#line 141 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"			} else {				#line 92 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"	BATloopFast(b, p, q, xx) {		ptr h = BUNhloc(b,p);		ptr t = BUNtloc(b,p);		for (r = p + xx; (r < q) && (simple_CMP(h,BUNhloc(b,r),int) == 0); r += xx) {			if (HITk(t, BUNtloc(b,r)))				goto nextlocloc_int;		}		bunfastins(bn, h, t);  nextlocloc_int:;	}#line 143 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"			}		} else if (b->tvarsized) {			#line 103 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"	zz = BUNindex(bn, BUNfirst(bn));	if (!bn->hhash){		if (BAThash(bn, BATcapacity(bn)/2) == NULL) {			BBPreclaim(bn);			return NULL;		}	}	BATloopFast(b, p, q, xx) {		ptr h = BUNhloc(b,p);		ptr t = BUNtvar(b,p);		int ins = 1;		hash_t yy;		if (BATprepareHash(bn)) {			BBPreclaim(bn);			return NULL;		}		HASHloop_int(bn, bn->hhash, yy, h, r) {			if (HITk(t, BUNtvar(bn,r))) {				ins=0;				break;			}		}		if (ins) {			bunfastins(bn, h, t);			if (bn->hhash)				HASHins_int(bn->hhash, (hash_t) zz, h);			zz++;		}	}#line 146 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"		} else {			#line 103 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"	zz = BUNindex(bn, BUNfirst(bn));	if (!bn->hhash){		if (BAThash(bn, BATcapacity(bn)/2) == NULL) {			BBPreclaim(bn);			return NULL;		}	}	BATloopFast(b, p, q, xx) {		ptr h = BUNhloc(b,p);		ptr t = BUNtloc(b,p);		int ins = 1;		hash_t yy;		if (BATprepareHash(bn)) {			BBPreclaim(bn);			return NULL;		}		HASHloop_int(bn, bn->hhash, yy, h, r) {			if (HITk(t, BUNtloc(bn,r))) {				ins=0;				break;			}		}		if (ins) {			bunfastins(bn, h, t);			if (bn->hhash)				HASHins_int(bn->hhash, (hash_t) zz, h);			zz++;		}	}#line 148 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"		}		(void) cmp;		break;	}#line 169 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"#endif#ifndef NOEXPAND_FLT	case TYPE_flt:		#line 134 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"	{		int xx, (*cmp)(ptr, ptr) = BATatoms[b->ttype].atomCmp;		size_t zz;		BUN p, q, r;		if (BAThordered(b)&1) {			if (b->tvarsized) {				#line 92 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"	BATloopFast(b, p, q, xx) {		ptr h = BUNhloc(b,p);		ptr t = BUNtvar(b,p);		for (r = p + xx; (r < q) && (simple_CMP(h,BUNhloc(b,r),flt) == 0); r += xx) {			if (HITk(t, BUNtvar(b,r)))				goto nextlocvar_flt;		}		bunfastins(bn, h, t);  nextlocvar_flt:;	}#line 141 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"			} else {				#line 92 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"	BATloopFast(b, p, q, xx) {		ptr h = BUNhloc(b,p);		ptr t = BUNtloc(b,p);		for (r = p + xx; (r < q) && (simple_CMP(h,BUNhloc(b,r),flt) == 0); r += xx) {			if (HITk(t, BUNtloc(b,r)))				goto nextlocloc_flt;		}		bunfastins(bn, h, t);  nextlocloc_flt:;	}#line 143 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"			}		} else if (b->tvarsized) {			#line 103 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB/src/gdk/gdk_setop.mx"	zz = BUNindex(bn, BUNfirst(bn));	if (!bn->hhash){		if (BAThash(bn, BATcapacity(bn)/2) == NULL) {			BBPreclaim(bn);			return NULL;		}	}	BATloopFast(b, p, q, xx) {		ptr h = BUNhloc(b,p);		ptr t = BUNtvar(b,p);		int ins = 1;		hash_t yy;		if (BATprepareHash(bn)) {

⌨️ 快捷键说明

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