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

📄 group.c

📁 一个内存数据库的源代码这是服务器端还有客户端
💻 C
📖 第 1 页 / 共 5 页
字号:
            for( idx=0; idx< b->thash->mask; idx++)            for( xx=b->thash->hash[idx]; xx != HASH_MAX; xx= b->thash->link[xx]){		declare_unclustered		ptr tcur;		p= BUNptr(b,xx);		tcur = BUNtloc(b,p);#else	BATloopFast(b, p, q, xx) {		declare_unclustered		ptr tcur = BUNtloc(b,p);#endif		/* hash-lookup of 'tcur' in map */		hash_t c = HASH_lng(tcur);		c = mix_int(c) & mask;		chain_unclustered {			r = BUNptr(map,zz);			e = (mapentry_t*) BUNhloc(map,r);			if (tst_grp_unclustered(simple_EQ, BUNtloc(map,r), lng)) {				if (m == NULL)					e->cnt++;				goto found;			}		}		/* not found-> insert new element in map (and hash) */		if (m) {			zz = mapsize;		} else {			entry.gid = *(oid*) BUNhead(b,p);		}		entry.link = hash[c];		hash[c] = mapsize++;		bunfastins(map, &entry, tcur);		e = &entry;found:		/* ultra-fast 'insert' of [oid,gid] into ct */		if (bn->htype)			*dst++ = *(oid*) BUNhead(b,p);		*dst++ = m?zz:e->gid;	}#ifdef MKspeedup	BATsort(BATmirror(bn));	}#endif	bn->batBuns->free = ((BUN) dst) - bn->batBuns->base;	BATsetcount(bn, bn->batBuns->free/BUNsize(bn));	bn->tsorted = 0;	if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ);	ALIGNsetH(bn,b);	if (hash && !m)		GDKfree(hash);	return m ? NULL : map2histo(map);bunins_failed:	BBPreclaim(bn);	if (hash && !m)		GDKfree(hash);	return NULL;}#line 539 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/group.mx"#line 430 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/group.mx"BAT *CTgroup_any_unclustered_STANDARD(group_params_STANDARD BAT *b, BAT *bn, map_T *m){	oid *dst = (oid*) BUNfirst(bn);	hash_t xx=0, *hash, mask;	size_t zz, mapsize;	mapentry_t entry, *e;	BUN p, q, r;	BAT *map = NULL;	declare_atom#ifdef MKspeedup	size_t idx;#endif	map_init_STANDARD(map,hash,mask,entry,mapsize);	if (map == NULL)		return NULL;	/* core hash grouping algorithm */#ifdef MKspeedup/* MK: Experimental code. Should be triggered when you attemptto consume a lot of your physical memory. First indication, a factor 2.*/		(void) q;        if( BATprepareHash(BATmirror(b))){            stream_printf(GDKout,"#M5 IO group join\n");            for( idx=0; idx< b->thash->mask; idx++)            for( xx=b->thash->hash[idx]; xx != HASH_MAX; xx= b->thash->link[xx]){		declare_unclustered		ptr tcur;		p= BUNptr(b,xx);		tcur = BUNtail(b,p);#else	BATloopFast(b, p, q, xx) {		declare_unclustered		ptr tcur = BUNtail(b,p);#endif		/* hash-lookup of 'tcur' in map */		hash_t c = HASH_any(tcur);		c = mix_int(c) & mask;		chain_unclustered {			r = BUNptr(map,zz);			e = (mapentry_t*) BUNhloc(map,r);			if (tst_grp_unclustered(atom_EQ, BUNtail(map,r), any)) {				if (m == NULL)					e->cnt++;				goto found;			}		}		/* not found-> insert new element in map (and hash) */		if (m) {			zz = mapsize;		} else {			entry.gid = *(oid*) BUNhead(b,p);		}		entry.link = hash[c];		hash[c] = mapsize++;		bunfastins(map, &entry, tcur);		e = &entry;found:		/* ultra-fast 'insert' of [oid,gid] into ct */		if (bn->htype)			*dst++ = *(oid*) BUNhead(b,p);		*dst++ = m?zz:e->gid;	}#ifdef MKspeedup	BATsort(BATmirror(bn));	}#endif	bn->batBuns->free = ((BUN) dst) - bn->batBuns->base;	BATsetcount(bn, bn->batBuns->free/BUNsize(bn));	bn->tsorted = 0;	if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ);	ALIGNsetH(bn,b);	if (hash && !m)		GDKfree(hash);	return m ? NULL : map2histo(map);bunins_failed:	BBPreclaim(bn);	if (hash && !m)		GDKfree(hash);	return NULL;}#line 540 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/group.mx"/* Generate both 'normal' CTgroup and parameterized CTgroups */#line 544 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/group.mx"#line 536 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/group.mx"#line 430 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/group.mx"BAT *CTgroup_chr_clustered_STANDARD(group_params_STANDARD BAT *b, BAT *bn, map_T *m){	oid *dst = (oid*) BUNfirst(bn);	hash_t xx=0, *hash, mask;	size_t zz, mapsize;	mapentry_t entry, *e;	BUN p, q, r;	BAT *map = NULL;	declare_simple#ifdef MKspeedup	size_t idx;#endif	map_init_STANDARD(map,hash,mask,entry,mapsize);	if (map == NULL)		return NULL;	/* core hash grouping algorithm */#ifdef MKspeedup/* MK: Experimental code. Should be triggered when you attemptto consume a lot of your physical memory. First indication, a factor 2.*/		(void) q;        if( BATprepareHash(BATmirror(b))){            stream_printf(GDKout,"#M5 IO group join\n");            for( idx=0; idx< b->thash->mask; idx++)            for( xx=b->thash->hash[idx]; xx != HASH_MAX; xx= b->thash->link[xx]){		declare_clustered		ptr tcur;		p= BUNptr(b,xx);		tcur = BUNtloc(b,p);#else	BATloopFast(b, p, q, xx) {		declare_clustered		ptr tcur = BUNtloc(b,p);#endif		/* hash-lookup of 'tcur' in map */		hash_t c = HASH_chr(tcur);		c = mix_int(c) & mask;		chain_clustered {			r = BUNptr(map,zz);			e = (mapentry_t*) BUNhloc(map,r);			if (tst_grp_clustered(simple_EQ, BUNtloc(map,r), chr)) {				if (m == NULL)					e->cnt++;				goto found;			}		}		/* not found-> insert new element in map (and hash) */		if (m) {			zz = mapsize;		} else {			entry.gid = *(oid*) BUNhead(b,p);		}		entry.link = hash[c];		hash[c] = mapsize++;		bunfastins(map, &entry, tcur);		e = &entry;found:		/* ultra-fast 'insert' of [oid,gid] into ct */		if (bn->htype)			*dst++ = *(oid*) BUNhead(b,p);		*dst++ = m?zz:e->gid;	}#ifdef MKspeedup	BATsort(BATmirror(bn));	}#endif	bn->batBuns->free = ((BUN) dst) - bn->batBuns->base;	BATsetcount(bn, bn->batBuns->free/BUNsize(bn));	bn->tsorted = 0;	if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ);	ALIGNsetH(bn,b);	if (hash && !m)		GDKfree(hash);	return m ? NULL : map2histo(map);bunins_failed:	BBPreclaim(bn);	if (hash && !m)		GDKfree(hash);	return NULL;}#line 536 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/group.mx"#line 430 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/group.mx"BAT *CTgroup_sht_clustered_STANDARD(group_params_STANDARD BAT *b, BAT *bn, map_T *m){	oid *dst = (oid*) BUNfirst(bn);	hash_t xx=0, *hash, mask;	size_t zz, mapsize;	mapentry_t entry, *e;	BUN p, q, r;	BAT *map = NULL;	declare_simple#ifdef MKspeedup	size_t idx;#endif	map_init_STANDARD(map,hash,mask,entry,mapsize);	if (map == NULL)		return NULL;	/* core hash grouping algorithm */#ifdef MKspeedup/* MK: Experimental code. Should be triggered when you attemptto consume a lot of your physical memory. First indication, a factor 2.*/		(void) q;        if( BATprepareHash(BATmirror(b))){            stream_printf(GDKout,"#M5 IO group join\n");            for( idx=0; idx< b->thash->mask; idx++)            for( xx=b->thash->hash[idx]; xx != HASH_MAX; xx= b->thash->link[xx]){		declare_clustered		ptr tcur;		p= BUNptr(b,xx);		tcur = BUNtloc(b,p);#else	BATloopFast(b, p, q, xx) {		declare_clustered		ptr tcur = BUNtloc(b,p);#endif		/* hash-lookup of 'tcur' in map */		hash_t c = HASH_sht(tcur);		c = mix_int(c) & mask;		chain_clustered {			r = BUNptr(map,zz);			e = (mapentry_t*) BUNhloc(map,r);			if (tst_grp_clustered(simple_EQ, BUNtloc(map,r), sht)) {				if (m == NULL)					e->cnt++;				goto found;			}		}		/* not found-> insert new element in map (and hash) */		if (m) {			zz = mapsize;		} else {			entry.gid = *(oid*) BUNhead(b,p);		}		entry.link = hash[c];		hash[c] = mapsize++;		bunfastins(map, &entry, tcur);		e = &entry;found:		/* ultra-fast 'insert' of [oid,gid] into ct */		if (bn->htype)			*dst++ = *(oid*) BUNhead(b,p);		*dst++ = m?zz:e->gid;	}#ifdef MKspeedup	BATsort(BATmirror(bn));	}#endif	bn->batBuns->free = ((BUN) dst) - bn->batBuns->base;	BATsetcount(bn, bn->batBuns->free/BUNsize(bn));	bn->tsorted = 0;	if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ);	ALIGNsetH(bn,b);	if (hash && !m)		GDKfree(hash);	return m ? NULL : map2histo(map);bunins_failed:	BBPreclaim(bn);	if (hash && !m)		GDKfree(hash);	return NULL;}#line 537 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/group.mx"#line 430 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/group.mx"BAT *CTgroup_int_clustered_STANDARD(group_params_STANDARD BAT *b, BAT *bn, map_T *m){	oid *dst = (oid*) BUNfirst(bn);	hash_t xx=0, *hash, mask;	size_t zz, mapsize;	mapentry_t entry, *e;	BUN p, q, r;	BAT *map = NULL;	declare_simple#ifdef MKspeedup	size_t idx;#endif	map_init_STANDARD(map,hash,mask,entry,mapsize);	if (map == NULL)		return NULL;	/* core hash grouping algorithm */#ifdef MKspeedup/* MK: Experimental code. Should be triggered when you attemptto consume a lot of your physical memory. First indication, a factor 2.*/		(void) q;        if( BATprepareHash(BATmirror(b))){            stream_printf(GDKout,"#M5 IO group join\n");            for( idx=0; idx< b->thash->mask; idx++)            for( xx=b->thash->hash[idx]; xx != HASH_MAX; xx= b->thash->link[xx]){		declare_clustered		ptr tcur;		p= BUNptr(b,xx);		tcur = BUNtloc(b,p);#else	BATloopFast(b, p, q, xx) {		declare_clustered		ptr tcur = BUNtloc(b,p);#endif		/* hash-lookup of 'tcur' in map */		hash_t c = HASH_int(tcur);		c = mix_int(c) & mask;		chain_clustered {			r = BUNptr(map,zz);			e = (mapentry_t*) BUNhloc(map,r);			if (tst_grp_clustered(simple_EQ, BUNtloc(map,r), int)) {				if (m == NULL)					e->cnt++;				goto found;			}		}		/* not found-> insert new element in map (and hash) */		if (m) {			zz = mapsize;		} else {			entry.gid = *(oid*) BUNhead(b,p);		}		entry.link = hash[c];		hash[c] = mapsize++;		bunfastins(map, &entry, tcur);		e = &entry;found:		/* ultra-fast 'insert' of [oid,gid] into ct */		if (bn->htype)			*dst++ = *(oid*) BUNhead(b,p);		*dst++ = m?zz:e->gid;	}#ifdef MKspeedup	BATsort(BATmirror(bn));	}#endif	bn->batBuns->free = ((BUN) dst) - bn->batBuns->base;	BATsetcount(bn, bn->batBuns->free/BUNsize(bn));	bn->tsorted = 0;	if (!(bn->batDirty&2)) bn = BATsetaccess(bn, BAT_READ);	ALIGNsetH(bn,b);	if (hash && !m)		GDKfree(hash);	return m ? NULL : map2histo(map);bunins_failed:	BBPreclaim(bn);	if (hash && !m)		GDKfree(hash);	return NULL;}#line 538 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/group.mx"#line 430 "/export/scratch0/monet/monet.GNU.64.64.d.14791/MonetDB5/src/modules/kernel/group.mx"BAT *CTgroup_lng_clustered_STANDARD(group_params_STANDARD BAT *b, BAT *bn, map_T *m){	oid *dst = (oid*) BUNfirst(bn);	hash_t xx=0, *hash, mask;	size_t zz, mapsize;	mapentry_t entry, *e;	BUN p, q, r;	BAT *map = NULL;	declare_simple#ifdef MKspeedup	size_t idx;#endif	map_init_STANDARD(map,hash,mask,entry,mapsize);	if (map == NULL)		return NULL;	/* core hash grouping algorithm */#ifdef MKspeedup/* MK: Experimental code. Should be triggered when you attemptto consume a lot of your physical memory. First indication, a factor 2.*/		(void) q;        if( BATprepareHash(BATmirror(b))){            stream_printf(GDKout,"#M5 IO group join\n");            for( idx=0; idx< b->thash->mask; idx++)            for( xx=b->thash->hash[idx]; xx != HASH_MAX; xx= b->thash->link[xx]){		declare_clustered		ptr tcur;		p= BUNptr(b,xx);		tcur = BUNtloc(b,p);#else	BATloopFast(b, p, q, xx) {		declare_clustered		ptr tcur = BUNtloc(b,p);#endif		/* hash-lookup of 'tcur' in map */		hash_t c = HASH_lng(tcur);		c = mix_int(c) & mask;		chain_clustered {			r = BUNptr(map,zz);			e = (mapentry_t*) BUNhloc(map,r);			if (tst_grp_clustered(simple_EQ, BUNtloc(map,r), lng)) {				if (m == NULL)					e->cnt++;				goto found;			}		}		/* not found-> insert new element in map (and hash) */		if (m) {			zz = mapsize;		} else {			entry.gid = *(oid*) BUNhead(b,p);		}		entry.link = hash[c];		hash[c] = mapsize++;		bunfastins(map, &entry, tcur);		e = &entry;found:		/* ultra-fast 'insert' of [oid,gid] into ct */		if (bn->htype)			*dst++ = *(oid*) BUNhead(b,p);		*dst++ = m?zz:e->gid;	}#ifdef MKspeedup	BATsort(BATmirror(bn));	}#endif	bn->batBuns->free = ((BUN) dst) - bn->batBuns->base;	BATsetcount(bn, bn->batBuns->free/BUNsize(bn));

⌨️ 快捷键说明

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