Пример #1
0
void QCodeModel::q_uncache(QCodeNode *n, QByteArray cxt = QByteArray())
{
	if ( isCachable(n, cxt) )
	{
		m_cache.remove(cxt);
		
		//qDebug("De-Caching %s", cxt.constData());
	}
	
	foreach ( QCodeNode *child, n->children )
		q_uncache(child, cxt);
	
}
Пример #2
0
void QCodeModel::q_cache(QCodeNode *n, QByteArray cxt = QByteArray())
{
	if ( isCachable(n, cxt) )
	{
		m_cache.insert(cxt, n);
		
		//qDebug("Caching %s [0x%x] in 0x%x", cxt.constData(), n, this);
	}
	
	foreach ( QCodeNode *child, n->children )
		q_cache(child, cxt);
	
}
Пример #3
0
    string DBHashCmd::hashCollection( OperationContext* opCtx, Database* db, const string& fullCollectionName, bool* fromCache ) {
        scoped_ptr<scoped_lock> cachedHashedLock;

        if ( isCachable( fullCollectionName ) ) {
            cachedHashedLock.reset( new scoped_lock( _cachedHashedMutex ) );
            string hash = _cachedHashed[fullCollectionName];
            if ( hash.size() > 0 ) {
                *fromCache = true;
                return hash;
            }
        }

        *fromCache = false;
        Collection* collection = db->getCollection( opCtx, fullCollectionName );
        if ( !collection )
            return "";

        IndexDescriptor* desc = collection->getIndexCatalog()->findIdIndex( opCtx );

        auto_ptr<PlanExecutor> exec;
        if ( desc ) {
            exec.reset(InternalPlanner::indexScan(opCtx,
                                                  collection,
                                                  desc,
                                                  BSONObj(),
                                                  BSONObj(),
                                                  false,
                                                  InternalPlanner::FORWARD,
                                                  InternalPlanner::IXSCAN_FETCH));
        }
        else if ( collection->isCapped() ) {
            exec.reset(InternalPlanner::collectionScan(opCtx,
                                                       fullCollectionName,
                                                       collection));
        }
        else {
            log() << "can't find _id index for: " << fullCollectionName << endl;
            return "no _id _index";
        }

        md5_state_t st;
        md5_init(&st);

        long long n = 0;
        PlanExecutor::ExecState state;
        BSONObj c;
        verify(NULL != exec.get());
        while (PlanExecutor::ADVANCED == (state = exec->getNext(&c, NULL))) {
            md5_append( &st , (const md5_byte_t*)c.objdata() , c.objsize() );
            n++;
        }
        if (PlanExecutor::IS_EOF != state) {
            warning() << "error while hashing, db dropped? ns=" << fullCollectionName << endl;
        }
        md5digest d;
        md5_finish(&st, d);
        string hash = digestToString( d );

        if ( cachedHashedLock.get() ) {
            _cachedHashed[fullCollectionName] = hash;
        }

        return hash;
    }
Пример #4
0
 void DBHashCmd::wipeCacheForCollection( const StringData& ns ) {
     if ( !isCachable( ns ) )
         return;
     scoped_lock lk( _cachedHashedMutex );
     _cachedHashed.erase( ns.toString() );
 }