Changeset: 426820b32019 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=426820b32019
Modified Files:
        gdk/gdk.h
        gdk/gdk_aggr.c
        gdk/gdk_align.c
        gdk/gdk_bat.c
        gdk/gdk_batop.c
        gdk/gdk_bbp.c
        gdk/gdk_group.c
        gdk/gdk_hash.c
        gdk/gdk_heap.c
        gdk/gdk_imprints.c
        gdk/gdk_join.c
        gdk/gdk_logger.c
        gdk/gdk_orderidx.c
        gdk/gdk_private.h
        gdk/gdk_project.c
        gdk/gdk_select.c
        gdk/gdk_storage.c
        gdk/gdk_tm.c
        gdk/gdk_unique.c
        monetdb5/mal/mal_dataflow.c
        monetdb5/mal/mal_debugger.c
        monetdb5/mal/mal_profiler.c
        monetdb5/mal/mal_resource.c
        monetdb5/mal/mal_resource.h
        monetdb5/mal/mal_runtime.c
        monetdb5/modules/kernel/bat5.c
        monetdb5/modules/kernel/status.c
        sql/backends/monet5/sql.c
        sql/storage/bat/bat_storage.c
Branch: viewless
Log Message:

no parentid or views in gdk, only shared vheap when needed.

(compiles but assertions fail during run)


diffs (truncated from 2289 to 300 lines):

diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -582,7 +582,7 @@ typedef struct {
        storage_t storage;      /* storage mode (mmap/malloc). */
        storage_t newstorage;   /* new desired storage mode at re-allocation. */
        bte farmid;             /* id of farm where heap is located */
-       bat parentid;           /* cache id of VIEW parent bat */
+       bat sharevheapid;       /* cache id of bat that share a vheap*/
 } Heap;
 
 typedef struct {
@@ -745,7 +745,7 @@ typedef struct {
         persistence:1,         /* should the BAT persist on disk? */
         role:8,                /* role of the bat */
         unused:17;             /* value=0 for now (sneakily used by mat.c) */
-       int sharecnt;           /* incoming view count */
+       int sharevheapcnt;      /* incoming share vheap count */
 
        /* delta status administration */
        BUN inserted;           /* start of inserted elements */
@@ -821,7 +821,7 @@ typedef struct BATiter {
 #define batInserted    S.inserted
 #define batCount       S.count
 #define batCapacity    S.capacity
-#define batSharecnt    S.sharecnt
+#define vHeapSharecnt  S.sharevheapcnt
 #define batRestricted  S.restricted
 #define batRole                S.role
 #define creator_tid    S.tid
@@ -2531,40 +2531,19 @@ gdk_export void BATassertProps(BAT *b);
 #define BATPROPS_ALL   1       /* derive all possible properties; no matter 
what cost (key=hash) */
 #define BATPROPS_CHECK  3      /* BATPROPS_ALL, but start from scratch and 
report illegally set properties */
 
-gdk_export BAT *VIEWcreate(oid seq, BAT *b);
-gdk_export void VIEWbounds(BAT *b, BAT *view, BUN l, BUN h);
-
-#define ALIGNapp(x, y, f, e)                                           \
-       do {                                                            \
-               if (!(f) && ((x)->batRestricted == BAT_READ ||          \
-                            (x)->batSharecnt > 0)) {                   \
-                       GDKerror("%s: access denied to %s, aborting.\n", \
-                                (y), BATgetId(x));                     \
-                       return (e);                                     \
-               }                                                       \
-       } while (false)
-
 /* The batRestricted field indicates whether a BAT is readonly.
  * we have modes: BAT_WRITE  = all permitted
  *                BAT_APPEND = append-only
  *                BAT_READ   = read-only
- * VIEW bats are always mapped read-only.
  */
 
-#define BAThrestricted(b) ((b)->batRestricted)
-#define BATtrestricted(b) (VIEWtparent(b) ? 
BBP_cache(VIEWtparent(b))->batRestricted : (b)->batRestricted)
+#define BATrestricted(b) ((b)->batRestricted)
 
-/* the parentid in a VIEW is correct for the normal view. We must
- * correct for the reversed view.
+/* 
+ * checks if the vheap is shared under the hood
  */
-#define isVIEW(x)                                                      \
-       (assert((x)->batCacheid > 0),                                   \
-        ((x)->theap.parentid ||                                        \
-         ((x)->tvheap && (x)->tvheap->parentid != (x)->batCacheid)))
-
-#define viewless(x) (!VIEWtparent(x) && !VIEWvtparent(x))
-#define VIEWtparent(x) ((x)->theap.parentid)
-#define VIEWvtparent(x)        ((x)->tvheap == NULL || (x)->tvheap->parentid 
== (x)->batCacheid ? 0 : (x)->tvheap->parentid)
+#define isShared(x)     ((x)->tvheap && (x)->tvheap->sharevheapid != 
(x)->batCacheid)
+#define SHAREvheap(x)  (((x)->tvheap == NULL || (x)->tvheap->sharevheapid == 
(x)->batCacheid) ? 0 : (x)->tvheap->sharevheapid)
 
 /*
  * @+ BAT Iterators
diff --git a/gdk/gdk_aggr.c b/gdk/gdk_aggr.c
--- a/gdk/gdk_aggr.c
+++ b/gdk/gdk_aggr.c
@@ -2633,16 +2633,9 @@ BATmin(BAT *b, void *aggr)
        } else {
                oid pos;
                BATiter bi;
-               BAT *pb = NULL;
 
-               if (BATcheckorderidx(b) ||
-                   (VIEWtparent(b) &&
-                    (pb = BBPdescriptor(VIEWtparent(b))) != NULL &&
-                    pb->theap.base == b->theap.base &&
-                    BATcount(pb) == BATcount(b) &&
-                    pb->hseqbase == b->hseqbase &&
-                    BATcheckorderidx(pb))) {
-                       const oid *ords = (const oid *) (pb ? 
pb->torderidx->base : b->torderidx->base) + ORDERIDXOFF;
+               if (BATcheckorderidx(b)) {
+                       const oid *ords = (const oid *) (b->torderidx->base) + 
ORDERIDXOFF;
                        BUN r;
                        if (!b->tnonil) {
                                r = binsearch(ords, 0, b->ttype, Tloc(b, 0),
@@ -2662,10 +2655,8 @@ BATmin(BAT *b, void *aggr)
                        } else {
                                pos = ords[r];
                        }
-               } else if ((VIEWtparent(b) == 0 ||
-                           BATcount(b) == 
BATcount(BBPdescriptor(VIEWtparent(b)))) &&
-                          BATcheckimprints(b)) {
-                       Imprints *imprints = VIEWtparent(b) ? 
BBPdescriptor(VIEWtparent(b))->timprints : b->timprints;
+               } else if (BATcheckimprints(b)) {
+                       Imprints *imprints = b->timprints;
                        int i;
 
                        pos = oid_nil;
@@ -2727,22 +2718,13 @@ BATmax(BAT *b, void *aggr)
        } else {
                oid pos;
                BATiter bi;
-               BAT *pb = NULL;
 
-               if (BATcheckorderidx(b) ||
-                   (VIEWtparent(b) &&
-                    (pb = BBPdescriptor(VIEWtparent(b))) != NULL &&
-                    pb->theap.base == b->theap.base &&
-                    BATcount(pb) == BATcount(b) &&
-                    pb->hseqbase == b->hseqbase &&
-                    BATcheckorderidx(pb))) {
-                       const oid *ords = (const oid *) (pb ? 
pb->torderidx->base : b->torderidx->base) + ORDERIDXOFF;
+               if (BATcheckorderidx(b)) {
+                       const oid *ords = (const oid *) (b->torderidx->base) + 
ORDERIDXOFF;
 
                        pos = ords[BATcount(b) - 1];
-               } else if ((VIEWtparent(b) == 0 ||
-                           BATcount(b) == 
BATcount(BBPdescriptor(VIEWtparent(b)))) &&
-                          BATcheckimprints(b)) {
-                       Imprints *imprints = VIEWtparent(b) ? 
BBPdescriptor(VIEWtparent(b))->timprints : b->timprints;
+               } else if (BATcheckimprints(b)) {
+                       Imprints *imprints = b->timprints;
                        int i;
 
                        pos = oid_nil;
@@ -2935,7 +2917,6 @@ BATgroupquantile(BAT *b, BAT *g, BAT *e,
                BBPunfix(g->batCacheid);
        } else {
                BUN index, r, p = BATcount(b);
-               BAT *pb = NULL;
                const oid *ords;
 
                bn = COLnew(0, tp, 1, TRANSIENT);
@@ -2944,14 +2925,8 @@ BATgroupquantile(BAT *b, BAT *g, BAT *e,
 
                t1 = NULL;
 
-               if (BATcheckorderidx(b) ||
-                   (VIEWtparent(b) &&
-                    (pb = BBPdescriptor(VIEWtparent(b))) != NULL &&
-                    pb->theap.base == b->theap.base &&
-                    BATcount(pb) == BATcount(b) &&
-                    pb->hseqbase == b->hseqbase &&
-                    BATcheckorderidx(pb))) {
-                       ords = (const oid *) (pb ? pb->torderidx->base : 
b->torderidx->base) + ORDERIDXOFF;
+               if (BATcheckorderidx(b)) {
+                       ords = (const oid *) (b->torderidx->base) + ORDERIDXOFF;
                } else {
                        if (BATsort(NULL, &t1, NULL, b, NULL, g, false, false) 
!= GDK_SUCCEED)
                                goto bunins_failed;
diff --git a/gdk/gdk_align.c b/gdk/gdk_align.c
--- a/gdk/gdk_align.c
+++ b/gdk/gdk_align.c
@@ -63,89 +63,6 @@ ALIGNsynced(BAT *b1, BAT *b2)
        return BATcount(b1) == BATcount(b2) && b1->hseqbase == b2->hseqbase;
 }
 
-/*
- * @+ View BATS
- * The general routine for getting a 'view' BAT upon another BAT is
- * @emph{VIEWcreate}. On this @emph{#read-only} BAT (there is kernel
- * support for this), you can then make vertical slices.
- *
- * It is possible to create a view on a writable BAT. Updates in the
- * parent are then automatically reflected in the VIEW.  Note that the
- * VIEW bat itself can never be modified.
- *
- * Horizontal views should only be given out on a view BAT, but only
- * if it is dead sure the parent BAT is read-only.  This because they
- * cannot physically share the batBuns heap with the parent, as they
- * need a modified version.
- */
-BAT *
-VIEWcreate(oid seq, BAT *b)
-{
-       BAT *bn;
-       bat tp = 0;
-
-       BATcheck(b, "VIEWcreate", NULL);
-
-       bn = BATcreatedesc(seq, b->ttype, FALSE, TRANSIENT);
-       if (bn == NULL)
-               return NULL;
-
-       tp = VIEWtparent(b);
-       if ((tp == 0 && b->ttype != TYPE_void) || b->theap.copied)
-               tp = b->batCacheid;
-       assert(b->ttype != TYPE_void || !tp);
-       /* the T column descriptor is fully copied. We need copies
-        * because in case of a mark, we are going to override a
-        * column with a void. Take care to zero the accelerator data,
-        * though. */
-       bn->batInserted = b->batInserted;
-       bn->batCount = b->batCount;
-       bn->batCapacity = b->batCapacity;
-       bn->T = b->T;
-
-       if (tp)
-               BBPshare(tp);
-       if (bn->tvheap) {
-               assert(b->tvheap);
-               assert(bn->tvheap->parentid > 0);
-               BBPshare(bn->tvheap->parentid);
-       }
-
-       /* note: theap points into bn which was just overwritten
-        * with a copy from the parent.  Clear the copied flag since
-        * our heap was not copied from our parent(s) even if our
-        * parent's heap was copied from its parent. */
-       bn->theap.copied = 0;
-       bn->tprops = NULL;
-
-       /* correct values after copy of head and tail info */
-       if (tp)
-               bn->theap.parentid = tp;
-       BATinit_idents(bn);
-       bn->batRestricted = BAT_READ;
-       bn->thash = NULL;
-       /* imprints are shared, but the check is dynamic */
-       bn->timprints = NULL;
-       /* Order OID index */
-       bn->torderidx = NULL;
-       if (BBPcacheit(bn, 1) != GDK_SUCCEED) { /* enter in BBP */
-               if (tp)
-                       BBPunshare(tp);
-               if (bn->tvheap)
-                       BBPunshare(bn->tvheap->parentid);
-               GDKfree(bn);
-               return NULL;
-       }
-       ALGODEBUG fprintf(stderr, "#VIEWcreate(" ALGOBATFMT ")=" ALGOBATFMT 
"\n", ALGOBATPAR(b), ALGOBATPAR(bn));
-       return bn;
-}
-
-/*
- * The BATmaterialize routine produces in-place materialized version
- * of a void bat (which should not be a VIEW) (later we should add the
- * code for VIEWs).
- */
-
 gdk_return
 BATmaterialize(BAT *b)
 {
@@ -156,7 +73,6 @@ BATmaterialize(BAT *b)
        oid t, *x;
 
        BATcheck(b, "BATmaterialize", GDK_FAIL);
-       assert(!isVIEW(b));
        tt = b->ttype;
        cnt = BATcapacity(b);
        tail = b->theap;
@@ -204,222 +120,4 @@ BATmaterialize(BAT *b)
        /* cleanup the old heaps */
        HEAPfree(&tail, false);
        return GDK_SUCCEED;
-}
-
-/*
- * The @#VIEWunlink@ routine cuts a reference to the parent. Part of the view
- * destroy sequence.
- */
-static void
-VIEWunlink(BAT *b)
-{
-       if (b) {
-               bat tp = VIEWtparent(b);
-               bat vtp = VIEWvtparent(b);
-               BAT *tpb = NULL;
-               BAT *vtpb = NULL;
-
-               assert(b->batCacheid > 0);
-               if (tp)
-                       tpb = BBP_cache(tp);
-               if (tp && !vtp)
-                       vtp = tp;
-               if (vtp)
-                       vtpb = BBP_cache(vtp);
-
-               if (tpb == NULL && vtpb == NULL)
-                       return;
-
-               /* unlink heaps shared with parent */
-               assert(b->tvheap == NULL || b->tvheap->parentid > 0);
-               if (b->tvheap && b->tvheap->parentid != b->batCacheid)
-                       b->tvheap = NULL;
-
-               /* unlink properties shared with parent */
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to