Definition at line 197 of file IDashQueryEngine.h. References Impala::Core::Table::TableTem< Col1T, Col2T, Col3T, Col4T, Col5T, Col6T, Col7T, Col8T, Col9T >::Add(), Impala::Core::Table::TableTem< Col1T, Col2T, Col3T, Col4T, Col5T, Col6T, Col7T, Col8T, Col9T >::Get1(), Impala::Core::Table::TableTem< Col1T, Col2T, Col3T, Col4T, Col5T, Col6T, Col7T, Col8T, Col9T >::Get2(), Impala::Core::Table::Table::Size(), and Impala::Core::Table::Sort(). Referenced by MergeResults(). 00198 { 00199 ShotResultList merged; 00200 std::map<int, double> fusionvalue; 00201 std::map<int, double> weights; 00202 00203 // note: 00204 // using fixed N = 1000 here, because of unequal list lengths. 00205 // We assume the number of shots required (for trecvid) = max. 1000. 00206 int N = 1000; 00207 00208 // phase 1: assign equal weights to all lists 00209 // upgrade: assign unequal weights. :-) 00210 int listidx = 0; 00211 std::list<ShotResultList >::iterator i; 00212 for (i = lists.begin(); i != lists.end(); i++) 00213 weights[listidx++] = 1.0 / (double)lists.size(); 00214 00215 // phase 2: itterate through all shots from all lists, 00216 // and increment fusionvalue 00217 listidx = 0; 00218 for (i = lists.begin(); i != lists.end(); i++) { 00219 00220 double weight = weights[listidx++]; 00221 int rank = 0; 00222 for (ShotResultList::iterator j = i->begin(); j != i->end(); j++) 00223 { 00224 int shotid = (*j).shotid; 00225 double weightedbordacc = weight * (double)(N - rank++); 00226 if (fusionvalue.find(shotid) == fusionvalue.end()) 00227 fusionvalue[shotid] = weightedbordacc; 00228 else 00229 fusionvalue[shotid] = fusionvalue[shotid] + weightedbordacc; 00230 } 00231 } 00232 00233 // phase 3: sort by highest fusionvalues, return top N 00234 // note: all this std::map//list//Core::Table swapping might be a 00235 // wee bit expensive.... 00236 ShotWithWeight* sww = new ShotWithWeight(fusionvalue.size()); 00237 std::map<int, double>::iterator mapIt; 00238 for (mapIt = fusionvalue.begin(); mapIt != fusionvalue.end(); mapIt++) 00239 sww->Add(mapIt->first, mapIt->second); 00240 00241 double maxscore = sww->Get2(sww->Size() - 1); 00242 int rank = 1; 00243 //Table::Sort(sww, 2); // sort on weights 00244 Table::Sort(sww, 2, true); // ascending 00245 for (int i=sww->Size()-1; i>=0; i--) 00246 { 00247 ShotResult t; 00248 t.shotid = sww->Get1(i); 00249 t.score = sww->Get2(i) / maxscore; 00250 t.rank = rank++; 00251 merged.push_back(t); 00252 } 00253 return merged; 00254 }
Here is the call graph for this function:
|