void SingleIndexBarrelReader::createTermReader(const std::string& sSuffix)
{
    FileSystemPtr& pFileSys = m_pFileSys;
    if (m_bMultiIndexFields)
    {
        MultiFieldTermReader* pMultiReader =
            new MultiFieldTermReader(m_pComponentBuilder);
        m_pTermReader.assign(pMultiReader);
        pMultiReader->open(pFileSys, m_pInStreamPool, sSuffix, getDocSchema(), m_pDocFilter);
    }
    else
    {
        DocumentSchema::Iterator iter = m_pDocSchema->iterator();
        while (iter.hasNext())
        {
            const FieldSchema* pFieldSchema = iter.next();
            if (pFieldSchema->isIndexed())
            {
                TermReader* pTermReader =
                    m_pComponentBuilder->buildTermReader(pFieldSchema->getId());
                FIRTEX_ASSERT2(pTermReader != NULL);

                m_pTermReader.assign(pTermReader);
                m_pTermReader->open(pFileSys, m_pInStreamPool, sSuffix,
                        pFieldSchema, m_pDocFilter);
                break;
            }
        }
    }
}
SingleIndexBarrelReader::SingleIndexBarrelReader(
        const FileSystemPtr& pFileSys,
        const DocumentSchema* pDocSchema,
        const ComponentBuilder* pComponentBuilder)
    : IndexBarrelReader(pFileSys, pDocSchema, pComponentBuilder)
    , m_pBarrelInfo(NULL)
    , m_pDocFilter(NULL)
{
    size_t nIndexFields = 0;
    DocumentSchema::Iterator it = pDocSchema->iterator();
    while (it.hasNext())
    {
        const FieldSchema* pFieldSchema = it.next();
        if (pFieldSchema->isIndexed())
        {
            ++nIndexFields;
        }
    }

    m_bMultiIndexFields = (nIndexFields > 1);
}
void SingleIndexBarrelReader::createForwardIndex(const std::string& sSuffix)
{
    DocumentSchema::Iterator iter = m_pDocSchema->iterator();
    while (iter.hasNext())
    {
        const FieldSchema* pFieldSchema = iter.next();
        if(pFieldSchema->hasForwardIndex())
        {
            fieldid_t fieldId = pFieldSchema->getId();
            ForwardIndexReader* pFDReader =
                m_pComponentBuilder->buildForwardIndexReader(fieldId);
            FIRTEX_ASSERT2(pFDReader != NULL);

            if (fieldId >= (fieldid_t)m_forwardIndexReaders.size())
            {
                m_forwardIndexReaders.resize(fieldId + 1);
            }
            m_forwardIndexReaders[fieldId].assign(pFDReader);
            pFDReader->open(m_pFileSys, pFieldSchema, FORWARD_INDEX_FILEEXT, sSuffix);
        }
    }
}
示例#4
0
PrimaryKeyIndexPtr IndexBarrelKeeper::createPrimaryKeyIndex()
{
    tstring sPrimKeyName;
    DocumentSchema::Iterator it = m_pDocSchema->iterator();
    while (it.hasNext())
    {
        const FieldSchema* pFieldSchema = it.next();
        if (pFieldSchema->getTypeName() == "PRIMARY_KEY")
        {
            sPrimKeyName = pFieldSchema->getName();
            break;
        }
    }

    if (!sPrimKeyName.empty())
    {
        PrimaryKeyIndexPtr pPrimKeyIndex(new PrimaryKeyIndex(sPrimKeyName));
        return pPrimKeyIndex;
    }
    else
    {
        return PrimaryKeyIndexPtr();
    }
}