Changeset: 9bed3972fc5b for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=9bed3972fc5b
Modified Files:
        monetdb5/modules/mal/mosaic.c
        sql/backends/monet5/sql.c
        sql/storage/bat/bat_storage.c
Branch: mosaic
Log Message:

fixes for persistent compressed bats.

assumptions/limitations for compress/decompress alter statements
        1) auto commit mode
        2) read only columns
        3) single transaction (active)
        4) directly create persistent compressed bats
Decompress now fails as it creates a transient bat, where
we expect an persistent.


diffs (105 lines):

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
@@ -233,7 +233,7 @@ MOScompressInternal(Client cntxt, int *r
        // It should always take less space then the orginal column.
        // But be prepared that a last block header may  be stored
        // use a size overshoot. Also be aware of possible dictionary headers
-       bn = BATnew( TYPE_void, b->ttype, cnt + 3 *  MosaicBlkSize + 
MosaicHdrSize, b->batPersistence);
+       bn = BATnew( TYPE_void, b->ttype, cnt + 3 *  MosaicBlkSize + 
MosaicHdrSize, PERSISTENT /*current logger doesn't handle compression calls, ie 
make persistent before entering log b->batPersistence*/);
        if (bn == NULL) {
                BBPreleaseref(b->batCacheid);
                throw(MAL,"mosaic.compress", MAL_MALLOC_FAIL);
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
@@ -585,10 +585,10 @@ alter_table(Client cntxt, mvc *sql, char
                        if (c->t->access == TABLE_WRITABLE) 
                                return sql_message("40002!ALTER TABLE: SET 
STORAGE for column %s.%s only allowed on READ or INSERT ONLY tables", 
c->t->base.name, c->base.name);
 
-                               if( c->storage_type)
-                                       msg = MOScompressInternal(cntxt, &bid, 
&b->batCacheid, c->storage_type);
-                               else
-                                       msg = MOSdecompressInternal(cntxt, 
&bid, &b->batCacheid);
+                       if( c->storage_type)
+                               msg = MOScompressInternal(cntxt, &bid, 
&b->batCacheid, c->storage_type);
+                       else
+                               msg = MOSdecompressInternal(cntxt, &bid, 
&b->batCacheid);
                        if (msg)
                                return msg;
                        allocate_delta(sql->session->tr, nc);
diff --git a/sql/storage/bat/bat_storage.c b/sql/storage/bat/bat_storage.c
--- a/sql/storage/bat/bat_storage.c
+++ b/sql/storage/bat/bat_storage.c
@@ -1910,6 +1910,24 @@ update_table(sql_trans *tr, sql_table *f
        return ok;
 }
 
+static int
+tr_log_storage( sql_trans *tr, sql_delta *cbat )
+{
+       int ok = LOG_OK;
+       BAT *b;
+
+       (void)tr;
+       assert(tr->parent == gtrans);
+       assert(store_nr_active == 1);
+
+       /* log new snapshot */
+       b = temp_descriptor(cbat->bid);
+       logger_add_bat(bat_logger, b, cbat->name);
+       ok = log_bat_persists(bat_logger, b, cbat->name);
+       bat_destroy(b);
+       return ok;
+}
+
 static int 
 tr_log_delta( sql_trans *tr, sql_delta *cbat, int cleared)
 {
@@ -1984,7 +2002,10 @@ log_table(sql_trans *tr, sql_table *ft)
 
                if (!cc->base.wtime || !cc->base.allocated) 
                        continue;
-               ok = tr_log_delta(tr, cc->data, ft->cleared);
+               if (ft->access > TABLE_WRITABLE) /* TODO we need a proper way 
to check for changes off the storage */
+                       ok = tr_log_storage(tr, cc->data);
+               else
+                       ok = tr_log_delta(tr, cc->data, ft->cleared);
        }
        if (ok == LOG_OK && ft->idxs.set) {
                for (n = ft->idxs.set->h; ok == LOG_OK && n; n = n->next) {
@@ -2001,6 +2022,22 @@ log_table(sql_trans *tr, sql_table *ft)
 }
 
 static int 
+tr_snapshot_storage( sql_trans *tr, sql_delta *cbat)
+{
+       int ok = LOG_OK;
+       BAT *b = temp_descriptor(cbat->bid);
+
+       assert(tr->parent == gtrans);
+       assert(store_nr_active == 1);
+
+       (void)tr;
+       bat_set_access(b, BAT_READ);
+       BATmode(b, PERSISTENT);
+       bat_destroy(b);
+       return ok;
+}
+
+static int 
 tr_snapshot_bat( sql_trans *tr, sql_delta *cbat)
 {
        int ok = LOG_OK;
@@ -2035,7 +2072,10 @@ snapshot_table(sql_trans *tr, sql_table 
 
                if (!cc->base.wtime || !cc->base.allocated) 
                        continue;
-               tr_snapshot_bat(tr, cc->data);
+               if (ft->access > TABLE_WRITABLE) /* TODO we need a proper way 
to check for changes off the storage */
+                       tr_snapshot_storage(tr, cc->data);
+               else
+                       tr_snapshot_bat(tr, cc->data);
        }
        if (ok == LOG_OK && ft->idxs.set) {
                for (n = ft->idxs.set->h; ok == LOG_OK && n; n = n->next) {
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to