Changeset: b2ed58c93d3b for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=b2ed58c93d3b
Added Files:
        monetdb5/modules/mal/Tests/mosaic_none_qry.mal
        monetdb5/modules/mal/Tests/mosaic_rle_qry.mal
Modified Files:
        monetdb5/modules/mal/Makefile.ag
        monetdb5/modules/mal/Tests/All
        monetdb5/modules/mal/mosaic.c
        monetdb5/modules/mal/mosaic_hdr.c
        monetdb5/modules/mal/mosaic_none.c
        monetdb5/modules/mal/mosaic_rle.c
Branch: mosaic
Log Message:

Subselect on int none/rle works


diffs (truncated from 876 to 300 lines):

diff --git a/monetdb5/modules/mal/Makefile.ag b/monetdb5/modules/mal/Makefile.ag
--- a/monetdb5/modules/mal/Makefile.ag
+++ b/monetdb5/modules/mal/Makefile.ag
@@ -86,6 +86,7 @@ EXTRA_DIST = batExtensions.mal iterator.
        profiler.mal recycle.mal remote.mal sabaoth.mal trader.mal \
        transaction.mal txtsim.mal tablet.mal tablet.h sample.mal json_util.mal 
\
        mal_mapi.mal mat.mal tokenizer.mal calc.mal \
-       batcalc.mal batmtime.mal querylog.mal sysmon.mal mosaic.mal
+       batcalc.mal batmtime.mal querylog.mal sysmon.mal mosaic.mal \
+       mosaic_none.c mosaic_rle.c
 
 EXTRA_DIST_DIR = Tests
diff --git a/monetdb5/modules/mal/Tests/All b/monetdb5/modules/mal/Tests/All
--- a/monetdb5/modules/mal/Tests/All
+++ b/monetdb5/modules/mal/Tests/All
@@ -72,6 +72,7 @@ mosaic_rle
 mosaic_mix
 
 mosaic_none_qry
+mosaic_rle_qry
 #HAVE_RAPTOR?rdf
 
 # might show different output if openssl is compiled without full sha2
