Esempio n. 1
0
        void MongoCluster::loadCluster() {
            clear();
            //TODO: Add a sanity check this is actually a mongoS/ config server
            //Load shards && tag map
            mongo::Cursor cur = _dbConn->query("config.shards", mongo::BSONObj());
            while (cur->more()) {
                mongo::BSONObj obj = cur->next();
                std::string shard = obj.getStringField("_id");
                std::string connect = obj.getStringField("host");
                size_t shardnamepos = connect.find_first_of('/');
                //If this is a replica the name starts: replicaName/<host list>, standalone: <host>
                if (shardnamepos != std::string::npos)
                    connect = "mongodb://" + connect.substr(shardnamepos + 1) + "/?replicaSet=" + connect.substr(0, shardnamepos);
                else
                    connect = "mongodb://" + connect;
                if (shard.empty() || connect.empty())
                    throw std::logic_error("Couldn't load shards, empty values, is this a "
                            "sharded cluster?");
                std::string tag = obj.getStringField("tag");
                auto sharditr = _shards.emplace(std::move(shard), std::move(connect)).first;
                if (!tag.empty())
                    _shardTags[tag].push_back(sharditr);
            }
            _sharded = _shards.size();

            //Load shard chunk ranges
            loadIndex(&_nsChunks, "config.chunks", &_shards, "shard");
            //Load tag bound ranges
            loadIndex(&_nsTagRanges, "config.tags", &_shardTags, "tag");

            //Get all the mongoS
            cur = _dbConn->query("config.mongos", mongo::BSONObj());
            while (cur->more()) {
                mongo::BSONObj o = cur->next();
                _mongos.emplace_back(std::string("mongodb://") + o.getStringField("_id"));
            }

            cur = _dbConn->query("config.databases", mongo::BSONObj());
            while (cur->more()) {
                mongo::BSONObj obj = cur->next();
                std::string dbName = obj.getStringField("_id");
                _dbs.emplace(std::make_pair(dbName,
                        MetaDatabase(dbName, obj.getBoolField("partitioned"), obj.getStringField("primary"))));
            }

            cur = _dbConn->query("config.collections", mongo::BSONObj());
            DatabaseName prevDb;
            while (cur->more()) {
                mongo::BSONObj obj = cur->next();
                NameSpace currNs = obj.getStringField("_id");
                _colls.emplace(std::make_pair(currNs, MetaNameSpace(currNs, obj.getBoolField("dropped"),
                               obj.getObjectField("key").getOwned(), obj.getBoolField("unique"))));
            }

        }
void DocumentationPlugin::reinit(KListView *contents, IndexBox *index, QStringList restrictions)
{
    config->setGroup("Locations");
    QMap<QString, QString> entryMap = config->entryMap("Locations");

    //remove deleted in configuration catalogs
    for (QStringList::const_iterator it = deletedConfigurationItems.constBegin();
        it != deletedConfigurationItems.constEnd(); ++it)
    {
        if (namedCatalogs.contains(*it))
            delete namedCatalogs[*it];
    }
    deletedConfigurationItems.clear();
    
    //update configuration
    for (QMap<QString, QString>::const_iterator it = entryMap.begin();
        it != entryMap.end(); ++it)
    {
        config->setGroup("Locations");
        if (restrictions.contains(it.key()) || (!catalogEnabled(it.key())))
        {
            if (namedCatalogs.contains(it.key()))
                delete namedCatalogs[it.key()];
        }
        else
        {
            kdDebug() << "updating 1" << endl;
            if (!namedCatalogs.contains(it.key()))    //create catalog if it does not exist
            {
                DocumentationCatalogItem * item = createCatalog(contents, it.key(), config->readPathEntry(it.key()));
                loadIndex(index, item);
                index->setDirty(true);
//                index->refill(indexes[item]);
            }
            else if (!indexEnabled(namedCatalogs[it.key()]))    //clear index if it is disabled in configuration
            {
                kdDebug() << "    updating: clearCatalogIndex" << endl;
                clearCatalogIndex(namedCatalogs[it.key()]);
            }
            else if ( (indexEnabled(namedCatalogs[it.key()]))    //index is requested in configuration but does not yet exist
                && (!indexes.contains(namedCatalogs[it.key()])) )
            {
                kdDebug() << "    index requested " << endl;
                loadIndex(index, namedCatalogs[it.key()]);
                index->setDirty(true);
            }
            m_indexCreated = true;
        }
    }
}
Esempio n. 3
0
/**
 * @brief (Re)build the index file
 */
