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

Check if lowNode is Null before trying to get a write lock.


diffs (105 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
@@ -29,6 +29,7 @@ static FrequencyNode *_InternalFrequency
 static MT_Lock frequencylock;
 static MT_Id idletime_thread;
 MT_Lock CRKIndexLock;
+pthread_rwlock_t CRKFirstPieceRWLock;
 
 
 int isIdleQuery = 0;
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
@@ -38,6 +38,7 @@ typedef struct frequency{
 typedef  str (*IdleFuncPtr)(int *);
 crackers_export int isIdleQuery;
 crackers_export MT_Lock CRKIndexLock;
+crackers_export pthread_rwlock_t CRKFirstPieceRWLock;
 
 crackers_export FrequencyNode *getFrequencyStruct(char which);
 crackers_export void push(int bat_id,FrequencyNode* head);
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
@@ -277,6 +277,7 @@ createView:
        int  m;
        int *t;
        int createIndex=0;
+       pthread_rwlock_t *plock=0;
        oid vl=0, vh=0, posl, posh;
        /* vl and vh are the low and high index values to create the view with 
the result */
        oid cl1=0, ch1=0, cl2=0, ch2=0;
@@ -419,7 +420,7 @@ createView:
 
                         BBPincref(b->batCacheid,TRUE);
                         BBPunfix(bo->batCacheid);
-                        goto createView;
+                        goto tempcreateView;
                 }
                
        }
@@ -457,7 +458,7 @@ createView:
                posh = BUNlast(b)-1;
 
                @:crkThreeTree@5(@1,posl,posh,@5)@
-               goto createView;
+               goto tempcreateView;
        }
        
        /* Take the index of the bat */
@@ -581,10 +582,11 @@ createView:
                 if (foundLow == 0) {
                        pthread_rwlock_rdlock(&CrackerIndex[m].columnRWLock);
                        lowNode = findNodeL_@1(*low, TRUE, 
CrackerIndex[m].Tree, c, idxFirst, NULL);
-                       if (pthread_rwlock_trywrlock(&lowNode->pieceLock)){
+                       plock = (lowNode == NULL)? &CRKFirstPieceRWLock : 
&lowNode->pieceLock;
+                       if (pthread_rwlock_trywrlock(plock)){
                                
pthread_rwlock_unlock(&CrackerIndex[m].columnRWLock);
-                               pthread_rwlock_wrlock(&lowNode->pieceLock);
-                               pthread_rwlock_unlock(&lowNode->pieceLock);
+                               pthread_rwlock_wrlock(plock);
+                               pthread_rwlock_unlock(plock);
                                goto retry;     // some other thread might 
already crack on low, try to find it again
                        }
                        pthread_rwlock_unlock(&CrackerIndex[m].columnRWLock);
@@ -606,15 +608,16 @@ createView:
                        }
                        vh = ch2;
                        pthread_rwlock_unlock(&CrackerIndex[m].columnRWLock);
-                       pthread_rwlock_unlock(&lowNode->pieceLock);
+                       pthread_rwlock_unlock(plock);
                }
                if (foundHgh == 0) {
                        pthread_rwlock_rdlock(&CrackerIndex[m].columnRWLock);
                        lowNode = findNodeL_@1(*hgh, TRUE, 
CrackerIndex[m].Tree, c, idxFirst, NULL);
-                       if (pthread_rwlock_trywrlock(&lowNode->pieceLock)){
+                       plock = (lowNode == NULL)? &CRKFirstPieceRWLock : 
&lowNode->pieceLock;
+                       if (pthread_rwlock_trywrlock(plock)){
                                
pthread_rwlock_unlock(&CrackerIndex[m].columnRWLock);
-                               pthread_rwlock_wrlock(&lowNode->pieceLock);
-                               pthread_rwlock_unlock(&lowNode->pieceLock);
+                               pthread_rwlock_wrlock(plock);
+                               pthread_rwlock_unlock(plock);
                                goto retry;     // some other thread might 
already crack on low, try to find it again
                        }
                        pthread_rwlock_unlock(&CrackerIndex[m].columnRWLock);
@@ -631,7 +634,7 @@ createView:
                        if ((vl == 0) && (*t < *low) && (*inclusiveLow == TRUE))
                                vl = vl + 1;
                        pthread_rwlock_unlock(&CrackerIndex[m].columnRWLock);
-                       pthread_rwlock_unlock(&lowNode->pieceLock);
+                       pthread_rwlock_unlock(plock);
                }
        } else {
                t = (int *) Tloc(b, BUNfirst(b));
@@ -659,7 +662,7 @@ createView:
        /*fprintf(ofp,"%d\n",FN->c);
        fclose(ofp);*/
 
-//     @:CreateResult()@
+       /*@:CreateResult()@*/
 
        tempcreateView:;
 
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
http://mail.monetdb.org/mailman/listinfo/checkin-list

Reply via email to