Changeset: 8465a987fa7e for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=8465a987fa7e
Modified Files:
gdk/gdk.h
gdk/gdk_bbp.c
gdk/gdk_mosaic.c
monetdb5/modules/mosaic/mosaic.c
monetdb5/modules/mosaic/mosaic.h
Branch: mosaic
Log Message:
MOSdecompress returns a view that shares the mosaic heap of its compressed
parent.
diffs (181 lines):
diff --git a/gdk/gdk.h b/gdk/gdk.h
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -2575,10 +2575,13 @@ gdk_export void VIEWbounds(BAT *b, BAT *
#define isVIEW(x) \
(assert((x)->batCacheid > 0), \
((x)->theap.parentid || \
- ((x)->tvheap && (x)->tvheap->parentid != (x)->batCacheid)))
+ ((x)->tvheap && (x)->tvheap->parentid != (x)->batCacheid) || \
+ ((x)->tmosaic && (x)->tmosaic->parentid != (x)->batCacheid)))
#define VIEWtparent(x) ((x)->theap.parentid)
#define VIEWvtparent(x) ((x)->tvheap == NULL || (x)->tvheap->parentid
== (x)->batCacheid ? 0 : (x)->tvheap->parentid)
+// TODO check if this part of the check "(x)->tmosaic->parentid ==
(x)->batCacheid" is necessary.
+#define VIEWmosaictparent(x) ((x)->tmosaic == NULL || (x)->tmosaic->parentid
== (x)->batCacheid ? 0 : (x)->tmosaic->parentid)
/*
* @+ BAT Iterators
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -1450,6 +1450,7 @@ BBPexit(void)
* to locks) do it */
bat tp = VIEWtparent(b);
bat vtp = VIEWvtparent(b);
+ bat mosaictp =
VIEWmosaictparent(b);
if (tp) {
BBP_desc(tp)->batSharecnt--;
--BBP_lrefs(tp);
@@ -1458,6 +1459,10 @@ BBPexit(void)
BBP_desc(vtp)->batSharecnt--;
--BBP_lrefs(vtp);
}
+ if (mosaictp) {
+
BBP_desc(mosaictp)->batSharecnt--;
+ --BBP_lrefs(mosaictp);
+ }
VIEWdestroy(b);
} else {
BATfree(b);
diff --git a/gdk/gdk_mosaic.c b/gdk/gdk_mosaic.c
--- a/gdk/gdk_mosaic.c
+++ b/gdk/gdk_mosaic.c
@@ -109,7 +109,10 @@ void
MOSdestroy(BAT *bn)
{ Heap *h;
- if( bn && bn->tmosaic && !VIEWtparent(bn)){
+ // Only destoy the mosaic heap of the BAT if it is not sharing the
mosaic heap of some parent BAT.
+ // TODO: Check if !VIEWtparent(bn) is still necessary given
VIEWmosaictparent.
+ // TODO: Check if this is correct.
+ if( bn && bn->tmosaic && !VIEWtparent(bn) && !VIEWmosaictparent(bn)){
h= bn->tmosaic;
bn->tmosaic = NULL;
if( HEAPdelete(h, BBP_physical(bn->batCacheid), "mosaic"))
diff --git a/monetdb5/modules/mosaic/mosaic.c b/monetdb5/modules/mosaic/mosaic.c
--- a/monetdb5/modules/mosaic/mosaic.c
+++ b/monetdb5/modules/mosaic/mosaic.c
@@ -32,8 +32,8 @@ str MOScompressInternal(Client cntxt, ba
static void
MOSinit(MOStask task, BAT *b){
char *base;
- if( isVIEW(b))
- b= BATdescriptor(VIEWtparent(b));
+ if( VIEWmosaictparent(b) != 0)
+ b= BATdescriptor(VIEWmosaictparent(b));
assert(b);
assert( b->tmosaic);
base = b->tmosaic->base;
@@ -371,6 +371,8 @@ MOScompressInternal(Client cntxt, bat *b
BBPunfix(bsrc->batCacheid);
throw(MAL,"mosaic.compress", "heap construction failes");
}
+
+ assert(bsrc->tmosaic->parentid == *bid);
// initialize the non-compressed read pointer
task->src = Tloc(bsrc, 0);
@@ -566,9 +568,9 @@ MOScompress(Client cntxt, MalBlkPtr mb,
// recreate the uncompressed heap from its mosaic version
str
-MOSdecompressInternal(Client cntxt, bat *bid)
+MOSdecompressInternal(Client cntxt, bat *ret, bat *bid)
{
- BAT *bsrc;
+ BAT *bsrc, * res;
MOStask task;
str msg;
int error;
@@ -615,8 +617,34 @@ MOSdecompressInternal(Client cntxt, bat
throw(MAL, "mosaic.decompress", "Can not claim server");
}
+ BBPshare(bsrc->tmosaic->parentid);
+
+ res = COLnew(0, bsrc->ttype, bsrc->batCapacity, TRANSIENT);
+ BATsetcount(res, bsrc->batCount);
+ res->tmosaic = bsrc->tmosaic;
+
+ // TODO: We should also compress the string heap itself somehow.
+ // For now we just share the string heap of the original compressed bat.
+ if (bsrc->tvheap) {
+ BBPshare(bsrc->tvheap->parentid);
+ res->tvheap = bsrc->tvheap;
+ }
+
+ res->tunique = bsrc->tunique;
+ res->tkey = bsrc->tkey;
+ res->tsorted = bsrc->tsorted;
+ res->trevsorted = bsrc->trevsorted;
+ res->tseqbase = oid_nil;
+ res->tnonil = bsrc->tnonil;
+ res->tnil = bsrc->tnil;
+
+ *ret = res->batCacheid;
+
MOSinit(task,bsrc);
- task->src = Tloc(bsrc, 0);
+
+ task->bsrc = res;
+ task->src = Tloc(res, 0);
+
task->timer = GDKusec();
while(task->blk){
@@ -694,11 +722,10 @@ MOSdecompressInternal(Client cntxt, bat
// remove the compressed mirror
GDKfree(task);
// continue with all work
- // TODO Check if the heap structures are all set to dirty
- bsrc->batDirtydesc = true;
- MOSdestroy(bsrc);
- BATsettrivprop(bsrc);
- BBPunfix(bsrc->batCacheid);
+
+ // MOSdestroy(bsrc); NOTE: Do NOT destroy the mosaic index of the
parent. Otherwise sharing doesn't make sense
+ BATsettrivprop(bsrc); // TODO: What's the purpose of this statement?
+ // BBPunfix(bsrc->batCacheid);
MCexitMaintenance(cntxt);
return MAL_SUCCEED;
@@ -717,14 +744,15 @@ MOSdecompress(Client cntxt, MalBlkPtr mb
if ((b = BATdescriptor(*bid)) == NULL)
throw(MAL, "mosaic.decompress", INTERNAL_BAT_ACCESS);
BBPkeepref(*ret = b->batCacheid);
- return MOSdecompressInternal(cntxt, getArgReference_bat(stk,pci,1));
+ // TODO use bid instead of getArgReference_bat(stk,pci,1)
+ return MOSdecompressInternal(cntxt, ret,
getArgReference_bat(stk,pci,1));
}
str
MOSdecompressStorage(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
{
(void) mb;
- return MOSdecompressInternal(cntxt, getArgReference_bat(stk,pci,1));
+ return MOSdecompressInternal(cntxt, getArgReference_bat(stk,pci,1),
getArgReference_bat(stk,pci,1));
}
// The remainders is cloned from the generator code base
@@ -1504,7 +1532,7 @@ MOSanalyseReport(Client cntxt, BAT *b, B
pat[i].xf= task->ratio;
pat[i].clk2 = GDKms();
- MOSdecompressInternal(cntxt, &bid);
+ MOSdecompressInternal(cntxt, &bid, &bid);
pat[i].clk2 = GDKms()- pat[i].clk2;
diff --git a/monetdb5/modules/mosaic/mosaic.h b/monetdb5/modules/mosaic/mosaic.h
--- a/monetdb5/modules/mosaic/mosaic.h
+++ b/monetdb5/modules/mosaic/mosaic.h
@@ -186,7 +186,7 @@ mal_export char *MOSfiltername[];
mal_export BUN MOSblocklimit;
mal_export str MOScompress(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr
pci);
mal_export str MOSdecompress(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
-mal_export str MOSdecompressInternal(Client cntxt, bat *bid);
+mal_export str MOSdecompressInternal(Client cntxt, bat *ret, bat *bid);
mal_export str MOSdecompressStorage(Client cntxt, MalBlkPtr mb, MalStkPtr stk,
InstrPtr pci);
mal_export str MOScompressInternal(Client cntxt, bat *bid, MOStask task, bool
debug);
mal_export str MOSanalyse(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr
pci);
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list