All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.elassandra.index.search.TokenRangesDirectoryReader Maven / Gradle / Ivy

There is a newer version: 6.2.3.31
Show newest version
package org.elassandra.index.search;

import java.io.IOException;

import org.apache.lucene.index.DirectoryReader;
import org.apache.lucene.index.FilterDirectoryReader;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.IndexReader.CacheHelper;
import org.apache.lucene.search.Query;

public class TokenRangesDirectoryReader extends FilterDirectoryReader {
    final Query query;
    final TokenRangesBitsetFilterCache cache;
    
    public TokenRangesDirectoryReader(DirectoryReader in, Query query, TokenRangesBitsetFilterCache cache) throws IOException {
        super(in, new FilterDirectoryReader.SubReaderWrapper() {
            @Override
            public LeafReader wrap(LeafReader reader) {
                try {
                    return new TokenRangesLeafReader(in, reader, query, cache);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        this.query = query;
        this.cache = cache;
        assert !(in instanceof TokenRangesDirectoryReader);
    }
    
    @Override
    protected DirectoryReader doWrapDirectoryReader(DirectoryReader in) throws IOException {
        return new TokenRangesDirectoryReader(in, query, cache);
    }
    
    @Override
    public CacheHelper getReaderCacheHelper() {
        // safe to delegate since this reader does not alter the index
        return in.getReaderCacheHelper();
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy