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

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

Introduction

In this page you can find the example usage for org.apache.lucene.codecs PostingsWriterBase 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 FieldsConsumer fieldsConsumer(final SegmentWriteState state) throws IOException {
    final PostingsWriterBase postingsWriter = new Siren10PostingsWriter(state, this.getFactory());

    boolean success = false;
    try {/*w ww .j  a v  a 2 s .c om*/
        final FieldsConsumer ret = new BlockTreeTermsWriter(state, postingsWriter,
                BlockTreeTermsWriter.DEFAULT_MIN_BLOCK_SIZE, BlockTreeTermsWriter.DEFAULT_MAX_BLOCK_SIZE);
        success = true;
        return ret;
    } finally {
        if (!success) {
            postingsWriter.close();
        }
    }
}

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

License:Apache License

@Override
public FieldsConsumer fieldsConsumer(final SegmentWriteState state) throws IOException {
    final PostingsWriterBase docs = new Siren10PostingsWriter(state, this.getFactory());

    boolean success = false;
    try {//  www.j  a  v a 2  s . c o m
        final FieldsConsumer ret = new BlockTreeTermsWriter(state, docs,
                BlockTreeTermsWriter.DEFAULT_MIN_BLOCK_SIZE, BlockTreeTermsWriter.DEFAULT_MAX_BLOCK_SIZE);
        success = true;
        return ret;
    } finally {
        if (!success) {
            docs.close();
        }
    }
}