Search in sources :

Example 1 with BlockTermState

use of org.apache.lucene.codecs.BlockTermState in project lucene-solr by apache.

the class FSTOrdTermsWriter method write.

@Override
public void write(Fields fields) throws IOException {
    for (String field : fields) {
        Terms terms = fields.terms(field);
        if (terms == null) {
            continue;
        }
        FieldInfo fieldInfo = fieldInfos.fieldInfo(field);
        boolean hasFreq = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS) >= 0;
        TermsEnum termsEnum = terms.iterator();
        TermsWriter termsWriter = new TermsWriter(fieldInfo);
        long sumTotalTermFreq = 0;
        long sumDocFreq = 0;
        FixedBitSet docsSeen = new FixedBitSet(maxDoc);
        while (true) {
            BytesRef term = termsEnum.next();
            if (term == null) {
                break;
            }
            BlockTermState termState = postingsWriter.writeTerm(term, termsEnum, docsSeen);
            if (termState != null) {
                termsWriter.finishTerm(term, termState);
                sumTotalTermFreq += termState.totalTermFreq;
                sumDocFreq += termState.docFreq;
            }
        }
        termsWriter.finish(hasFreq ? sumTotalTermFreq : -1, sumDocFreq, docsSeen.cardinality());
    }
}
Also used : BlockTermState(org.apache.lucene.codecs.BlockTermState) FixedBitSet(org.apache.lucene.util.FixedBitSet) Terms(org.apache.lucene.index.Terms) FieldInfo(org.apache.lucene.index.FieldInfo) BytesRef(org.apache.lucene.util.BytesRef) TermsEnum(org.apache.lucene.index.TermsEnum)

Example 2 with BlockTermState

use of org.apache.lucene.codecs.BlockTermState in project lucene-solr by apache.

the class OrdsSegmentTermsEnum method seekExact.

@Override
public void seekExact(BytesRef target, TermState otherState) {
    // }
    assert clearEOF();
    if (target.compareTo(term.get()) != 0 || !termExists) {
        assert otherState != null && otherState instanceof BlockTermState;
        BlockTermState blockState = (BlockTermState) otherState;
        currentFrame = staticFrame;
        currentFrame.state.copyFrom(otherState);
        term.copyBytes(target);
        currentFrame.metaDataUpto = currentFrame.getTermBlockOrd();
        currentFrame.termOrd = blockState.ord + 1;
        assert currentFrame.metaDataUpto > 0;
        validIndexPrefix = 0;
    } else {
    // if (DEBUG) {
    //   System.out.println("  skip seek: already on target state=" + currentFrame.state);
    // }
    }
    positioned = true;
}
Also used : BlockTermState(org.apache.lucene.codecs.BlockTermState)

Example 3 with BlockTermState

use of org.apache.lucene.codecs.BlockTermState in project lucene-solr by apache.

the class OrdsSegmentTermsEnum method termState.

@Override
public TermState termState() throws IOException {
    assert !eof;
    currentFrame.decodeMetaData();
    BlockTermState ts = (BlockTermState) currentFrame.state.clone();
    assert currentFrame.termOrd > 0;
    ts.ord = currentFrame.termOrd - 1;
    //if (DEBUG) System.out.println("BTTR.termState seg=" + segment + " state=" + ts);
    return ts;
}
Also used : BlockTermState(org.apache.lucene.codecs.BlockTermState)

Example 4 with BlockTermState

use of org.apache.lucene.codecs.BlockTermState in project lucene-solr by apache.

the class FSTTermsWriter method write.

@Override
public void write(Fields fields) throws IOException {
    for (String field : fields) {
        Terms terms = fields.terms(field);
        if (terms == null) {
            continue;
        }
        FieldInfo fieldInfo = fieldInfos.fieldInfo(field);
        boolean hasFreq = fieldInfo.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS) >= 0;
        TermsEnum termsEnum = terms.iterator();
        TermsWriter termsWriter = new TermsWriter(fieldInfo);
        long sumTotalTermFreq = 0;
        long sumDocFreq = 0;
        FixedBitSet docsSeen = new FixedBitSet(maxDoc);
        while (true) {
            BytesRef term = termsEnum.next();
            if (term == null) {
                break;
            }
            BlockTermState termState = postingsWriter.writeTerm(term, termsEnum, docsSeen);
            if (termState != null) {
                termsWriter.finishTerm(term, termState);
                sumTotalTermFreq += termState.totalTermFreq;
                sumDocFreq += termState.docFreq;
            }
        }
        termsWriter.finish(hasFreq ? sumTotalTermFreq : -1, sumDocFreq, docsSeen.cardinality());
    }
}
Also used : BlockTermState(org.apache.lucene.codecs.BlockTermState) FixedBitSet(org.apache.lucene.util.FixedBitSet) Terms(org.apache.lucene.index.Terms) FieldInfo(org.apache.lucene.index.FieldInfo) BytesRef(org.apache.lucene.util.BytesRef) TermsEnum(org.apache.lucene.index.TermsEnum)

Aggregations

BlockTermState (org.apache.lucene.codecs.BlockTermState)4 FieldInfo (org.apache.lucene.index.FieldInfo)2 Terms (org.apache.lucene.index.Terms)2 TermsEnum (org.apache.lucene.index.TermsEnum)2 BytesRef (org.apache.lucene.util.BytesRef)2 FixedBitSet (org.apache.lucene.util.FixedBitSet)2