Changeset: 03a7b8c1c6e6 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=03a7b8c1c6e6
Modified Files:
monetdb5/modules/mal/bbp.c
monetdb5/modules/mal/bbp.h
monetdb5/modules/mal/bbp.mal
Branch: default
Log Message:
Remove experimental code
diffs (262 lines):
diff --git a/monetdb5/modules/mal/bbp.c b/monetdb5/modules/mal/bbp.c
--- a/monetdb5/modules/mal/bbp.c
+++ b/monetdb5/modules/mal/bbp.c
@@ -505,221 +505,3 @@ str CMDbbp(bat *ID, bat *NS, bat *HT, ba
return MAL_SUCCEED;
}
-/*
- * Compression and decompression are handled explicity. A compressed BAT is
- * recognized by its file extension on the heap name.
- * Compression of heaps can be useful to reduce the diskspace and as
preparation
- * for shipping data around. We keep the truncated file around for consistency
- * of the database structures.
- */
-
-static void
-CMDtruncateheap(Heap *h,str fnme)
-{
- FILE *f;
- char buf[PATHLENGTH];
- if (h == 0 || h->filename == 0 || h->storage != STORE_MMAP)
- return;
- /* reduce disk footprint */
- snprintf(buf, PATHLENGTH, "%s/%s.%s", BATDIR, fnme,
(strrchr(h->filename,'.')? strrchr(h->filename,'.')+1:""));
- if ((f = fopen(buf, "w")) == NULL) {
- IODEBUG mnstr_printf(GDKstdout, "#failed to truncate: %s\n",
- strerror(errno));
- } else {
- fclose(f);
- }
- IODEBUG mnstr_printf(GDKstdout, "#truncate %s file\n", fnme);
-}
-
-static str
-CMDcompressheap(Heap *h, str fnme)
-{
-#ifdef HAVE_LIBZ
- stream *fp;
- char buf[PATHLENGTH];
- char buf2[PATHLENGTH];
-
- if ( h && h->filename && h->base && h->storage == STORE_MMAP){
-
snprintf(buf2,PATHLENGTH,"%s.%s",fnme,(strrchr(h->filename,'.')?
strrchr(h->filename,'.')+1:""));
- GDKfilepath(buf, BATDIR, buf2, "gz");
- fp = open_gzwstream(buf);
- if ( fp ) {
- if ( (ssize_t) h->size !=
mnstr_write(fp,(void*)h->base,1,h->size) ){
- close_stream(fp);
- throw(MAL,"bbp.compress","compress write
error");
- }
- IODEBUG mnstr_printf(GDKstdout,"#compress %s size "
SZFMT" is now compressed\n", buf,h->size);
- close_stream(fp);
- }
- }
-#else
- (void) h;
- (void) fnme;
-#endif
- return MAL_SUCCEED;
-}
-
-static int
-CMDdecompressheap(Heap *h, Heap *hn, str fnme)
-{
-#ifdef HAVE_LIBZ
- stream *fp;
- char buf[PATHLENGTH];
- char buf2[PATHLENGTH];
-
- if ( !h || !hn)
- return 0;
-
- if ( h->storage != STORE_MMAP || h->filename == 0)
- return -9;
-
- snprintf(buf2,PATHLENGTH,"%s.%s",fnme,(strrchr(h->filename,'.')?
strrchr(h->filename,'.')+1:""));
- GDKfilepath(buf, BATDIR, buf2, "gz");
- fp = open_gzrstream(buf);
- if ( fp && !mnstr_errnr(fp)){
- if ( HEAPextend(hn,h->size,0) < 0)
- return -999;
- /* skip header */
- if ((ssize_t) h->size != mnstr_read(fp, (void*) hn->base,1,
h->size))
- return -999;
- hn->free = h->free;
- if (h->parentid)
- BBPkeepref( h->parentid);
- hn->parentid = h->parentid;
- hn->newstorage = h->newstorage;
- hn->hashash = h->hashash;
- assert(h->copied == 0);
- IODEBUG mnstr_printf(GDKstdout,"#decompress %s size " SZFMT"
\n", buf, h->size);
- close_stream(fp);
- return 1;
- }
-#else
- (void) h;
- (void) hn;
- (void) fnme;
-#endif
- return 0;
-}
-
-str
-CMDbbpcompress(int *ret, int *bid, str *fnme)
-{
- BAT *b;
- str msg;
-
- b = (BAT *) BATdescriptor(*bid);
- if (b == 0)
- throw(MAL, "bbp.compress", INTERNAL_BAT_ACCESS);
- if ( BATcount(b) ){
- IODEBUG mnstr_printf(GDKstdout,"#compress BAT %d %s %s \n",
*bid, BBP_physical(*bid), *fnme);
- if ( (msg = CMDcompressheap(&b->H->heap, *fnme)) )
- return msg;
- if ( (msg = CMDcompressheap(b->H->vheap, *fnme)) )
- return msg;
- if ( (msg = CMDcompressheap(&b->T->heap, *fnme)) )
- return msg;
- if ( (msg = CMDcompressheap(b->T->vheap, *fnme)) )
- return msg;
- }
- BBPkeepref(*ret = b->batCacheid);
- return MAL_SUCCEED;
-}
-str
-CMDbbpdecompress(int *ret, int *bid, str *fnme)
-{
- BAT *b, *bn;
- int decomp=0;
-
- b = (BAT *) BATdescriptor(*bid);
- if (b == 0)
- throw(MAL, "bbp.decompress", INTERNAL_BAT_ACCESS);
- if (BATcount(b) ){
- assert(b->htype == TYPE_void);
- bn = BATnew(TYPE_void,b->ttype,0);
- /* copy the properties of the source */
- bn->hsorted = b->hsorted;
- bn->hrevsorted = b->hrevsorted;
- bn->tsorted = b->tsorted;
- bn->trevsorted = b->trevsorted;
- bn->hkey = b->hkey;
- bn->tkey = b->tkey;
- bn->H->nonil = b->H->nonil;
- bn->T->nonil = b->T->nonil;
- bn->H->dense = b->H->dense;
- bn->T->dense = b->T->dense;
- bn->hseqbase = b->hseqbase;
- bn->tseqbase = b->tseqbase;
-
- /* use the stored width for varsized atoms */
- bn->H->width = b->H->width;
- bn->H->shift = b->H->shift;
- bn->T->width = b->T->width;
- bn->T->shift = b->T->shift;
-
- if (b->H->type)
- decomp +=
CMDdecompressheap(&b->H->heap,&bn->H->heap,*fnme);
- if (b->H->type)
- decomp +=
CMDdecompressheap(b->H->vheap,bn->H->vheap,*fnme);
- if (b->T->type)
- decomp +=
CMDdecompressheap(&b->T->heap,&bn->T->heap,*fnme);
- if (b->T->type)
- decomp +=
CMDdecompressheap(b->T->vheap,bn->T->vheap,*fnme);
- IODEBUG mnstr_printf(GDKstdout,"#decompressed BAT %d %s decomp
%d \n", *bid, BBP_physical(*bid),decomp);
- if (decomp < -800) {
- BBPreleaseref(bn->batCacheid);
- BBPreleaseref(b->batCacheid);
- throw(MAL,"bbp.decompress",MAL_MALLOC_FAIL);
- }
- if ( decomp <= 0){
- BBPreleaseref(bn->batCacheid);
- BBPkeepref(*ret = b->batCacheid);
- return MAL_SUCCEED;
- }
- BATsetcapacity(bn, BATcount(b));
- BATsetcount(bn, BATcount(b));
- BATsetaccess(bn, b->batRestricted);
- BBPreleaseref(b->batCacheid);
- BBPkeepref(*ret = bn->batCacheid);
- return MAL_SUCCEED;
- }
- BBPkeepref(*ret = b->batCacheid);
- return MAL_SUCCEED;
-}
-
-str
-CMDbbptruncate(int *ret, int *bid, str *fnme)
-{
- BAT *b;
-
- b = (BAT *) BATdescriptor(*bid);
- if (b == 0)
- throw(MAL, "bbp.truncate", INTERNAL_BAT_ACCESS);
- IODEBUG mnstr_printf(GDKstdout,"#truncate BAT %d %s \n", *bid,
BBP_physical(*bid));
- CMDtruncateheap(&b->H->heap,*fnme);
- CMDtruncateheap(b->H->vheap,*fnme);
- CMDtruncateheap(&b->T->heap,*fnme);
- CMDtruncateheap(b->T->vheap,*fnme);
- HASHdestroy(b);
- BBPkeepref(*ret = *bid);
- return MAL_SUCCEED;
-}
-
-str
-CMDbbpexpand(int *ret, int *bid, str *fnme)
-{
- BAT *b;
- int decomp = 0;
-
- b = (BAT *) BATdescriptor(*bid);
- if (b == 0)
- throw(MAL, "bbp.expand", INTERNAL_BAT_ACCESS);
- decomp += CMDdecompressheap(&b->H->heap,&b->H->heap,*fnme);
- decomp += CMDdecompressheap(b->H->vheap,b->H->vheap,*fnme);
- decomp += CMDdecompressheap(&b->T->heap,&b->T->heap,*fnme);
- decomp += CMDdecompressheap(b->T->vheap,b->T->vheap,*fnme);
- if (decomp < 0)
- throw(MAL,"bbp.expand",MAL_MALLOC_FAIL);
- BBPkeepref(*ret = *bid);
- return MAL_SUCCEED;
-}
-
diff --git a/monetdb5/modules/mal/bbp.h b/monetdb5/modules/mal/bbp.h
--- a/monetdb5/modules/mal/bbp.h
+++ b/monetdb5/modules/mal/bbp.h
@@ -67,9 +67,5 @@ bbp_export str CMDbbpLRefCount(int *ret)
bbp_export str CMDbbpgetIndex(int *res, int *bid);
bbp_export str CMDgetBATrefcnt(int *res, int *bid);
bbp_export str CMDgetBATlrefcnt(int *res, int *bid);
-bbp_export str CMDbbpcompress(int *ret, int *bid, str *fnme);
-bbp_export str CMDbbpdecompress(int *ret, int *bid, str *fnme);
-bbp_export str CMDbbptruncate(int *ret, int *bid, str *fnme);
-bbp_export str CMDbbpexpand(int *ret, int *bid, str *fnme);
bbp_export str CMDbbp(bat *ID, bat *NS, bat *HT, bat *TT, bat *CNT, bat
*REFCNT, bat *LREFCNT, bat *LOCATION, bat *HEAT, bat *DIRTY, bat *STATUS, bat
*KIND);
#endif /* _BBP_H_*/
diff --git a/monetdb5/modules/mal/bbp.mal b/monetdb5/modules/mal/bbp.mal
--- a/monetdb5/modules/mal/bbp.mal
+++ b/monetdb5/modules/mal/bbp.mal
@@ -77,20 +77,3 @@ comment "Estimate the amount of disk spa
command getPageSize():int
address CMDgetPageSize
comment "Obtain the memory page size";
-
-command compress(b:bat[:oid,:any_2],fnme:str):bat[:oid,:any_2]
-address CMDbbpcompress
-comment "Generate a compressed image of the BAT on a specific file";
-
-command decompress(b:bat[:oid,:any_2],fnme:str):bat[:oid,:any_2]
-address CMDbbpdecompress
-comment "Obtain a temporary decompressed image of a BAT from a specific file";
-
-command truncate(b:bat[:oid,:any_2],fnme:str):bat[:oid,:any_2]
-address CMDbbptruncate
-comment "Truncate the heaps if a compressed image exist";
-
-command expand(b:bat[:oid,:any_2],fnme:str):bat[:oid,:any_2]
-address CMDbbpexpand
-comment "Expand a compressed image of BAT heaps";
-
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list