void PlaybackController::buildIndex()
{
	if(!m_indexbuilder.isNull()) {
		qWarning("Index builder already running!");
		return;
	}

	m_indexbuilder = new IndexBuilder(m_reader->filename(), indexFileName());

	const qreal filesize = m_reader->filesize();
	connect(m_indexbuilder, &IndexBuilder::progress, [this, filesize](int progress) {
		m_indexBuildProgress = progress / filesize;
		emit indexBuildProgressed(m_indexBuildProgress);
	});

	connect(m_indexbuilder, &IndexBuilder::done, [this](bool ok, const QString &error) {
		if(!ok) {
			m_indexBuildProgress = 0;
			emit indexBuildProgressed(0);
			emit indexLoadError(error, true);
		} else {
			loadIndex();
		}
	});

	QThreadPool::globalInstance()->start(m_indexbuilder);
}
Esempio n. 4
0
int main(){
	exception e;
	VTDGen *vg = NULL;
	VTDNav *vn = NULL;
	AutoPilot *ap = NULL;
	XMLModifier *xm = NULL;
	FILE *f = NULL;
	UCSChar *string = NULL; 
	int i;
    f = fopen("d:/ximpleware_2.2_c/vtd-xml/codeGuru/6/input.vxl","rb");
	if (f==NULL)
		return 0;
	Try{
		xm = createXMLModifier();
		ap = createAutoPilot2();
		selectXPath(ap,L"/a/b");
		vg = createVTDGen();		
		vn = loadIndex (vg,f);
		bind(ap,vn);
		bind4XMLModifier(xm,vn);
		while((i=evalXPath(ap))!=-1){
			insertAttribute(xm,L" attr1='val'");
		}
		output2(xm,"d:/ximpleware_2.2_c/vtd-xml/codeGuru/6/new.xml");
		free(vn->XMLDoc);		
	}Catch(e){// handle various types of exceptions here
	}
	fclose(f);		
	freeAutoPilot(ap);
	freeXMLModifier(xm);
	freeVTDGen(vg);
	freeVTDNav(vn);
	return 0;
}
Esempio n. 5
0
void KateProjectWorker::loadProject (QString fileName, QVariantMap projectMap)
{
  /**
   * setup project file name
   * name should be FIX after initial setting
   */
  Q_ASSERT (m_fileName.isEmpty() || (m_fileName == fileName));
  m_fileName = fileName;

  /**
   * Create dummy top level parent item and empty map inside shared pointers
   * then load the project recursively
   */
  KateProjectSharedQStandardItem topLevel (new QStandardItem ());
  KateProjectSharedQMapStringItem file2Item (new QMap<QString, QStandardItem *> ());
  loadProject (topLevel.data(), projectMap, file2Item.data());
  
  /**
   * create some local backup of some data we need for further processing!
   */
  QStringList files = file2Item->keys ();
  
  /**
   * feed back our results
   */
  QMetaObject::invokeMethod (m_project, "loadProjectDone", Qt::QueuedConnection, Q_ARG(KateProjectSharedQStandardItem, topLevel), Q_ARG(KateProjectSharedQMapStringItem, file2Item));
  
  /**
   * load index
   */
  loadIndex (files);
}
/**
 * @brief (Re)build the index file
 */
