int main(int argc, char *argv[]) { int i; char *version, *cmd; Args *args; FILE *fp; cmd = (char *)emalloc(256 * sizeof(char)); version = VERSION; setprogname2("asp"); args = getArgs(argc, argv); if (args->v) printSplash(version); if (args->h || args->e) printUsage(version); if (args->numInputFiles == 0) { fp = stdin; scanFile(fp, args); } else { for (i = 0; i < args->numInputFiles; i++) { sprintf(cmd, "sort -k 2 %s", args->inputFiles[i]); fp = popen(cmd, "r"); scanFile(fp, args); pclose(fp); } } tabReset(); freeArgs(args); free(progname()); free(cmd); return 0; }
int main(int argc, char *argv[]){ int i; char *version; Args *args; FILE *fp; version = "0.3"; setprogname2("inspectPro"); args = getArgs(argc, argv); if(args->v) printSplash(version); if(args->h || args->e) printUsage(version); if(args->numInputFiles == 0){ fp = stdin; scanFile(fp, args); }else{ for(i=0;i<args->numInputFiles;i++){ fp = efopen(args->inputFiles[i],"rb"); scanFile(fp, args); fclose(fp); } } free(args); free(progname()); return 0; }
void MergeLineSection::mergeLine( WCPtrOrderedVector<MergeFile>& files ) //---------------------------------------------------------------------- { uint_8 i; uint_32 * drSizes; uint_32 totLen = 0; for( i = 0; i < files.entries(); i += 1 ){ drSizes = files[ i ]->getDRSizes(); scanFile( files[ i ], i, drSizes[ DR_DEBUG_LINE ] ); #if INSTRUMENTS Log.printf( " File %s - %ld bytes\n", files[i]->getFileName(), drSizes[ DR_DEBUG_LINE ] ); totLen += drSizes[ DR_DEBUG_LINE ]; #endif } #if INSTRUMENTS Log.printf( " %d files, %ld bytes\n", i, totLen ); #endif _outFile->startWriteSect( DR_DEBUG_LINE ); writePrologue(); _outFile->endWriteSect(); }
//??? void Photos::openFiles() { QString path = QFileDialog::getOpenFileName(this,"","/","*.*"); if( "" != path) { position = 0; imageList.clear(); imagePath = path; //"/"??????stringList QStringList stringList = imagePath.split("/"); //?????и stringList.removeLast(); dirPath = stringList.join("/"); setPixmap(imagePath); //?? enableButton(); //? scanFile(dirPath); //? ui->label->setVisible(false); } }
//==============================External SP Case=============================== TimedTextASSSource::TimedTextASSSource(const sp<DataSource>& dataSource) : mExSource(dataSource), mExMetaData(new MetaData), mExIndex(0) { mASSFlag = TextDescriptions::OUT_OF_BAND_TEXT_ASS; #ifdef SELF_TEST scanFile(); int64_t startTimeUs = 0; int64_t endTimeUs = 0; Parcel parcel; MediaSource::ReadOptions options; status_t err =OK; int len =7; int st[] = {888, 18111, 22000, 28888, 38000, 54800, 76000}; //ms for(int i =0; i< len; i++){ int64_t temp = st[i] * 1000ll; //us options.setSeekTo(temp); err = read(&startTimeUs, &endTimeUs, &parcel, &options); ALOGE("[--SELF_TEST--] seekTime=%lld, getStartTime=%lld, getEndTime=%lld, isReadSuccessfully:%d", temp, startTimeUs, endTimeUs, err); } #endif }
status_t TimedTextSRTSource::start() { status_t err = scanFile(); if (err != OK) { reset(); } return err; }
void MergeRefSection::mergeRefs( WCPtrOrderedVector<MergeFile>& files ) //--------------------------------------------------------------------- { uint_8 i; uint_32 * drSizes; uint_32 totLen = 0; uint_32 offset; RefLineCol lnCol; _outFile->startWriteSect( DR_DEBUG_REF ); _outFile->writeDWord( 1 ); // reserve a dword for length for( i = 0; i < files.entries(); i += 1 ) { drSizes = files[ i ]->getDRSizes(); #if INSTRUMENTS Log.printf( " File %s - %ld bytes\n", files[i]->getFileName(), drSizes[ DR_DEBUG_REF ] ); totLen += drSizes[ DR_DEBUG_REF ]; #endif scanFile( files[ i ], i, lnCol ); } offset = _outFile->tell( DR_DEBUG_REF ); _outFile->seek( DR_DEBUG_REF, 0 ); _outFile->writeDWord( offset - sizeof(uint_32) ); #if INSTRUMENTS Log.printf( " %d files, %ld bytes\n", i, totLen ); #endif _outFile->endWriteSect(); }
//*********************************************************** //* This is the main entry point for an import. It is passed //* the file which contains the export data. It then //* opens up the file, checks the validity of the data, and //* then begins to parse through all of the crap. //*********************************************************** void BatchImport::import(QString file) { fileName = file; errorMessage = ""; lastError = 0; QFile xmlFile(fileName); QFile scanFile(fileName); if (!xmlFile.open(QIODevice::ReadOnly) || !scanFile.open(QIODevice::ReadOnly)) { lastError = 16; errorMessage = "Cannot open file."; return; } reader = new QXmlStreamReader(&xmlFile); while (!reader->atEnd()) { reader->readNext(); QLOG_DEBUG() << reader->name().toString(); if (reader->hasError()) { errorMessage = reader->errorString(); QLOG_ERROR() << "************************* ERROR READING BACKUP " << errorMessage; lastError = 16; return; } if (reader->name().toString().toLower() == "noteadd" && reader->isStartElement()) { addNoteNode(); } } xmlFile.close(); }
TimedTextSUBSource::TimedTextSUBSource(const sp<DataSource>& dataSource) : mSource(dataSource), mMetaData(new MetaData), mIndex(0), mFrameRate(TimedTextUtil::DEFAULT_FRAME_RATE){ mFileEncodeType = ENCODE_TYPE_NORMAL; #ifdef SELF_TEST scanFile(); int64_t startTimeUs = 0; int64_t endTimeUs = 0; Parcel parcel; MediaSource::ReadOptions options; status_t err =OK; int len =7; int st[] = {888, 18111, 22000, 28888, 38000, 54800, 76000}; //ms for(int i =0; i< len; i++){ int64_t temp = st[i] * 1000ll; //us options.setSeekTo(temp); err = read(&startTimeUs, &endTimeUs, &parcel, &options); ALOGE("[--SELF_TEST--] seekTime=%lld, getStartTime=%lld, getEndTime=%lld, isReadSuccessfully:%d", temp, startTimeUs, endTimeUs, err); } #endif }
TimedTextSRTSource::TimedTextSRTSource(const sp<DataSource>& dataSource) : mSource(dataSource), mMetaData(new MetaData), mIndex(0) { #ifdef MTK_SUBTITLE_SUPPORT mFileEncodeType = ENCODE_TYPE_NORMAL; #endif #ifdef SELF_TEST scanFile(); int64_t startTimeUs = 0; int64_t endTimeUs = 0; Parcel parcel; MediaSource::ReadOptions options; status_t err =OK; int len =7; int st[] = {888, 18111, 22000, 28888, 38000, 54800, 76000}; //ms for(int i =0; i< len; i++){ int64_t temp = st[i] * 1000ll; //us options.setSeekTo(temp); err = read(&startTimeUs, &endTimeUs, &parcel, &options); ALOGE("[--SELF_TEST--] seekTime=%lld, getStartTime=%lld, getEndTime=%lld, isReadSuccessfully:%d", temp, startTimeUs, endTimeUs, err); } #endif // TODO: Need to detect the language, because SRT doesn't give language // information explicitly. mMetaData->setCString(kKeyMediaLanguage, "und"); }
int main( int argc, char *argv[] ) { readFile(); //clear_token_buffer(); scanFile(); //createBeamer(); }
status_t TimedTextASSSource::ex_start() { status_t err = scanFile(); if (err != OK) { ex_reset(); } // information explicitly. mExMetaData->setCString(kKeyMediaLanguage, ""); return OK; }
void VRMLFile::scanStandardPrototypes(const Char8 *szFilename) { #ifdef OSG_DEBUG_VRML VRMLNodeHelper::resetIndent(); #endif preStandardProtos(); scanFile(szFilename); postStandardProtos(); }
status_t TimedTextSRTSource::start() { status_t err = scanFile(); if (err != OK) { reset(); } // TODO: Need to detect the language, because SRT doesn't give language // information explicitly. mMetaData->setCString(kKeyMediaLanguage, ""); return err; }
void ImageScanner::newFile(int albumId) { loadFromDisk(); addImage(albumId); if (!scanFromIdenticalFile()) { scanFile(NewScan); } }
void parseConfigFile(Options& opts, const string& filename) { ifstream cfgstream(filename.c_str(), ifstream::in); if (!cfgstream) { cerr << "Failed to open config file: `" << filename << "'" << endl; exit(EXIT_FAILURE); } scanFile(opts, cfgstream); }
void ImageScanner::copiedFrom(int albumId, qlonglong srcId) { loadFromDisk(); addImage(albumId); // first use source, if it exists if (!copyFromSource(srcId)) // check if we can establish identity if (!scanFromIdenticalFile()) // scan newly { scanFile(NewScan); } }
int main(int argc, char** argv) { int err, strSize, wordsSize, symSize; char** file; FILE* in; int i; int j = 0; if(argc != 2) { perror("Bad arguments\n"); exit(1); } in = fopen(argv[1], "r"); file = scanFile(in, &err, &strSize, &wordsSize, &symSize); if(err == 3) { perror("Bad alloc\n"); freeFile(in, file, strSize); exit(3); } if(err == 4) { perror("Bad input file\n"); freeFile(in, file, strSize); exit(4); } if(err == 5) { perror("Bad file format\n"); freeFile(in, file, strSize); exit(5); } printf("Number of strings: %d\nNumber of words: %d\nNumber of symbols: %d\n", strSize, wordsSize, symSize + strSize); sort(file, strSize); for(i = 0; i < strSize; ++i) { j = 0; while(file[i][j] != '\n') { printf("%c", file[i][j]); ++j; } printf("\n"); } freeFile(in, file, strSize); return 0; }
// default implementation of scanMemory, which defers to scanFile. int CSPlugin::scanMemory(HTTPHeader * requestheader, HTTPHeader * docheader, const char *user, int filtergroup, const char *ip, const char *object, unsigned int objectsize) { // there is no capability to scan memory with some AV as we pass it // a file name to scan. So we save the memory to disk and pass that. // Then delete the temp file. String tempfilepath; if (writeMemoryTempFile(object, objectsize, &tempfilepath) != DGCS_OK) { #ifdef DGDEBUG std::cerr << "Error creating/writing temp file for scanMemory." << std::endl; #endif syslog(LOG_ERR, "%s", "Error creating/writing temp file for scanMemory."); return DGCS_SCANERROR; } int rc = scanFile(requestheader, docheader, user, filtergroup, ip, tempfilepath.toCharArray()); #ifndef DGDEBUG unlink(tempfilepath.toCharArray()); // delete temp file #endif return rc; }
void ScriptExtender::setup(){ QStringList paths; paths << QString(QFileInfo( QCoreApplication::arguments().at(0) ).absolutePath ()) + "/scripts/"; paths << QString(QDir::homePath ())+ "/.lumina/scripts/"; for(int p = 0; p < paths.size(); p++){ QDir dir(paths.at(p)); dir.setFilter( QDir::Files | QDir::NoSymLinks ); dir.setSorting( QDir::Size | QDir::Reversed ); QFileInfoList list = dir.entryInfoList(); for (int i = 0; i < list.size(); ++i) { QFileInfo fileInfo = list.at(i); if (fileInfo.suffix()=="js"){ scanFile(QString(paths.at(p)).append(fileInfo.fileName())); } } } }
mpgDecoder::mpgDecoder(FILE* File, QObject *parent ) : fileDecoder(File, parent ) { // use QFile as input Buffer, which is needed by libMad, cause it cannot detect EOF.... madFile = new QFile(); madFile->open(fHandle, QIODevice::ReadOnly); // current position timer needs to be initialized first as its set in scanFile() endPositionTimer = new mad_timer_t; scanFile(); #ifdef HAVE_MAD // Allocate Memory for the MAD decoder Library madStream = new mad_stream; madFrame = new mad_frame; madSynth = new mad_synth; currentPositionTimer = new mad_timer_t; mad_inputBuffer = new unsigned char[163840+MAD_BUFFER_GUARD]; memset(mad_inputBuffer,0 , 163840+MAD_BUFFER_GUARD); // Initiate libMad structs mad_stream_init( madStream ); mad_frame_init( madFrame ); mad_synth_init( madSynth ); mad_timer_reset( currentPositionTimer ); #endif //allocate decoder output ringbuffers mad_outputBuffer = new soundRingBuffer[2]; mad_outputBuffer[0].setName("mad_output1"); mad_outputBuffer[1].setName("mad_output2"); returnBuffer = new float*[2]; returnBuffer[0] = new float[8192]; returnBuffer[1] = new float[8192]; memset(returnBuffer[0], 0, 8192*sizeof(float)); memset(returnBuffer[1], 0, 8192*sizeof(float)); frameCounter=0; }
QgsDelimitedTextProvider::QgsDelimitedTextProvider( QString uri ) : QgsVectorDataProvider( uri ) , mLayerValid( false ) , mValid( false ) , mFile( 0 ) , mGeomRep( GeomNone ) , mFieldCount( 0 ) , mXFieldIndex( -1 ) , mYFieldIndex( -1 ) , mWktFieldIndex( -1 ) , mWktHasZM( false ) , mWktHasPrefix( false ) , mXyDms( false ) , mSubsetString( "" ) , mSubsetExpression( 0 ) , mBuildSubsetIndex( true ) , mUseSubsetIndex( false ) , mMaxInvalidLines( 50 ) , mShowInvalidLines( true ) , mRescanRequired( false ) , mCrs() , mWkbType( QGis::WKBNoGeometry ) , mGeometryType( QGis::UnknownGeometry ) , mBuildSpatialIndex( false ) , mSpatialIndex( 0 ) { // Add supported types to enable creating expression fields in field calculator mNativeTypes << QgsVectorDataProvider::NativeType( tr( "Whole number (integer)" ), "integer", QVariant::Int, 0, 10 ) << QgsVectorDataProvider::NativeType( tr( "Whole number (integer - 64 bit)" ), "int8", QVariant::LongLong ) << QgsVectorDataProvider::NativeType( tr( "Decimal number (double)" ), "double precision", QVariant::Double, -1, -1, -1, -1 ) << QgsVectorDataProvider::NativeType( tr( "Text, unlimited length (text)" ), "text", QVariant::String, -1, -1, -1, -1 ) ; QgsDebugMsg( "Delimited text file uri is " + uri ); QUrl url = QUrl::fromEncoded( uri.toAscii() ); mFile = new QgsDelimitedTextFile(); mFile->setFromUrl( url ); QString subset; if ( url.hasQueryItem( "geomType" ) ) { QString gtype = url.queryItemValue( "geomType" ).toLower(); if ( gtype == "point" ) mGeometryType = QGis::Point; else if ( gtype == "line" ) mGeometryType = QGis::Line; else if ( gtype == "polygon" ) mGeometryType = QGis::Polygon; else if ( gtype == "none " ) mGeometryType = QGis::NoGeometry; } if ( mGeometryType != QGis::NoGeometry ) { if ( url.hasQueryItem( "wktField" ) ) { mWktFieldName = url.queryItemValue( "wktField" ); mGeomRep = GeomAsWkt; QgsDebugMsg( "wktField is: " + mWktFieldName ); } else if ( url.hasQueryItem( "xField" ) && url.hasQueryItem( "yField" ) ) { mGeomRep = GeomAsXy; mGeometryType = QGis::Point; mXFieldName = url.queryItemValue( "xField" ); mYFieldName = url.queryItemValue( "yField" ); QgsDebugMsg( "xField is: " + mXFieldName ); QgsDebugMsg( "yField is: " + mYFieldName ); if ( url.hasQueryItem( "xyDms" ) ) { mXyDms = ! url.queryItemValue( "xyDms" ).toLower().startsWith( "n" ); } } else { mGeometryType = QGis::NoGeometry; } } if ( url.hasQueryItem( "decimalPoint" ) ) mDecimalPoint = url.queryItemValue( "decimalPoint" ); if ( url.hasQueryItem( "crs" ) ) mCrs.createFromString( url.queryItemValue( "crs" ) ); if ( url.hasQueryItem( "subsetIndex" ) ) { mBuildSubsetIndex = ! url.queryItemValue( "subsetIndex" ).toLower().startsWith( "n" ); } if ( url.hasQueryItem( "spatialIndex" ) ) { mBuildSpatialIndex = ! url.queryItemValue( "spatialIndex" ).toLower().startsWith( "n" ); } if ( url.hasQueryItem( "subset" ) ) { subset = url.queryItemValue( "subset" ); QgsDebugMsg( "subset is: " + subset ); } if ( url.hasQueryItem( "quiet" ) ) mShowInvalidLines = false; // Do an initial scan of the file to determine field names, types, // geometry type (for Wkt), extents, etc. Parameter value subset.isEmpty() // avoid redundant building indexes if we will be building a subset string, // in which case indexes will be rebuilt. scanFile( subset.isEmpty() ); if ( ! subset.isEmpty() ) { setSubsetString( subset ); } }
//*********************************************************** //* This is the main entry point for an import. It is passed //* the file which contains the export data. It then //* opens up the file, checks the validity of the data, and //* then begins to parse through all of the crap. //*********************************************************** void ImportData::import(QString file) { fileName = file; errorMessage = ""; lastError = 0; QFile xmlFile(fileName); QFile scanFile(fileName); if (!xmlFile.open(QIODevice::ReadOnly) || !scanFile.open(QIODevice::ReadOnly)) { lastError = 16; errorMessage = "Cannot open file."; return; } QTextStream *countReader = new QTextStream(&scanFile); int recCnt = 0; QMessageBox mb; mb.setWindowTitle(tr("Scanning File")); mb.setText(QString::number(recCnt) + tr(" notes found.")); QPushButton *cancelButton = mb.addButton(QMessageBox::Cancel); connect(cancelButton, SIGNAL(clicked()), this, SLOT(cancel())); mb.show(); QCoreApplication::processEvents(); while (!countReader->atEnd() && !stopNow) { QString line = countReader->readLine(); if (line.contains("<note>", Qt::CaseInsensitive)) { recCnt++; mb.setText(QString::number(recCnt) + tr(" notes found.")); QCoreApplication::processEvents(); } } notebookData.clear(); progress->setMaximum(recCnt); progress->setMinimum(0); if (backup) { progress->setWindowTitle(tr("Importing")); progress->setLabelText(tr("Importing Notes")); } else { progress->setWindowTitle(tr("Restore")); progress->setLabelText(tr("Restoring Notes")); } progress->setWindowModality(Qt::ApplicationModal); connect(progress, SIGNAL(canceled()), this, SLOT(cancel())); progress->setVisible(true); mb.close(); progress->show(); recCnt = 0; reader = new QXmlStreamReader(&xmlFile); NSqlQuery query(global.db); query.exec("begin"); int commitCount = 100; while (!reader->atEnd() && !stopNow) { if (commitCount <= 0) { query.exec("commit"); commitCount = 100; } commitCount--; reader->readNext(); if (reader->hasError()) { errorMessage = reader->errorString(); QLOG_ERROR() << "************************* ERROR READING BACKUP " << errorMessage; lastError = 16; return; } if (reader->name().toString().toLower() == "nevernote-export" && reader->isStartElement()) { QXmlStreamAttributes attributes = reader->attributes(); QString version = attributes.value("version").toString(); QString type = attributes.value("exportType").toString(); QString application = attributes.value("application").toString(); if (version != "0.85" && version != "0.86" && version != "0.95") { lastError = 1; errorMessage = "Unknown backup version = " +version; return; } if (application.toLower() != "nevernote") { lastError = 2; errorMessage = "This backup is from an unknown application = " +application; return; } if (type.toLower() == "backup" && !backup) { lastError = 4; errorMessage = "This is backup file, not an export file"; progress->hide(); return; } if (type.toLower() == "export" && backup) { lastError = 5; errorMessage = "This is an export file, not a backup file"; return; } } if (reader->name().toString().toLower() == "synchronization" && reader->isStartElement() && backup) { processSynchronizationNode(); } if (reader->name().toString().toLower() == "note" && reader->isStartElement()) { processNoteNode(); recCnt++; progress->setValue(recCnt); } if (reader->name().toString().toLower() == "notebook" && reader->isStartElement() && (backup || importNotebooks)) { processNotebookNode(); } if (reader->name().toString().toLower() == "tag" && reader->isStartElement() && (backup || importTags)) { processTagNode(); } if (reader->name().toString().toLower() == "savedsearch" && reader->isStartElement() && backup) { processSavedSearchNode(); } if (reader->name().toString().toLower() == "linkednotebook" && reader->isStartElement() && backup) { processLinkedNotebookNode(); } if (reader->name().toString().toLower() == "SharedNotebook" && reader->isStartElement() && backup) { processSharedNotebookNode(); } } xmlFile.close(); query.exec("commit"); // Now we do what is a "ahem" hack. We need to // go through all of the notes & rebuild the NoteTable. This // is because we may have gotten notes & tags before the notebook // & tag names existed. There is probably a more efficient way // to do this, but since we don't really do this often this works // as well as any other way. NoteTable noteTable(global.db); for (qint32 i=0; i<noteList.size(); i++) { qint32 lid = noteTable.getLid(noteList[i]); if (lid > 0) { Note note; bool dirty = noteTable.isDirty(lid); noteTable.get(note, lid, false, false); noteTable.updateNoteList(lid, note, dirty, 0); } } query.exec("commit"); progress->hide(); }
TEST_F(YARATest, test_match_false) { Row r = scanFile(alwaysFalse); // Should have 0 count EXPECT_TRUE(r["count"] == "0"); }
TEST_F(YARATest, test_match_true) { Row r = scanFile(alwaysTrue); // Should have 1 count EXPECT_TRUE(r["count"] == "1"); }
int main(int argc, char *argv[]){ char *ruta_db, *ruta_queries; double **db, **queries, *db_vector, *queries_vector; int num_db, num_queries, dim, k, i, j; int num_threads, thread_num; Elem *answer; //variables para medir el tiempo struct rusage r1, r2; double user_time, sys_time, real_time; struct timeval t1, t2; if (argc != 8){ printf("Error :: Ejecutar como : main.out archivo_BD Num_elem archivo_queries Num_queries dim k nombre_usuario\n"); return 1; } ruta_db = (char *)malloc(sizeof(char)*(strlen(argv[1])+1)); strcpy(ruta_db, argv[1]); num_db = atoi(argv[2]); ruta_queries = (char *)malloc(sizeof(char)*(strlen(argv[3])+1)); strcpy(ruta_queries, argv[3]); num_queries = atoi(argv[4]); int dimaux=0,add=0; dim = atoi(argv[5]); k = atoi(argv[6]); char path[256]; sprintf(path, "/home/%s/Salida.txt",argv[7]); printf("%s\n",path ); int validamod=dim%16; if(validamod!=0){ if (dim<16){ dimaux=16; }else{ add = 16-validamod; dimaux=dim+add; } }else{ dimaux=0; } fflush(stdout); db= (double **)malloc(sizeof(double *)*num_db); for (i=0; i<num_db; i++) db[i] = (double *)malloc(sizeof(double)*dimaux); queries = (double **)malloc(sizeof(double *)*num_queries); for (i=0; i<num_queries; i++) queries[i] = (double *)malloc(sizeof(double)*dimaux); answer = (Elem *)malloc(sizeof(Elem)*num_queries*k); //scan DB scanFile(ruta_db, db, dim, num_db,dimaux); scanFile(ruta_queries, queries, dim, num_queries,dimaux); //Se transfieren datos de una matriz a un vector db_vector = (double *)_mm_malloc(sizeof(double)*dimaux*num_db, 64); for (i=0; i < dimaux*num_db; i++) db_vector[i] = 0.0; if (sizeof(double)*dimaux*num_queries < 64) { queries_vector = (double *)_mm_malloc(sizeof(double)*16, 64); for (i=0; i < 16; i++) queries_vector[i] = 0.0; } else { queries_vector = (double *)_mm_malloc(sizeof(double)*dimaux*num_queries, 64); for (i=0; i < dimaux*num_queries; i++) queries_vector[i] = 0.0; } matrixToVector(db, dimaux, num_db, db_vector); matrixToVector(queries, dimaux, num_queries, queries_vector); fflush(stdout); //inicio de la medida de tiempo getrusage(RUSAGE_SELF, &r1); gettimeofday(&t1, 0); #pragma offload target(mic:0) in(dim) in(db_vector:length(num_db*dimaux)) in(queries_vector:length(num_queries*dimaux)) out(answer:length(k*num_queries)) { #pragma omp parallel private(i, j, thread_num) shared(db_vector, num_db, queries_vector, num_queries, dimaux, k, answer, num_threads) { Elem *heap; heap = (Elem *)malloc(sizeof(Elem)*k); #pragma omp master { num_threads = omp_get_num_threads(); printf("run with %d threads\n", num_threads); } #pragma omp barrier thread_num = omp_get_thread_num(); int n_elem; Elem e_temp; double d; for(i=thread_num*dimaux; i<num_queries*dimaux; i+=num_threads*dimaux){ n_elem = 0; for(j=0; j<k; j++){ e_temp.dist = distancia(&(queries_vector[i]), &(db_vector[j*dimaux]), dimaux); e_temp.ind = j; inserta2(heap, &e_temp, &n_elem); } for(j=k; j<num_db; j++){ d = distancia(&(queries_vector[i]), &(db_vector[j*dimaux]), dimaux); if(d < topH(heap, &n_elem)) { e_temp.dist = d; e_temp.ind = j; popush2(heap, &n_elem, &e_temp); } } for(j=0; j<k; j++){ extrae2(heap, &n_elem, &e_temp); answer[(i/dimaux)*k+j].ind = e_temp.ind; answer[(i/dimaux)*k+j].dist = e_temp.dist; } } free(heap); } } gettimeofday(&t2, 0); getrusage(RUSAGE_SELF, &r2); Salida = fopen(path, "w"); for (i = 0; i < num_queries; ++i){ fprintf(Salida, "Consulta id:: %d\n",i); for (j = 0; j < k; ++j) { fprintf(Salida,"ind = %d :: dist = %f\n",answer[(i*k)+j].ind,answer[(i*k)+j].dist); } fprintf(Salida, "---------------------------------\n"); } fclose(Salida); user_time = (r2.ru_utime.tv_sec - r1.ru_utime.tv_sec) + (r2.ru_utime.tv_usec - r1.ru_utime.tv_usec)/1000000.0; sys_time = (r2.ru_stime.tv_sec - r1.ru_stime.tv_sec) + (r2.ru_stime.tv_usec - r1.ru_stime.tv_usec)/1000000.0; real_time = (t2.tv_sec - t1.tv_sec) + (double)(t2.tv_usec - t1.tv_usec)/1000000; printf("\nCPU Time = %lf", sys_time + user_time); printf("\nReal Time = %lf\n", real_time); return 0; }
void ImageScanner::newFileFullScan(int albumId) { loadFromDisk(); addImage(albumId); scanFile(NewScan); }
void ImageScanner::rescan() { loadFromDisk(); updateImage(); scanFile(Rescan); }
int main(int argc, char *argv[]) { char *com; char **raFiles = NULL; int raCount = 0; char *expFile; char *expression; size_t size; struct keyExp *exp; int i; if (argc < 4) usage(); expFile = argv[1]; com = argv[2]; if (sameWord(com, "count")) { command = ctCount; out = stdout; raCount = argc-3; raFiles = argv+3; } else if (sameWord(com, "print")) { if (argc < 5) usage(); command = ctPrint; selectKey = argv[3]; out = stdout; raCount = argc-4; raFiles = argv+4; } else if (sameWord(com, "save")) { if (argc < 6) usage(); command = ctPrint; selectKey = argv[3]; out = mustOpen(argv[4], "w"); raCount = argc-5; raFiles = argv+5; } else if (sameWord(com, "stats")) { if (argc < 6) usage(); command = ctStats; selectKey = argv[3]; out = mustOpen(argv[4], "w"); raCount = argc-5; raFiles = argv+5; statHash = newHash(20); } else if (sameWord(com, "hist")) { if (argc < 6) usage(); command = ctHist; selectKey = argv[3]; out = mustOpen(argv[4], "w"); raCount = argc-5; raFiles = argv+5; statHash = newHash(18); } if (sameWord(expFile, "all")) exp = NULL; else { readInGulp(expFile, &expression, &size); exp = keyExpParse(expression); } kvt = newKvt(128); for (i=0; i<raCount; ++i) { scanFile(exp, raFiles[i]); } printf("%d matched %s\n", matchCount, expFile); if (command == ctStats) { struct useCount *u; slSort(&useCounts, cmpUse); for (u = useCounts; u != NULL; u = u->next) { fprintf(out, "%d %s\n", u->count, u->what); } printf("%d unique values for %s\n", slCount(useCounts), selectKey); } else if (command == ctHist) { struct useCount *u; fillInVal(useCounts); slSort(&useCounts, cmpVal); fprintf(out, "value uses\n"); fprintf(out, "------------\n"); for (u=useCounts; u != NULL; u = u->next) { fprintf(out, "%5d %5d\n", u->val, u->count); } } return 0; }
void ImportEnex::import(QString file) { fileName = file; errorMessage = ""; lastError = 0; QFile xmlFile(fileName); QFile scanFile(fileName); if (!xmlFile.open(QIODevice::ReadOnly) || !scanFile.open(QIODevice::ReadOnly)) { lastError = 16; errorMessage = "Cannot open file."; return; } reader = new QXmlStreamReader(&xmlFile); QTextStream *countReader = new QTextStream(&scanFile); int recCnt = 0; QMessageBox mb; mb.setWindowTitle(tr("Scanning File")); mb.setText(QString::number(recCnt) + tr(" notes found.")); QPushButton *cancelButton = mb.addButton(QMessageBox::Cancel); connect(cancelButton, SIGNAL(clicked()), this, SLOT(canceled())); mb.show(); QCoreApplication::processEvents(); while (!countReader->atEnd() && !stopNow) { QString line = countReader->readLine(); if (line.contains("<note>")) { recCnt++; mb.setText(QString::number(recCnt) + tr(" notes found.")); QCoreApplication::processEvents(); } } progress->setMaximum(recCnt); progress->setMinimum(0); progress->setWindowTitle(tr("Importing Notes")); progress->setLabelText(tr("Importing Notes")); progress->setWindowModality(Qt::ApplicationModal); connect(progress, SIGNAL(canceled()), this, SLOT(canceled())); progress->setVisible(true); mb.close(); progress->show(); NSqlQuery query(global.db); query.exec("begin"); recCnt = 0; while (!reader->atEnd() && !stopNow) { reader->readNext(); if (reader->hasError()) { errorMessage = reader->errorString(); QLOG_ERROR() << "************************* ERROR READING BACKUP " << errorMessage; lastError = 16; return; } if (reader->name().toString().toLower() == "en-export" && reader->isStartElement()) { QXmlStreamAttributes attributes = reader->attributes(); QString version = attributes.value("version").toString(); QString application = attributes.value("application").toString(); // Version 5.x & 6.x are for Windows if (version != "5.x" && version != "6.x" && version.toLower() != "evernote mac") { lastError = 1; errorMessage = "Unknown export version = " +version; return; } if (application.toLower() != "evernote/windows" && application.toLower() != "evernote") { lastError = 2; errorMessage = "This export is from an unknown application = " +application; return; } } if (reader->name().toString().toLower() == "note" && reader->isStartElement()) { recCnt++; progress->setValue(recCnt); QLOG_DEBUG() << "Importing Note " << recCnt; processNoteNode(); } } xmlFile.close(); query.exec("commit"); progress->hide(); }