Package org.apache.solr.uninverting
Class FieldCacheImpl
- java.lang.Object
-
- org.apache.solr.uninverting.FieldCacheImpl
-
- All Implemented Interfaces:
FieldCache
public class FieldCacheImpl extends Object implements FieldCache
Expert: The default cache implementation, storing all values in memory. A WeakHashMap is used for storage.- NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classFieldCacheImpl.BinaryDocValuesImplstatic classFieldCacheImpl.LongsFromArraystatic classFieldCacheImpl.SortedDocValuesImpl-
Nested classes/interfaces inherited from interface org.apache.solr.uninverting.FieldCache
FieldCache.CacheEntry, FieldCache.CreationPlaceholder, FieldCache.Parser, FieldCache.PointParser
-
-
Field Summary
-
Fields inherited from interface org.apache.solr.uninverting.FieldCache
DEFAULT, DOUBLE_POINT_PARSER, FLOAT_POINT_PARSER, INT_POINT_PARSER, INT32_TERM_PREFIX, INT64_TERM_PREFIX, LEGACY_DOUBLE_PARSER, LEGACY_FLOAT_PARSER, LEGACY_INT_PARSER, LEGACY_LONG_PARSER, LONG_POINT_PARSER
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description FieldCache.CacheEntry[]getCacheEntries()EXPERT: Generates an array of CacheEntry objects representing all items currently in the FieldCache.org.apache.lucene.util.BitsgetDocsWithField(org.apache.lucene.index.LeafReader reader, String field, FieldCache.Parser parser)Checks the internal cache for an appropriate entry, and if none is found, reads the terms/points infieldand returns a bit set at the size ofreader.maxDoc(), with turned on bits for each docid that does have a value for this field.org.apache.lucene.index.SortedSetDocValuesgetDocTermOrds(org.apache.lucene.index.LeafReader reader, String field, org.apache.lucene.util.BytesRef prefix)Checks the internal cache for an appropriate entry, and if none is found, reads the term values infieldand returns aDocTermOrdsinstance, providing a method to retrieve the terms (as ords) per document.org.apache.lucene.index.NumericDocValuesgetNumerics(org.apache.lucene.index.LeafReader reader, String field, FieldCache.Parser parser)Returns aNumericDocValuesover the values found in documents in the given field.org.apache.lucene.index.BinaryDocValuesgetTerms(org.apache.lucene.index.LeafReader reader, String field)Checks the internal cache for an appropriate entry, and if none is found, reads the term values infieldand returns aBinaryDocValuesinstance, providing a method to retrieve the term (as a BytesRef) per document.org.apache.lucene.index.BinaryDocValuesgetTerms(org.apache.lucene.index.LeafReader reader, String field, float acceptableOverheadRatio)Expert: just likeFieldCache.getTerms(org.apache.lucene.index.LeafReader,String), but you can specify whether more RAM should be consumed in exchange for faster lookups (default is "true").org.apache.lucene.index.SortedDocValuesgetTermsIndex(org.apache.lucene.index.LeafReader reader, String field)Checks the internal cache for an appropriate entry, and if none is found, reads the term values infieldand returns aSortedDocValuesinstance, providing methods to retrieve sort ordinals and terms (as a ByteRef) per document.org.apache.lucene.index.SortedDocValuesgetTermsIndex(org.apache.lucene.index.LeafReader reader, String field, float acceptableOverheadRatio)Expert: just likeFieldCache.getTermsIndex(org.apache.lucene.index.LeafReader,String), but you can specify whether more RAM should be consumed in exchange for faster lookups (default is "true").voidpurgeAllCaches()EXPERT: Instructs the FieldCache to forcibly expunge all entries from the underlying caches.voidpurgeByCacheKey(org.apache.lucene.index.IndexReader.CacheKey coreCacheKey)Expert: drops all cache entries associated with this readerIndexReader.CacheHelper.getKey().
-
-
-
Method Detail
-
purgeAllCaches
public void purgeAllCaches()
Description copied from interface:FieldCacheEXPERT: Instructs the FieldCache to forcibly expunge all entries from the underlying caches. This is intended only to be used for test methods as a way to ensure a known base state of the Cache (with out needing to rely on GC to free WeakReferences). It should not be relied on for "Cache maintenance" in general application code.- Specified by:
purgeAllCachesin interfaceFieldCache
-
purgeByCacheKey
public void purgeByCacheKey(org.apache.lucene.index.IndexReader.CacheKey coreCacheKey)
Description copied from interface:FieldCacheExpert: drops all cache entries associated with this readerIndexReader.CacheHelper.getKey(). NOTE: this cache key must precisely match the reader that the cache entry is keyed on. If you pass a top-level reader, it usually will have no effect as Lucene now caches at the segment reader level.- Specified by:
purgeByCacheKeyin interfaceFieldCache
-
getCacheEntries
public FieldCache.CacheEntry[] getCacheEntries()
Description copied from interface:FieldCacheEXPERT: Generates an array of CacheEntry objects representing all items currently in the FieldCache.NOTE: These CacheEntry objects maintain a strong reference to the Cached Values. Maintaining references to a CacheEntry the AtomicIndexReader associated with it has garbage collected will prevent the Value itself from being garbage collected when the Cache drops the WeakReference.
- Specified by:
getCacheEntriesin interfaceFieldCache
-
getDocsWithField
public org.apache.lucene.util.Bits getDocsWithField(org.apache.lucene.index.LeafReader reader, String field, FieldCache.Parser parser) throws IOExceptionDescription copied from interface:FieldCacheChecks the internal cache for an appropriate entry, and if none is found, reads the terms/points infieldand returns a bit set at the size ofreader.maxDoc(), with turned on bits for each docid that does have a value for this field.- Specified by:
getDocsWithFieldin interfaceFieldCacheparser- May benullif coming from the inverted index, otherwise can be aFieldCache.PointParserto compute from point values.- Throws:
IOException
-
getNumerics
public org.apache.lucene.index.NumericDocValues getNumerics(org.apache.lucene.index.LeafReader reader, String field, FieldCache.Parser parser) throws IOExceptionDescription copied from interface:FieldCacheReturns aNumericDocValuesover the values found in documents in the given field. If the field was indexed asNumericDocValuesField, it simply usesLeafReader.getNumericDocValues(String)to read the values. Otherwise, it checks the internal cache for an appropriate entry, and if none is found, reads the terms/points infieldas longs and returns an array of sizereader.maxDoc()of the value each document has in the given field.- Specified by:
getNumericsin interfaceFieldCache- Parameters:
reader- Used to get field values.field- Which field contains the longs.parser- Computes long for string values. May benullif the requested field was indexed asNumericDocValuesFieldorLegacyLongField.- Returns:
- The values in the given field for each document.
- Throws:
IOException- If any error occurs.
-
getTermsIndex
public org.apache.lucene.index.SortedDocValues getTermsIndex(org.apache.lucene.index.LeafReader reader, String field) throws IOExceptionDescription copied from interface:FieldCacheChecks the internal cache for an appropriate entry, and if none is found, reads the term values infieldand returns aSortedDocValuesinstance, providing methods to retrieve sort ordinals and terms (as a ByteRef) per document.- Specified by:
getTermsIndexin interfaceFieldCache- Parameters:
reader- Used to get field values.field- Which field contains the strings.- Returns:
- The values in the given field for each document.
- Throws:
IOException- If any error occurs.
-
getTermsIndex
public org.apache.lucene.index.SortedDocValues getTermsIndex(org.apache.lucene.index.LeafReader reader, String field, float acceptableOverheadRatio) throws IOExceptionDescription copied from interface:FieldCacheExpert: just likeFieldCache.getTermsIndex(org.apache.lucene.index.LeafReader,String), but you can specify whether more RAM should be consumed in exchange for faster lookups (default is "true"). Note that the first call for a given reader and field "wins", subsequent calls will share the same cache entry.- Specified by:
getTermsIndexin interfaceFieldCache- Throws:
IOException
-
getTerms
public org.apache.lucene.index.BinaryDocValues getTerms(org.apache.lucene.index.LeafReader reader, String field) throws IOExceptionDescription copied from interface:FieldCacheChecks the internal cache for an appropriate entry, and if none is found, reads the term values infieldand returns aBinaryDocValuesinstance, providing a method to retrieve the term (as a BytesRef) per document.- Specified by:
getTermsin interfaceFieldCache- Parameters:
reader- Used to get field values.field- Which field contains the strings.- Returns:
- The values in the given field for each document.
- Throws:
IOException- If any error occurs.
-
getTerms
public org.apache.lucene.index.BinaryDocValues getTerms(org.apache.lucene.index.LeafReader reader, String field, float acceptableOverheadRatio) throws IOExceptionDescription copied from interface:FieldCacheExpert: just likeFieldCache.getTerms(org.apache.lucene.index.LeafReader,String), but you can specify whether more RAM should be consumed in exchange for faster lookups (default is "true"). Note that the first call for a given reader and field "wins", subsequent calls will share the same cache entry.- Specified by:
getTermsin interfaceFieldCache- Throws:
IOException
-
getDocTermOrds
public org.apache.lucene.index.SortedSetDocValues getDocTermOrds(org.apache.lucene.index.LeafReader reader, String field, org.apache.lucene.util.BytesRef prefix) throws IOExceptionDescription copied from interface:FieldCacheChecks the internal cache for an appropriate entry, and if none is found, reads the term values infieldand returns aDocTermOrdsinstance, providing a method to retrieve the terms (as ords) per document.- Specified by:
getDocTermOrdsin interfaceFieldCache- Parameters:
reader- Used to build aDocTermOrdsinstancefield- Which field contains the strings.prefix- prefix for a subset of the terms which should be uninverted. Can be null orFieldCache.INT32_TERM_PREFIXorFieldCache.INT64_TERM_PREFIX- Returns:
- a
DocTermOrdsinstance - Throws:
IOException- If any error occurs.
-
-