void PlaybackController::buildIndex()
{
	if(!m_indexbuilder.isNull()) {
		qWarning("Index builder already running!");
		return;
	}

	QThread *thread = new QThread;
	m_indexbuilder = new IndexBuilder(m_reader->filename(), indexFileName());
	m_indexbuilder->moveToThread(thread);

	const qreal filesize = m_reader->filesize();
	connect(m_indexbuilder.data(), &IndexBuilder::progress, [this, filesize](int progress) {
		m_indexBuildProgress = progress / filesize;
		emit indexBuildProgressed(m_indexBuildProgress);
	});

	connect(m_indexbuilder.data(), &IndexBuilder::done, [this](bool ok, const QString &error) {
		if(!ok) {
			m_indexBuildProgress = 0;
			emit indexBuildProgressed(0);
			emit indexLoadError(error, true);
		} else {
			loadIndex();
		}
	});

	connect(thread, &QThread::started, m_indexbuilder.data(), &IndexBuilder::run);
	connect(m_indexbuilder.data(), &IndexBuilder::done, thread, &QThread::quit);
	connect(m_indexbuilder.data(), &IndexBuilder::done, m_indexbuilder.data(), &QThread::deleteLater);
	connect(thread, &QThread::finished, thread, &QThread::deleteLater);

	thread->start();
}
Esempio n. 7
0
void Sprite::load(FileObject &ff)
/*!\brief Laden einer Textur-Datei
 *
 * \desc
 * Mit dieser Funktion kann eine bereits geöffnete Textur-Sprite-Datei geladen werden.
 *
 * \param[in] ff Pointer auf die CFileObject-Klasse, die die Daten enthält.
 * \param[in] flags Flags mit der die Textur-Surfaces erstellt werden sollen. Dies ist eine Kombination der Werte
 * innerhalb der Enumeration ppl6::grafix::Surface::Flags
 * \returns Konnte die Datei erfolgreich geladern werden, gibt die Funktion 1 (true) zurück,
 * im Fehlerfall 0 (false). Im Fehlerfall wird ein entsprechender Fehlercode gesetzt.
 */
{
	PFPFile File;
	clear();
	File.load(ff);
	int major, minor;
	File.getVersion(&major,&minor);
	if (File.getID()!="TEXS" || major!=1 || minor!=0) throw InvalidSpriteException();
	// Texture Chunks laden
	PFPChunk *chunk;
	PFPFile::Iterator it;
	File.reset(it);
	while ((chunk=File.findNextChunk(it,"SURF"))) {
		loadTexture(chunk);
	}
	// Index Chunks laden
	File.reset(it);
	while ((chunk=File.findNextChunk(it,"INDX"))) {
		loadIndex(chunk);
	}
}
Esempio n. 8
0
CCArchive::CCArchive(const Common::String &filename, const Common::String &prefix,
		bool encoded): BaseCCArchive(), _filename(filename),
		_prefix(prefix), _encoded(encoded) {
	_prefix.toLowercase();
	File f(filename);
	loadIndex(&f);
}
Esempio n. 9
0
void BPlusIndexP::initializeIndex() {
	int buffersCount = _bufferManager->buffersCount();

	if (buffersCount > 0) {
		loadIndex();
	} else {
		_head = new IndexPage();
		persistPage(_head);
	}
}
Esempio n. 10
0
			/* 
			 * load indexes for multiple files 
			 */
			static ::libmaus::autoarray::AutoArray< ::libmaus::autoarray::AutoArray< IndexEntry > > 
				loadIndex(std::vector<std::string> const & filenames)
			{
				::libmaus::autoarray::AutoArray< ::libmaus::autoarray::AutoArray< IndexEntry > > index(filenames.size());
				
				for ( uint64_t i = 0; i < index.size(); ++i )
					index[i] = loadIndex(filenames[i]);
				
				return index;
			}
Esempio n. 11
0
			RLDecoderIndexBase(std::vector<std::string> const & rfilenames)
			: 
			  filenames(rfilenames),
			  index(loadIndex(filenames)),
			  n( getLength(filenames) ),
			  symaccu(computeSymAccu()),
			  symtree(symaccu),
			  segaccu(computeSegAccu()),
			  segtree(segaccu)
			{
			}
