Package org.apache.lucene.facet.taxonomy
Class CachedOrdinalsReader
- java.lang.Object
-
- org.apache.lucene.facet.taxonomy.OrdinalsReader
-
- org.apache.lucene.facet.taxonomy.CachedOrdinalsReader
-
- All Implemented Interfaces:
Accountable
public class CachedOrdinalsReader extends OrdinalsReader implements Accountable
A per-segment cache of documents' facet ordinals. EveryCachedOrdinalsReader.CachedOrds
holds the ordinals in a rawint[]
, and therefore consumes as much RAM as the total number of ordinals found in the segment, but saves the CPU cost of decoding ordinals during facet counting.NOTE: every
CachedOrdinalsReader.CachedOrds
is limited to 2.1B total ordinals. If that is a limitation for you then consider limiting the segment size to fewer documents, or use an alternative cache which pages through the category ordinals.NOTE: when using this cache, it is advised to use a
DocValuesFormat
that does not cache the data in memory, at least for the category lists fields, or otherwise you'll be doing double-caching.NOTE: create one instance of this and re-use it for all facet implementations (the cache is per-instance, not static).
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
CachedOrdinalsReader.CachedOrds
Holds the cached ordinals in two parallelint[]
arrays.-
Nested classes/interfaces inherited from class org.apache.lucene.facet.taxonomy.OrdinalsReader
OrdinalsReader.OrdinalsSegmentReader
-
-
Constructor Summary
Constructors Constructor Description CachedOrdinalsReader(OrdinalsReader source)
Sole constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Collection<Accountable>
getChildResources()
String
getIndexFieldName()
Returns the indexed field name thisOrdinalsReader
is reading from.OrdinalsReader.OrdinalsSegmentReader
getReader(LeafReaderContext context)
Set current atomic reader.long
ramBytesUsed()
-
-
-
Constructor Detail
-
CachedOrdinalsReader
public CachedOrdinalsReader(OrdinalsReader source)
Sole constructor.
-
-
Method Detail
-
getIndexFieldName
public String getIndexFieldName()
Description copied from class:OrdinalsReader
Returns the indexed field name thisOrdinalsReader
is reading from.- Specified by:
getIndexFieldName
in classOrdinalsReader
-
getReader
public OrdinalsReader.OrdinalsSegmentReader getReader(LeafReaderContext context) throws IOException
Description copied from class:OrdinalsReader
Set current atomic reader.- Specified by:
getReader
in classOrdinalsReader
- Throws:
IOException
-
ramBytesUsed
public long ramBytesUsed()
- Specified by:
ramBytesUsed
in interfaceAccountable
-
getChildResources
public Collection<Accountable> getChildResources()
- Specified by:
getChildResources
in interfaceAccountable
-
-