Changeset: f725af507d6d for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=f725af507d6d
Modified Files:
        gdk/gdk.h
        gdk/gdk_align.c
        gdk/gdk_bat.c
        gdk/gdk_batop.c
        gdk/gdk_bbp.c
        gdk/gdk_mosaic.c
        gdk/gdk_private.h
        gdk/gdk_storage.c
        monetdb5/modules/mal/mosaic.c
        sql/backends/monet5/sql.c
        sql/backends/monet5/sql_upgrades.c
Branch: mosaic
Log Message:

Aligned with default and orderidx


diffs (truncated from 2824 to 300 lines):

diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -791,7 +791,7 @@ gdk_export int VALisnil(const ValRecord 
  *           bit    hsorted;          // are head values currently ordered?
  *           bit    hvarsized;        // for speed: head type is varsized?
  *           bit    hnonil;           // head has no nils
- *           oid    halign;          // alignment OID for head.
+ *           oid    halign;           // alignment OID for head.
  *           // Head storage
  *           int    hloc;             // byte-offset in BUN for head elements
  *           Heap   *hheap;           // heap for varsized head values
@@ -810,6 +810,7 @@ gdk_export int VALisnil(const ValRecord 
  *           Heap   *theap;           // heap for varsized tail values
  *           Hash   *thash;           // linear chained hash table on tail
  *           Imprints *timprints;     // column imprints index on tail
+ *           Heap   *mosaic;             // compressed representation
  *  } BAT;
  * @end verbatim
  *
@@ -899,7 +900,6 @@ typedef struct {
 
 #define GDKLIBRARY_INET_COMPARE        061026  /* version with missing inet 
cmp func */
 #define GDKLIBRARY_64_BIT_INT  061027  /* version that had no 128-bit integer 
option, yet */
-#define GDKLIBRARY_NOCOMPRESS  061027  /* version without compression (mosaic) 
*/
 #define GDKLIBRARY             061030
 
 typedef struct BAT {
@@ -958,6 +958,7 @@ typedef int (*GDKfcn) ();
 #define tident         T->id
 #define halign         H->align
 #define talign         T->align
+#define tmosaic T->mosaic
 
 #define batMaphead     S->map_head
 #define batMaptail     S->map_tail
@@ -2004,16 +2005,18 @@ gdk_export oid OIDnew(oid inc);
  *  BAThash (BAT *b, BUN masksize)
  * @end multitable
  *
- * The current BAT implementation supports two search accelerators:
- * hashing and imprints.  The routine BAThash makes sure that a hash
- * accelerator on the tail of the BAT exists. GDK_FAIL is returned
- * upon failure to create the supportive structures.
+ * The current BAT implementation supports three search/storage accelerators:
+ * hashing, imprints, and mosaic.
+ *
+ * The routine BAThash makes sure that a hash accelerator on the tail of the
+ * BAT exists. GDK_FAIL is returned upon failure to create the supportive
+ * structures.
  */
 gdk_export gdk_return BAThash(BAT *b, BUN masksize);
 
 /* support routines for the mosaic approach */
-gdk_export gdk_return MOSheapAlloc(BAT *b, BUN cap);
-gdk_export void MOSheapDestroy(BAT *b);
+gdk_export gdk_return MOSalloc(BAT *b);
+gdk_export void MOSdestroy(BAT *b);
 
 /*
  * @- Column Imprints Functions
diff --git a/gdk/gdk_align.c b/gdk/gdk_align.c
--- a/gdk/gdk_align.c
+++ b/gdk/gdk_align.c
@@ -326,6 +326,7 @@ VIEWcreate_(BAT *h, BAT *t, int slice_vi
        /* imprints are shared, but the check is dynamic */
        bn->H->imprints = NULL;
        bn->T->imprints = NULL;
+       bn->T->mosaic = NULL;
        BBPcacheit(bs, 1);      /* enter in BBP */
        /* View of VIEW combine, ie we need to fix the head of the mirror */
        if (vc) {
@@ -436,7 +437,7 @@ BATmaterializet(BAT *b)
        /* cleanup possible ACC's */
        HASHdestroy(b);
        IMPSdestroy(b);
-       MOSheapDestroy(b);
+       MOSdestroy(b);
 
        b->T->heap.filename = NULL;
        if (HEAPalloc(&b->T->heap, cnt, sizeof(oid)) != GDK_SUCCEED) {
@@ -791,7 +792,7 @@ VIEWdestroy(BAT *b)
        if (b->T->hash)
                HASHremove(b);
        IMPSdestroy(b);
-       MOSheapDestroy(b);
+       MOSdestroy(b);
        VIEWunlink(b);
 
        if (b->htype && !b->H->heap.parentid) {
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -449,7 +449,7 @@ BATextend(BAT *b, BUN newcap)
                return GDK_FAIL;
        HASHdestroy(b);
        IMPSdestroy(b);
-       MOSheapDestroy(b);
+       MOSdestroy(b);
        return GDK_SUCCEED;
 }
 
@@ -493,7 +493,7 @@ BATclear(BAT *b, int force)
        /* kill all search accelerators */
        HASHdestroy(b);
        IMPSdestroy(b);
-       MOSheapDestroy(b);
+       MOSdestroy(b);
 
        /* we must dispose of all inserted atoms */
        if ((b->batDeleted == b->batInserted || force) &&
@@ -594,7 +594,7 @@ BATfree(BAT *b)
        b->T->props = NULL;
        HASHdestroy(b);
        IMPSdestroy(b);
-       MOSheapDestroy(b);
+       MOSdestroy(b);
        if (b->htype)
                HEAPfree(&b->H->heap, 0);
        else
@@ -1185,7 +1185,7 @@ BUNins(BAT *b, const void *h, const void
                }
        }
        IMPSdestroy(b); /* no support for inserts in imprints yet */
-       MOSheapDestroy(b);
+       MOSdestroy(b);
        return GDK_SUCCEED;
       bunins_failed:
        return GDK_FAIL;
@@ -1278,7 +1278,7 @@ BUNappend(BAT *b, const void *t, bit for
 
 
        IMPSdestroy(b); /* no support for inserts in imprints yet */
-       MOSheapDestroy(b);
+       MOSdestroy(b);
 
        /* first adapt the hashes; then the user-defined accelerators.
         * REASON: some accelerator updates (qsignature) use the hashes!
@@ -1457,7 +1457,7 @@ BUNdelete_(BAT *b, BUN p, bit force)
        b->batCount--;
        b->batDirty = 1;        /* bat is dirty */
        IMPSdestroy(b); /* no support for inserts in imprints yet */
-       MOSheapDestroy(b);
+       MOSdestroy(b);
        return p;
 }
 
diff --git a/gdk/gdk_batop.c b/gdk/gdk_batop.c
--- a/gdk/gdk_batop.c
+++ b/gdk/gdk_batop.c
@@ -690,7 +690,7 @@ BATappend(BAT *b, BAT *n, bit force)
        }
 
        IMPSdestroy(b);         /* imprints do not support updates yet */
-       MOSheapDestroy(b);
+       MOSdestroy(b);
        /* a hash is useless for void bats */
        if (b->H->hash)
                HASHremove(BATmirror(b));
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -715,7 +715,7 @@ heapinit(COLrec *col, const char *buf, i
                   &n) < 13)
                GDKfatal("BBPinit: invalid format for BBP.dir\n%s", buf);
 
-       if (properties & ~0x1F81)
+       if (properties & ~0x0F81)
                GDKfatal("BBPinit: unknown properties are set: incompatible 
database\n");
        *hashash = var & 2;
        var &= ~2;
@@ -1229,7 +1229,7 @@ heap_entry(FILE *fp, COLrec *col)
                           (((unsigned short) col->key & 0x01) << 8) |
                           ((unsigned short) col->dense << 9) |
                           ((unsigned short) col->nonil << 10) |
-                          ((unsigned short) col->nil << 11) ,
+                          ((unsigned short) col->nil << 11),
                       col->nokey[0],
                       col->nokey[1],
                       col->nosorted,
@@ -3869,6 +3869,9 @@ BBPdiskscan(const char *parent)
                } else if (strncmp(p + 1, "timprints", 9) == 0) {
                        BAT *b = getdesc(bid);
                        delete = b == NULL;
+               } else if (strncmp(p + 1, "mosaic", 6) == 0) {
+                       BAT *b = getdesc(bid);
+                       delete = b == NULL;
                } else if (strncmp(p + 1, "priv", 4) != 0 && strncmp(p + 1, 
"new", 3) != 0 && strncmp(p + 1, "head", 4) != 0 && strncmp(p + 1, "tail", 4) 
!= 0) {
                        ok = FALSE;
                }
diff --git a/gdk/gdk_mosaic.c b/gdk/gdk_mosaic.c
--- a/gdk/gdk_mosaic.c
+++ b/gdk/gdk_mosaic.c
@@ -15,14 +15,15 @@
 #include "gdk_private.h"
 
 gdk_return
-MOSheapAlloc(BAT *bn, BUN cap)
+MOSalloc(BAT *bn)
 {
     const char *nme = BBP_physical(bn->batCacheid);
 
     if ( (bn->T->mosaic = (Heap*)GDKzalloc(sizeof(Heap))) == NULL ||
         (bn->T->mosaic->filename = GDKfilepath(NOFARM, NULL, nme, "mosaic")) 
== NULL)
         return GDK_FAIL;
-    if( HEAPalloc(bn->T->mosaic, cap , Tsize(bn)) != GDK_SUCCEED)
+       
+    if( HEAPalloc(bn->T->mosaic, BATcapacity(bn) + 25*1024 , Tsize(bn)) != 
GDK_SUCCEED)
         return GDK_FAIL;
     bn->T->mosaic->parentid = bn->batCacheid;
     bn->T->mosaic->farmid = BBPselectfarm(bn->batRole, bn->ttype, varheap);
@@ -30,14 +31,14 @@ MOSheapAlloc(BAT *bn, BUN cap)
 }
 
 void
-MOSheapDestroy(BAT *bn)
+MOSdestroy(BAT *bn)
 {      Heap *h;
        
        if( bn && bn->T->mosaic && !VIEWtparent(bn)){
                h= bn->T->mosaic;
                bn->T->mosaic = NULL;
                if( HEAPdelete(h, BBP_physical(bn->batCacheid), "mosaic"))
-                       IODEBUG fprintf(stderr,"#MOSheapDestroy (%s) failed", 
BATgetId(bn));
+                       IODEBUG fprintf(stderr,"#MOSdestroy (%s) failed", 
BATgetId(bn));
                bn->T->mosaic = NULL;
                GDKfree(h);
        }
diff --git a/gdk/gdk_private.h b/gdk/gdk_private.h
--- a/gdk/gdk_private.h
+++ b/gdk/gdk_private.h
@@ -20,7 +20,8 @@ enum heaptype {
        offheap,
        varheap,
        hashheap,
-       imprintsheap
+       imprintsheap,
+       mosaicheap
 };
 
 /*
@@ -55,6 +56,10 @@ struct BATstore {
        __attribute__((__visibility__("hidden")));
 __hidden gdk_return BATcheckmodes(BAT *b, int persistent)
        __attribute__((__visibility__("hidden")));
+__hidden gdk_return BATcheckmodes(BAT *b, int persistent)
+       __attribute__((__visibility__("hidden")));
+__hidden int BATcheckmosaic(BAT *b)
+       __attribute__((__visibility__("hidden")));
 __hidden BATstore *BATcreatedesc(int ht, int tt, int heapnames, int role)
        __attribute__((__visibility__("hidden")));
 __hidden void BATdelete(BAT *b)
diff --git a/gdk/gdk_storage.c b/gdk/gdk_storage.c
--- a/gdk/gdk_storage.c
+++ b/gdk/gdk_storage.c
@@ -975,7 +975,7 @@ BATdelete(BAT *b)
                b = loaded;
                HASHdestroy(b);
                IMPSdestroy(b);
-               MOSheapDestroy(b);
+               MOSdestroy(b);
        }
        assert(!b->H->heap.base || !b->T->heap.base || b->H->heap.base != 
b->T->heap.base);
        if (b->batCopiedtodisk || (b->H->heap.storage != STORE_MEM)) {
diff --git a/monetdb5/modules/mal/mosaic.c b/monetdb5/modules/mal/mosaic.c
--- a/monetdb5/modules/mal/mosaic.c
+++ b/monetdb5/modules/mal/mosaic.c
@@ -404,7 +404,7 @@ MOScompressInternal(Client cntxt, bat *r
                // Then we total size may go beyond the original size and we 
should terminate the process.
                // This should be detected before we compress a block, in the 
estimate functions
                // or when we extend the non-compressed collector block
-               if( MOSheapAlloc(bsrc, BATcapacity(bsrc) + (MosaicHdrSize + 
MosaicBlkSize)/Tsize(bsrc)+ BATTINY) == GDK_FAIL)
+               if( MOSalloc(bsrc) == GDK_FAIL)
                        throw(MAL,"mosaic.compress", "heap construction 
failes");
        }
        
@@ -435,7 +435,7 @@ MOScompressInternal(Client cntxt, bat *r
                // default is to extend the non-compressed block with a single 
element
                cand = MOSoptimizer(cntxt, task, typewidth);
                if( task->dst >= bsrc->T->mosaic->base + bsrc->T->mosaic->size 
- 16 ){
-                       MOSheapDestroy(bsrc);
+                       MOSdestroy(bsrc);
                        msg= createException(MAL,"mosaic","abort compression 
due to size");
                        task->hdr = 0;
                        goto finalize;
diff --git a/sql/backends/monet5/sql.c b/sql/backends/monet5/sql.c
--- a/sql/backends/monet5/sql.c
+++ b/sql/backends/monet5/sql.c
@@ -1063,25 +1063,25 @@ rel_check_tables(sql_table *nt, sql_tabl
 {
        node *n, *m;
 
-       if (cs_size(&nt->columns) != cs_size(&nnt->columns)) 
+       if (cs_size(&nt->columns) != cs_size(&nnt->columns))
                return sql_message("3F000!ALTER MERGE TABLE: to be added table 
doesn't match MERGE TABLE definition");
        for (n = nt->columns.set->h, m = nnt->columns.set->h; n && m; n = 
n->next, m = m->next) {
                sql_column *nc = n->data;
                sql_column *mc = m->data;
 
-               if (subtype_cmp(&nc->type, &mc->type) != 0) 
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to