void DocumentationPlugin::createIndex(IndexBox *index)
{
    if (m_indexCreated)
        return;
    
    for (QValueList<DocumentationCatalogItem *>::iterator it = catalogs.begin();
        it != catalogs.end(); ++it)
    {
        loadIndex(index, *it);
    }
    m_indexCreated = true;
}
Esempio n. 13
0
int main(){

	exception e;
	FILE *f = NULL ,*fw = NULL;
	int i = 0,t,result,count=0;
 	wchar_t *tmpString;	
	
	UByte *xml = NULL; // this is the buffer containing the XML content, UByte means unsigned byte
	VTDGen *vg = NULL; // This is the VTDGen that parses XML
	VTDNav *vn = NULL; // This is the VTDNav that navigates the VTD records
	AutoPilot *ap = NULL;
	XMLModifier *xm = NULL;

	// allocate a piece of buffer then reads in the document content
	// assume "c:\soap2.xml" is the name of the file
	f = fopen("oldpo.vxl","rb");
	fw = fopen("newpo_update.xml","wb");

	Try{
		vg = createVTDGen();
		vn = loadIndex(vg,f);
		ap = createAutoPilot2();
		xm = createXMLModifier();
		if (selectXPath(ap,L"/purchaseOrder/items/item[@partNum='872-AA']")){
			bind(ap,vn);
			bind4XMLModifier(xm,vn);
			while((result=evalXPath(ap))!= -1){
				remove4XMLModifier(xm);
				insertBeforeElement(xm,L"<something/>");	
			}
		}
		if (selectXPath(ap,L"/purchaseOrder/items/item/USPrice[.<40]/text()")){
			while((result=evalXPath(ap))!= -1){
				updateToken(xm,result,L"200");
			}
		}
		output(xm,fw);
		
		fclose(f);
		fclose(fw);
		// remember C has no automatic garbage collector
		// needs to deallocate manually.
		freeVTDNav(vn);
		freeVTDGen(vg);
		freeXMLModifier(xm);
		freeAutoPilot(ap);
	}
	Catch (e) {
		// manual garbage collection here
		freeVTDGen(vg);
	}
  return 0;
}
Esempio n. 14
0
			GapDecoderIndexBase(std::vector<std::string> const & rfilenames)
			: 
			  filenames(filterFilenamesByLength(rfilenames)),
			  index(loadIndex(filenames)),
			  symaccu(computeSymAccu()),
			  symtree(symaccu),
			  segaccu(computeSegmentAccu()),
			  segtree(segaccu),
			  blocksizes(getBlockSizes()),
			  blockintervals(computeBlockIntervals()),
			  blockintervaltree(blockintervals),
			  n ( getLength(filenames) )
			{}
Esempio n. 15
0
int main(int argc, char** argv) {
    ArgParser args(argc, argv);

    if (!args.isSet("i")) usage(argv);

    const std::string algo = args.get<std::string>("a", "pairwise"),
        indexfn = args.get<std::string>("i"),
        queryfn = args.get<std::string>("q", "queries.txt");
    const uint32_t threshold = args.get<uint32_t>("t", 3);

    Timer timer;

    // load queries
    std::vector<std::vector<uint32_t>> queries;
    loadQueries(queries, queryfn);
    std::cout << queries.size() << " queries loaded in " << timer.getAndReset() << "s" << std::endl;

    // load index
    Index* index = loadIndex(algo, indexfn);
    if (index == nullptr) {
        usage(argv);
    }
    std::cout << "Loaded index in " << timer.getAndReset() << "s" << std::endl;

    // create benchmark object
    Benchmark *benchmark = createBenchmark(algo, threshold);
    benchmark->setIndex(index);

    std::cout << "Querying index with " << queries.size() << " queries..." << std::endl;
    timer.reset();

    // Query!
    for (const std::vector<uint32_t> &query : queries) {
        benchmark->query(query);
    }

    double queryDuration = timer.get();
    std::cout << "Queried index in " << queryDuration << "s" << std::endl;

    std::cout << "RESULT"
        << " algo="  << algo
        << " index=" << indexfn
        << " queries=" << queryfn
        << " numQueries=" << queries.size()
        << " queryDuration=" << queryDuration
        << " msPerQuery=" << queryDuration * 1000 / queries.size()
        // TODO max/min query time
        << std::endl;
}
Esempio n. 16
0
void getTestSubset(int numMrnas, int numEsts, char *accList,
                   char* selectAccFile, char* relName, char* database,
                   char* outDir)
