CQMThread Class Reference

List of all members.

Public Member Functions

 ~CQMThread ()
 CQMThread (CQuery &inQueryProcessor, const CXMLElement &inQuery, double inWeight, int inResultSize, double inDifferenceToBest)
 CQMThread (const CQMThread &in)
void runThread (void)
void runFastThread (void)
void join (void)
double getWeight () const

Public Attributes

CQuerymQueryProcessor
const CXMLElementmQuery
int mResultSize
double mDifferenceToBest
CXMLElementmResult
CIDRelevanceLevelPairListmFastResult

Private Attributes

bool mIsThreaded
double mWeight


Detailed Description

calls fastQuery for every child, merges the results and translates them back into URLs

NOTE THIS IS COMMENTED OUT. IT WAS TOO INEFFICIENT. IT WOULD BECOME A CHOICE IF WE WOULD OUTPUT THINGS RATHER SORTED BY THEIR URL THAN BY THEIR SCORE

CIDRelevanceLevelPairList* CQMultiple::fastQuery(const CXMLElement& inQuery, int inNumberOfInterestingImages, double inDifferenceToBest){

cout << "CMultiple Number of children:" << mChildren.size() << endl;

list<CWeightedResult> lTemporary; double lWeightSum(0);

for(lCChildren::const_iterator i=mChildren.begin(); i!=mChildren.end(); i++){ lWeightSum+=i->mWeight;

lTemporary.push_back(CWeightedResult());

cout << "this CMultiple:" << this << ", i->mQuery:" << i->mQuery << ", i->mWeight:" << i->mWeight << endl;

lTemporary.back().mList=i->mQuery->fastQuery(inQuery, mAccessor->size(), inDifferenceToBest);

if(lTemporary.back().mList){ lTemporary.back().mList->sort(CSortByID_IRLP()); lTemporary.back().mI=lTemporary.back().mList->begin();

lTemporary.back().mWeight=i->mWeight; }else{ lTemporary.pop_back(); } }

CIDRelevanceLevelPairList* lReturnValue=new CIDRelevanceLevelPairList();

while(lTemporary.size()){

list<CWeightedResult>::iterator lMinimumIterator=lTemporary.begin(); for(list<CWeightedResult>::iterator i=++lTemporary.begin(); i!=lTemporary.end(); i++){ the ID pointed to by i is smaller lMinimumIterator if((i->mI)->getID()<(lMinimumIterator->mI)->getID()){ lMinimumIterator=i; } } if((lReturnValue->size()) && ((lMinimumIterator->mI)->getID()==lReturnValue->back().getID())){ lReturnValue->back().setRelevanceLevel( lReturnValue->back().getRelevanceLevel() + ((lMinimumIterator->mI)->getRelevanceLevel()

lMinimumIterator->mWeight) ); }else{ lReturnValue->push_back(*lMinimumIterator->mI); lReturnValue->back().setRelevanceLevel( ((lMinimumIterator->mI)->getRelevanceLevel()

lMinimumIterator->mWeight) ); } (lMinimumIterator->mI)++; end of this list, so we delete it if(lMinimumIterator->mI==lMinimumIterator->mList->end()){ lTemporary.erase(lMinimumIterator); } } lReturnValue->sort(CSortByID_IRLP());// for testing, to see if there are any duplicates lReturnValue->sort(); lReturnValue->reverse(); cout << "Size of the result " << lReturnValue->size() << endl;

{ CIDRelevanceLevelPairList::iterator iSkip=lReturnValue->begin(); for(int i=0; i<inNumberOfInterestingImages && i<lReturnValue->size(); i++){ iSkip->setRelevanceLevel(iSkip->getRelevanceLevel()/lWeightSum); iSkip++; } lReturnValue->erase(iSkip,lReturnValue->end()); }

return lReturnValue; }; all information about a query thread for a CQMultiple

Definition at line 239 of file CQMultiple.cc.


Constructor & Destructor Documentation

CQMThread::~CQMThread (  )  [inline]

destructor

Definition at line 263 of file CQMultiple.cc.

00263               {
00264     delete mQuery;
00265   }

CQMThread::CQMThread ( CQuery inQueryProcessor,
const CXMLElement inQuery,
double  inWeight,
int  inResultSize,
double  inDifferenceToBest 
) [inline]

constructor

