Search in sources :

Example 1 with FieldInfosFormat

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

the class SegmentReader method initFieldInfos.

/**
   * init most recent FieldInfos for the current commit
   */
private FieldInfos initFieldInfos() throws IOException {
    if (!si.hasFieldUpdates()) {
        return core.coreFieldInfos;
    } else {
        // updates always outside of CFS
        FieldInfosFormat fisFormat = si.info.getCodec().fieldInfosFormat();
        final String segmentSuffix = Long.toString(si.getFieldInfosGen(), Character.MAX_RADIX);
        return fisFormat.read(si.info.dir, si.info, segmentSuffix, IOContext.READONCE);
    }
}
Also used : FieldInfosFormat(org.apache.lucene.codecs.FieldInfosFormat)

Example 2 with FieldInfosFormat

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

the class IndexWriter method readFieldInfos.

// reads latest field infos for the commit
// this is used on IW init and addIndexes(Dir) to create/update the global field map.
// TODO: fix tests abusing this method!
static FieldInfos readFieldInfos(SegmentCommitInfo si) throws IOException {
    Codec codec = si.info.getCodec();
    FieldInfosFormat reader = codec.fieldInfosFormat();
    if (si.hasFieldUpdates()) {
        // there are updates, we read latest (always outside of CFS)
        final String segmentSuffix = Long.toString(si.getFieldInfosGen(), Character.MAX_RADIX);
        return reader.read(si.info.dir, si.info, segmentSuffix, IOContext.READONCE);
    } else if (si.info.getUseCompoundFile()) {
        // cfs
        try (Directory cfs = codec.compoundFormat().getCompoundReader(si.info.dir, si.info, IOContext.DEFAULT)) {
            return reader.read(cfs, si.info, "", IOContext.READONCE);
        }
    } else {
        // no cfs
        return reader.read(si.info.dir, si.info, "", IOContext.READONCE);
    }
}
Also used : Codec(org.apache.lucene.codecs.Codec) FieldInfosFormat(org.apache.lucene.codecs.FieldInfosFormat) MMapDirectory(org.apache.lucene.store.MMapDirectory) Directory(org.apache.lucene.store.Directory) FSDirectory(org.apache.lucene.store.FSDirectory)

Aggregations

FieldInfosFormat (org.apache.lucene.codecs.FieldInfosFormat)2 Codec (org.apache.lucene.codecs.Codec)1 Directory (org.apache.lucene.store.Directory)1 FSDirectory (org.apache.lucene.store.FSDirectory)1 MMapDirectory (org.apache.lucene.store.MMapDirectory)1