/* Get the test subset. */
{
struct gbRelease* release;
struct hash* accTbl = hashNew(20);
unsigned types = 0;

/* note, we find mRNAs and ESTs seperately, but extract in one pass, as
 * daily updates have both in a single file */
if (numMrnas > 0)
    types |= GB_MRNA;
if (numEsts > 0)
    types |= GB_EST;

release = loadIndex(relName, types, database);

if (selectAccFile != NULL)
    getRequestedAccs(selectAccFile, release, accTbl);

if (numMrnas > 0)
    findAccs(numMrnas, GB_MRNA, release, accTbl);
if (numEsts > 0)
    findAccs(numEsts, GB_EST, release, accTbl);

copyAccs(release, types, accTbl, outDir);

if (accList != NULL)
    {
    FILE *accListFh;
    struct hashCookie cookie;
    struct hashEl* hel;
    
    gbMakeFileDirs(accList);
    accListFh = mustOpen(accList, "w");
    cookie = hashFirst(accTbl);
    while ((hel = hashNext(&cookie)) != NULL)
        fprintf(accListFh, "%s\n", hel->name);
    carefulClose(&accListFh);
    }

hashFree(&accTbl);
gbIndexFree(&release->index);
}
Esempio n. 17
0
			/**
			 * constructor
			 *
			 * @param filename name of BAM file
			 * @param rranges range descriptor string
			 * @param rputrank put ranks on alignments
			 **/
			BamRangeDecoder(std::string const & filename, std::string const & rranges, bool const rputrank = false)
			:
			  libmaus2::bambam::BamAlignmentDecoder(rputrank),
			  Pheader(loadHeader(filename)),
			  header(*Pheader),
			  Pindex(loadIndex(deriveBamIndexName(filename))),
			  index(*Pindex),
			  ranges(libmaus2::bambam::BamRangeParser::parse(rranges,header)),
			  rangeidx(0),
			  rangecur(0),
			  wrapper(filename,header),
			  chunks(),
			  chunkidx(0),
			  decoder(wrapper.getDecoder()),
			  algn(decoder.getAlignment()),
			  active(setup())
			{
			}
