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

📄 bat5.mx

📁 一个内存数据库的源代码这是服务器端还有客户端
💻 MX
📖 第 1 页 / 共 5 页
字号:
		BBPreleaseref(b->batCacheid);		return MAL_SUCCEED;	}	BBPreleaseref(b->batCacheid);	throw(MAL, "bat.delete_buns", "GDKerror");}char *BKCdelete(int *r, int *bid, ptr h){	BAT *b;	(void) r;	if ((b = BATdescriptor(*bid)) == NULL) {		throw(MAL, "bat.delete", "Cannot access descriptor");	}	@:derefStr(b,h,h)@	if (BUNdelHead(b, h,FALSE) != NULL) {		BBPreleaseref(b->batCacheid);		return MAL_SUCCEED;	}	BBPreleaseref(b->batCacheid);	throw(MAL, "bat.delete", "GDKerror");}strBKCdelete_all(int *r, int *bid){	BAT *b;	(void) r;	if ((b = BATdescriptor(*bid)) == NULL) {		throw(MAL, "bat.delete", "Cannot access descriptor");	}	if (BATclear(b) != NULL) {		BBPreleaseref(b->batCacheid);		return MAL_SUCCEED;	}	BBPreleaseref(b->batCacheid);	throw(MAL, "bat.delete", "GDKerror");}strBKCdelete_bat_bun(int *r, int *bid, int *sid){	BAT *b, *s;	(void) r;	if ((b = BATdescriptor(*bid)) == NULL) {		throw(MAL, "bat.delete", "Cannot access descriptor");	}	if ((s = BATdescriptor(*sid)) == NULL) {		BBPreleaseref(b->batCacheid);		throw(MAL, "bat.delete", "Cannot access descriptor");	}	if (BATdel(b, s,FALSE) != NULL) {		BBPreleaseref(b->batCacheid);		BBPreleaseref(s->batCacheid);		return MAL_SUCCEED;	}	BBPreleaseref(b->batCacheid);	BBPreleaseref(s->batCacheid);	throw(MAL, "bat.delete_bat_buns", "GDKerror");}strBKCdelete_bat(int *r, int *bid, int *sid){	BAT *b, *s;	(void) r;	if ((b = BATdescriptor(*bid)) == NULL) {		throw(MAL, "bat.delete", "Cannot access descriptor");	}	if ((s = BATdescriptor(*sid)) == NULL) {		BBPreleaseref(b->batCacheid);		throw(MAL, "bat.delete", "Cannot access descriptor");	}	if (BATdelHead(b, s,FALSE) != NULL) {		BBPreleaseref(b->batCacheid);		BBPreleaseref(s->batCacheid);		return MAL_SUCCEED;	}	BBPreleaseref(b->batCacheid);	BBPreleaseref(s->batCacheid);	throw(MAL, "bat.delete_bats", "GDKerror");}strBKCdestroy_bat(bit *r, str *input){	CMDdestroy(r, *input);	return MAL_SUCCEED;}char *BKCdestroyImmediate(signed char*r, int *bid){	BAT *b;	char buf[512];	if ((b = BATdescriptor(*bid)) == NULL) {		throw(MAL, "bat.destroy", "Cannot access descriptor");	}	BBPlogical(b->batCacheid, buf);	BBPreleaseref(b->batCacheid);	CMDdestroy(r, buf);	return MAL_SUCCEED;}char *BKCdestroy(signed char *r, int *bid){	BAT *b;	(void) r;	if ((b = BATdescriptor(*bid)) == NULL) {		throw(MAL, "bat.destroy", "Cannot access descriptor");	}	*bid = 0;	BATmode(b, TRANSIENT);	BBPreleaseref(b->batCacheid);	return MAL_SUCCEED;}/* The SQL frontend uses void-head bats */size_tvoid_delete_bat(BAT *b, BAT *d, int delta){	size_t nr = 0;	BUN r, s;	ptr nil = ATOMnilptr(b->ttype);	if (delta) {		for (r = d->batInserted; r < BUNlast(d); r = BUNnext(d, r)) {			oid delid = *(oid *) BUNtail(d, r);			void_inplace5(b, delid, nil, TRUE);			nr++;		}	} else {		BATloop(d, r, s) {			oid delid = *(oid *) BUNtail(d, r);			void_inplace5(b, delid, nil, TRUE);			nr++;		}	}	return nr;}size_tvoid_insert_delta(BAT *b, BAT *u){	size_t nr = 0;	BUN r;	for (r = u->batInserted; r < BUNlast(u); r = BUNnext(u, r)) {		BUNappend(b, BUNtail(u, r),FALSE);		nr++;	}	return nr;}size_tvoid_replace_delta(BAT *b, BAT *u){	size_t nr = 0;	BUN r;	for (r = u->batInserted; r < BUNlast(u); r = BUNnext(u, r)) {		oid updid = *(oid *) BUNhead(u, r);		ptr val = BUNtail(u, r);		void_inplace5(b, updid, val, TRUE);		nr++;	}	return nr;}char *BKCappend_wrap(int *r, int *bid, int *uid){	BAT *i, *u;	(void) r;	if ((i = BATdescriptor(*bid)) == NULL) {		throw(MAL, "bat.append", "Cannot access descriptor");	}	if ((u = BATdescriptor(*uid)) == NULL) {		BBPreleaseref(i->batCacheid);		throw(MAL, "bat.append", "Cannot access descriptor");	}	BATappend(i, u,FALSE);	BBPreleaseref(i->batCacheid);	BBPreleaseref(u->batCacheid);	return MAL_SUCCEED;}strBKCappend_val_wrap(int *r, int *bid, ptr u){	BAT *i;	(void) r;	if ((i = BATdescriptor(*bid)) == NULL) {		throw(MAL, "bat.append", "Cannot access descriptor");	}	@:derefStr(i,t,u)@	BUNappend(i, u,FALSE);	BBPreleaseref(i->batCacheid);	return MAL_SUCCEED;}strBKCappend_reverse_val_wrap(int *r, int *bid, ptr u){	BAT *i;	(void) r;	if ((i = BATdescriptor(*bid)) == NULL) {		throw(MAL, "bat.append", "Cannot access descriptor");	}	@:derefStr(i,t,u)@	BUNappend(BATmirror(i), u,FALSE);	BBPreleaseref(i->batCacheid);	return MAL_SUCCEED;}char *BKCappend_force_wrap(int *r, int *bid, int *uid, bit *force){	BAT *i, *u;	(void) r;	if ((i = BATdescriptor(*bid)) == NULL) {		throw(MAL, "bat.append", "Cannot access descriptor");	}	if ((u = BATdescriptor(*uid)) == NULL) {		BBPreleaseref(i->batCacheid);		throw(MAL, "bat.append", "Cannot access descriptor");	}	BATappend(i, u, *force);	BBPreleaseref(i->batCacheid);	BBPreleaseref(u->batCacheid);	return MAL_SUCCEED;}strBKCappend_val_force_wrap(int *r, int *bid, ptr u, bit *force){	BAT *i;	(void) r;	if ((i = BATdescriptor(*bid)) == NULL) {		throw(MAL, "bat.append", "Cannot access descriptor");	}	@:derefStr(i,t,u)@	BUNappend(i, u, *force);	BBPreleaseref(i->batCacheid);	return MAL_SUCCEED;}str BKCbun_inplace(int *r, int *bid, oid *id, ptr t){	BAT *o;	(void) r;	if ((o = BATdescriptor(*bid)) == NULL) {		throw(MAL, "bat.inplace", "Cannot access descriptor");	}	void_inplace5(o, *id, t,FALSE);	BBPreleaseref(o->batCacheid);	return MAL_SUCCEED;}str BKCbun_inplace_force(int *r, int *bid, oid *id, ptr t, bit *force){	BAT *o;	(void) r;	if ((o = BATdescriptor(*bid)) == NULL) {		throw(MAL, "bat.inplace", "Cannot access descriptor");	}	void_inplace5(o, *id, t, *force);	BBPreleaseref(o->batCacheid);	return MAL_SUCCEED;}strBKCbat_inplace(int *r, int *bid, int *rid){	BAT *o, *d;	(void) r;	if ((o = BATdescriptor(*bid)) == NULL) {		throw(MAL, "bat.inplace", "Cannot access descriptor");	}	if ((d = BATdescriptor(*rid)) == NULL) {		BBPreleaseref(o->batCacheid);		throw(MAL, "bat.inplace", "Cannot access descriptor");	}	void_replace_bat5(o, d,FALSE);	BBPreleaseref(o->batCacheid);	BBPreleaseref(d->batCacheid);	return MAL_SUCCEED;}strBKCbat_inplace_force(int *r, int *bid, int *rid, bit *force){	BAT *o, *d;	(void) r;	if ((o = BATdescriptor(*bid)) == NULL) {		throw(MAL, "bat.inplace", "Cannot access descriptor");	}	if ((d = BATdescriptor(*rid)) == NULL) {		BBPreleaseref(o->batCacheid);		throw(MAL, "bat.inplace", "Cannot access descriptor");	}	void_replace_bat5(o, d, *force);	BBPreleaseref(o->batCacheid);	BBPreleaseref(d->batCacheid);	return MAL_SUCCEED;}/*end of SQL enhancement */char *BKCgetAlpha(int *r, int *bid){	BAT *b, *c;	if ((b = BATdescriptor(*bid)) == NULL) {		throw(MAL, "bat.getInserted", "Cannot access descriptor");	}	c = BATalpha(b);	*r = c->batCacheid;	BBPkeepref(c->batCacheid);	BBPreleaseref(b->batCacheid);	return MAL_SUCCEED;}char *BKCgetDelta(int *r, int *bid){	BAT *b, *c;	if ((b = BATdescriptor(*bid)) == NULL) {		throw(MAL, "bat.getDeleted", "Cannot access descriptor");	}	c = BATdelta(b);	*r = c->batCacheid;	BBPkeepref(c->batCacheid);	BBPreleaseref(b->batCacheid);	return MAL_SUCCEED;}strBKCgetCapacity(lng *res, int *bid){	CMDcapacity(res, bid);	return MAL_SUCCEED;}strBKCgetHeadType(str *res, int *bid){	CMDhead(res, bid);	return MAL_SUCCEED;}strBKCgetTailType(str *res, int *bid){	CMDtail(res, bid);	return MAL_SUCCEED;}strBKCgetRole(str *res, int *bid){	BAT *b;	if ((b = BATdescriptor(*bid)) == NULL) {		throw(MAL, "bat.getType", "Cannot access descriptor");	}	*res = GDKstrdup((*bid > 0) ? b->hident : b->tident);	BBPreleaseref(b->batCacheid);	return MAL_SUCCEED;}strBKCsetkey(int *res, int *bid, bit *param){	BAT *b;	if ((b = BATdescriptor(*bid)) == NULL) {		throw(MAL, "bat.setKey", "Cannot access descriptor");	}	BATkey(b, *param ? BOUND2BTRUE :FALSE);	*res = b->batCacheid;	BBPkeepref(b->batCacheid);	return MAL_SUCCEED;}strBKCsetSet(int *res, int *bid, bit *param){	BAT *b;	if ((b = BATdescriptor(*bid)) == NULL) {		throw(MAL, "bat.setSet", "Cannot access descriptor");	}	BATset(b, *param ? BOUND2BTRUE :FALSE);	*res = b->batCacheid;	BBPkeepref(b->batCacheid);	return MAL_SUCCEED;}strBKCisaSet(int *res, int *bid){	BAT *b;	if ((b = BATdescriptor(*bid)) == NULL) {		throw(MAL, "bat.isaSet", "Cannot access descriptor");	}	*res = b->batSet;	BBPreleaseref(b->batCacheid);	return MAL_SUCCEED;}strBKCsetSorted(bit *res, int *bid){	BAT *b;	if ((b = BATdescriptor(*bid)) == NULL) {		throw(MAL, "bat.isSorted", "Cannot access descriptor");	}	CMDordered(res, b);	*res = BATordered(b) ? 1 : 0;	BBPreleaseref(b->batCacheid);	return MAL_SUCCEED;}strBKCisSorted(bit *res, int *bid){	BAT *b;	if ((b = BATdescriptor(*bid)) == NULL) {		throw(MAL, "bat.isSorted", "Cannot access descriptor");	}	*res = BATordered(b) ? 1 : 0;	BBPreleaseref(b->batCacheid);	return MAL_SUCCEED;}strBKCisSortedReverse(bit *res, int *bid){	BAT *b;	if ((b = BATdescriptor(*bid)) == NULL) {		throw(MAL, "bat.isSorted", "Cannot access descriptor");	}	*res = BATordered_rev(b) ? 1 : 0;	BBPreleaseref(b->batCacheid);	return MAL_SUCCEED;}@-We must take care of the special case of a nil column (TYPE_void,seqbase=nil)such nil columns never set hkey (and BUNins will never invalidate it if set) yeta nil column of a BAT with <= 1 entries does not contain doubles => return TRUE.@cstrBKCgetKey(bit *ret, int *bid){	BAT *b;	if ((b = BATdescriptor(*bid)) == NULL) {		throw(MAL, "bat.setPersistence", "Cannot access descriptor");	}	CMDgetkey(ret, b);	BBPreleaseref(b->batCacheid);	return MAL

⌨️ 快捷键说明

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