Example usage for org.apache.lucene.index SegmentInfo getUseCompoundFile

List of usage examples for org.apache.lucene.index SegmentInfo getUseCompoundFile

Introduction

In this page you can find the example usage for org.apache.lucene.index SegmentInfo getUseCompoundFile.

Prototype

public boolean getUseCompoundFile() 

Source Link

Document

Returns true if this segment is stored as a compound file; else, false.

Usage

From source file:org.apache.blur.lucene.codec.Blur022SegmentInfoWriter.java

License:Apache License

@Override
public void write(Directory dir, SegmentInfo si, FieldInfos fis, IOContext ioContext) throws IOException {
    final String fileName = IndexFileNames.segmentFileName(si.name, "", Blur022SegmentInfoFormat.SI_EXTENSION);
    si.addFile(fileName);//from w w  w  .j  a  va2s. co  m

    final IndexOutput output = dir.createOutput(fileName, ioContext);

    boolean success = false;
    try {
        CodecUtil.writeHeader(output, Blur022SegmentInfoFormat.CODEC_NAME,
                Blur022SegmentInfoFormat.VERSION_CURRENT);
        output.writeString(si.getVersion());
        output.writeInt(si.getDocCount());

        output.writeByte((byte) (si.getUseCompoundFile() ? SegmentInfo.YES : SegmentInfo.NO));
        output.writeStringStringMap(si.getDiagnostics());
        Map<String, String> attributes = si.attributes();
        TreeMap<String, String> newAttributes = new TreeMap<String, String>();
        if (attributes != null) {
            newAttributes.putAll(attributes);
        }
        newAttributes.put(Blur022StoredFieldsFormat.STORED_FIELDS_FORMAT_CHUNK_SIZE,
                Integer.toString(_compressionChunkSize));
        newAttributes.put(Blur022StoredFieldsFormat.STORED_FIELDS_FORMAT_COMPRESSION_MODE, _compressionMode);
        output.writeStringStringMap(newAttributes);
        output.writeStringSet(si.files());

        success = true;
    } finally {
        if (!success) {
            IOUtils.closeWhileHandlingException(output);
            si.dir.deleteFile(fileName);
        } else {
            output.close();
        }
    }
}

From source file:org.elasticsearch.index.merge.policy.BalancedSegmentMergePolicy.java

License:Apache License

private boolean isOptimized(IndexWriter writer, SegmentInfo info) throws IOException {
    return !info.hasDeletions() && !info.hasSeparateNorms() && info.dir == writer.getDirectory()
            && info.getUseCompoundFile() == getUseCompoundFile();
}

From source file:proj.zoie.api.impl.ZoieMergePolicy.java

License:Apache License

/** Returns true if this single nfo is optimized (has no
 *  pending norms or deletes, is in the same dir as the
 *  writer, and matches the current compound file setting */
@Override/*w w  w. jav  a 2s  .co  m*/
protected boolean isMerged(SegmentInfo info) throws IOException {
    IndexWriter w = writer.get();
    return !info.hasDeletions() && !info.hasSeparateNorms() && info.dir == w.getDirectory()
            && info.getUseCompoundFile() == getUseCompoundFile();
}