void searchInCoordinateIndex(QString const &pathToIndex, QString const &pathToCoordinateIndex)
{
	IndexLoader loader(pathToIndex);
	QMultiHash<QString, QString> hashTable = loader.loadedIndex();

	if (hashTable.isEmpty()) {
		qDebug() << "Index is not loaded";
	}

	CoordinateIndexLoader coordinateLoader(pathToCoordinateIndex);
	QHash<QString, QMultiHash<QString, QString>> coordinateHashTable = coordinateLoader.loadedIndex();

	if (coordinateHashTable.isEmpty()) {
		qDebug() << "Coordinate index is not loaded";
	}

	qDebug() << "Requests: \n";
	QString line = "";

	Searcher search(hashTable);
	CoordinateIndexSearcher coordinateSearch(coordinateHashTable);

	QTextStream in(stdin);
	in.setCodec(QTextCodec::codecForName("IBM 866"));

	do {
		line = in.readLine();
		if (line != ":q") {
			QStringList result = search.processRequest(line);
			coordinateSearch.processRequest(result, line);
		}
	} while (line != ":q");
}
Пример #2
0
int mythfile_open(const char *pathname, int flags)
{
    LOG(VB_FILE, LOG_DEBUG, QString("mythfile_open('%1', %2)")
            .arg(pathname).arg(flags));

    struct stat fileinfo;
    if (mythfile_stat(pathname, &fileinfo))
        return -1;

    if (S_ISDIR( fileinfo.st_mode )) // libmythdvdnav tries to open() a dir
        return errno = EISDIR, -1;

    int fileID = -1;
    if (strncmp(pathname, "myth://", 7))
    {
        int lfd = open(pathname, flags);
        if (lfd < 0)
            return -1;

        m_fileWrapperLock.lockForWrite();
        fileID = getNextFileID();
        m_localfiles[fileID] = lfd;
        m_filenames[fileID] = pathname;
        m_fileWrapperLock.unlock();
    }
    else
    {
        RingBuffer *rb = NULL;
        RemoteFile *rf = NULL;

        if ((fileinfo.st_size < 512) &&
            (fileinfo.st_mtime < (time(NULL) - 300)))
        {
            if (flags & O_WRONLY)
                rf = new RemoteFile(pathname, true, false); // Writeable
            else
                rf = new RemoteFile(pathname, false, true); // Read-Only

            if (!rf)
                return -1;
        }
        else
        {
            if (flags & O_WRONLY)
                rb = RingBuffer::Create(
                    pathname, true, false,
                    RingBuffer::kDefaultOpenTimeout, true); // Writeable
            else
                rb = RingBuffer::Create(
                    pathname, false, true,
                    RingBuffer::kDefaultOpenTimeout, true); // Read-Only

            if (!rb)
                return -1;

            rb->Start();
        }

        m_fileWrapperLock.lockForWrite();
        fileID = getNextFileID();

        if (rf)
            m_remotefiles[fileID] = rf;
        else if (rb)
            m_ringbuffers[fileID] = rb;

        m_filenames[fileID] = pathname;
        m_fileWrapperLock.unlock();
    }

    m_callbackLock.lock();
    if (!m_fileOpenCallbacks.isEmpty())
    {
        QString path(pathname);
        QHashIterator<QString,Callback> it(m_fileOpenCallbacks);
        while (it.hasNext())
        {
            it.next();
            if (path.startsWith(it.key()))
                it.value().m_callback(it.value().m_object);
        }
    }
    m_callbackLock.unlock();

    return fileID;
}