Esempio n. 18
0
//  If this proves far too slow, rewrite the _names string to separate IDs with 0xff, then use
//  strstr on the whole thing.  To find the ID, scan down the string counting the number of 0xff's.
//
//  Similar code is used for fastaFile::find()
//
uint32
seqStore::find(const char *sequencename) {

  if (_names == NULL)
    loadIndex();

  char   *ptr = _names;

  for (uint32 iid=0; iid < _header._numberOfSequences; iid++) {
    if (strcmp(sequencename, ptr) == 0)
      return(iid);

    while (*ptr)
      ptr++;
    ptr++;
  }

  return(~uint32ZERO);
}
Esempio n. 19
0
TLib::TLib(MemoryManager &memManager, const Common::String &filename) :
		_memoryManager(memManager) {

	// If the resource strings list isn't yet loaded, load them
	if (_resStrings.size() == 0) {
		Common::File f;
		if (f.open("tsage.cfg")) {
			while (!f.eos()) {
				_resStrings.push_back(f.readLine());
			}
			f.close();
		}
	}

	if (!_file.open(filename))
		error("Missing file %s", filename.c_str());

	loadIndex();
}
Esempio n. 20
0
// @biref: sorting the result based on bayes theorem
int searchTrie::sorting()
{
    int i,k;
    if(tot==0) return 0;
    loadIndex();
    // load the indexNode based on the searching result, store at results[tot]
    qsort(results, tot, sizeof(indexNode), cmp1);
    k=0;
    for(i=1;i<tot;i++)
        if(strcmp(results[i].entry,results[k].entry)!=0){
            k++;
            results[k]=results[i];
        }
    // eliminate the duplicate words
    tot=k+1;
    qsort(results, tot, sizeof(indexNode), cmp2);
    // sorting all of words based on frequency
    return 0;
}
Esempio n. 21
0
void KateProjectWorker::run(ThreadWeaver::JobPointer, ThreadWeaver::Thread *)
{
    /**
     * Create dummy top level parent item and empty map inside shared pointers
     * then load the project recursively
     */
    KateProjectSharedQStandardItem topLevel(new QStandardItem());
    KateProjectSharedQMapStringItem file2Item(new QMap<QString, KateProjectItem *> ());
    loadProject(topLevel.data(), m_projectMap, file2Item.data());

    /**
     * create some local backup of some data we need for further processing!
     */
    QStringList files = file2Item->keys();

    emit loadDone(topLevel, file2Item);

    /**
     * load index
     */
    loadIndex(files);
}
Esempio n. 22
0
File: Unit1.cpp Progetto: r043v/ripr
void drawIndex(void)
{  loadIndex();
   int *ptr, color=indexBoundColor ;
   Form1->lastFrmImg->Picture->Bitmap->PixelFormat = pf32bit ;
   if(frmIndex.enable == 2) // draw 4 pink line to see index pos
   { ptr = (int*)(Form1->lastFrmImg->Picture->Bitmap->ScanLine[frmIndex.y]) ;
     for(int x=frmIndex.x;x<frmIndex.x+frmIndex.szx;x++) ptr[x]=color ;
     for(int y=frmIndex.y +1;y<frmIndex.y+frmIndex.szy -1;y++)
     { ptr = (int*)(Form1->lastFrmImg->Picture->Bitmap->ScanLine[y]) ;
       ptr[frmIndex.x]=color ; ptr[frmIndex.x+frmIndex.szx - 1]=color ;
     };
     ptr = (int*)(Form1->lastFrmImg->Picture->Bitmap->ScanLine[frmIndex.y+frmIndex.szy - 1]) ;
     for(int x=frmIndex.x;x<frmIndex.x+frmIndex.szx;x++) ptr[x]=color ;
     // draw index colors in the right down img.
     Form1->indexPalImg->Picture->Bitmap->PixelFormat = pf32bit ; // set deep to 32 bits
     int lnb = (frmIndex.colorNb)>>2 ;
     Form1->indexPalImg->Picture->Graphic->Height = lnb + ((frmIndex.colorNb)>(lnb<<2))*1 ;
     Form1->indexPalImg->Picture->Graphic->Width  = 4 ;
     Form1->indexPalImg->Top = Form1->lblCurColor->Top - (Form1->indexPalImg->Picture->Graphic->Height)*24 ;
     Form1->Edit3->Text = frmIndex.colorNb ;
     Form1->Edit4->Text = frmIndex.szx ;
     Form1->Edit5->Text = frmIndex.szy ;
     int c=0, cpt=0 ;
     int l=0 ; ptr = (int*)(Form1->indexPalImg->Picture->Bitmap->ScanLine[l]);
               for(lnb=0;lnb<4;lnb++)ptr[lnb]=0xd6d3ce ; // 0xd6d3ce -> window gray 
     while(c<frmIndex.colorNb) // show color under index
     { ptr[c%4] = frmIndex.color[c++] ;
       if(++cpt == 4)
        if(++l < Form1->indexPalImg->Picture->Graphic->Height)
        { ptr = (int*)(Form1->indexPalImg->Picture->Bitmap->ScanLine[l]);
          for(lnb=0;lnb<4;lnb++)ptr[lnb]=0xd6d3ce ; cpt=0 ;
        }
     };
     Form1->lastFrmImg->Refresh();
     Form1->indexPalImg->Refresh();
     Form1->Label1->Caption = isIndex(frmBuffer,frmSx,frmSy,frmIndex.x,frmIndex.y);
     if(preview) if(preview->Visible) preview->Image1->Picture->Assign(Form1->lastFrmImg->Picture) ;
   }
Esempio n. 23
0
			static unique_ptr_type load(std::string const & filename)
			{
				::libmaus::aio::CheckedInputStream in(filename.c_str());
				
				if ( ! in.is_open() )
				{
					::libmaus::exception::LibMausException se;
					se.getStream() << "ImpHuffmanWaveletTree::load(): failed to open file " << filename << std::endl;
					se.finish();
					throw se;
				}
				
				uint64_t const n = ::libmaus::util::NumberSerialisation::deserialiseNumber(in);
				::libmaus::util::shared_ptr< ::libmaus::huffman::HuffmanTreeNode >::type const sroot = ::libmaus::huffman::HuffmanTreeNode::deserialize(in);
				uint64_t const numnodes = ::libmaus::util::NumberSerialisation::deserialiseNumber(in);
				in.close();
				
				std::vector<uint64_t> const nodepos = loadIndex(filename);
				
				unique_ptr_type p ( new this_type(filename,n,sroot,numnodes,nodepos) );
				
				return UNIQUE_PTR_MOVE(p);
			}
Esempio n. 24
0
// V2
void ResourceReader::open(const char *filename) {
	_fd = new Common::File();
	_fd->open(filename);

	_fd->skip(0x18); // skip header for now

	uint16 indexCount = _fd->readUint16LE();

	for (uint16 i = 0; i < indexCount; i++) {

		uint32 resType = _fd->readUint32BE();
		uint32 indexOffs = _fd->readUint32LE();
		_fd->readUint32LE();
		_fd->readUint32LE();
		_fd->readUint32LE();
		_fd->readUint16LE();
		_fd->readUint16LE();

		// We don't need ARCH, FREE and OMNI resources
		if (resType == kResARCH || resType == kResFREE || resType == kResOMNI)
			continue;

		//debug(2, "resType = %08X; indexOffs = %d\n", resType, indexOffs);

		uint32 oldOffs = _fd->pos();

		ResourceSlots *resSlots = new ResourceSlots();
		_fd->seek(indexOffs);
		loadIndex(resSlots);
		_resSlots[resType] = resSlots;

		_fd->seek(oldOffs);

	}

	_cacheCount = 0;
}
Esempio n. 25
0
SharedLogicalTxnParticipant FtrsTableWriterFactory::loadParticipant(
    LogicalTxnClassId classId,
    ByteInputStream &logStream)
{
    assert(classId == getParticipantClassId());

    TupleDescriptor clusteredTupleDesc;
    clusteredTupleDesc.readPersistent(logStream, typeFactory);

    uint nIndexes;
    logStream.readValue(nIndexes);

    FtrsTableWriterParams params;
    params.indexParams.resize(nIndexes);

    for (uint i = 0; i < nIndexes; ++i) {
        loadIndex(clusteredTupleDesc, params.indexParams[i], logStream);
    }

    params.updateProj.readPersistent(logStream);

    return SharedLogicalTxnParticipant(
        new FtrsTableWriter(params));
}
Esempio n. 26
0
CCArchive::CCArchive(const Common::String &filename, bool encoded):
		BaseCCArchive(), _filename(filename), _encoded(encoded) {
	File f(filename);
	loadIndex(&f);
}
Esempio n. 27
0
int main (int argc, char **argv)

   { char str[102400];
     Index S;
     int k;
     Tdist r;
     struct stat sdata;
     struct tms t1,t2;
     int numQueries = 0;
    
     if (argc != 2)
        { fprintf (stderr,"Usage: %s index-file\n",argv[0]);
          exit(1);
        }

     fprintf (stderr,"reading index...\n");
     S = loadIndex (argv[1]);
     stat (argv[1],&sdata);
     fprintf (stderr,"read %lli bytes\n",(long long)sdata.st_size);

     numDistances = 0;

     while (true)
        { Obj qry;
	  int siz;
	  bool fixed;

          if (scanf ("%[0123456789-.]s",str) == 0) break;
	  if (!strcmp(str,"-0")) break; // -0 -> terminate

          if (str[0] == '-') // negative => kNN
             { fixed = false;
               if (sscanf (str+1,"%d",&k) == 0) break; // syntax error
	     }
          else  // range query
             { fixed = true;
#ifdef CONT
               if (sscanf (str,"%f",&r) == 0) break; // syntax error
#else
               if (sscanf (str,"%d",&r) == 0) break; // syntax error
#endif
	     }
	  if (getchar() != ',') break; // syntax error
	  if (scanf ("%[^\n]s",str) == 0) break; // syntax error
	  if (getchar() != '\n') break; // syntax error
	  qry = parseobj (str);

          numQueries++;
          if (fixed)
	     { times(&t1);
	       siz = search(S,qry,r,true);
	       times(&t2);
               fprintf (stderr,"%i objects found\n",siz);
	     }
	  else
	     { times(&t1);
	       r = searchNN (S,qry,k,true);
	       siz = k;
	       times(&t2);
#ifdef CONT
               fprintf (stderr,"kNNs at distance %f\n",r);
#else
               fprintf (stderr,"kNNs at distance %i\n",r);
#endif
	     }
	}
     fprintf(stderr,"Total distances per query: %f\n",
		numDistances/(float)numQueries);
     fprintf (stderr,"freeing...\n");
     freeIndex (S,true);
     fprintf (stderr,"done\n");
	   return 0;
   }
Esempio n. 28
0
bool
seqStore::getSequence(uint32 iid,
                      char *&h, uint32 &hLen, uint32 &hMax,
                      char *&s, uint32 &sLen, uint32 &sMax) {

  if (_index == NULL)
    loadIndex();

  if (iid >= _header._numberOfSequences) {
    fprintf(stderr, "seqStore::getSequence(full)--  iid "F_U32" more than number of sequences "F_U32"\n",
            iid, _header._numberOfSequences);
    return(false);
  }

  if (sMax == 0)  s = 0L;  //  So the delete below doesn't bomb
  if (hMax == 0)  h = 0L;

  if (sMax < _index[iid]._seqLength + 1) {
    sMax = _index[iid]._seqLength + 1024;
    delete [] s;
    s = new char [sMax];
  }

  if (hMax < _index[iid]._hdrLength + 1) {
    hMax = _index[iid]._hdrLength + 1024;
    delete [] h;
    h = new char [hMax];
  }

  hLen = 0;
  sLen = 0;

  //  Copy the defline into h

  memcpy(h, _names + _index[iid]._hdrPosition, _index[iid]._hdrLength);

  h[_index[iid]._hdrLength] = 0;

  //  Decode and copy the sequence into s

  uint32 seqLen  = _index[iid]._seqLength;
  uint32 block   = _index[iid]._block;
  uint64 seekpos = _index[iid]._seqPosition * 2;

  _bpf->seek(seekpos);

  while (sLen < seqLen) {
    assert(_bpf->tell() == _block[block]._bpf * 2);
    assert(sLen == _block[block]._pos);

    if (_block[block]._isACGT == 0) {
      memset(s + sLen, 'N', _block[block]._len);
      sLen += _block[block]._len;
    } else {
      for (uint32 xx=0; xx<_block[block]._len; xx++) {
        s[sLen++] = alphabet.bitsToLetter(_bpf->getBits(2));
      }
    }

    block++;
  }

  s[sLen] = 0;

  return(true);
}
Esempio n. 29
0
bool
seqStore::getSequence(uint32 iid,
                      uint32 bgn, uint32 end, char *s) {

  if (_index == NULL)
    loadIndex();

  if (iid >= _header._numberOfSequences) {
    fprintf(stderr, "seqStore::getSequence(part)--  iid "F_U32" more than number of sequences "F_U32"\n",
            iid, _header._numberOfSequences);
    return(false);
  }

  if (bgn >= end) {
    fprintf(stderr, "seqStore::getSequence(part)--  for iid "F_U32"; invalid bgn="F_U32" end="F_U32"; seqLen="F_U32"\n",
            iid, bgn, end, _index[iid]._seqLength);
    return(false);
  }

  //  Decode and copy the sequence into s

  uint32 block  = _index[iid]._block;
  uint32 sLen   = 0;  //  length of sequence we've copied
  uint32 sPos   = 0;  //  position in the sequence

  //  Skip blocks before we care.
  //
  while (sPos + _block[block]._len < bgn) {
    sPos += _block[block]._len;
    block++;
  }

  assert(sPos == _block[block]._pos);

  //  Move into the block (we could just set sPos = bgn...).
  sPos += bgn - _block[block]._pos;

  //  Handle the partial block.  Copy what is left in the block, or
  //  the requested size, whichever is smaller.

  uint32 partLen = MIN((_block[block]._pos + _block[block]._len - bgn),
                       (end - bgn));

  if (_block[block]._isACGT == 0) {
    memset(s, 'N', partLen);
    sLen += partLen;
    _bpf->seek(_block[block+1]._bpf * 2);
  } else {
    _bpf->seek((_block[block]._bpf + bgn - _block[block]._pos) * 2);

    for (uint32 xx=0; xx<partLen; xx++)
      s[sLen++] = alphabet.bitsToLetter(_bpf->getBits(2));
  }

  sPos += partLen;

  block++;

  while (sPos < end) {
    assert(_bpf->tell() == _block[block]._bpf * 2);
    assert(sPos == _block[block]._pos);

    //  Like the partial block above, pick how much to copy as the
    //  smaller of the block size and what is left to fill.

    partLen = MIN((_block[block]._len), (end - sPos));

    if (_block[block]._isACGT == 0) {
      memset(s + sLen, 'N', partLen);
      sLen += partLen;
    } else {
      for (uint32 xx=0; xx<partLen; xx++)
        s[sLen++] = alphabet.bitsToLetter(_bpf->getBits(2));
    }

    sPos += partLen;

    block++;
  }

  s[sLen] = 0;

  return(true);
}
Esempio n. 30
0
LocalMailFolder::LocalMailFolder(const QString &_storageDevice)
        : MailFolder(_storageDevice)
{
    setupFiles();
    loadIndex();
};