#include <CQuery.h>

Public Member Functions | |
| CQuery () | |
| virtual | ~CQuery () |
| CQuery (CAccessorAdminCollection &inAccessorAdminCollection, CAlgorithm &inAlgorithm) | |
| void | addChild (CQuery *inChild, double inWeight=1) |
| virtual CXMLElement * | query (const CXMLElement &inQuery) |
| virtual CIDRelevanceLevelPairList * | fastQuery (const CXMLElement &inQuery, int inNumberOfInterestingImages, double inDifferenceToBest)=0 |
| a query which returns ID/RelevanceLevel pairs instead of instead of URL/RelevanceLevel pairs | |
| virtual CXMLElement * | getRandomImages (int inNumberOfInterestingImages) const |
| virtual CIDRelevanceLevelPairList * | getRandomIDs (int inNumberOfInterestingImages) const |
| virtual list< TID > * | getAllIDs () const |
| virtual list< CAccessorElement > * | getAllAccessorElements () const |
| virtual bool | setAlgorithm (CAlgorithm &inAlgorithm) |
| const CAlgorithm & | getAlgorithm () const |
| virtual void | finishInit () |
Protected Types | |
| typedef list< lCChild > | lCChildren |
Protected Member Functions | |
| virtual void | init ()=0 |
Protected Attributes | |
| CAccessor * | mAccessor |
| CAccessorAdmin * | mAccessorAdmin |
| CAccessorAdminCollection * | mAccessorAdminCollection |
| CAlgorithm * | mAlgorithm |
| lCChildren | mChildren |
Classes | |
| class | lCChild |
Definition at line 73 of file CQuery.h.
typedef list<lCChild> CQuery::lCChildren [protected] |
| CQuery::CQuery | ( | ) |
default constructor
Definition at line 108 of file CQuery.cc.
References gQuery.
00108 : 00109 mAccessorAdmin(0), 00110 mAlgorithm(0), 00111 mAccessor((CAccessor*)0), 00112 mAccessorAdminCollection(0){ 00113 cout << "\nGQOUERY" << gQuery << endl; 00114 00115 gQuery++; 00116 }
| CQuery::~CQuery | ( | ) | [virtual] |
| CQuery::CQuery | ( | CAccessorAdminCollection & | inAccessorAdminCollection, | |
| CAlgorithm & | inAlgorithm | |||
| ) |
this constructor takes all the information ANY CQuery needs to configure itself.
inAccessorAdminCollection The CQuery needs to know where to get the right accessor from. inAlgorithm This structure contains all the information about the algorithm, including which accessor to get.
Definition at line 84 of file CQuery.cc.
References CAlgorithm::getCollectionID(), CAccessorAdminCollection::getProxy(), gQuery, mAccessorAdmin, mAccessorAdminCollection, and mAlgorithm.
00086 : 00087 mAccessorAdminCollection(&inAccessorAdminCollection), 00088 mAlgorithm(&inAlgorithm), 00089 mAccessorAdmin(0), 00090 mAccessor(0){ 00091 cout << "\nGQOUERY" << gQuery << endl; 00092 gQuery++; 00093 00094 //get proxy by CollectionID 00095 mAccessorAdmin=&mAccessorAdminCollection->getProxy(mAlgorithm->getCollectionID()); 00096 } /***************************************
| virtual void CQuery::init | ( | ) | [protected, pure virtual] |
Initializer, used by both construcors
Implemented in CQHierarchy, CQInvertedFile, CQMultiple, and CQParallel.
| void CQuery::addChild | ( | CQuery * | inChild, | |
| double | inWeight = 1 | |||
| ) |
adding a child to this. We expect children to be nonzero and initialised when they are entered. this assumes no destruction responsabilities for the entered data.
adding a child to this. We expect children to be initialised when they are entered. *this assumes no destruction responsabilities for the entered data.
Definition at line 280 of file CQuery.cc.
References mChildren.
Referenced by CQueryTreeNode::configure().
00281 { 00282 00283 mChildren.push_back(lCChild()); 00284 mChildren.back().mQuery=inChild; 00285 mChildren.back().mWeight=inWeight; 00286 };
| CXMLElement * CQuery::query | ( | const CXMLElement & | inQuery | ) | [virtual] |
do a query
Query: do a fast query, then translate the results.
Reimplemented in CQMultiple.
Definition at line 300 of file CQuery.cc.
References CXMLElement::addAttribute(), CXMLElement::addChild(), mrml_const::calculated_similarity, CXMLElement::child_list_begin(), CXMLElement::child_list_end(), CXMLElement::doubleReadAttribute(), fastQuery(), getRandomImages(), CAccessor::IDToAccessorElement(), mrml_const::image_location, CXMLElement::longReadAttribute(), mAccessor, CXMLElement::moveUp(), mrml_const::query_result, mrml_const::query_result_element, mrml_const::query_result_element_list, mrml_const::result_cutoff, mrml_const::result_size, and mrml_const::thumbnail_location.
Referenced by CQMultiple::doQueryThread(), CQueryTreeNode::query(), and CQMultiple::query().
00300 { 00301 00302 pair<bool,long> lNumberOfInterestingImages= 00303 inQuery.longReadAttribute(mrml_const::result_size); 00304 00305 int inNumberOfInterestingImages= 00306 lNumberOfInterestingImages.second; 00307 00308 pair<bool,double> lCutoff= 00309 inQuery.doubleReadAttribute(mrml_const::result_cutoff); 00310 00311 double inCutoff= 00312 lCutoff.second; 00313 00314 00315 //gMutex->lock();//debugging 00316 if(inQuery.child_list_begin()!=inQuery.child_list_end()){ 00317 CSelfDestroyPointer<CIDRelevanceLevelPairList> lFastQueryResult(fastQuery(inQuery, 00318 inNumberOfInterestingImages, 00319 inCutoff)); 00320 00321 #warning put time stamp here 00322 cout << "Assembling a query result tree " 00323 << endl; 00324 if(lFastQueryResult){ 00325 cout << "from a result of size" 00326 << lFastQueryResult->size() 00327 << endl; 00328 }else{ 00329 cout << "THERE IS NO RESULT" 00330 << (CIDRelevanceLevelPairList*)lFastQueryResult 00331 << endl; 00332 } 00333 #ifdef _TREE_BUILD_PRINTOUT 00334 #endif 00335 00336 CXMLElement* lReturnValue(new CXMLElement(mrml_const::query_result,0)); 00337 00338 00339 00340 CXMLElement* lReturnList(new CXMLElement(mrml_const::query_result_element_list,0)); 00341 lReturnValue->addChild(lReturnList); 00342 lReturnValue->moveUp(); 00343 assert(mAccessor); 00344 00345 if(lFastQueryResult && mAccessor){ 00346 for(CIDRelevanceLevelPairList::const_iterator i=lFastQueryResult->begin(); 00347 i!=lFastQueryResult->end(); 00348 i++){ 00349 00350 CXMLElement* lReturnElement(new CXMLElement(mrml_const::query_result_element, 00351 0)); 00352 { 00353 double lRelevanceLevel(i->getRelevanceLevel()); 00354 string lString(mrml_const::calculated_similarity); 00355 lReturnElement->addAttribute(lString, 00356 lRelevanceLevel); 00357 } 00358 00359 00360 00361 { 00362 string lURL(mAccessor->IDToAccessorElement(i->getID()).second.getURL()); 00363 00364 00365 string lString(mrml_const::image_location); 00366 00367 lReturnElement->addAttribute(lString, 00368 lURL); 00369 } 00370 00371 00372 { 00373 string lURL(mAccessor->IDToAccessorElement(i->getID()).second.getThumbnailURL()); 00374 00375 string lString(mrml_const::thumbnail_location); 00376 lReturnElement->addAttribute(lString, 00377 lURL); 00378 } 00379 00380 lReturnList->addChild(lReturnElement); 00381 00382 lReturnList->moveUp(); 00383 00384 } 00385 //gMutex->unlock();//debugging 00386 return lReturnValue; 00387 } 00388 }else{ 00389 //gMutex->unlock();//debugging 00390 return getRandomImages(inNumberOfInterestingImages); 00391 } 00392 00393 //gMutex->unlock();//debugging 00394 return 0; 00395 }
| virtual CIDRelevanceLevelPairList* CQuery::fastQuery | ( | const CXMLElement & | inQuery, | |
| int | inNumberOfInterestingImages, | |||
| double | inDifferenceToBest | |||
| ) | [pure virtual] |
a query which returns ID/RelevanceLevel pairs instead of instead of URL/RelevanceLevel pairs
Implemented in CQHierarchy, CQInvertedFile, CQMultiple, and CQParallel.
Referenced by CQMultiple::doFastQueryThread(), CQueryTreeNode::fastQuery(), and query().
| CXMLElement * CQuery::getRandomImages | ( | int | inNumberOfInterestingImages | ) | const [virtual] |
get some random images (handed through to accessor)
Reimplemented in CQParallel.
Definition at line 134 of file CQuery.cc.
References CXMLElement::addAttribute(), CXMLElement::addChild(), mrml_const::calculated_similarity, CAccessor::getRandomAccessorElements(), mrml_const::image_location, mAccessor, CXMLElement::moveUp(), mrml_const::query_result, mrml_const::query_result_element, mrml_const::query_result_element_list, and mrml_const::thumbnail_location.
Referenced by query(), and CQMultiple::query().
00134 { 00135 00136 cout << "Getting " << inNumberOfInterestingImages << " random images " 00137 << endl; 00138 00139 list<CAccessorElement> lURLList; 00140 00141 mAccessor->getRandomAccessorElements(lURLList, 00142 inNumberOfInterestingImages); 00143 00144 CXMLElement* lResultList=new CXMLElement(mrml_const::query_result_element_list, 00145 0); 00146 00147 for(list<CAccessorElement>::const_iterator i=lURLList.begin(); 00148 i!=lURLList.end(); 00149 i++){ 00150 00151 CXMLElement* lResultElement=new CXMLElement(mrml_const::query_result_element, 00152 0); 00153 00154 lResultElement->addAttribute(mrml_const::image_location, 00155 i->getURL()); 00156 lResultElement->addAttribute(mrml_const::thumbnail_location, 00157 i->getThumbnailURL()); 00158 lResultElement->addAttribute(mrml_const::calculated_similarity, 00159 double(1)); 00160 00161 lResultList->addChild(lResultElement); 00162 lResultList->moveUp(); 00163 } 00164 00165 CXMLElement* lReturnValue=new CXMLElement(mrml_const::query_result, 00166 0); 00167 lReturnValue->addChild(lResultList); 00168 00169 return lReturnValue; 00170 };
| CIDRelevanceLevelPairList * CQuery::getRandomIDs | ( | int | inNumberOfInterestingImages | ) | const [virtual] |
get some random images (handed through to accessor)
Definition at line 183 of file CQuery.cc.
References CAccessor::getRandomAccessorElements(), and mAccessor.
Referenced by CQInvertedFile::fastQuery().
00183 { 00184 list<CAccessorElement> lURLList; 00185 00186 mAccessor->getRandomAccessorElements(lURLList, 00187 inNumberOfInterestingImages); 00188 00189 CIDRelevanceLevelPairList* lReturnValue(new CIDRelevanceLevelPairList()); 00190 00191 for(list<CAccessorElement>::const_iterator i=lURLList.begin(); 00192 i!=lURLList.end(); 00193 i++){ 00194 lReturnValue->push_back(CIDRelevanceLevelPair(i->getID(),0)); 00195 } 00196 return lReturnValue; 00197 };
| list< TID > * CQuery::getAllIDs | ( | ) | const [virtual] |
get the IDs of all images (handed through to accessor)
Reimplemented in CQParallel.
Definition at line 214 of file CQuery.cc.
References CAccessor::getAllIDs(), and mAccessor.
00214 { 00215 list<TID>* lIDList=new list<TID>(); 00216 00217 mAccessor->getAllIDs(*lIDList); 00218 00219 return lIDList; 00220 };
| list< CAccessorElement > * CQuery::getAllAccessorElements | ( | ) | const [virtual] |
get the IDs of all images (handed through to accessor)
Definition at line 236 of file CQuery.cc.
References CAccessor::getAllAccessorElements(), and mAccessor.
00236 { 00237 list<CAccessorElement>* lURLList=new list<CAccessorElement>(); 00238 00239 mAccessor->getAllAccessorElements(*lURLList); 00240 00241 return lURLList; 00242 };
| bool CQuery::setAlgorithm | ( | CAlgorithm & | inAlgorithm | ) | [virtual] |
set the Algorithm. set a new algorithm. Build a new query if necessary.
Reimplemented in CQHierarchy, CQInvertedFile, CQMultiple, and CQParallel.
Definition at line 256 of file CQuery.cc.
References mAlgorithm.
Referenced by CQMultiple::setAlgorithm(), CQInvertedFile::setAlgorithm(), and CQHierarchy::setAlgorithm().
00256 { 00257 mAlgorithm=&inAlgorithm; 00258 };
| const CAlgorithm & CQuery::getAlgorithm | ( | ) | const |
get the Algorithm. same scheme as in setCollection
Definition at line 271 of file CQuery.cc.
References mAlgorithm.
00271 { 00272 return *mAlgorithm; 00273 };
| void CQuery::finishInit | ( | ) | [virtual] |
it might be necessary to wait until all the children are added before ending the initialisation phase.
This function is called by CAlgorithm.
initialisation taking place when all children etc have been added
Reimplemented in CQInvertedFile, and CQParallel.
Definition at line 292 of file CQuery.cc.
00292 { 00293 // in the most general query nothing happens here 00294 // it is just a kind of container 00295 };
CAccessor* CQuery::mAccessor [protected] |
needed to translate URLs to IDs this is a pointer, only because we cannot change references it does not imply any destruction responsability
Definition at line 81 of file CQuery.h.
Referenced by CQInvertedFile::buildNormalizedQueryList(), CQInvertedFile::buildQueryHash(), CQHierarchy::CQHierarchy(), CQInvertedFile::CQInvertedFile(), CQMultiple::CQMultiple(), CQInvertedFile::DIDToScore(), CQMultiple::fastQuery(), CQInvertedFile::fastQuery(), CQHierarchy::fastQuery(), CQInvertedFile::finishInit(), getAllAccessorElements(), getAllIDs(), getRandomIDs(), getRandomImages(), CQInvertedFile::init(), CQInvertedFile::keepScore(), CQInvertedFile::keepScorePruning(), query(), CQMultiple::query(), CQMultiple::setAlgorithm(), CQInvertedFile::setAlgorithm(), CQHierarchy::setAlgorithm(), and CQInvertedFile::URLToScore().
CAccessorAdmin* CQuery::mAccessorAdmin [protected] |
This is where the the Accessor comes from. Also the AccessorAdmin is not to be deleted by this.
Definition at line 86 of file CQuery.h.
Referenced by CQHierarchy::CQHierarchy(), CQInvertedFile::CQInvertedFile(), CQMultiple::CQMultiple(), CQuery(), CQMultiple::setAlgorithm(), CQInvertedFile::setAlgorithm(), CQHierarchy::setAlgorithm(), and CQInvertedFile::~CQInvertedFile().
CAccessorAdminCollection* CQuery::mAccessorAdminCollection [protected] |
Where to get CAccessorAdmins from.
Reimplemented in CQParallel.
Definition at line 91 of file CQuery.h.
Referenced by CQuery(), CQMultiple::setAlgorithm(), CQInvertedFile::setAlgorithm(), and CQHierarchy::setAlgorithm().
CAlgorithm* CQuery::mAlgorithm [protected] |
the structure containing everything we know about the algorithm used do not destroy this
Definition at line 98 of file CQuery.h.
Referenced by CQInvertedFile::CQInvertedFile(), CQuery(), getAlgorithm(), CQInvertedFile::init(), setAlgorithm(), CQMultiple::setAlgorithm(), CQInvertedFile::setAlgorithm(), CQHierarchy::setAlgorithm(), and CQInvertedFile::~CQInvertedFile().
lCChildren CQuery::mChildren [protected] |
The children of this.
Definition at line 114 of file CQuery.h.
Referenced by addChild(), CQMultiple::fastQuery(), CQParallel::finishInit(), and CQMultiple::query().
1.5.6