Пример #1
0
/*
 * Destroy a view.
 */
void
VIEWdestroy(BAT *b)
{
	assert(isVIEW(b));

	/* remove any leftover private hash structures */
	if (b->H->hash)
		HASHremove(BATmirror(b));
	if (b->T->hash)
		HASHremove(b);
	IMPSdestroy(b);
	VIEWunlink(b);

	if (b->htype && !b->H->heap.parentid) {
		HEAPfree(&b->H->heap, 0);
	} else {
		b->H->heap.base = NULL;
		b->H->heap.filename = NULL;
	}
	if (b->ttype && !b->T->heap.parentid) {
		HEAPfree(&b->T->heap, 0);
	} else {
		b->T->heap.base = NULL;
		b->T->heap.filename = NULL;
	}
	b->H->vheap = NULL;
	b->T->vheap = NULL;
	BATfree(b);
}
Пример #2
0
/* in the commit epilogue, the BBP-status of the bats is changed to
 * reflect their presence in the succeeded checkpoint.  Also bats from
 * the previous checkpoint that were deleted now are physically
 * destroyed.
 */
static void
epilogue(int cnt, bat *subcommit)
{
	int i = 0;

	while (++i < cnt) {
		bat bid = subcommit ? subcommit[i] : i;

		if (BBP_status(bid) & BBPPERSISTENT) {
			BBP_status_on(bid, BBPEXISTING, subcommit ? "TMsubcommit" : "TMcommit");
		} else if (BBP_status(bid) & BBPDELETED) {
			/* check mmap modes of bats that are now
			 * transient. this has to be done after the
			 * commit succeeded, because the mmap modes
			 * allowed on transient bats would be
			 * dangerous on persistent bats. If the commit
			 * failed, the already processed bats that
			 * would become transient after the commit,
			 * but didn't due to the failure, would be a
			 * consistency risk.
			 */
			BAT *b = BBP_cache(bid);
			if (b) {
				/* check mmap modes */
				if (BATcheckmodes(b, true) != GDK_SUCCEED)
					fprintf(stderr, "#epilogue: BATcheckmodes failed\n");
			}
		}
		if ((BBP_status(bid) & BBPDELETED) && BBP_refs(bid) <= 0 && BBP_lrefs(bid) <= 0) {
			BAT *b = BBPquickdesc(bid, TRUE);

			/* the unloaded ones are deleted without
			 * loading deleted disk images */
			if (b) {
				BATdelete(b);
				if (BBP_cache(bid)) {
					/* those that quickdesc
					 * decides to load => free
					 * memory */
					BATfree(b);
				}
			}
			BBPclear(bid);	/* clear with locking */
		}
		BBP_status_off(bid, BBPDELETED | BBPSWAPPED | BBPNEW, subcommit ? "TMsubcommit" : "TMcommit");
	}
	GDKclrerr();
}