Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

void Impala::Persistency::FeatureTableRepositoryInMonet::Add ( const FeatureLocator loc,
FeatureTable tab 
) [inline]

Definition at line 101 of file FeatureTableRepositoryInMonet.h.

References Impala::Util::Bin2Hex(), Impala::FileNameBase(), 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::Persistency::RepositoryInMonetDB::GetConnection(), Impala::Persistency::FeatureLocator::GetContainer(), Impala::Core::Vector::VectorTem< ElemT >::GetData(), Impala::Persistency::Locator::GetDataSet(), Impala::Persistency::FeatureLocator::GetFeatureString(), Impala::Persistency::FeatureLocator::GetIsIndex(), Impala::Persistency::FeatureLocator::GetWalkType(), ILOG_ERROR, ILOG_INFO, Impala::MakeString(), Impala::QUID_CLASS_FRAME, Impala::QuidClass(), Impala::QuidId(), RepMonet(), Impala::Core::Vector::VectorTem< ElemT >::Size(), Impala::Core::Table::Table::Size(), and Impala::Timer::SplitTime().

00102     {
00103         if (loc.GetIsIndex())
00104         {
00105             ILOG_ERROR("Index not implemented (yet)");
00106             return;
00107         }
00108         if (loc.GetWalkType() != "Frames")
00109         {
00110             ILOG_ERROR("Only implemented for Frames");
00111             return;
00112         }
00113 
00114         Connection* conn = RepMonet().GetConnection(loc);
00115 
00116         String vidSetBase = FileNameBase(loc.GetDataSet());
00117         Core::VideoSet::VideoSet* vidSet = VideoSetRepository().Get(loc);
00118         int fileIdx = vidSet->GetFileId(loc.GetContainer());
00119         Quid vidQuid = vidSet->GetQuidVideo(fileIdx, true);
00120 
00121         String q = "select i_add_feature('" + loc.GetFeatureString() + "');";
00122         conn->Query(q, false, false);
00123 
00124         conn->Query("delete from i_bulk_feature_vector;", false, false);
00125         int totalSize = tab->Size();
00126         int bulkSize = 2000;
00127         Timer timer;
00128         for (int i=0 ; i<totalSize ; i+=bulkSize)
00129         {
00130             int left = totalSize - i;
00131             int nr = (left > bulkSize) ? bulkSize : left;
00132             String q = "copy " + MakeString(nr) +
00133                 " records into i_bulk_feature_vector from stdin" +
00134                 " using delimiters ' ';\n";
00135             for (int j=i ; j<i+nr ; j++)
00136             {
00137                 Quid frameQuid = tab->Get1(j);
00138                 if (QuidClass(frameQuid) != QUID_CLASS_FRAME)
00139                     ILOG_ERROR("Quid is not a frame");
00140                 int frameNr = QuidId(frameQuid);
00141                 FeatureTable::VectorReal64 v = tab->Get2(j);
00142                 size_t dataSize = v.Size() * sizeof(Real64);
00143                 UInt8* data = (UInt8*) v.GetData();
00144                 String hexData = Util::Bin2Hex(data, dataSize);
00145 
00146                 q += MakeString(vidQuid) + " " + MakeString(frameNr) + " "
00147                     + hexData + "\n";
00148             }
00149             conn->Query(q, false, false);
00150             ILOG_INFO("Did bulk " << i << " at " << timer.SplitTime());
00151 
00152             conn->Query("insert into feature_vector (fragment_id, file_id, \
00153                                                      feature_id, vector) \
00154                          select fr.fragment_id, f.file_id, fe.feature_id, \
00155                                 bfv.vector \
00156                          from i_bulk_feature_vector bfv, file f, \
00157                               fragment fr, feature fe \
00158                          where bfv.quid = f.quid and \
00159                                f.media_id = fr.media_id and \
00160                                fr.fragment_start = bfv.fragment_start and \
00161                                fr.fragment_length = 1 and \
00162                                fr.keyframe = false and \
00163                                fe.feature_name = '" + loc.GetFeatureString() + "' \
00164                          order by bfv.fragment_start;", false, false);
00165             ILOG_INFO("Did insert select at " << timer.SplitTime());
00166             conn->Query("delete from i_bulk_feature_vector;", false, false);
00167         }
00168     }

Here is the call graph for this function:


Generated on Fri Mar 19 11:34:56 2010 for ImpalaSrc by  doxygen 1.5.1