Changeset: 5d19f5af0a14 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5d19f5af0a14
Modified Files:
gdk/gdk.h
gdk/gdk_bat.c
gdk/gdk_bbp.mx
monetdb5/modules/kernel/algebra.mx
Branch: holindex
Log Message:
Merged from default
diffs (259 lines):
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -791,7 +791,6 @@ typedef struct {
dirty:2, /* dirty wrt disk? */
dirtyflushed:1, /* was dirty before commit started? */
descdirty:1, /* bat descriptor dirty marker */
- lview:1, /* bat is a *logical* view on parentid */
set:1, /* real set semantics */
restricted:2, /* access priviliges */
persistence:2, /* should the BAT persist on disk? */
@@ -2766,17 +2765,16 @@ gdk_export int ALIGNsetH(BAT *b1, BAT *b
* always refer to the same parent column (i.e. no correction needed)
*/
#define isVIEW(x) \
- (!(x)->P->lview && \
- ((x)->H->heap.parentid || \
- (x)->T->heap.parentid || \
- ((x)->H->vheap && (x)->H->vheap->parentid != ABS((x)->batCacheid)) ||
\
- ((x)->T->vheap && (x)->T->vheap->parentid != ABS((x)->batCacheid))))
+ ((x)->H->heap.parentid || \
+ (x)->T->heap.parentid || \
+ ((x)->H->vheap && (x)->H->vheap->parentid != ABS((x)->batCacheid)) || \
+ ((x)->T->vheap && (x)->T->vheap->parentid != ABS((x)->batCacheid)))
#define isVIEWCOMBINE(x) ((x)->H == (x)->T)
-#define VIEWhparent(x) ((x)->P->lview?0:(x)->H->heap.parentid)
-#define VIEWvhparent(x)
(((x)->P->lview||(x)->H->vheap==NULL||(x)->H->vheap->parentid==ABS((x)->batCacheid))?0:(x)->H->vheap->parentid)
-#define VIEWtparent(x) ((x)->P->lview?0:(x)->T->heap.parentid)
-#define VIEWvtparent(x)
(((x)->P->lview||(x)->T->vheap==NULL||(x)->T->vheap->parentid==ABS((x)->batCacheid))?0:(x)->T->vheap->parentid)
+#define VIEWhparent(x) ((x)->H->heap.parentid)
+#define VIEWvhparent(x)
(((x)->H->vheap==NULL||(x)->H->vheap->parentid==ABS((x)->batCacheid))?0:(x)->H->vheap->parentid)
+#define VIEWtparent(x) ((x)->T->heap.parentid)
+#define VIEWvtparent(x)
(((x)->T->vheap==NULL||(x)->T->vheap->parentid==ABS((x)->batCacheid))?0:(x)->T->vheap->parentid)
/* VIEWparentcol(b) tells whether the head column was inherited from the parent
* "as is". We must check whether the type was not overridden in the view.
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -665,7 +665,7 @@ BATdestroy( BATstore *bs )
* BAT copying is an often used operation. So it deserves attention.
* When making a copy of a BAT, the following aspects are of
* importance:
-
+ *
* - the requested head and tail types. The purpose of the copy may be
* to slightly change these types (e.g. void <-> oid). We may also
* remap between types as long as they share the same
@@ -688,49 +688,13 @@ BATdestroy( BATstore *bs )
* In GDK, the result is a BAT that is BAT_WRITE iff (writable ==
* TRUE).
*
- * There is a special parameter setting (writable == 2), which does
- * create an independent BAT (not a view that shares the same heaps),
- * however tries to share VM heap resources using copy-on-write
- * maps. Note that the result of this is a read-only BAT
- * (BAT_READ). The copy-on-write VM tricks can be used to isolate
- * these copies from changes in the parent.
- *
* In these cases the copy becomes a logical view on the original,
* which ensures that the original cannot be modified or destroyed
* (which could affect the shared heaps).
*/
static int
-HEAPshare(Heap *dst, Heap *src, int copy_on_write)
+heapcopy(BAT *bn, char *ext, Heap *dst, Heap *src)
{
- /* use copy-on-write mmap for isolatable copy */
- if (src->storage == STORE_MMAP) {
- *dst = *src;
- dst->base = (char *) -1;
- dst->filename = GDKstrdup(src->filename);
- if (dst->filename) {
- char path[PATHLENGTH];
-
- GDKfilepath(path, BATDIR, dst->filename, NULL);
- dst->base = GDKmmap(path, MMAP_READ | MMAP_SEQUENTIAL |
(copy_on_write ? MMAP_COPY : 0), 0, dst->maxsize);
- if (dst->base != (char *) -1) {
- dst->copied = 1;
- dst->newstorage = dst->storage = copy_on_write
? STORE_PRIV : STORE_MMAP;
- return 0;
- }
- GDKfree(dst->filename);
- dst->filename = NULL;
- }
- }
- return -1;
-}
-
-static int
-heapcopy(BAT *bn, char *ext, Heap *dst, Heap *src, int *remap)
-{
- if (*remap && HEAPshare(dst, src, *remap) == 0) {
- return 0; /* use a shared memory heap */
- }
- *remap = 0;
if (src->filename && src->newstorage != STORE_MEM) {
str nme = BBP_physical(bn->batCacheid);
@@ -869,11 +833,6 @@ BATcopy(BAT *b, int ht, int tt, int writ
} else if (bunstocopy == BUN_NONE) {
/* case (3): just copy the heaps; if possible
* with copy-on-write VM support */
- int remap = writable == 2;
- int hremap = remap && BAThrestricted(b) != BAT_WRITE &&
ht != TYPE_void;
- int tremap = remap && BATtrestricted(b) != BAT_WRITE &&
tt != TYPE_void;
- int hvremap = hremap && ATOMstorage(ht) == TYPE_str &&
!GDK_ELIMDOUBLES(b->H->vheap);
- int tvremap = tremap && ATOMstorage(tt) == TYPE_str &&
!GDK_ELIMDOUBLES(b->T->vheap);
BUN hcap = 0, tcap = 0;
Heap bhhp, bthp, hhp, thp;
memset(&bhhp, 0, sizeof(Heap));
@@ -881,10 +840,10 @@ BATcopy(BAT *b, int ht, int tt, int writ
memset(&hhp, 0, sizeof(Heap));
memset(&thp, 0, sizeof(Heap));
- if ((b->htype && heapcopy(bn, "head", &bhhp,
&b->H->heap, &hremap) < 0) ||
- (b->ttype && heapcopy(bn, "tail", &bthp,
&b->T->heap, &tremap) < 0) ||
- (bn->H->vheap && heapcopy(bn, "hheap", &hhp,
b->H->vheap, &hvremap) < 0) ||
- (bn->T->vheap && heapcopy(bn, "theap", &thp,
b->T->vheap, &tvremap) < 0)) {
+ if ((b->htype && heapcopy(bn, "head", &bhhp,
&b->H->heap) < 0) ||
+ (b->ttype && heapcopy(bn, "tail", &bthp,
&b->T->heap) < 0) ||
+ (bn->H->vheap && heapcopy(bn, "hheap", &hhp,
b->H->vheap) < 0) ||
+ (bn->T->vheap && heapcopy(bn, "theap", &thp,
b->T->vheap) < 0)) {
HEAPfree(&thp);
HEAPfree(&hhp);
HEAPfree(&bthp);
@@ -918,18 +877,6 @@ BATcopy(BAT *b, int ht, int tt, int writ
* the heap as in the source */
bn->batFirst = b->batFirst;
bn->batInserted = b->batInserted;
-
- /* if we have copy-on-write heaps, bn is a
- * logical view on b to ensure the heaps stay
- * stable */
- if (hremap || hvremap) {
- bn->P->lview = TRUE;
- BBPshare(bn->H->heap.parentid = b->batCacheid);
- }
- if (tremap || tvremap) {
- bn->P->lview = TRUE;
- BBPshare(bn->T->heap.parentid = -b->batCacheid);
- }
} else if (BATatoms[ht].atomFix || BATatoms[tt].atomFix || (ht
&& tt) || ATOMstorage(MAX(ht, tt)) >= TYPE_str) {
/* case (4): one-by-one BUN insert (really slow) */
BUN p, q, r = BUNfirst(bn);
@@ -2662,21 +2609,6 @@ BATcheckmodes(BAT *b, int existing)
} \
} while (0)
-static int
-batunshare(BAT *b, str fcn)
-{
- if (b->H->heap.base)
- heap_unshare(&b->H->heap, head, 0);
- if (b->T->heap.base)
- heap_unshare(&b->T->heap, tail, 0);
- if (b->H->vheap)
- heap_unshare(b->H->vheap, H->vheap, ABS(b->batCacheid));
- if (b->T->vheap)
- heap_unshare(b->T->vheap, T->vheap, ABS(b->batCacheid));
- b->P->lview = 0;
- return 0;
-}
-
BAT *
BATsetaccess(BAT *b, int newmode)
{
@@ -2695,11 +2627,6 @@ BATsetaccess(BAT *b, int newmode)
int m0, m1, m2 = 0, m3 = 0;
int b0, b1, b2 = 0, b3 = 0;
- /* copy-on-write isolated bats that change mode should
- * be made independent */
- if (b->P->lview && newmode != BAT_READ && batunshare(b,
"BATsetaccess") < 0)
- return NULL;
-
if (b->batSharecnt && newmode != BAT_READ) {
PROPDEBUG THRprintf(GDKout, "#BATsetaccess: %s has %d
views; deliver a copy.\n", BATgetId(b), b->batSharecnt);
@@ -2803,10 +2730,6 @@ BATmode(BAT *b, int mode)
if (mode != b->batPersistence) {
bat bid = ABS(b->batCacheid);
- if (b->P->lview) {
- if (batunshare(b, "BATmode") < 0)
- return NULL;
- }
if (mode == PERSISTENT) {
check_type(b->htype);
check_type(b->ttype);
diff --git a/gdk/gdk_bbp.mx b/gdk/gdk_bbp.mx
--- a/gdk/gdk_bbp.mx
+++ b/gdk/gdk_bbp.mx
@@ -2191,7 +2191,7 @@ BBPrename(bat bid, const char *nme)
*/
@h
#define BBPswappable(b) ((b) && (b)->batCacheid && BBP_refs((b)->batCacheid)
== 0)
-#define BBPtrimmable(b) (BBPswappable(b) && b->P->lview == 0 && isVIEW(b) == 0
&& (BBP_status((b)->batCacheid)&BBPWAITING) == 0)
+#define BBPtrimmable(b) (BBPswappable(b) && isVIEW(b) == 0 &&
(BBP_status((b)->batCacheid)&BBPWAITING) == 0)
/*
* The BBP_ref contains the amount of live references to a BAT. These
* might be in recursive BATs, C or MAL variables. The count is
@@ -2279,21 +2279,18 @@ incref(bat i, int logical, int lock)
if (hp) {
incref(hp, 0, lock);
b = getBBPdescriptor(hp, lock);
- if (!bs->P.lview) {
- bs->B.H->heap.base = b->H->heap.base + (size_t)
bs->B.H->heap.base;
- /* if we shared the hash before, share
- * it again note that if the parent's
- * hash is destroyed, we also don't
- * have a hash anymore */
- if (bs->B.H->hash == (Hash *) -1)
- bs->B.H->hash = b->H->hash;
- }
+ bs->B.H->heap.base = b->H->heap.base + (size_t)
bs->B.H->heap.base;
+ /* if we shared the hash before, share
+ * it again note that if the parent's
+ * hash is destroyed, we also don't
+ * have a hash anymore */
+ if (bs->B.H->hash == (Hash *) -1)
+ bs->B.H->hash = b->H->hash;
}
if (tp) {
incref(tp, 0, lock);
b = getBBPdescriptor(tp, lock);
- if (!bs->P.lview &&
- bs->B.H != bs->B.T) { /* mirror? */
+ if (bs->B.H != bs->B.T) { /* mirror? */
bs->B.T->heap.base = b->H->heap.base + (size_t)
bs->B.T->heap.base;
/* if we shared the hash before, share
* it again note that if the parent's
@@ -2389,12 +2386,10 @@ decref(bat i, int logical, int releaseSh
assert(b == NULL || b->T->vheap == NULL ||
b->T->vheap->parentid == 0 || BBP_refs(b->T->vheap->parentid) > 0);
refs = --BBP_refs(i);
if (b && refs == 0) {
- if ((hp = b->H->heap.parentid) != 0 &&
- !b->P->lview)
+ if ((hp = b->H->heap.parentid) != 0)
b->H->heap.base = (char *)
(b->H->heap.base - BBP_cache(hp)->H->heap.base);
if ((tp = b->T->heap.parentid) != 0 &&
- b->H != b->T &&
- !b->P->lview)
+ b->H != b->T)
b->T->heap.base = (char *)
(b->T->heap.base - BBP_cache(tp)->H->heap.base);
/* if a view shared the hash with its
* parent, indicate this, but only if
diff --git a/monetdb5/modules/kernel/algebra.mx
b/monetdb5/modules/kernel/algebra.mx
--- a/monetdb5/modules/kernel/algebra.mx
+++ b/monetdb5/modules/kernel/algebra.mx
@@ -1576,7 +1576,6 @@ CMD@1(BAT **result, BAT* b, int *param)
#define BATtmark_default(b)
BATmirror(BATmark(BATmirror(b),OIDnew(BATcount(b))))
#define BAThmark_default(b) BATmirror(BATmark(b,OIDnew(BATcount(b))))
#define BATwcopy(b) BATcopy(b, b->htype, b->ttype, 1)
-#define BATrcopy(b) BATcopy(b, b->htype, b->ttype, 2)
@c
@:unary(histogram,BAThistogram)@
@:unary(sort,BATsort)@
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list