Changeset: 65544fc482d0 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=65544fc482d0
Modified Files:
        monetdb5/extras/crackers/crackers_core_unordered.mx
        monetdb5/extras/crackers/crackers_select_ops.mx
        monetdb5/extras/crackers/crackers_selectholpl_ops.mx
Branch: holindex
Log Message:

Implement single-threaded out-of-place two-way cracking for the first query 
(instead of BATcopy + multi-threaded crack).


diffs (155 lines):

diff --git a/monetdb5/extras/crackers/crackers_core_unordered.mx 
b/monetdb5/extras/crackers/crackers_core_unordered.mx
--- a/monetdb5/extras/crackers/crackers_core_unordered.mx
+++ b/monetdb5/extras/crackers/crackers_core_unordered.mx
@@ -111,6 +111,7 @@ crackers_export str CRKparallelscan_@1 (
 @
 @= crackInTwoUnorderedPieces_decl
 str CRKcrackUnorderedZero_@2_@1( BAT *b, @1 mval, oid first, oid last, oid 
*pos, int nthreads, int vector_elements);
+str CRKcrackUnorderedTwoCopy_@2_@1( BAT *b, @1 pivot, BUN first, BUN last, BUN 
*pos, BAT *bc);
 str CRKparallelscan_@2_@1( BAT *b, BAT *ob, @1 mval, oid first, oid last, int 
nthreads);
 str CRKparallelcopy_@2_@1( BAT *b, BAT *ob, oid first, oid last, int nthreads);
 @
@@ -1877,7 +1878,32 @@ CRKparallelcopy_@2_@1( BAT *b, BAT *ob, 
 
        return msg;
 }
+str
+CRKcrackUnorderedTwoCopy_@2_@1( BAT *b, @1 pivot, BUN first, BUN last, BUN 
*pos, BAT *bc)
+{
+        @1  *src_t_basebat = (@1*)Tloc(b, BUNfirst(b));
+        @1  *src_t_crackerbat = (@1*)Tloc(bc, BUNfirst(bc));
+        oid *src_h_crackerbat = (oid *) Hloc(bc,BUNfirst(bc));
+        oid hf = b->hseqbase + first;
+        oid hl =  b->hseqbase + last;
+        BUN i, j[2] = {first, last}, kt[2] = {1,-1}, kh[2] = {-1,1};
+        oid h[2] = {hl, hf};
 
+        for(i = first; i <= last; i++)
+        {
+                bit x = src_t_basebat[i] @8 pivot;
+                src_t_crackerbat[j[x]] = src_t_basebat[i];
+                src_h_crackerbat[j[x]] = h[x];
+                j[x] += kt[x];
+                h[x] += kh[x];
+        }
+
+        assert(j[0] > first);
+
+        *pos = j[0];
+
+        return MAL_SUCCEED;
+}
 @
 @= crackInThreeUnorderedPieces_impl
 str
diff --git a/monetdb5/extras/crackers/crackers_select_ops.mx 
b/monetdb5/extras/crackers/crackers_select_ops.mx
--- a/monetdb5/extras/crackers/crackers_select_ops.mx
+++ b/monetdb5/extras/crackers/crackers_select_ops.mx
@@ -300,7 +300,22 @@ CRKparallelscanselect_@1_MT(int *vid, in
                gapH = -1;
                /*vh--;*/
        }
+@
+@= crkTwoRTreeCopy
+        /*CRACK in two pieces cl2-ch2 using <incHgh bound*/
+        if (*inclusiveHgh == TRUE)
+                CRKcrackUnorderedTwoCopy@2_LE_@1(bo,*hgh, cl2, ch2,&vh, b);
+        else
+                CRKcrackUnorderedTwoCopy@2_RE_@1(bo,*hgh, cl2, ch2,&vh, b);
 
+        if (vh < cl2)
+                /*then the left piece is empty*/
+                gapH = -1;
+        if (vh > ch2){
+                /*then the right piece is empty*/
+                gapH = -1;
+                /*vh--;*/
+        }
 @
 @= CreateResult
 createView:
@@ -964,6 +979,10 @@ CRKRangeLeftNilTree_@1(int *vid, int *bi
                BATmode(b,PERSISTENT);
                bo->batRestricted= BAT_READ;
 
+               //CRKparallelcopy_LE_@1(b, bo, (BUN) 0, BATcount(bo)-1, 
nthreads);
+               //BATkey(BATmirror(b),FALSE);
+                //BATsetcount(b,BATcount(bo));
+
                m = newCrackerIndex_@1(*bid,b->batCacheid);
 
                if ((c = BATdescriptor(CrackerIndex[m].cid)) == NULL)
@@ -972,6 +991,7 @@ CRKRangeLeftNilTree_@1(int *vid, int *bi
                cl2 = BUNfirst(b);
                ch2 = BUNlast(b)-(oid)1;
                @:crkTwoRTree(@1)@
+               //@:crkTwoRTreeCopy(@1)@
                if (gapH>0) addCrackerIndex_@1(m,hgh,HBound,vh,c);
                vl = BUNfirst(b);
                pieces=pieces+2;
diff --git a/monetdb5/extras/crackers/crackers_selectholpl_ops.mx 
b/monetdb5/extras/crackers/crackers_selectholpl_ops.mx
--- a/monetdb5/extras/crackers/crackers_selectholpl_ops.mx
+++ b/monetdb5/extras/crackers/crackers_selectholpl_ops.mx
@@ -449,6 +449,22 @@ CRKrandomholpl_@1_MT(int *bid, bit *incl
                /*vh--;*/
        }
 @
+@= crkTwoRTreeCopy
+        /*CRACK in two pieces cl2-ch2 using <incHgh bound*/
+        if (*inclusiveHgh == TRUE)
+                CRKcrackUnorderedTwoCopy@2_LE_@1(bo,*hgh, cl2, ch2,&vh, b);
+        else
+                CRKcrackUnorderedTwoCopy@2_RE_@1(bo,*hgh, cl2, ch2,&vh, b);
+
+        if (vh < cl2)
+                /*then the left piece is empty*/
+                gapH = -1;
+        if (vh > ch2){
+                /*then the right piece is empty*/
+                gapH = -1;
+                /*vh--;*/
+        }
+@
 @= CreateResult
 createView:
        assert(0);
@@ -1412,20 +1428,24 @@ CRKRangeLeftNilTree_@1(int *vid, int *bi
                }
 
                gettimeofday(&tv0_copy, 0);
-               b=BATnew(TYPE_oid, bo->ttype,BATcount(bo));
+                b = BATcopy(bo, bo->htype, bo->ttype, TRUE);
+                if ( bo->htype == TYPE_void)
+                        b = BATmaterializeh(b);
+               //b=BATnew(TYPE_oid, bo->ttype,BATcount(bo));
+               gettimeofday(&tv1_copy, 0);
+               fprintf(ofp_copy,"%d\n",(int)dt(tv0_copy,tv1_copy)*1000000);
+
                b->hsorted = FALSE;
                b->tsorted = FALSE;
                b->hdense = FALSE;
                b->tdense = FALSE;
-               CRKparallelcopy_LE_@1(b, bo, (BUN) 0, BATcount(bo)-1, nthreads);
-               BATkey(BATmirror(b),FALSE);
-                BATsetcount(b,BATcount(bo));
                b->batRestricted= BAT_READ;
                BATmode(b,PERSISTENT);
                bo->batRestricted= BAT_READ;
-               BBPincref(*bid, TRUE);
-               gettimeofday(&tv1_copy, 0);
-               fprintf(ofp_copy,"%d\n",(int)dt(tv0_copy,tv1_copy)*1000000);
+
+               //CRKparallelcopy_LE_@1(b, bo, (BUN) 0, BATcount(bo)-1, 
nthreads);
+               //BATkey(BATmirror(b),FALSE);
+                //BATsetcount(b,BATcount(bo));
 
                m = newCrackerIndex_@1(*bid,b->batCacheid);
 
@@ -1435,6 +1455,7 @@ CRKRangeLeftNilTree_@1(int *vid, int *bi
                cl2 = BUNfirst(b);
                ch2 = BUNlast(b)-(oid)1;
                @:crkTwoRTree(@1)@
+               //@:crkTwoRTreeCopy(@1)@
                if (gapH>0)
                {
                        addCrackerIndex_@1(m,hgh,HBound,vh,c);
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to