diff --git a/monetdb5/modules/mal/Tests/mosaic_none_qry.mal 
b/monetdb5/modules/mal/Tests/mosaic_none_qry.mal
new file mode 100644
--- /dev/null
+++ b/monetdb5/modules/mal/Tests/mosaic_none_qry.mal
@@ -0,0 +1,52 @@
+# Compression of noncompressable column
+
+
+b:= bat.new(:oid,:int);
+bat.append(b,50);
+bat.append(b,19531015);
+bat.append(b,9);
+b:= bat.append(b,b);
+
+io.print(b);
+x:= mosaic.compress(b);
+#mosaic.dump(x);
+s:= algebra.subselect(b,0,50,false,false,false);
+io.print(s);
+xs:= mosaic.subselect(x,0,50,false,false,false);
+io.print(xs);
+
+s:= algebra.subselect(b,0,50,false,true,false);
+io.print(s);
+xs:= mosaic.subselect(x,0,50,false,true,false);
+io.print(xs);
+
+s:= algebra.subselect(b,0,50,true,false,false);
+io.print(s);
+xs:= mosaic.subselect(x,0,50,true,false,false);
+io.print(xs);
+
+s:= algebra.subselect(b,0,50,true,true,false);
+io.print(s);
+xs:= mosaic.subselect(x,0,50,true,true,false);
+io.print(xs);
+
+s:= algebra.subselect(b,nil:int,50,false,false,false);
+io.print(s);
+xs:= mosaic.subselect(x,nil:int,50,false,false,false);
+io.print(xs);
+
+s:= algebra.subselect(b,50,nil:int,false,false,false);
+io.print(s);
+xs:= mosaic.subselect(x,50,nil:int,false,false,false);
+io.print(xs);
+
+s:= algebra.subselect(b,nil:int,nil:int,false,false,false);
+io.print(s);
+xs:= mosaic.subselect(x,nil:int,nil:int,false,false,false);
+io.print(xs);
+
+s:= algebra.subselect(b,nil:int,nil:int,false,false,true);
+io.print(s);
+xs:= mosaic.subselect(x,nil:int,nil:int,false,false,true);
+io.print(xs);
+
diff --git a/monetdb5/modules/mal/Tests/mosaic_rle_qry.mal 
b/monetdb5/modules/mal/Tests/mosaic_rle_qry.mal
new file mode 100644
--- /dev/null
+++ b/monetdb5/modules/mal/Tests/mosaic_rle_qry.mal
@@ -0,0 +1,54 @@
+# Compression of noncompressable column
+
+
+b:= bat.new(:oid,:int);
+bat.append(b,50);
+bat.append(b,50);
+bat.append(b,9);
+bat.append(b,9);
+bat.append(b,9);
+b:= bat.append(b,b);
+
+io.print(b);
+x:= mosaic.compress(b);
+#mosaic.dump(x);
+s:= algebra.subselect(b,0,50,false,false,false);
+io.print(s);
+xs:= mosaic.subselect(x,0,50,false,false,false);
+io.print(xs);
+
+s:= algebra.subselect(b,0,50,false,true,false);
+io.print(s);
+xs:= mosaic.subselect(x,0,50,false,true,false);
+io.print(xs);
+
+s:= algebra.subselect(b,0,50,true,false,false);
+io.print(s);
+xs:= mosaic.subselect(x,0,50,true,false,false);
+io.print(xs);
+
+s:= algebra.subselect(b,0,50,true,true,false);
+io.print(s);
+xs:= mosaic.subselect(x,0,50,true,true,false);
+io.print(xs);
+
+s:= algebra.subselect(b,nil:int,50,false,false,false);
+io.print(s);
+xs:= mosaic.subselect(x,nil:int,50,false,false,false);
+io.print(xs);
+
+s:= algebra.subselect(b,50,nil:int,false,false,false);
+io.print(s);
+xs:= mosaic.subselect(x,50,nil:int,false,false,false);
+io.print(xs);
+
+s:= algebra.subselect(b,nil:int,nil:int,false,false,false);
+io.print(s);
+xs:= mosaic.subselect(x,nil:int,nil:int,false,false,false);
+io.print(xs);
+
+s:= algebra.subselect(b,nil:int,nil:int,false,false,true);
+io.print(s);
+xs:= mosaic.subselect(x,nil:int,nil:int,false,false,true);
+io.print(xs);
+
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
@@ -81,9 +81,14 @@ typedef struct MOSTASK{
        MosaicHdr hdr;  // start of the destination heap
        MosaicBlk blk;  // current block header
        char *dst;              // write pointer into current compressed blocks
+
        BUN     elm;            // elements left to compress
        char *src;              // read pointer into source
 
+       oid *lb, *rb;   // Collected oids from operations
+       oid *cl;                // candidate admin
+       lng     n;                      // element count in candidate list
+
        // collect compression statistics for the particular task
        lng time[MOSAIC_METHODS];
        lng wins[MOSAIC_METHODS];       
@@ -100,6 +105,27 @@ typedef struct MOSINDEX{
 
 /* Run through a column to produce a compressed version */
 
+#ifdef _MSC_VER
+#define nextafter   _nextafter
+float nextafterf(float x, float y);
+#endif
+
+#define PREVVALUEbte(x) ((x) - 1)
+#define PREVVALUEsht(x) ((x) - 1)
+#define PREVVALUEint(x) ((x) - 1)
+#define PREVVALUElng(x) ((x) - 1)
+#define PREVVALUEoid(x) ((x) - 1)
+#define PREVVALUEflt(x) nextafterf((x), -GDK_flt_max)
+#define PREVVALUEdbl(x) nextafter((x), -GDK_dbl_max)
+
+#define NEXTVALUEbte(x) ((x) + 1)
+#define NEXTVALUEsht(x) ((x) + 1)
+#define NEXTVALUEint(x) ((x) + 1)
+#define NEXTVALUElng(x) ((x) + 1)
+#define NEXTVALUEoid(x) ((x) + 1)
+#define NEXTVALUEflt(x) nextafterf((x), GDK_flt_max)
+#define NEXTVALUEdbl(x) nextafter((x), GDK_dbl_max)
+
 /* simple include the details of the hardwired compressors */
 #include "mosaic_hdr.c"
 #include "mosaic_none.c"
@@ -507,10 +533,6 @@ float nextafterf(float x, float y);
  * The actual decompression should wait until we know that
  * the administration thru SQL layers works properly.
  */
-#define calculate_range(TPE, TPE2)                                     \
-       do {                                                            \
-       } while (0)
-
 str
 MOSsubselect(Client cntxt, MalBlkPtr mb, MalStkPtr stk, InstrPtr pci)
 {
@@ -518,12 +540,13 @@ MOSsubselect(Client cntxt, MalBlkPtr mb,
        void *low, *hgh;
        int *ret, *bid, *cid= 0;
        int i;
-       oid *cl = 0;
-       BAT *b, *bn= NULL, *cand = NULL;
+       BUN first =0, last = 0, cnt= 0;
+       BAT *b, *bn, *cand = NULL;
        str msg = MAL_SUCCEED;
        MOStask task;
 
        (void) cntxt;
+       (void) mb;
        ret = (int *) getArgReference(stk, pci, 0);
        bid = (int *) getArgReference(stk, pci, 1);
 
@@ -532,11 +555,12 @@ MOSsubselect(Client cntxt, MalBlkPtr mb,
                i = 3;
        } else
                i = 2;
-       low = (void *) getArgReference(stk, pci, i + 2);
-       hgh = (void *) getArgReference(stk, pci, i + 3);
-       li = (bit *) getArgReference(stk, pci, i + 4);
-       hi = (bit *) getArgReference(stk, pci, i + 5);
-       anti = (bit *) getArgReference(stk, pci, i + 6);
+       low = (void *) getArgReference(stk, pci, i);
+       hgh = (void *) getArgReference(stk, pci, i + 1);
+       li = (bit *) getArgReference(stk, pci, i + 2);
+       hi = (bit *) getArgReference(stk, pci, i + 3);
+       anti = (bit *) getArgReference(stk, pci, i + 4);
+       //
        // use default implementation if possible
        if( !isCompressed(*bid))
                return ALGsubselect1(ret,bid,low,hgh,li,hi,anti);
@@ -544,78 +568,85 @@ MOSsubselect(Client cntxt, MalBlkPtr mb,
        b= BATdescriptor(*bid);
        if( b == NULL)
                        throw(MAL, "mosaic.subselect",RUNTIME_OBJECT_MISSING);
+       // determine the elements in the compressed structure
+       last = b->T->heap.count;
 
+       task= (MOStask) GDKzalloc(sizeof(*task));
+       if( task == NULL){
+               BBPreleaseref(b->batCacheid);
+               throw(MAL, "mosaic.subselect", RUNTIME_OBJECT_MISSING);
+       }
+
+       // accumulator for the oids
+       bn = BATnew(TYPE_void, TYPE_oid, last, TRANSIENT);
+       if( bn == NULL){
+               BBPreleaseref(b->batCacheid);
+               throw(MAL, "mosaic.subselect", RUNTIME_OBJECT_MISSING);
+       }
+       task->lb = (oid*) Tloc(bn,BUNfirst(bn));
+
+       MOSinit(task,b);
+       // drag along the candidate list into the task descriptor
        if (cid) {
                cand = BATdescriptor(*cid);
-               if (cand == NULL)
+               if (cand == NULL){
+                       BBPreleaseref(b->batCacheid);
+                       BBPreleaseref(bn->batCacheid);
                        throw(MAL, "mosaic.subselect", RUNTIME_OBJECT_MISSING);
-               cl = (oid *) Tloc(cand, BUNfirst(cand));
-       }
-       (void) cl;
-       (void) hi;
-       (void) li;
-       (void) anti;
-       (void) mb;
-       // inject the de-decompression
-       task= (MOStask) GDKzalloc(sizeof(*task));
-       task->type = b->ttype;
-       task->elm =  b->T->heap.count;
-       task->dst = (void*) Tloc(b,BUNfirst(b));
-       task->blk = (MosaicBlk) task->dst;
-       task->dst += MosaicHdrSize;
-       task->blk = (MosaicBlk) task->dst;
-       MOSfindChunk(cntxt,task,0);
+               }
+               task->cl = (oid*) Tloc(cand, BUNfirst(cand));
+               task->n = BATcount(cand);
+               first = *(oid*) task->src;
+       } else 
+               first = 0;
 
-       // loop thru all the chunks and collect the results
-       while(task->blk )
+       // loop thru all the chunks and collect the partial results
+       if ( task->cl && task->n && (BUN) *task->cl > first)
+               first = (BUN)  *task->cl;
+       MOSfindChunk(cntxt,task,first);
+       while(task->blk && first < last ){
                switch(task->blk->tag){
                case MOSAIC_RLE:
+                       MOSsubselect_rle(cntxt,task,first,first + 
task->blk->cnt,low,hgh,li,hi,anti);
+                       first += task->blk->cnt;
                        MOSskip_rle(task);
                        break;
                case MOSAIC_NONE:
                default:
+                       MOSsubselect_none(cntxt,task,first,first + 
task->blk->cnt,low,hgh,li,hi,anti);
+                       first += task->blk->cnt;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to