org.elassandra.index.search.TokenRangesBitsetProducer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of elasticsearch Show documentation
Show all versions of elasticsearch Show documentation
Elasticsearch subproject :server
package org.elassandra.index.search;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.lucene.index.IndexReaderContext;
import org.apache.lucene.index.LeafReader;
import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.ReaderUtil;
import org.apache.lucene.search.DocIdSetIterator;
import org.apache.lucene.search.FilteredDocIdSetIterator;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.Query;
import org.apache.lucene.search.Scorer;
import org.apache.lucene.search.Weight;
import org.apache.lucene.search.join.BitSetProducer;
import org.apache.lucene.util.Accountable;
import org.apache.lucene.util.BitSet;
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.RamUsageEstimator;
import java.io.IOException;
import java.util.Collection;
import java.util.Collections;
import java.util.Map;
import java.util.WeakHashMap;
import java.util.stream.Collectors;
/**
* A {@link BitSetProducer} that wraps a query and caches matching
* {@link BitSet}s per segment.
*/
public class TokenRangesBitsetProducer implements BitSetProducer, Accountable {
private static final Logger logger = LogManager.getLogger(TokenRangesBitsetProducer.class);
//memory usage of a simple term query
static final long QUERY_DEFAULT_RAM_BYTES_USED = 192;
static final long HASHTABLE_RAM_BYTES_PER_ENTRY =
2 * RamUsageEstimator.NUM_BYTES_OBJECT_REF // key + value
* 2; // hash tables need to be oversized to avoid collisions, assume 2x capacity
static class Value implements Accountable {
int tombestones;
BitSet bitset;
Value(int tombestones, BitSet bitset) {
this.tombestones = tombestones;
this.bitset = bitset;
}
@Override
public long ramBytesUsed() {
return HASHTABLE_RAM_BYTES_PER_ENTRY + (bitset==null ? 0 : bitset.ramBytesUsed());
}
@Override
public Collection getChildResources() {
return null;
}
}
private final TokenRangesBitsetFilterCache bitsetFilterCache;
private final Query query;
private final Map
© 2015 - 2025 Weber Informatics LLC | Privacy Policy