Пример #1
0
void TProfiler::profile() {
	QDir rootDir;
	rootDir.mkdir(_dir1);
	rootDir.mkdir(_dir2);

	_hashDir[0] = QDir(rootDir.absolutePath() + "/" + _dir1);
	_hashDir[1] = QDir(rootDir.absolutePath() + "/" + _dir2);
        clean(_hashDir[0]);
        clean(_hashDir[1]);
	for (int i = 0; i < _steps.size(); ++i) {
		for (int numberOfPackages = _steps[i].begin;
				numberOfPackages < _steps[i].end;
				numberOfPackages += _steps[i].step) {
			qDebug() << numberOfPackages;
			for (int hasher = 0; hasher < 2; ++hasher) {
				DataBase base(
						_hashDir[hasher].absolutePath() + "/"
								+ QString::number(numberOfPackages) + ".db",
						_dbSize, numberOfPackages, _hashers[hasher]);
                                base.buildDB(_source, _recToRead);
				searchInDB(&base);
				logResult(numberOfPackages, hasher);
				cleanResult();
			}
		}

	}
#ifdef DEBUG4
	qDebug() << _ro[0];
	qDebug() << _ro[1];
	qDebug();
	qDebug() << _over[0];
	qDebug() << _over[1];
#endif
	flushLogs();
}
Пример #2
0
void findAndRecordAllPaths( Node *node, Signature labels, int *labelIdxs,
        NodePtrVec *result, Bitfield *visited, NodeVecVec *storage,
        SearchOptions *options )
{
    EdgeList *edge;
    /* NodePtrVec *nextLegVisited = NULL; */
    Bitfield *nextLegVisited = NULL;


    /* A little basic error checking */
    if ( !node || !labels || !labelIdxs || !result|| !visited )
    {
        return;
    }

    /* If this node is already in the vector, we have found a loop. return false. */
/*
    if ( NodePtrVec_findReverse( visited, node ) )
        return( false );
    else
        NodePtrVec_push( visited, node );
*/
    if ( Bitfield_nodeVisited( visited, node ) )
        return;

    /* put this node on the result vector to show that we've been here */
    NodePtrVec_push( result, node );

    /* Check this node's edges to see if there's a match */
    /* Note: We have a NodePtrVec holding the set of nodes with this label. It
     *       may be more optimal to see if a given edge node is in that set
     *       rather than doing a bunch of inefficient strcmp calls. Another approach
     *       would be to have unique hash values for each label, and thereby be
     *       able to compare those. However for the initial version of this code,
     *       keeping things simple and straightforward, we're doing the string
     *       compare.
     */

    for ( edge = node->edges; edge != NULL; edge = edge->nextEdge )
    {

        // string based:
        if ( edge->targetNode->label && strcmp( edge->targetNode->label, labels[0] ) == 0 )
        // index based: if ( edge->targetNode->labelIdx == labelIdxs[0] )
        {
            // strcmp based:
            if ( labels[1] != NULL ) /* more steps in the signature */
            // index based: if ( labelIdxs[1] != -1 ) /* more steps in the signature */
            {
                nextLegVisited = Bitfield_new(visited->bitsNeeded);
                findAndRecordAllPaths(edge->targetNode, &labels[1], &labelIdxs[1], result,
                        nextLegVisited, storage, options );
                Bitfield_delete(nextLegVisited);
            }
            else /* We have exhausted the signature - ultimate victory! */
            {
                /* Register this edge node as being the final node */
                // printf ("\tFound!\n");
                NodePtrVec_push(result, edge->targetNode);
                Bitfield_nodeVisited(visited, edge->targetNode);/* Mark it as visited */
                logResult(storage, result, options); // <<<--- here's where I record it
                NodePtrVec_pop(result);
            }
        }
    }


    /* IF we made it here, we need to continue through the tree, seeing if any of our
     * edge nodes have a connection to a labeled node.
     */
    for ( edge = node->edges; edge != NULL; edge = edge->nextEdge )
    {
        findAndRecordAllPaths(edge->targetNode, labels, labelIdxs, result, visited, storage, options);
    }

    NodePtrVec_pop( result ); /* take current node off the result vector */
    return;
}