Changeset: b00d3ff91665 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b00d3ff91665
Modified Files:
sql/storage/bat/bat_storage.c
sql/storage/bat/bat_storage.h
sql/storage/sql_storage.h
sql/storage/store.c
Branch: newstorage
Log Message:
sql_timestamps not properly created yet
diffs (truncated from 484 to 300 lines):
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
@@ -56,6 +56,8 @@ delta_bind_del(sql_dbat *bat, int access
assert(access == RDONLY || access == RD_INS);
assert(access!=RD_UPD);
+ //printf("%d\n",bat->dtrbid);
+
b = temp_descriptor(bat->dbid);
assert(b);
return b;
@@ -584,7 +586,46 @@ dup_del(sql_trans *tr, sql_table *ot, sq
sql_dbat *bat = t->data = ZNEW(sql_dbat), *obat = ot->data;
int ok = dup_dbat( tr, obat, bat, isNew(t), isTempTable(t));
assert(t->base.allocated == 0);
+ //t->base.allocated = 1;
+ return ok;
+}
+
+static int
+dup_tsbats(sql_trans *tr, sql_timestamps *ots, sql_timestamps *ts, int is_new,
int temp) {
+
+ ts->insbid = ots->insbid;
+ ts->delbid = ots->delbid;
+ ts->cnt = ots->cnt;
+ ts->insname = _STRDUP(ots->insname);
+ ts->delname = _STRDUP(ots->delname);
+ ts->wtime = ots->wtime;
+
+ if(ts->insbid) {
+ if (is_new)
+ ots->insbid = temp_copy(ts->insbid, temp);
+ else
+ ts->insbid = ebat_copy(ts->insbid, 0, temp);
+ }
+
+ if(ts->delbid) {
+ if (is_new)
+ ots->delbid = temp_copy(ts->delbid, temp);
+ else
+ ts->delbid = ebat_copy(ts->delbid, 0, temp);
+ }
+ (void)tr;
+
+ return LOG_OK;
+}
+
+static int
+dup_timestamps(sql_trans *tr, sql_table *ot, sql_table *t) {
+
+ sql_timestamps *ts = t->timestamps = ZNEW(sql_timestamps), *ots =
ot->timestamps;
+ int ok = dup_tsbats(tr, ots, ts, isNew(t), isTempTable(t));
+ assert(t->base.allocated == 0);
t->base.allocated = 1;
+
return ok;
}
@@ -1167,7 +1208,7 @@ snapshot_create_idx(sql_trans *tr, sql_i
assert(tr->parent == gtrans && !isTempTable(ni->t));
return snapshot_new_persistent_bat( tr, ni->data);
}
-/**
+
static int
load_timestamps(sql_timestamps *ts, int insbid, int delbid)
{
@@ -1179,7 +1220,7 @@ load_timestamps(sql_timestamps *ts, int
ts->cnt = BATcount(insb);
return LOG_OK;
}
-*/
+
static int
load_dbat(sql_dbat *bat, int bid) {
@@ -1190,13 +1231,12 @@ load_dbat(sql_dbat *bat, int bid) {
return LOG_OK;
}
-/**
static int
create_timestamps(sql_trans *tr, sql_table *t) {
int ok = LOG_OK;
BAT *b;
- sql_timestamps *ts = t->data;
+ sql_timestamps *ts = t->timestamps;
if (!ts) {
t->timestamps = ts = ZNEW(sql_timestamps);
@@ -1233,7 +1273,7 @@ create_timestamps(sql_trans *tr, sql_tab
}
return ok;
}
-*/
+
static int
create_del(sql_trans *tr, sql_table *t)
{
@@ -1285,7 +1325,7 @@ log_create_dbat( sql_dbat *bat )
return ok;
}
-/**
+
static int
log_create_tsbats (sql_timestamps *ts)
{
@@ -1313,7 +1353,7 @@ log_create_timestamps(sql_trans *tr, sql
assert(tr->parent == gtrans && !isTempTable(t));
return log_create_tsbats(t->timestamps);
}
-*/
+
static int
log_create_del(sql_trans *tr, sql_table *t)
{
@@ -1353,7 +1393,7 @@ snapshot_create_del(sql_trans *tr, sql_t
return LOG_OK;
}
-/**static int
+static int
snapshot_create_timestamps(sql_trans *tr, sql_table *t)
{
sql_timestamps *ts = t->timestamps;
@@ -1362,8 +1402,22 @@ snapshot_create_timestamps(sql_trans *tr
(void)tr;
- if (BATcount())
-}*/
+ bat_set_access(insb, BAT_READ);
+ if (BATcount(insb) > SNAPSHOT_MINSIZE)
+ BATmode(insb, PERSISTENT);
+ if (BATcount(insb) > (BUN) REMAP_PAGE_MAXSIZE)
+ BATmmap(insb, STORE_MMAP, STORE_MMAP, STORE_MMAP, STORE_MMAP,
0);
+ bat_destroy(insb);
+
+ bat_set_access(delb, BAT_READ);
+ if (BATcount(delb) > SNAPSHOT_MINSIZE)
+ BATmode(delb, PERSISTENT);
+ if (BATcount(delb) > (BUN) REMAP_PAGE_MAXSIZE)
+ BATmmap(delb, STORE_MMAP, STORE_MMAP, STORE_MMAP, STORE_MMAP,
0);
+ bat_destroy(delb);
+
+ return LOG_OK;
+}
static int
log_destroy_delta(sql_trans *tr, sql_delta *b)
@@ -1516,6 +1570,45 @@ destroy_del(sql_trans *tr, sql_table *t)
return ok;
}
+static int
+destroy_tsbats(sql_trans *tr, sql_timestamps *ts) {
+
+ sql_timestamps *n = ts->next;
+
+ if(ts->insname)
+ _DELETE(ts->insname);
+ if(ts->insbid)
+ temp_destroy(ts->insbid);
+ if(ts->delname)
+ _DELETE(ts->delname);
+ if(ts->delbid)
+ temp_destroy(ts->delbid);
+
+ ts->insbid = 0;
+ ts->insname = NULL;
+ ts->delbid = 0;
+ ts->delname = NULL;
+ _DELETE(ts);
+
+ if (n)
+ return destroy_tsbats(tr,n);
+
+ return LOG_OK;
+}
+
+static int
+destroy_timestamps(sql_trans *tr, sql_table *t) {
+
+ int ok = LOG_OK;
+
+ if(t->timestamps && t->base.allocated) {
+ t->base.allocated=0;
+ ok = destroy_tsbats(tr, t->timestamps);
+ }
+ t->timestamps = NULL;
+ return ok;
+}
+
static int
log_destroy_dbat(sql_trans *tr, sql_dbat *bat)
{
@@ -1554,6 +1647,42 @@ log_destroy_del(sql_trans *tr, sql_table
return LOG_OK;
}
+static int
+log_destroy_tsbats(sql_trans *tr, sql_timestamps *ts) {
+
+ int ok = LOG_OK;
+
+ (void)tr;
+ if(ts->insbid && ts->insname) {
+ log_bid bid;
+
+ ok = log_bat_transient(bat_logger, ts->insname);
+ bid = logger_find_bat(bat_logger, ts->insname);
+ if(bid)
+ logger_del_bat(bat_logger, bid);
+ }
+
+ if(ts->delbid && ts->delname) {
+ log_bid bid;
+
+ ok = log_bat_transient(bat_logger, ts->delname);
+ bid = logger_find_bat(bat_logger, ts->delname);
+ if(bid)
+ logger_del_bat(bat_logger, bid);
+ }
+
+ return ok;
+}
+
+static int
+log_destroy_timestamps(sql_trans *tr, sql_table *t) {
+
+ if(t->timestamps && t->base.allocated)
+ return log_destroy_tsbats(tr, t->timestamps);
+
+ return LOG_OK;
+}
+
static BUN
clear_delta(sql_trans *tr, sql_delta *bat)
{
@@ -1686,7 +1815,6 @@ clear_dbat(sql_trans *tr, sql_dbat *bat)
static BUN
clear_del(sql_trans *tr, sql_table *t)
{
-
printf("in clear_del\n");
if (!t->data || !t->base.allocated) {
@@ -2142,6 +2270,8 @@ update_table(sql_trans *tr, sql_table *f
tt->base.wtime = ft->base.wtime;
if (ft->data)
destroy_del(tr, ft);
+ if (ft->timestamps)
+ destroy_timestamps(tr, ft);
ft->base.allocated = ft->base.rtime = ft->base.wtime = 0;
return ok;
}
@@ -2343,26 +2473,32 @@ bat_storage_init( store_functions *sf)
sf->create_col = (create_col_fptr)&create_col;
sf->create_idx = (create_idx_fptr)&create_idx;
sf->create_del = (create_del_fptr)&create_del;
+ sf->create_timestamps = (create_timestamps_fptr)&create_timestamps;
sf->log_create_col = (create_col_fptr)&log_create_col;
sf->log_create_idx = (create_idx_fptr)&log_create_idx;
sf->log_create_del = (create_del_fptr)&log_create_del;
+ sf->log_create_timestamps =
(create_timestamps_fptr)&log_create_timestamps;
sf->snapshot_create_col = (create_col_fptr)&snapshot_create_col;
sf->snapshot_create_idx = (create_idx_fptr)&snapshot_create_idx;
sf->snapshot_create_del = (create_del_fptr)&snapshot_create_del;
+ sf->snapshot_create_timestamps =
(create_timestamps_fptr)&snapshot_create_timestamps;
sf->dup_col = (dup_col_fptr)&dup_col;
sf->dup_idx = (dup_idx_fptr)&dup_idx;
sf->dup_del = (dup_del_fptr)&dup_del;
+ sf->dup_timestamps = (dup_timestamps_fptr)&dup_timestamps;
sf->destroy_col = (destroy_col_fptr)&destroy_col;
sf->destroy_idx = (destroy_idx_fptr)&destroy_idx;
sf->destroy_del = (destroy_del_fptr)&destroy_del;
+ sf->destroy_timestamps = (destroy_timestamps_fptr)&destroy_timestamps;
sf->log_destroy_col = (destroy_col_fptr)&log_destroy_col;
sf->log_destroy_idx = (destroy_idx_fptr)&log_destroy_idx;
sf->log_destroy_del = (destroy_del_fptr)&log_destroy_del;
+ sf->log_destroy_timestamps =
(destroy_timestamps_fptr)&log_destroy_timestamps;
sf->clear_col = (clear_col_fptr)&clear_col;
sf->clear_idx = (clear_idx_fptr)&clear_idx;
diff --git a/sql/storage/bat/bat_storage.h b/sql/storage/bat/bat_storage.h
--- a/sql/storage/bat/bat_storage.h
+++ b/sql/storage/bat/bat_storage.h
@@ -51,6 +51,7 @@ typedef struct sql_timestamps {
int insbid;
int wtime;
int cnt;
+ struct sql_timestamps *next;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list