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

void Impala::Samples::MonetTest::DoInsertFeatures ( Connection *  conn  ) 

Definition at line 1025 of file mainMonetTest.cpp.

References Impala::Util::Bin2Hex(), 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::CmdOptions::GetArg(), Impala::Core::Vector::VectorTem< ElemT >::GetData(), Impala::Core::Database::RawDataSet::GetDatabase(), Impala::Core::Database::RawDataSet::GetFilePathFeatureData(), Impala::CmdOptions::GetInstance(), Impala::CmdOptions::GetInt(), Impala::CmdOptions::GetNrArg(), Impala::Core::VideoSet::VideoSet::GetQuidVideo(), Impala::Core::Database::RawDataSet::GetSetNameBase(), ILOG_ERROR, ILOG_INFO, ILOG_NDC_POP, ILOG_NDC_PUSH, ILOG_VAR, Impala::Core::Feature::FeatureTable::MakeFromFile(), Impala::MakeString(), Impala::Core::VideoSet::MakeVideoSet(), Impala::Core::Database::RawDataSet::NrFiles(), Impala::QUID_CLASS_FRAME, Impala::QuidClass(), Impala::QuidId(), Impala::Core::Vector::VectorTem< ElemT >::Size(), Impala::Core::Table::Table::Size(), and Impala::Timer::SplitTime().

Referenced by mainMonetTest().

01026 {
01027     ILOG_VAR(Impala.Samples.MonetTest.DoInsertFeatures);
01028     CmdOptions& options = CmdOptions::GetInstance();
01029     if (options.GetNrArg() < 6)
01030     {
01031         ILOG_ERROR("Need more parameters");
01032         return;
01033     }
01034 
01035     String vidSetName = options.GetArg(4);
01036     VideoSet* vidSet = Core::VideoSet::MakeVideoSet(vidSetName);
01037     FeatureDefinition def(options.GetArg(5));
01038 
01039     String q = "select i_add_feature('" + def.AsString() + "');";
01040     conn->Query(q, false, false);
01041 
01042     int startFile = options.GetInt("startFile");
01043     for (int v=startFile ; v<vidSet->NrFiles() ; v++)
01044     {
01045         String fName = vidSet->GetFilePathFeatureData("Frames", def, v, false,
01046                                                       -1, false, false);
01047         if (fName.empty())
01048         {
01049             ILOG_ERROR("Unable to find " << def.AsString());
01050             continue;
01051         }
01052         FeatureTable* tab =
01053             Core::Feature::FeatureTable::MakeFromFile(def, fName,
01054                                                       vidSet->GetDatabase());
01055         ILOG_INFO("vid " << v << " has " << tab->Size() << " vectors");
01056         ILOG_NDC_PUSH("v=" << v);
01057         Quid vidQuid = vidSet->GetQuidVideo(v, true);
01058 
01059         conn->Query("delete from i_bulk_feature_vector;", false, false);
01060         int totalSize = tab->Size();
01061         int bulkSize = 2000;
01062         Timer timer;
01063         for (int i=0 ; i<totalSize ; i+=bulkSize)
01064         {
01065             int left = totalSize - i;
01066             int nr = (left > bulkSize) ? bulkSize : left;
01067             String q = "copy " + MakeString(nr) +
01068                 " records into i_bulk_feature_vector from stdin" +
01069                 " using delimiters ' ';\n";
01070             for (int j=i ; j<i+nr ; j++)
01071             {
01072                 Quid frameQuid = tab->Get1(j);
01073                 if (QuidClass(frameQuid) != QUID_CLASS_FRAME)
01074                     ILOG_ERROR("Quid is not a frame");
01075                 int frameNr = QuidId(frameQuid);
01076                 FeatureTable::VectorReal64 v = tab->Get2(j);
01077                 size_t dataSize = v.Size() * sizeof(Real64);
01078                 UInt8* data = (UInt8*) v.GetData();
01079                 String hexData = Util::Bin2Hex(data, dataSize);
01080 
01081                 q += MakeString(vidQuid) + " " + MakeString(frameNr) + " "
01082                     + hexData + "\n";
01083             }
01084             conn->Query(q, false, false);
01085             ILOG_INFO("Did bulk " << i << " at " << timer.SplitTime());
01086 
01087             String vidSetBase = vidSet->GetSetNameBase();
01088             conn->Query("insert into feature_vector (fragment_id, file_id, \
01089                                                      feature_id, vector) \
01090                          select fr.fragment_id, f.file_id, fe.feature_id, \
01091                                 bfv.vector \
01092                          from i_bulk_feature_vector bfv, file f, \
01093                               fragment fr, feature fe \
01094                          where bfv.quid = f.quid and \
01095                                f.media_id = fr.media_id and \
01096                                fr.fragment_start = bfv.fragment_start and \
01097                                fr.fragment_length = 1 and \
01098                                fr.keyframe = false and \
01099                                fe.feature_name = '" + def.AsString() + "' \
01100                          order by bfv.fragment_start;", false, false);
01101             ILOG_INFO("Did insert select at " << timer.SplitTime());
01102             conn->Query("delete from i_bulk_feature_vector;", false, false);
01103         }
01104         delete tab;
01105         ILOG_NDC_POP;
01106     }
01107     delete vidSet;
01108 }

Here is the call graph for this function:


Generated on Fri Mar 19 11:38:28 2010 for ImpalaSrc by  doxygen 1.5.1