Changeset: 5b1a2f2b07ad for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=5b1a2f2b07ad
Modified Files:
        monetdb5/extras/crackers/crackers_holistic.c
        monetdb5/extras/crackers/crackers_holistic.h
        monetdb5/extras/crackers/crackers_holistic.mal
Branch: holindex
Log Message:

Add extra cost models.


diffs (truncated from 410 to 300 lines):

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
@@ -164,7 +164,7 @@ searchBAT(FrequencyNode* head,int bat_id
        }
        return temp;
 }
-
+/*this function returns the maximum weight from the list and is used for the 
following cost models: 1,3,5,7,9*/
 FrequencyNode*
 findMax(FrequencyNode* head)
 {
@@ -187,34 +187,20 @@ findMax(FrequencyNode* head)
        }
        return ret_node;
 }
-/*this function is used for the variation of the 1st cost model*/
+/*this function returns the maximum weight from the list and is used for the 
following cost models: 2,4,6,8,10*/
 FrequencyNode*
 findMax_2(FrequencyNode* head)
 {
        FrequencyNode* temp;
        FrequencyNode* ret_node=NULL;
        double tmpW;
-       //int bat;
        temp=head->next;
        tmpW=temp->weight;
-       //bat=temp->bid;
        while(temp!=NULL)
        {
-               if(temp->weight >= 0 && temp->f1 >0)
-               {
-                       ret_node=temp;
-                       tmpW=temp->weight;
-                       break;
-               }
-               temp=temp->next;
-       }
-       temp=head->next;
-       while(temp!=NULL)
-       {
-               if((temp->weight >= tmpW)&&(temp->f1 >0))
+               if((tmpW > 0) && (temp->weight >= tmpW))
                {
                        tmpW=temp->weight;
-                       //bat=temp->bid;
                        ret_node=temp;
                }
                temp=temp->next;
@@ -223,7 +209,9 @@ findMax_2(FrequencyNode* head)
 }
 
 
-/*this function updates the weights in the list in the first experiment (1st 
cost model)*/
+/*The following function updates the weights in the list*/
+/*This cost model takes into consideration only the distance from the optimal 
index.*/
+/*The initial weights are initialized to the distance from the optimal index 
(NON-ZERO)*/
 double
 changeWeight_1(FrequencyNode* node,int N,int L1)
 {
@@ -238,8 +226,9 @@ changeWeight_1(FrequencyNode* node,int N
        /*fprintf(stderr,"W=%lf\n",node->weight);*/
        return node->weight;
 }
-
-/*this function updates the weights in the list in the second experiment (2nd 
cost model)*/
+/*The following function updates the weights in the list*/
+/*This cost model takes into consideration only the distance from the optimal 
index.*/
+/*The initial weights are initialized to 0 (ZERO)*/
 double
 changeWeight_2(FrequencyNode* node,int N,int L1)
 {
@@ -252,6 +241,32 @@ changeWeight_2(FrequencyNode* node,int N
        /*fprintf(stderr,"p=%d Sp=%lf d=%lf\n",p,Sp,d);*/
        if (node->f1==0)
        {
+               node->weight = 0;
+       }
+       else
+       {
+               node->weight = d;
+       }
+
+       /*fprintf(stderr,"W=%lf\n",node->weight);*/
+       return node->weight;
+}
+
+/*The following function updates the weights in the list*/
+/*This cost model takes into consideration both the frequency of the queries 
that use the index and the distance from the optimal index.*/
+/*The initial weights are initialized to the distance from the optimal index 
(NON-ZERO)*/
+double
+changeWeight_3(FrequencyNode* node,int N,int L1)
+{
+       int p; /*number of pieces in the index*/
+       double Sp; /*average size of each piece*/
+       double d; /*distance from optimal piece(L1)*/
+       p = node->c;
+       Sp =((double)N)/p;      
+       d = Sp - L1;
+       /*fprintf(stderr,"p=%d Sp=%lf d=%lf\n",p,Sp,d);*/
+       if (node->f1==0)
+       {
                node->weight = d;
        }
        else
@@ -261,28 +276,37 @@ changeWeight_2(FrequencyNode* node,int N
        /*fprintf(stderr,"W=%lf\n",node->weight);*/
        return node->weight;
 }
-
-/*this function updates the weights in the list in the third experiment (3rd 
cost model)*/
+/*The following function updates the weights in the list*/
+/*This cost model takes into consideration both the frequency of the queries 
that use the index and the distance from the optimal index.*/
+/*The initial weights are initialized to 0 (ZERO)*/
 double
-changeWeight_3(FrequencyNode* node,int N,int L1)
+changeWeight_4(FrequencyNode* node,int N,int L1)
 {
-        int p; /*number of pieces in the index*/
-        double Sp; /*average size of each piece*/
-        double d; /*distance from optimal piece(L1)*/
-        p = node->c;
-        Sp =((double)N)/p;
-        d = Sp - L1;
-        /*fprintf(stderr,"p=%d Sp=%lf d=%lf\n",p,Sp,d);*/
-       if(d>0)
-               node->weight = (double)(node->f1) + d;
-        else
-               node->weight = d;
+       int p; /*number of pieces in the index*/
+       double Sp; /*average size of each piece*/
+       double d; /*distance from optimal piece(L1)*/
+       p = node->c;
+       Sp =((double)N)/p;      
+       d = Sp - L1;
+       /*fprintf(stderr,"p=%d Sp=%lf d=%lf\n",p,Sp,d);*/
+       if (node->f1==0)
+       {
+               node->weight = 0;
+       }
+       else
+       {
+               node->weight = (double)(node->f1) * d;
+       }
        /*fprintf(stderr,"W=%lf\n",node->weight);*/
-        return node->weight;
+       return node->weight;
 }
 
+/*The following function updates the weights in the list*/
+/*This cost model takes into consideration the frequency of the queries that 
use the index,*/
+/* the frequency of the queries that "hit" the range in the index and the 
distance from the optimal index.*/
+/*The initial weights are initialized to the distance from the optimal index 
(NON-ZERO)*/
 double
-changeWeight_4(FrequencyNode* node,int N,int L1)
+changeWeight_5(FrequencyNode* node,int N,int L1)
 {
        int p; /*number of pieces in the index*/
        double Sp; /*average size of each piece*/
@@ -307,7 +331,137 @@ changeWeight_4(FrequencyNode* node,int N
        return node->weight;
 
 }
+/*The following function updates the weights in the list*/
+/*This cost model takes into consideration the frequency of the queries that 
use the index,*/
+/* the frequency of the queries that "hit" the range in the index and the 
distance from the optimal index.*/
+/*The initial weights are initialized to 0 (ZERO)*/
+double
+changeWeight_6(FrequencyNode* node,int N,int L1)
+{
+       int p; /*number of pieces in the index*/
+       double Sp; /*average size of each piece*/
+       double d; /*distance from optimal piece(L1)*/
+       p = node->c;
+       Sp =((double)N)/p;      
+       d = Sp - L1;
+       /*fprintf(stderr,"p=%d Sp=%lf d=%lf\n",p,Sp,d);*/
 
+       if (node->f1==0)
+       {
+               node->weight = 0;
+       }
+       else
+       {
+               if (node->f2!=0)
+                       node->weight = ((double)(node->f1)/(double)(node->f2)) 
* d;
+               else
+                       node->weight = (double)(node->f1) * d;
+       }
+       /*fprintf(stderr,"W=%lf\n",node->weight);*/
+       return node->weight;
+
+}
+/*The following function updates the weights in the list*/
+/*This cost model takes into consideration mainly the frequency of the queries 
that use the index until the distance becomes equal to 0.*/
+/*The initial weights are initialized to 1 (NON-ZERO)*/
+double
+changeWeight_7(FrequencyNode* node,int N,int L1)
+{
+       int p; /*number of pieces in the index*/
+       double Sp; /*average size of each piece*/
+       double d; /*distance from optimal piece(L1)*/
+       p = node->c;
+       Sp =((double)N)/p;      
+       d = Sp - L1;
+       /*fprintf(stderr,"p=%d Sp=%lf d=%lf\n",p,Sp,d);*/
+       if (d > 0)
+       {
+               node->weight = 1.0;
+       }
+       else if (d>0)
+       {
+               node->weight = (double)(node->f1);
+       }
+       /*fprintf(stderr,"W=%lf\n",node->weight);*/
+       return node->weight;
+}
+
+/*The following function updates the weights in the list*/
+/*This cost model takes into consideration mainly the frequency of the queries 
that use the index until the distance becomes equal to 0.*/
+/*The initial weights are initialized to 0 (ZERO)*/
+double
+changeWeight_8(FrequencyNode* node,int N,int L1)
+{
+       int p; /*number of pieces in the index*/
+       double Sp; /*average size of each piece*/
+       double d; /*distance from optimal piece(L1)*/
+       p = node->c;
+       Sp =((double)N)/p;      
+       d = Sp - L1;
+       /*fprintf(stderr,"p=%d Sp=%lf d=%lf\n",p,Sp,d);*/
+       if (d > 0)
+       {
+               node->weight = (double)(node->f1);
+       }
+       /*fprintf(stderr,"W=%lf\n",node->weight);*/
+       return node->weight;
+}
+
+/*The following function updates the weights in the list*/
+/*This cost model takes into consideration mainly the frequency of the queries 
that use the index and*/
+/* the frequency of the queries that "hit" the range in the index.*/
+/*The initial weights are initialized to 1 (NON-ZERO)*/
+double
+changeWeight_9(FrequencyNode* node,int N,int L1)
+{
+       int p; /*number of pieces in the index*/
+       double Sp; /*average size of each piece*/
+       double d; /*distance from optimal piece(L1)*/
+       p = node->c;
+       Sp =((double)N)/p;      
+       d = Sp - L1;
+       /*fprintf(stderr,"p=%d Sp=%lf d=%lf\n",p,Sp,d);*/
+
+       if (node->f1==0)
+       {
+               node->weight = 1.0;
+       }
+       else if (d>0)
+       {
+               if (node->f2!=0)
+                       node->weight = ((double)(node->f1)/(double)(node->f2));
+               else
+                       node->weight = (double)(node->f1);
+       }
+       /*fprintf(stderr,"W=%lf\n",node->weight);*/
+       return node->weight;
+
+}
+/*The following function updates the weights in the list*/
+/*This cost model takes into consideration mainly the frequency of the queries 
that use the index and*/
+/* the frequency of the queries that "hit" the range in the index.*/
+/*The initial weights are initialized to 0 (ZERO)*/
+double
+changeWeight_10(FrequencyNode* node,int N,int L1)
+{
+       int p; /*number of pieces in the index*/
+       double Sp; /*average size of each piece*/
+       double d; /*distance from optimal piece(L1)*/
+       p = node->c;
+       Sp =((double)N)/p;      
+       d = Sp - L1;
+       /*fprintf(stderr,"p=%d Sp=%lf d=%lf\n",p,Sp,d);*/
+       if (d>0)
+       {
+               if (node->f2!=0)
+                       node->weight = ((double)(node->f1)/(double)(node->f2));
+               else
+                       node->weight = (double)(node->f1);
+       }
+       /*fprintf(stderr,"W=%lf\n",node->weight);*/
+       return node->weight;
+
+}
 
 void
 deleteNode(FrequencyNode* head,int bat_id)
@@ -365,8 +519,9 @@ CRKzeroFrequency(int *vid)
         return MAL_SUCCEED;
 }
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to