Changeset: 22695fcea790 for MonetDB URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=22695fcea790 Modified Files: monetdb5/extras/crackers/crackers.mx monetdb5/extras/crackers/crackers_holistic.c monetdb5/extras/crackers/crackers_holistic.h monetdb5/extras/crackers/crackers_selecthol_ops.mx monetdb5/extras/crackers/crackers_selectholpl_ops.mx Branch: holindex Log Message:
Call a new "select" function when there are idle resources. diffs (truncated from 768 to 300 lines): diff --git a/monetdb5/extras/crackers/crackers.mx b/monetdb5/extras/crackers/crackers.mx --- a/monetdb5/extras/crackers/crackers.mx +++ b/monetdb5/extras/crackers/crackers.mx @@ -273,7 +273,7 @@ address CRKselectholValue_@2 comment "Retrieve the subset using a cracker index producing preferably a BATview."; -command selecthol(b:bat[:oid,:@2],l:@2,h:@2,li:bit,hi:bit,iq:bit):bat[:oid,:@2] +command selecthol(b:bat[:oid,:@2],l:@2,h:@2,li:bit,hi:bit):bat[:oid,:@2] address CRKselectholBounds_@2 comment "Retrieve the subset using a cracker index producing preferably a BATview."; @@ -288,7 +288,7 @@ address CRKuselectholValue_@2 comment "Retrieve the subset using a cracker index producing preferably a BATview."; -command uselecthol(b:bat[:any_1,:@2],l:@2,h:@2,li:bit,hi:bit,iq:bit):bat[:any_1,:void] +command uselecthol(b:bat[:any_1,:@2],l:@2,h:@2,li:bit,hi:bit):bat[:any_1,:void] address CRKuselectholBounds_@2 comment "Retrieve the subset using a cracker index producing preferably a BATview."; @@ -353,7 +353,7 @@ address CRKselectholplValue_@2 comment "Retrieve the subset using a cracker index producing preferably a BATview."; -command selectholpl(b:bat[:oid,:@2],l:@2,h:@2,li:bit,hi:bit,iq:bit):bat[:oid,:@2] +command selectholpl(b:bat[:oid,:@2],l:@2,h:@2,li:bit,hi:bit):bat[:oid,:@2] address CRKselectholplBounds_@2 comment "Retrieve the subset using a cracker index producing preferably a BATview."; @@ -368,7 +368,7 @@ address CRKuselectholplValue_@2 comment "Retrieve the subset using a cracker index producing preferably a BATview."; -command uselectholpl(b:bat[:any_1,:@2],l:@2,h:@2,li:bit,hi:bit,iq:bit):bat[:any_1,:void] +command uselectholpl(b:bat[:any_1,:@2],l:@2,h:@2,li:bit,hi:bit):bat[:any_1,:void] address CRKuselectholplBounds_@2 comment "Retrieve the subset using a cracker index producing preferably a BATview."; diff --git a/monetdb5/extras/crackers/crackers_holistic.c b/monetdb5/extras/crackers/crackers_holistic.c --- a/monetdb5/extras/crackers/crackers_holistic.c +++ b/monetdb5/extras/crackers/crackers_holistic.c @@ -162,6 +162,29 @@ findMax(FrequencyNode* head) } return ret_node; } +/*this function returns the maximum weight (excluding the bid weight) from the list and is used for all the cost models*/ +FrequencyNode* +findOtherMax(FrequencyNode* head, int bat_id) +{ + FrequencyNode* temp=NULL; + FrequencyNode* ret_node=NULL; + double tmpW; + //int bat; + temp=head; + tmpW=temp->weight; + //bat=temp->bid; + while(temp!=NULL) + { + if((temp->weight >= tmpW) && (temp->bid != bat_id)) + { + tmpW=temp->weight; + //bat=temp->bid; + ret_node=temp; + } + temp=temp->next; + } + return ret_node; +} /*this function returns a random node from the list with positive weight*/ FrequencyNode* @@ -352,45 +375,28 @@ CRKrandomCrack(int *ret) { int bid=0; FrequencyNode* max_node; - BAT *b; - int low=0, hgh=0; - int *t; - int temp=0; - bit isIdleQuery=TRUE; - oid posl,posh,p; - //FILE *ofp1; - int dummy = 0; - //char outputFilename1[] = "/export/scratch2/petraki/experiments_paper1/thresholds/client1/waiting0/cpuload70/idletime4/idle_columns.txt"; - + int change_bat=0; bit inclusive=TRUE; FrequencyNode *fs = getFrequencyStruct('A'); - //ofp1 = fopen(outputFilename1,"a"); + (void) ret; max_node=findMax(fs); if(max_node!=NULL && max_node->weight > 0) { bid=max_node->bid; - b=BATdescriptor(bid); - t=(int*)Tloc(b,BUNfirst(b)); - posl=BUNfirst(b); - posh=BUNlast(b) - 1; - p=(rand()%(posh-posl+1))+posl; - low=t[p]; - p=(rand()%(posh-posl+1))+posl; - hgh=t[p]; - if(hgh < low) + change_bat = CRKrandomholpl_int(&bid,&inclusive); + if (change_bat == -1) { - temp=low; - low=hgh; - hgh=temp; + max_node=findOtherMax(fs,bid); + if(max_node!=NULL && max_node->weight > 0) + { + bid=max_node->bid; + (void) CRKrandomholpl_int(&bid,&inclusive); + } } - CRKselectholplBounds_int(&dummy, &bid, &low, &hgh, &inclusive, &inclusive,&isIdleQuery); - //fprintf(ofp1,"%d\n",max_node->bid); } - //fclose(ofp1); - return MAL_SUCCEED; } diff --git a/monetdb5/extras/crackers/crackers_holistic.h b/monetdb5/extras/crackers/crackers_holistic.h --- a/monetdb5/extras/crackers/crackers_holistic.h +++ b/monetdb5/extras/crackers/crackers_holistic.h @@ -50,6 +50,7 @@ crackers_export double changeWeight_1(Fr crackers_export double changeWeight_2(FrequencyNode* node,int N,int L1); crackers_export double changeWeight_3(FrequencyNode* node,int N,int L1); crackers_export FrequencyNode* findMax(FrequencyNode* head); +crackers_export FrequencyNode* findOtherMax(FrequencyNode* head,int bat_id); crackers_export FrequencyNode* pickRandom(FrequencyNode* head); crackers_export void deleteNode(FrequencyNode* head,int bat_id); crackers_export IdleFuncPtr IdleFunc; 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 @@ -54,8 +54,8 @@ All Rights Reserved. * @- Exported signatures */ @= SelectholFunctions_decl -crackers_export str CRKselectholBounds_@1(int *vid, int *bid, @1 *low, @1 *hgh, bit *inclusiveLow, bit *inclusiveHgh,bit *isIdleQuery); -crackers_export str CRKuselectholBounds_@1(int *vid, int *bid, @1 *low, @1 *hgh, bit *inclusiveLow, bit *inclusiveHgh, bit *isIdleQuery); +crackers_export str CRKselectholBounds_@1(int *vid, int *bid, @1 *low, @1 *hgh, bit *inclusiveLow, bit *inclusiveHgh); +crackers_export str CRKuselectholBounds_@1(int *vid, int *bid, @1 *low, @1 *hgh, bit *inclusiveLow, bit *inclusiveHgh); crackers_export str CRKselectholValue_@1(int *vid, int *bid, @1 *value); crackers_export str CRKuselectholValue_@1(int *vid, int *bid, @1 *value); crackers_export str CRKselecthol_@1(int *vid, int *bid, @1 *low, @1 *hgh); @@ -88,51 +88,47 @@ crackers_export str CRKsumholBounds_@1(i @= SelectholFunctions_impl str -CRKselectholBounds_@1(int *vid, int *bid, @1 *low, @1 *hgh, bit *inclusiveLow, bit *inclusiveHgh, bit *isIdleQuery){ +CRKselectholBounds_@1(int *vid, int *bid, @1 *low, @1 *hgh, bit *inclusiveLow, bit *inclusiveHgh){ if (@2_EQ(low,ATOMnilptr(TYPE_@1),@3@1)) - return CRKRangeLeftNilTree_@1(vid, bid, hgh, inclusiveHgh, TRUE, isIdleQuery); + return CRKRangeLeftNilTree_@1(vid, bid, hgh, inclusiveHgh, TRUE); else if (@2_EQ(hgh,ATOMnilptr(TYPE_@1),@3@1)) - return CRKRangeRightNilTree_@1(vid, bid, low, inclusiveLow, TRUE, isIdleQuery); + return CRKRangeRightNilTree_@1(vid, bid, low, inclusiveLow, TRUE); else - return CRKRangeTree_@1(vid, bid, low, hgh, inclusiveLow, inclusiveHgh, TRUE, isIdleQuery); + return CRKRangeTree_@1(vid, bid, low, hgh, inclusiveLow, inclusiveHgh, TRUE); } str -CRKuselectholBounds_@1(int *vid, int *bid, @1 *low, @1 *hgh, bit *inclusiveLow, bit *inclusiveHgh, bit *isIdleQuery){ +CRKuselectholBounds_@1(int *vid, int *bid, @1 *low, @1 *hgh, bit *inclusiveLow, bit *inclusiveHgh){ if (@2_EQ(low,ATOMnilptr(TYPE_@1),@3@1)) - return CRKRangeLeftNilTree_@1(vid, bid, hgh, inclusiveHgh, FALSE, isIdleQuery); + return CRKRangeLeftNilTree_@1(vid, bid, hgh, inclusiveHgh, FALSE); else if (@2_EQ(hgh,ATOMnilptr(TYPE_@1),@3@1)) - return CRKRangeRightNilTree_@1(vid, bid, low, inclusiveLow, FALSE, isIdleQuery); + return CRKRangeRightNilTree_@1(vid, bid, low, inclusiveLow, FALSE); else - return CRKRangeTree_@1(vid, bid, low, hgh, inclusiveLow, inclusiveHgh, FALSE, isIdleQuery); + return CRKRangeTree_@1(vid, bid, low, hgh, inclusiveLow, inclusiveHgh, FALSE); } str CRKselectholValue_@1(int *vid, int *bid, @1 *value){ bit inclusive = TRUE; - bit isIdleQuery=FALSE; - return CRKuselectholBounds_@1(vid, bid, value, value, &inclusive, &inclusive, &isIdleQuery); + return CRKuselectholBounds_@1(vid, bid, value, value, &inclusive, &inclusive); } str CRKuselectholValue_@1(int *vid, int *bid, @1 *value){ bit inclusive = TRUE; - bit isIdleQuery=FALSE; - return CRKuselectholBounds_@1(vid, bid, value, value, &inclusive, &inclusive, &isIdleQuery); + return CRKuselectholBounds_@1(vid, bid, value, value, &inclusive, &inclusive); } str CRKselecthol_@1(int *vid, int *bid, @1 *low, @1 *hgh){ bit inclusive = TRUE; - bit isIdleQuery=FALSE; - return CRKselectholBounds_@1(vid, bid, low, hgh, &inclusive, &inclusive, &isIdleQuery); + return CRKselectholBounds_@1(vid, bid, low, hgh, &inclusive, &inclusive); } str CRKuselecthol_@1(int *vid, int *bid, @1 *low, @1 *hgh){ bit inclusive = TRUE; - bit isIdleQuery=FALSE; - return CRKuselectholBounds_@1(vid, bid, low, hgh, &inclusive, &inclusive, &isIdleQuery); + return CRKuselectholBounds_@1(vid, bid, low, hgh, &inclusive, &inclusive); } str @@ -140,7 +136,6 @@ CRKthetaselecthol_@1(int *vid, int *bid, ptr nilptr = ATOMnilptr(TYPE_@1); char *op = *OP; bit lin = TRUE, rin = TRUE; - bit isIdleQuery=FALSE; @1 *low = nilptr, *high = nilptr; if (op[0] == '=') { @@ -156,7 +151,7 @@ CRKthetaselecthol_@1(int *vid, int *bid, throw(MAL, "crackers.thetaselecthol", "unknown operator"); } - return CRKselectholBounds_@1(vid, bid, low, high, &lin, &rin, &isIdleQuery); + return CRKselectholBounds_@1(vid, bid, low, high, &lin, &rin); } str @@ -164,7 +159,6 @@ CRKthetauselecthol_@1(int *vid, int *bid ptr nilptr = ATOMnilptr(TYPE_@1); char *op = *OP; bit lin = TRUE, rin = TRUE; - bit isIdleQuery=FALSE; @1 *low = nilptr, *high = nilptr; if (op[0] == '=') { @@ -179,7 +173,7 @@ CRKthetauselecthol_@1(int *vid, int *bid throw(MAL, "crackers.thetauselecthol", "unknown operator"); } - return CRKuselectholBounds_@1(vid, bid, low, high, &lin, &rin, &isIdleQuery); + return CRKuselectholBounds_@1(vid, bid, low, high, &lin, &rin); } str CRKsumholBounds_@1(int *vid, int *bid, @1 *low, @1 *hgh, bit *inclusiveLow, bit *inclusiveHgh){ @@ -386,9 +380,7 @@ createView: FN=searchBAT(FrequencyStructA,*bid); - if (*isIdleQuery==FALSE) - FN->f1 = FN->f1 + 1; - + FN->f1 = FN->f1 + 1; FN->c = FN->c + 2; FN->weight = changeWeight_1(FN,countBatElements,L1); @@ -443,10 +435,7 @@ createView: FN=searchBAT(FrequencyStructA,*bid); - if (*isIdleQuery==FALSE) - { - FN->f1 = FN->f1 + 1; - } + FN->f1 = FN->f1 + 1; /* If an index exists for this bat (so it has been cracked before) @@ -579,7 +568,7 @@ createView: - if((foundLow!=0 && foundHgh!=0)&&(*isIdleQuery==FALSE)) FN->f2 = FN->f2 + 1; + if((foundLow!=0 && foundHgh!=0)) FN->f2 = FN->f2 + 1; /* If one or both of the result view bounds were not found using the index then we have to crack */ @@ -660,10 +649,7 @@ createView: MT_lock_unset(&CrackerIndex[m].columnLock,"Lock Attribute"); gettimeofday(&tv1,0); ct+=dt(tv0,tv1); tv0=tv1; - if(*isIdleQuery==FALSE) - fprintf(ofp,"User_query \t 1 \t Wait_time\t %9.6lf \t Selection_time\t %9.6lf\n",wt,ct); - else - fprintf(ofp,"Idle_Query \t 0 \t Wait_time\t %9.6lf \t Selection_time\t %9.6lf\n",wt,ct); + fprintf(ofp,"User_query \t 1 \t Wait_time\t %9.6lf \t Selection_time\t %9.6lf\n",wt,ct); fclose(ofp); @@ -1065,7 +1051,7 @@ To do that, we first search the index to know and which parts we have to crack. Then we crack, if necessary, the appropriate pieces, update the index and return the result */ static str -CRKRangeTree_@1(int *vid, int *bid, @1 *low, @1 *hgh, bit *inclusiveLow, bit *inclusiveHgh, bit tail, bit *isIdleQuery){ _______________________________________________ checkin-list mailing list checkin-list@monetdb.org http://mail.monetdb.org/mailman/listinfo/checkin-list