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

virtual void Impala::Core::VideoSet::InterestPointProc::HandleDoneFile ( VideoSet vs,
int  fileId,
Stream::RgbDataSrc src 
) [inline, virtual]

Completed given DB_FILE in a "normal" walk.

Reimplemented from Impala::Core::VideoSet::Listener.

Definition at line 196 of file InterestPointProc.h.

References Impala::Util::IOBuffer::Available(), Impala::Core::Feature::InterestPointFeature::GetFeatureName(), Impala::Util::Database::GetInstance(), Impala::Util::Database::GetIOBuffer(), Impala::GetTmpPath(), ILOG_DEBUG, ILOG_ERROR, ILOG_INFO, ILOG_WARN, Impala::MakeString(), Impala::Core::Feature::InterestPointFeature::mClusterInput, Impala::Core::Feature::InterestPointFeature::mClusterInputData, Impala::Core::Feature::InterestPointFeature::mFeatureDefinition, mFeatureTables, mInterestPointFeature, mNoZIP, mSkipThisVideo, mTableInfoString, mTemporaryFilenames, mWalkType, Impala::PathJoin(), Impala::Util::IOBuffer::Read(), Impala::StringReplace(), Impala::Util::IOBuffer::Write(), and Impala::Core::Table::Write().

00197     {
00198         if(mSkipThisVideo) return;
00199         // Feature table logic
00200         String tableName = vs->GetFilePathFeatureData(mWalkType, mInterestPointFeature.mFeatureDefinition, fileId, false, -1, true, false);
00201         if(mFeatureTables.size() != 0) {
00202             for(int i = 0; i < mFeatureTables.size(); i++) {
00203                 Feature::FeatureDefinition tempDef(mInterestPointFeature.mFeatureDefinition.AsString());
00204                 if(i != 0) tempDef.AddParameter("sub", MakeString(i));
00205                 String tempTableName = vs->GetFilePathFeatureData(mWalkType, tempDef, fileId, false, -1, true, false);
00206                 mFeatureTables[i]->SetInfo(mTableInfoString);
00207                 Write(mFeatureTables[i], tempTableName, vs->GetDatabase(), true);
00208                 delete mFeatureTables[i];
00209                 mFeatureTables[i] = 0;
00210             }
00211             mFeatureTables.clear();
00212         }
00213         
00214         // ZIP-file logic
00215         if(!mNoZIP) {
00216             String serverPath = vs->GetFilePathFeatureData(mWalkType, mInterestPointFeature.GetFeatureName(), fileId, false, -1, true, false);
00217             String fName = PathJoin(GetTmpPath(), "tmp-" + mInterestPointFeature.GetFeatureName() + "-" + MakeString(fileId) + ".zip");
00218             String txtName = StringReplace(fName, ".zip", ".txt");
00219             String serverName = serverPath + ".zip";
00220 
00221             ILOG_DEBUG("fName:      " << fName);
00222             ILOG_DEBUG("txtName:    " << txtName);
00223             ILOG_DEBUG("serverName: " << serverName);
00224             if (fName == String("")) {
00225                 ILOG_ERROR("Empty file name");
00226             }
00227             
00228             // put it all in fName
00229             std::ofstream fs(txtName.c_str());
00230             for(std::vector<String>::iterator iter = mTemporaryFilenames.begin(); iter != mTemporaryFilenames.end(); iter++) {
00231                 fs << (*iter) << std::endl;
00232             }
00233             fs.close();
00234             
00235             String cmd = "zip ";
00236             cmd += fName;
00237             cmd += " -@ <";
00238             cmd += txtName;
00239             //TODO: call toZip.py here? Instead of Shell scripting?
00240             if (fName != String("")) {
00241                 // without override, fName will be empty if zip file already exists, so we cannot ZIP!
00242                 system(cmd.c_str());
00243             }
00244             
00245             // cleanup
00246             if(std::remove(txtName.c_str()) != 0) {
00247                 ILOG_WARN("Could not cleanup intermediate file: " << txtName);
00248             }
00249             
00250             // copy ZIP file to its final destination
00251             Util::IOBuffer* zip = new Util::IOBufferFile(fName, true, false);
00252             Impala::Util::Database& database(Impala::Util::Database::GetInstance());
00253             Util::IOBuffer* destination = database.GetIOBuffer(serverName, false, false, "tmp", 0, true);
00254             ILOG_INFO("ZIP file to copy to dataserver has " << zip->Available() << " bytes");
00255             static const int bufSize = 1024 * 1024;
00256             static unsigned char buffer[bufSize];
00257             while(true) {
00258                 int bytesread = zip->Read(buffer, bufSize);
00259                 if(bytesread == 0) break;
00260                 destination->Write(buffer, bytesread);
00261             }
00262             delete zip;
00263             delete destination;      // this will force a write through a channel, if needed
00264 
00265             // cleanup
00266             if(std::remove(fName.c_str()) != 0) {
00267                 ILOG_WARN("Could not cleanup temporary ZIP file: " << fName);
00268             }
00269         }
00270 
00271         // clusterInput mode
00272         if(mInterestPointFeature.mClusterInput && mInterestPointFeature.mClusterInputData)
00273         {
00274             String tableName = vs->GetFilePathFeatureData(mWalkType, mInterestPointFeature.mClusterInputData->GetFeatureDefinition(), fileId, false, -1, true, false);
00275             Write(mInterestPointFeature.mClusterInputData, tableName, vs->GetDatabase(), true);
00276             delete mInterestPointFeature.mClusterInputData;
00277             mInterestPointFeature.mClusterInputData = 0;
00278         }
00279         
00280         // cleanup
00281         for(std::vector<String>::iterator iter = mTemporaryFilenames.begin(); iter != mTemporaryFilenames.end(); iter++) {
00282             if(std::remove((*iter).c_str()) != 0) {
00283                 ILOG_WARN("Could not cleanup intermediate file: " << (*iter));
00284             }
00285         }
00286         mTemporaryFilenames.clear();
00287 
00288         ILOG_INFO("HandleDoneFile: " << fileId);
00289     }

Here is the call graph for this function:


Generated on Fri Mar 19 11:29:54 2010 for ImpalaSrc by  doxygen 1.5.1