Changeset: 23c1ed59b6b8 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=23c1ed59b6b8
Modified Files:
sql/backends/monet5/sql.c
sql/backends/monet5/sql.mal
sql/backends/monet5/sql_scenario.c
sql/scripts/75_storagemodel.sql
Branch: default
Log Message:
Make imprint use visible
The storage() scheme includes the imprints footprint now.
diffs (136 lines):
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
@@ -4285,7 +4285,7 @@ SQLoptimizersUpdate(Client cntxt, MalBlk
str
sql_storage(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
{
- BAT *sch, *tab, *col, *type, *loc, *cnt, *atom, *size, *heap, *indices,
*sort;
+ BAT *sch, *tab, *col, *type, *loc, *cnt, *atom, *size, *heap, *indices,
*sort, *imprints;
mvc *m = NULL;
str msg = getSQLContext(cntxt, mb, &m, NULL);
sql_trans *tr = m->session->tr;
@@ -4301,7 +4301,8 @@ sql_storage(Client cntxt, MalBlkPtr mb,
int *rsize = (int *) getArgReference(stk, pci, 7);
int *rheap = (int *) getArgReference(stk, pci, 8);
int *rindices = (int *) getArgReference(stk, pci, 9);
- int *rsort = (int *) getArgReference(stk, pci, 10);
+ int *rimprints = (int *) getArgReference(stk, pci, 10);
+ int *rsort = (int *) getArgReference(stk, pci, 11);
if ((msg = checkSQLContext(cntxt)) != NULL)
return msg;
@@ -4326,9 +4327,11 @@ sql_storage(Client cntxt, MalBlkPtr mb,
BATseqbase(heap, 0);
indices = BATnew(TYPE_void, TYPE_lng, 0);
BATseqbase(indices, 0);
+ imprints = BATnew(TYPE_void, TYPE_lng, 0);
+ BATseqbase(imprints, 0);
sort = BATnew(TYPE_void, TYPE_bit, 0);
BATseqbase(sort, 0);
- if (sch == NULL || tab == NULL || col == NULL || type == NULL || loc ==
NULL || sort == NULL || cnt == NULL || atom == NULL || size == NULL || heap ==
NULL || indices == NULL) {
+ if (sch == NULL || tab == NULL || col == NULL || type == NULL || loc ==
NULL || imprints == NULL || sort == NULL || cnt == NULL || atom == NULL || size
== NULL || heap == NULL || indices == NULL) {
if (sch)
BBPreleaseref(sch->batCacheid);
if (tab)
@@ -4349,6 +4352,8 @@ sql_storage(Client cntxt, MalBlkPtr mb,
BBPreleaseref(heap->batCacheid);
if (indices)
BBPreleaseref(indices->batCacheid);
+ if (imprints)
+ BBPreleaseref(imprints->batCacheid);
if (sort)
BBPreleaseref(sort->batCacheid);
throw(SQL, "sql.storage", MAL_MALLOC_FAIL);
@@ -4415,8 +4420,9 @@ sql_storage(Client cntxt, MalBlkPtr mb,
sz =
bn->T->hash ? bn->T->hash->heap->size : 0;
sz +=
bn->H->hash ? bn->H->hash->heap->size : 0;
- sz +=
IMPSimprintsize(bn);
indices =
BUNappend(indices, &sz, FALSE);
+ sz =
IMPSimprintsize(bn);
+ imprints =
BUNappend(imprints, &sz, FALSE);
/*printf("
indices "BUNFMT, bn->T->hash?bn->T->hash->heap->size:0); */
/*printf("\n");
*/
@@ -4480,6 +4486,8 @@ sql_storage(Client cntxt, MalBlkPtr mb,
sz =
bn->T->hash ? bn->T->hash->heap->size : 0;
sz +=
bn->H->hash ? bn->H->hash->heap->size : 0;
indices
= BUNappend(indices, &sz, FALSE);
+ sz =
IMPSimprintsize(bn);
+
imprints = BUNappend(imprints, &sz, FALSE);
/*printf(" indices "BUNFMT, bn->T->hash?bn->T->hash->heap->size:0); */
/*printf("\n"); */
w =
BATtordered(bn);
@@ -4501,6 +4509,7 @@ sql_storage(Client cntxt, MalBlkPtr mb,
BBPkeepref(*rsize = size->batCacheid);
BBPkeepref(*rheap = heap->batCacheid);
BBPkeepref(*rindices = indices->batCacheid);
+ BBPkeepref(*rimprints = imprints->batCacheid);
BBPkeepref(*rsort = sort->batCacheid);
return MAL_SUCCEED;
}
diff --git a/sql/backends/monet5/sql.mal b/sql/backends/monet5/sql.mal
--- a/sql/backends/monet5/sql.mal
+++ b/sql/backends/monet5/sql.mal
@@ -461,7 +461,8 @@ pattern storage()(
atomwidth:bat[:oid,:int],
columnsize:bat[:oid,:lng],
heap:bat[:oid,:lng],
- indices:bat[:oid,:lng],
+ hashes:bat[:oid,:lng],
+ imprints:bat[:oid,:lng],
sorted:bat[:oid,:bit])
address sql_storage
comment "return a table with storage information ";
diff --git a/sql/backends/monet5/sql_scenario.c
b/sql/backends/monet5/sql_scenario.c
--- a/sql/backends/monet5/sql_scenario.c
+++ b/sql/backends/monet5/sql_scenario.c
@@ -886,6 +886,24 @@ sql_update_default(Client c)
return err; /* usually MAL_SUCCEED */
}
+static str
+sql_update_default_storage(Client c)
+{
+ size_t bufsize = 4096, pos = 0;
+ char *buf = GDKmalloc(bufsize), *err = NULL;
+
+ /* change to storage functions */
+ pos += snprintf(buf + pos, bufsize - pos, "drop view sys.storage;\n");
+ pos += snprintf(buf + pos, bufsize - pos, "drop function
sys.storage();\n");
+ pos += snprintf(buf + pos, bufsize - pos, "create function
sys.storage() returns table (\"schema\" string, \"table\" string, \"column\"
string, \"type\" string, location string, \"count\" bigint, typewidth int,
columnsize bigint, heapsize bigint, hashes bigint, imprints bigint, sorted
boolean) external name sql.storage;\n");
+ pos += snprintf(buf + pos, bufsize - pos, "create view sys.storage as
select * from sys.storage();\n");
+
+ printf("Running database upgrade commands:\n%s\n", buf);
+ err = SQLstatementIntern(c, &buf, "update", 1, 0);
+ GDKfree(buf);
+ return err; /* usually MAL_SUCCEED */
+}
+
str
SQLinitClient(Client c)
{
@@ -1049,6 +1067,10 @@ SQLinitClient(Client c)
GDKfree(err);
}
}
+ if (0 && (err = sql_update_default_storage(c)) !=NULL) {
+ fprintf(stderr, "!%s\n", err);
+ GDKfree(err);
+ }
}
fflush(stdout);
fflush(stderr);
diff --git a/sql/scripts/75_storagemodel.sql b/sql/scripts/75_storagemodel.sql
--- a/sql/scripts/75_storagemodel.sql
+++ b/sql/scripts/75_storagemodel.sql
@@ -29,7 +29,7 @@
-- For strings we take a sample to determine their average length.
create function sys.storage()
-returns table ("schema" string, "table" string, "column" string, "type"
string, location string, "count" bigint, typewidth int, columnsize bigint,
heapsize bigint, indices bigint, sorted boolean)
+returns table ("schema" string, "table" string, "column" string, "type"
string, location string, "count" bigint, typewidth int, columnsize bigint,
heapsize bigint, hashes bigint, imprints bigint, sorted boolean)
external name sql.storage;
create view sys.storage as select * from sys.storage();
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list