Definition at line 267 of file CQMultiple.cc.

Referenced by CQMultiple::fastQuery().

00271                                 :
00272     mQueryProcessor(inQueryProcessor),
00273     mQuery(new CXMLElement(inQuery)),
00274     mWeight(inWeight),
00275     mResultSize(inResultSize),
00276     mDifferenceToBest(inDifferenceToBest),
00277     mFastResult(0),
00278     mResult(0){
00279   };

CQMThread::CQMThread ( const CQMThread in  )  [inline]

copy constructor

Definition at line 281 of file CQMultiple.cc.

00281                                 :
00282     mQueryProcessor(in.mQueryProcessor),
00283     mQuery(new CXMLElement(*in.mQuery)),
00284     mWeight(in.mWeight),
00285     mResultSize(in.mResultSize),
00286     mDifferenceToBest(in.mDifferenceToBest),
00287     mResult(0),
00288     mFastResult(0),
00289     mIsThreaded(0){
00290   };


Member Function Documentation

void CQMThread::runThread ( void   )  [inline]

running the thread

Definition at line 292 of file CQMultiple.cc.

References CQMultiple::doQueryThread().

00292                       {
00293     mResult=0;
00294 #ifdef __GIFT_USES_THREADS__
00295 #warning treading active
00296     mIsThreaded=true;
00297     pthread_create(&mThread,0,CQMultiple::doQueryThread,this);
00298 #else
00299 #warning treading blocked
00300     CQMultiple::doQueryThread(this);
00301 #endif
00302   }

void CQMThread::runFastThread ( void   )  [inline]

running the thread

Definition at line 304 of file CQMultiple.cc.

References CQMultiple::doFastQueryThread().

00304                           {
00305     mFastResult=0;
00306 #ifdef __GIFT_USES_THREADS__
00307 #warning treading active
00308     mIsThreaded=true;
00309     pthread_create(&mThread,0,CQMultiple::doFastQueryThread,this);
00310 #else
00311 #warning treading blocked
00312     CQMultiple::doFastQueryThread(this);
00313 #endif
00314   }

void CQMThread::join ( void   )  [inline]

joining this thread with the caller

Definition at line 316 of file CQMultiple.cc.

00316                  {
00317 #ifdef __GIFT_USES_THREADS__
00318     void** lReturnValue(NULL);
00319     cout << "PREJOIN" << endl;
00320     if(mIsThreaded){
00321       int lJoinResult(pthread_join(mThread,lReturnValue));
00322 
00323       if(lJoinResult){
00324   cout << "CQMultiple: ERROR IN JOINING " 
00325        << lJoinResult
00326        << endl;
00327       }
00328     }else{
00329       cout << "This was an unthreaded join!" 
00330      << endl;
00331     }
00332     mIsThreaded=false;
00333     cout << "POSTJOIN" << endl;
00334 #endif
00335   }

double CQMThread::getWeight (  )  const [inline]

gives back the weight the results should receive when summing up

Definition at line 338 of file CQMultiple.cc.

00338                          {
00339     return mWeight;
00340   }


Member Data Documentation

the thread administrator is this called as a thread or as a function

Definition at line 246 of file CQMultiple.cc.

double CQMThread::mWeight [private]

this is the weight the result should receive

Definition at line 248 of file CQMultiple.cc.

query processor used in this thread

Definition at line 251 of file CQMultiple.cc.

Referenced by CQMultiple::doFastQueryThread(), and CQMultiple::doQueryThread().

the query (an xml parse tree)

Definition at line 253 of file CQMultiple.cc.

Referenced by CQMultiple::doFastQueryThread(), and CQMultiple::doQueryThread().

the desired result size

Definition at line 255 of file CQMultiple.cc.

Referenced by CQMultiple::doFastQueryThread().

the cutoff

Definition at line 257 of file CQMultiple.cc.

Referenced by CQMultiple::doFastQueryThread().

the result of the query

Definition at line 259 of file CQMultiple.cc.

Referenced by CQMultiple::doFastQueryThread(), and CQMultiple::doQueryThread().

the result of the fastQuery

Definition at line 261 of file CQMultiple.cc.

Referenced by CQMultiple::doFastQueryThread().


The documentation for this class was generated from the following file:

Generated on Wed Jan 7 00:31:12 2009 for Gift by  doxygen 1.5.6