Changeset: 48f3148b6b34 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=48f3148b6b34
Modified Files:
monetdb5/extras/crackers/crackers_selecthol_ops.mx
monetdb5/extras/crackers/crackers_selectholpl_ops.mx
Branch: holindex
Log Message:
Calculate sum in order to verify the results.
diffs (272 lines):
diff --git a/monetdb5/extras/crackers/crackers_selecthol_ops.mx
b/monetdb5/extras/crackers/crackers_selecthol_ops.mx
--- a/monetdb5/extras/crackers/crackers_selecthol_ops.mx
+++ b/monetdb5/extras/crackers/crackers_selecthol_ops.mx
@@ -282,8 +282,9 @@ createView:
@
@= RangeSelectBody
+ @1 *t0;
BAT *b,*c,*bo;
- BAT *view;
+ //BAT *view;
int m;
int *t;
int createIndex=0;
@@ -302,17 +303,21 @@ createView:
int gapL = 1;
int gapH = 1;
bit rippledDeletions = FALSE;
- struct Node *lowNode=NULL, *hghNode=NULL, *lowNodeNext=NULL, *temp;
+ struct Node *lowNode=NULL, *hghNode=NULL, *lowNodeNext=NULL, *temp,
*stopNode;
BUN idxFirst;
struct timeval tv0, tv1;
- double wt=0, ct=0;
+ double wt=0, ct=0,st=0;
bit copy=TRUE;
-
+ unsigned long long sum = 0;
int countBatElements=0;
int L1=0; /*Number of elements that can fit into L1 cache (size: 32KB)*/
-
/*FILE *ofp;
char outputFilename1[] =
"/export/scratch2/petraki/experiments_1st_paper/experiments/stochastic/idle_time_2/pieces_holistic.txt";*/
+ FrequencyNode* FN;
+ FrequencyNode *FrequencyStructA = getFrequencyStruct('A');
+ (void) tail;
+
+ gettimeofday(&tv0,0);
/*ofp = fopen(outputFilename1,"a");
if (ofp == NULL) {
@@ -321,16 +326,9 @@ createView:
}*/
-
- FrequencyNode* FN;
- FrequencyNode *FrequencyStructA = getFrequencyStruct('A');
-
-
if ((bo = BATdescriptor(*bid)) != NULL)
L1=32000/ATOMsize(bo->ttype);
-
- gettimeofday(&tv0,0);
MT_lock_set(&CRKIndexLock,"Cracker Index Lock");
@@ -399,7 +397,7 @@ createView:
gettimeofday(&tv1,0); ct+=dt(tv0,tv1); tv0=tv1;
fprintf(stderr,"Wait time: %9.6lf Selection time:
%9.6lf\n",wt,ct);
- goto createView;
+ goto tempcreateView;
}
else{
assert(0);
@@ -433,7 +431,7 @@ createView:
BBPincref(b->batCacheid,TRUE);
BBPunfix(bo->batCacheid);
- goto createView;
+ goto tempcreateView;
}
}
@@ -483,7 +481,7 @@ createView:
posh = BUNlast(b)-1;
@:crkThreeTree@5(@1,posl,posh,@5)@
- goto createView;
+ goto tempcreateView;
}
/* Take the index of the bat */
@@ -641,9 +639,81 @@ createView:
/*fprintf(ofp,"%d\n",FN->c);
fclose(ofp);*/
+ //gettimeofday(&tv1,0); ct+=dt(tv0,tv1); tv0=tv1;
+ //fprintf(stderr,"Wait time: %9.6lf Selection time: %9.6lf\n",wt,ct);
+ /*@:CreateResult()@*/
+
+ tempcreateView:;
+
+ t0 = (@1 *)Tloc(b, BUNfirst(b));
+ *vid = 0;
+
+ posh = BUNlast(b)-1;
+ idxFirst = BUNfirst(c);
+
+ lowNode = findNodeL_@1(*low, *inclusiveLow, CrackerIndex[m].Tree, c,
idxFirst, NULL);
+ if (lowNode == NULL){
+ lowNodeNext = NULL;
+ temp = CrackerIndex[m].Tree;
+ if (temp->deleted == FALSE)
+ lowNodeNext = temp;
+ while (temp->left != NULL){
+ temp = temp->left;
+ if (temp->deleted == FALSE)
+ lowNodeNext = temp;
+ }
+ vl = 0;
+ } else {
+ lowNodeNext = findNextPiece(lowNode);
+ vl = lowNode->indexPosition;
+ }
+
+ stopNode = findNodeH_@1(*hgh, *inclusiveHgh, CrackerIndex[m].Tree, c,
idxFirst, NULL);
+
gettimeofday(&tv1,0); ct+=dt(tv0,tv1); tv0=tv1;
- fprintf(stderr,"Wait time: %9.6lf Selection time: %9.6lf\n",wt,ct);
- @:CreateResult()@
+
+ while (1){
+ hghNode = (lowNode == NULL)? lowNodeNext :
findNextPiece(lowNode);
+ vh = hghNode? hghNode->indexPosition : posh;
+ while (vl<=vh){
+ if (t0[vl] >= *low && t0[vl] < *hgh){
+ sum += t0[vl];
+ (*vid)++;
+ }
+ vl++;
+ }
+ if (!hghNode) break;
+ if (hghNode == stopNode) break;
+ lowNode = hghNode;
+ vl = vh+1;
+ }
+ gettimeofday(&tv1,0); st+=dt(tv0,tv1); tv0=tv1;
+
+ // verify the result
+ if (!(sum == ((unsigned long long) *hgh - *low) * ((unsigned long long)
*hgh + *low - 1)/ 2)){
+ fprintf(stderr,"lo=%d, hi=%d, %llu, %llu\n",
+ (int) *low, (int) *hgh, (unsigned long long) sum,
+ (unsigned long long) (((unsigned long long) *hgh -
*low) * ((unsigned long long) *hgh + *low - 1)/ 2));
+ assert(0);
+ }
+
+ BBPunfix(b->batCacheid);
+ BBPunfix(c->batCacheid);
+
+ if(*isIdleQuery==FALSE)
+ fprintf(stderr,"wt=%9.6lf ct=%9.6lf st=%9.6lf lo=%d, hi=%d
sum=%llu\n",wt,ct,st,(int) *low, (int) *hgh,(unsigned long long) sum);
+
+ //fprintf(out,"%9.6lf %9.6lf %9.6lf\n",wt,ct,st);
+ //fclose(out);
+
+ if (createIndex==1)
+ {
+ MT_lock_unset(&CRKIndexLock,"Cracker Index Lock");
+ createIndex=0;
+ }
+ else
+ MT_lock_unset(&CrackerIndex[m].columnLock,"Lock Attribute");
+
return MAL_SUCCEED;
@
@= crackOperations
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
@@ -279,9 +279,10 @@ createView:
@
@= RangeSelectBody
-
+ @1 *t0;
+ unsigned long long sum = 0;
BAT *b,*c,*bo;
- BAT *view;
+ //BAT *view;
int m;
int *t;
int createIndex=0;
@@ -301,11 +302,11 @@ createView:
int gapL = 1;
int gapH = 1;
bit rippledDeletions = FALSE;
- struct Node *lowNode=NULL, *hghNode=NULL, *lowNodeNext=NULL, *temp;
+ struct Node *lowNode=NULL, *hghNode=NULL, *lowNodeNext=NULL, *temp,
*stopNode=NULL;
BUN idxFirst;
int firstRetry=0;
struct timeval tv0, tv1;
- double wt=0, ct=0;
+ double wt=0, ct=0, st=0;
bit copy=TRUE;
int countBatElements=0;
int L1=0; /*Number of elements that can fit into L1 cache (size:
32KB)*/
@@ -313,7 +314,7 @@ createView:
char outputFilename1[] =
"/export/scratch2/petraki/experiments_1st_paper/experiments/stochastic/idle_time_2/pieces_holistic.txt";*/
FrequencyNode* FN;
FrequencyNode *FrequencyStructA = getFrequencyStruct('A');
-
+ (void) tail;
gettimeofday(&tv0,0);
@@ -682,6 +683,9 @@ createView:
tempcreateView:;
+ t0 = (@1 *)Tloc(b, BUNfirst(b));
+ *vid = 0;
+
posh = BUNlast(b)-1;
idxFirst = BUNfirst(c);
@@ -705,23 +709,46 @@ createView:
lowNodeNext = findNextPiece(lowNode);
vl = lowNode->indexPosition;
}
- hghNode = lowNodeNext;
- vh = hghNode? hghNode->indexPosition : posh;
pthread_rwlock_unlock(&CrackerIndex[m].columnRWLock);
gettimeofday(&tv1,0); ct+=dt(tv0,tv1); tv0=tv1;
- if (!tail)
- view = BATslice(VIEWhead_(b, BAT_READ), vl, vh+1);
- else
- view = BATslice(b, vl, vh+1);
+ while (1){
+ plock = (lowNode == NULL)? &CRKFirstPieceRWLock :
&lowNode->pieceLock;
+ pthread_rwlock_rdlock(plock);
+ gettimeofday(&tv1,0); wt+=dt(tv0,tv1); tv0=tv1;
+ hghNode = (lowNode == NULL)? lowNodeNext :
findNextPiece(lowNode);
+ vh = hghNode? hghNode->indexPosition : posh;
+ while (vl<=vh){
+ if (t0[vl] >= *low && t0[vl] < *hgh){
+ sum += t0[vl];
+ (*vid)++;
+ }
+ vl++;
+ }
+ pthread_rwlock_unlock(plock);
+ gettimeofday(&tv1,0); st+=dt(tv0,tv1); tv0=tv1;
+ if (!hghNode) break;
+ if (hghNode == stopNode) break;
+ lowNode = hghNode;
+ vl = vh+1;
+ }
- *vid = view->batCacheid;
- BBPkeepref(*vid);
+ // verify the result
+ if (!(sum == ((unsigned long long) *hgh - *low) * ((unsigned long long)
*hgh + *low - 1)/ 2)){
+ fprintf(stderr,"lo=%d, hi=%d, %llu, %llu\n",
+ (int) *low, (int) *hgh, (unsigned long long) sum,
+ (unsigned long long) (((unsigned long long) *hgh -
*low) * ((unsigned long long) *hgh + *low - 1)/ 2));
+ assert(0);
+ }
+
BBPunfix(b->batCacheid);
BBPunfix(c->batCacheid);
+ if(*isIdleQuery==FALSE)
+ fprintf(stderr,"wt=%9.6lf ct=%9.6lf st=%9.6lf lo=%d, hi=%d
sum=%llu\n",wt,ct,st,(int) *low, (int) *hgh,(unsigned long long) sum);
+
if (createIndex==1)
{
MT_lock_unset(&CRKIndexLock,"Cracker Index Lock");
_______________________________________________
checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list