Example usage for org.apache.lucene.codecs PostingsReaderBase close

List of usage examples for org.apache.lucene.codecs PostingsReaderBase close

Introduction

In this page you can find the example usage for org.apache.lucene.codecs PostingsReaderBase close.

Prototype

@Override
    public abstract void close() throws IOException;

Source Link

Usage

From source file:com.sindicetech.siren.index.codecs.siren10.Siren10PostingsFormat.java

License:Open Source License

@Override
public FieldsProducer fieldsProducer(final SegmentReadState state) throws IOException {
    final PostingsReaderBase postingsReader = new Siren10PostingsReader(state.directory, state.segmentInfo,
            state.context, state.segmentSuffix, this.getFactory());

    boolean success = false;
    try {/*  w w  w .j  ava 2  s  .c  o  m*/
        final FieldsProducer ret = new BlockTreeTermsReader(state.directory, state.fieldInfos,
                state.segmentInfo, postingsReader, state.context, state.segmentSuffix, state.termsIndexDivisor);
        success = true;
        return ret;
    } finally {
        if (!success) {
            postingsReader.close();
        }
    }
}

From source file:org.sindice.siren.index.codecs.siren10.Siren10PostingsFormat.java

License:Apache License

@Override
public FieldsProducer fieldsProducer(final SegmentReadState state) throws IOException {
    final PostingsReaderBase postings = new Siren10PostingsReader(state.dir, state.segmentInfo, state.context,
            state.segmentSuffix, this.getFactory());

    boolean success = false;
    try {//from  w  w  w .  j av  a2 s .  c  o m
        final FieldsProducer ret = new BlockTreeTermsReader(state.dir, state.fieldInfos, state.segmentInfo,
                postings, state.context, state.segmentSuffix, state.termsIndexDivisor);
        success = true;
        return ret;
    } finally {
        if (!success) {
            postings.close();
        }
    }
}