Package org.apache.lucene.search
Interface FieldCache
- 
public interface FieldCacheExpert: Maintains caches of term values.Created: May 19, 2004 11:13:14 AM
- Since:
 - lucene 1.4
 - See Also:
 FieldCacheSanityChecker
 
- 
- 
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceFieldCache.ByteParserDeprecated.static classFieldCache.BytesField values as 8-bit signed bytesstatic classFieldCache.CacheEntryEXPERT: A unique Identifier/Description for each item in the FieldCache.static classFieldCache.CreationPlaceholderPlaceholder indicating creation of this cache is currently in-progress.static interfaceFieldCache.DoubleParserInterface to parse doubles from document fields.static classFieldCache.DoublesField values as 64-bit doublesstatic interfaceFieldCache.FloatParserInterface to parse floats from document fields.static classFieldCache.FloatsField values as 32-bit floatsstatic interfaceFieldCache.IntParserInterface to parse ints from document fields.static classFieldCache.IntsField values as 32-bit signed integersstatic interfaceFieldCache.LongParserInterface to parse long from document fields.static classFieldCache.LongsField values as 64-bit signed long integersstatic interfaceFieldCache.ParserMarker interface as super-interface to all parsers.static interfaceFieldCache.ShortParserDeprecated.static classFieldCache.ShortsField values as 16-bit signed shorts 
- 
Field Summary
Fields Modifier and Type Field Description static FieldCacheDEFAULTExpert: The cache used internally by sorting and range query classes.static FieldCache.ByteParserDEFAULT_BYTE_PARSERDeprecated.static FieldCache.DoubleParserDEFAULT_DOUBLE_PARSERDeprecated.static FieldCache.FloatParserDEFAULT_FLOAT_PARSERDeprecated.static FieldCache.IntParserDEFAULT_INT_PARSERDeprecated.static FieldCache.LongParserDEFAULT_LONG_PARSERDeprecated.static FieldCache.ShortParserDEFAULT_SHORT_PARSERDeprecated.static FieldCache.DoubleParserNUMERIC_UTILS_DOUBLE_PARSERA parser instance for double values encoded withNumericUtils, e.g.static FieldCache.FloatParserNUMERIC_UTILS_FLOAT_PARSERA parser instance for float values encoded withNumericUtils, e.g.static FieldCache.IntParserNUMERIC_UTILS_INT_PARSERA parser instance for int values encoded byNumericUtils, e.g.static FieldCache.LongParserNUMERIC_UTILS_LONG_PARSERA parser instance for long values encoded byNumericUtils, e.g. 
- 
Method Summary
All Methods Instance Methods Abstract Methods Deprecated Methods Modifier and Type Method Description FieldCache.BytesgetBytes(AtomicReader reader, java.lang.String field, boolean setDocsWithField)Deprecated.(4.4) Index as a numeric field usingIntFieldand then usegetInts(AtomicReader, String, boolean)instead.FieldCache.BytesgetBytes(AtomicReader reader, java.lang.String field, FieldCache.ByteParser parser, boolean setDocsWithField)Deprecated.(4.4) Index as a numeric field usingIntFieldand then usegetInts(AtomicReader, String, boolean)instead.FieldCache.CacheEntry[]getCacheEntries()EXPERT: Generates an array of CacheEntry objects representing all items currently in the FieldCache.BitsgetDocsWithField(AtomicReader reader, java.lang.String field)Checks the internal cache for an appropriate entry, and if none is found, reads the terms 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.SortedSetDocValuesgetDocTermOrds(AtomicReader reader, java.lang.String field)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.FieldCache.DoublesgetDoubles(AtomicReader reader, java.lang.String field, boolean setDocsWithField)Returns aFieldCache.Doublesover the values found in documents in the given field.FieldCache.DoublesgetDoubles(AtomicReader reader, java.lang.String field, FieldCache.DoubleParser parser, boolean setDocsWithField)Returns aFieldCache.Doublesover the values found in documents in the given field.FieldCache.FloatsgetFloats(AtomicReader reader, java.lang.String field, boolean setDocsWithField)Returns aFieldCache.Floatsover the values found in documents in the given field.FieldCache.FloatsgetFloats(AtomicReader reader, java.lang.String field, FieldCache.FloatParser parser, boolean setDocsWithField)Returns aFieldCache.Floatsover the values found in documents in the given field.java.io.PrintStreamgetInfoStream()counterpart ofsetInfoStream(PrintStream)FieldCache.IntsgetInts(AtomicReader reader, java.lang.String field, boolean setDocsWithField)Returns anFieldCache.Intsover the values found in documents in the given field.FieldCache.IntsgetInts(AtomicReader reader, java.lang.String field, FieldCache.IntParser parser, boolean setDocsWithField)Returns anFieldCache.Intsover the values found in documents in the given field.FieldCache.LongsgetLongs(AtomicReader reader, java.lang.String field, boolean setDocsWithField)Returns aFieldCache.Longsover the values found in documents in the given field.FieldCache.LongsgetLongs(AtomicReader reader, java.lang.String field, FieldCache.LongParser parser, boolean setDocsWithField)Returns aFieldCache.Longsover the values found in documents in the given field.FieldCache.ShortsgetShorts(AtomicReader reader, java.lang.String field, boolean setDocsWithField)Deprecated.(4.4) Index as a numeric field usingIntFieldand then usegetInts(AtomicReader, String, boolean)instead.FieldCache.ShortsgetShorts(AtomicReader reader, java.lang.String field, FieldCache.ShortParser parser, boolean setDocsWithField)Deprecated.(4.4) Index as a numeric field usingIntFieldand then usegetInts(AtomicReader, String, boolean)instead.BinaryDocValuesgetTerms(AtomicReader reader, java.lang.String field, boolean setDocsWithField)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.BinaryDocValuesgetTerms(AtomicReader reader, java.lang.String field, boolean setDocsWithField, float acceptableOverheadRatio)Expert: just likegetTerms(AtomicReader,String,boolean), but you can specify whether more RAM should be consumed in exchange for faster lookups (default is "true").SortedDocValuesgetTermsIndex(AtomicReader reader, java.lang.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.SortedDocValuesgetTermsIndex(AtomicReader reader, java.lang.String field, float acceptableOverheadRatio)Expert: just likegetTermsIndex(AtomicReader,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(java.lang.Object coreCacheKey)Expert: drops all cache entries associated with this readerIndexReader.getCoreCacheKey().voidsetInfoStream(java.io.PrintStream stream)If non-null, FieldCacheImpl will warn whenever entries are created that are not sane according toFieldCacheSanityChecker. 
 - 
 
- 
- 
Field Detail
- 
DEFAULT
static final FieldCache DEFAULT
Expert: The cache used internally by sorting and range query classes. 
- 
DEFAULT_BYTE_PARSER
@Deprecated static final FieldCache.ByteParser DEFAULT_BYTE_PARSER
Deprecated.The default parser for byte values, which are encoded byByte.toString(byte) 
- 
DEFAULT_SHORT_PARSER
@Deprecated static final FieldCache.ShortParser DEFAULT_SHORT_PARSER
Deprecated.The default parser for short values, which are encoded byShort.toString(short) 
- 
DEFAULT_INT_PARSER
@Deprecated static final FieldCache.IntParser DEFAULT_INT_PARSER
Deprecated.The default parser for int values, which are encoded byInteger.toString(int) 
- 
DEFAULT_FLOAT_PARSER
@Deprecated static final FieldCache.FloatParser DEFAULT_FLOAT_PARSER
Deprecated.The default parser for float values, which are encoded byFloat.toString(float) 
- 
DEFAULT_LONG_PARSER
@Deprecated static final FieldCache.LongParser DEFAULT_LONG_PARSER
Deprecated.The default parser for long values, which are encoded byLong.toString(long) 
- 
DEFAULT_DOUBLE_PARSER
@Deprecated static final FieldCache.DoubleParser DEFAULT_DOUBLE_PARSER
Deprecated.The default parser for double values, which are encoded byDouble.toString(double) 
- 
NUMERIC_UTILS_INT_PARSER
static final FieldCache.IntParser NUMERIC_UTILS_INT_PARSER
A parser instance for int values encoded byNumericUtils, e.g. when indexed viaIntField/NumericTokenStream. 
- 
NUMERIC_UTILS_FLOAT_PARSER
static final FieldCache.FloatParser NUMERIC_UTILS_FLOAT_PARSER
A parser instance for float values encoded withNumericUtils, e.g. when indexed viaFloatField/NumericTokenStream. 
- 
NUMERIC_UTILS_LONG_PARSER
static final FieldCache.LongParser NUMERIC_UTILS_LONG_PARSER
A parser instance for long values encoded byNumericUtils, e.g. when indexed viaLongField/NumericTokenStream. 
- 
NUMERIC_UTILS_DOUBLE_PARSER
static final FieldCache.DoubleParser NUMERIC_UTILS_DOUBLE_PARSER
A parser instance for double values encoded withNumericUtils, e.g. when indexed viaDoubleField/NumericTokenStream. 
 - 
 
- 
Method Detail
- 
getDocsWithField
Bits getDocsWithField(AtomicReader reader, java.lang.String field) throws java.io.IOException
Checks the internal cache for an appropriate entry, and if none is found, reads the terms 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.- Throws:
 java.io.IOException
 
- 
getBytes
@Deprecated FieldCache.Bytes getBytes(AtomicReader reader, java.lang.String field, boolean setDocsWithField) throws java.io.IOException
Deprecated.(4.4) Index as a numeric field usingIntFieldand then usegetInts(AtomicReader, String, boolean)instead.Checks the internal cache for an appropriate entry, and if none is found, reads the terms infieldas a single byte and returns an array of sizereader.maxDoc()of the value each document has in the given field.- Parameters:
 reader- Used to get field values.field- Which field contains the single byte values.setDocsWithField- If true thengetDocsWithField(org.apache.lucene.index.AtomicReader, java.lang.String)will also be computed and stored in the FieldCache.- Returns:
 - The values in the given field for each document.
 - Throws:
 java.io.IOException- If any error occurs.
 
- 
getBytes
@Deprecated FieldCache.Bytes getBytes(AtomicReader reader, java.lang.String field, FieldCache.ByteParser parser, boolean setDocsWithField) throws java.io.IOException
Deprecated.(4.4) Index as a numeric field usingIntFieldand then usegetInts(AtomicReader, String, boolean)instead.Checks the internal cache for an appropriate entry, and if none is found, reads the terms infieldas bytes and returns an array of sizereader.maxDoc()of the value each document has in the given field.- Parameters:
 reader- Used to get field values.field- Which field contains the bytes.parser- Computes byte for string values.setDocsWithField- If true thengetDocsWithField(org.apache.lucene.index.AtomicReader, java.lang.String)will also be computed and stored in the FieldCache.- Returns:
 - The values in the given field for each document.
 - Throws:
 java.io.IOException- If any error occurs.
 
- 
getShorts
@Deprecated FieldCache.Shorts getShorts(AtomicReader reader, java.lang.String field, boolean setDocsWithField) throws java.io.IOException
Deprecated.(4.4) Index as a numeric field usingIntFieldand then usegetInts(AtomicReader, String, boolean)instead.Checks the internal cache for an appropriate entry, and if none is found, reads the terms infieldas shorts and returns an array of sizereader.maxDoc()of the value each document has in the given field.- Parameters:
 reader- Used to get field values.field- Which field contains the shorts.setDocsWithField- If true thengetDocsWithField(org.apache.lucene.index.AtomicReader, java.lang.String)will also be computed and stored in the FieldCache.- Returns:
 - The values in the given field for each document.
 - Throws:
 java.io.IOException- If any error occurs.
 
- 
getShorts
@Deprecated FieldCache.Shorts getShorts(AtomicReader reader, java.lang.String field, FieldCache.ShortParser parser, boolean setDocsWithField) throws java.io.IOException
Deprecated.(4.4) Index as a numeric field usingIntFieldand then usegetInts(AtomicReader, String, boolean)instead.Checks the internal cache for an appropriate entry, and if none is found, reads the terms infieldas shorts and returns an array of sizereader.maxDoc()of the value each document has in the given field.- Parameters:
 reader- Used to get field values.field- Which field contains the shorts.parser- Computes short for string values.setDocsWithField- If true thengetDocsWithField(org.apache.lucene.index.AtomicReader, java.lang.String)will also be computed and stored in the FieldCache.- Returns:
 - The values in the given field for each document.
 - Throws:
 java.io.IOException- If any error occurs.
 
- 
getInts
FieldCache.Ints getInts(AtomicReader reader, java.lang.String field, boolean setDocsWithField) throws java.io.IOException
Returns anFieldCache.Intsover the values found in documents in the given field.- Throws:
 java.io.IOException- See Also:
 getInts(AtomicReader, String, IntParser, boolean)
 
- 
getInts
FieldCache.Ints getInts(AtomicReader reader, java.lang.String field, FieldCache.IntParser parser, boolean setDocsWithField) throws java.io.IOException
Returns anFieldCache.Intsover the values found in documents in the given field. If the field was indexed asNumericDocValuesField, it simply usesAtomicReader.getNumericDocValues(String)to read the values. Otherwise, it checks the internal cache for an appropriate entry, and if none is found, reads the terms infieldas ints and returns an array of sizereader.maxDoc()of the value each document has in the given field.- Parameters:
 reader- Used to get field values.field- Which field contains the longs.parser- Computes int for string values. May benullif the requested field was indexed asNumericDocValuesFieldorIntField.setDocsWithField- If true thengetDocsWithField(org.apache.lucene.index.AtomicReader, java.lang.String)will also be computed and stored in the FieldCache.- Returns:
 - The values in the given field for each document.
 - Throws:
 java.io.IOException- If any error occurs.
 
- 
getFloats
FieldCache.Floats getFloats(AtomicReader reader, java.lang.String field, boolean setDocsWithField) throws java.io.IOException
Returns aFieldCache.Floatsover the values found in documents in the given field.- Throws:
 java.io.IOException- See Also:
 getFloats(AtomicReader, String, FloatParser, boolean)
 
- 
getFloats
FieldCache.Floats getFloats(AtomicReader reader, java.lang.String field, FieldCache.FloatParser parser, boolean setDocsWithField) throws java.io.IOException
Returns aFieldCache.Floatsover the values found in documents in the given field. If the field was indexed asNumericDocValuesField, it simply usesAtomicReader.getNumericDocValues(String)to read the values. Otherwise, it checks the internal cache for an appropriate entry, and if none is found, reads the terms infieldas floats and returns an array of sizereader.maxDoc()of the value each document has in the given field.- Parameters:
 reader- Used to get field values.field- Which field contains the floats.parser- Computes float for string values. May benullif the requested field was indexed asNumericDocValuesFieldorFloatField.setDocsWithField- If true thengetDocsWithField(org.apache.lucene.index.AtomicReader, java.lang.String)will also be computed and stored in the FieldCache.- Returns:
 - The values in the given field for each document.
 - Throws:
 java.io.IOException- If any error occurs.
 
- 
getLongs
FieldCache.Longs getLongs(AtomicReader reader, java.lang.String field, boolean setDocsWithField) throws java.io.IOException
Returns aFieldCache.Longsover the values found in documents in the given field.- Throws:
 java.io.IOException- See Also:
 getLongs(AtomicReader, String, LongParser, boolean)
 
- 
getLongs
FieldCache.Longs getLongs(AtomicReader reader, java.lang.String field, FieldCache.LongParser parser, boolean setDocsWithField) throws java.io.IOException
Returns aFieldCache.Longsover the values found in documents in the given field. If the field was indexed asNumericDocValuesField, it simply usesAtomicReader.getNumericDocValues(String)to read the values. Otherwise, it checks the internal cache for an appropriate entry, and if none is found, reads the terms infieldas longs and returns an array of sizereader.maxDoc()of the value each document has in the given field.- 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 asNumericDocValuesFieldorLongField.setDocsWithField- If true thengetDocsWithField(org.apache.lucene.index.AtomicReader, java.lang.String)will also be computed and stored in the FieldCache.- Returns:
 - The values in the given field for each document.
 - Throws:
 java.io.IOException- If any error occurs.
 
- 
getDoubles
FieldCache.Doubles getDoubles(AtomicReader reader, java.lang.String field, boolean setDocsWithField) throws java.io.IOException
Returns aFieldCache.Doublesover the values found in documents in the given field.- Throws:
 java.io.IOException- See Also:
 getDoubles(AtomicReader, String, DoubleParser, boolean)
 
- 
getDoubles
FieldCache.Doubles getDoubles(AtomicReader reader, java.lang.String field, FieldCache.DoubleParser parser, boolean setDocsWithField) throws java.io.IOException
Returns aFieldCache.Doublesover the values found in documents in the given field. If the field was indexed asNumericDocValuesField, it simply usesAtomicReader.getNumericDocValues(String)to read the values. Otherwise, it checks the internal cache for an appropriate entry, and if none is found, reads the terms infieldas doubles and returns an array of sizereader.maxDoc()of the value each document has in the given field.- Parameters:
 reader- Used to get field values.field- Which field contains the longs.parser- Computes double for string values. May benullif the requested field was indexed asNumericDocValuesFieldorDoubleField.setDocsWithField- If true thengetDocsWithField(org.apache.lucene.index.AtomicReader, java.lang.String)will also be computed and stored in the FieldCache.- Returns:
 - The values in the given field for each document.
 - Throws:
 java.io.IOException- If any error occurs.
 
- 
getTerms
BinaryDocValues getTerms(AtomicReader reader, java.lang.String field, boolean setDocsWithField) throws java.io.IOException
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.- Parameters:
 reader- Used to get field values.field- Which field contains the strings.setDocsWithField- If true thengetDocsWithField(org.apache.lucene.index.AtomicReader, java.lang.String)will also be computed and stored in the FieldCache.- Returns:
 - The values in the given field for each document.
 - Throws:
 java.io.IOException- If any error occurs.
 
- 
getTerms
BinaryDocValues getTerms(AtomicReader reader, java.lang.String field, boolean setDocsWithField, float acceptableOverheadRatio) throws java.io.IOException
Expert: just likegetTerms(AtomicReader,String,boolean), 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.- Throws:
 java.io.IOException
 
- 
getTermsIndex
SortedDocValues getTermsIndex(AtomicReader reader, java.lang.String field) throws java.io.IOException
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.- Parameters:
 reader- Used to get field values.field- Which field contains the strings.- Returns:
 - The values in the given field for each document.
 - Throws:
 java.io.IOException- If any error occurs.
 
- 
getTermsIndex
SortedDocValues getTermsIndex(AtomicReader reader, java.lang.String field, float acceptableOverheadRatio) throws java.io.IOException
Expert: just likegetTermsIndex(AtomicReader,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.- Throws:
 java.io.IOException
 
- 
getDocTermOrds
SortedSetDocValues getDocTermOrds(AtomicReader reader, java.lang.String field) throws java.io.IOException
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.- Parameters:
 reader- Used to build aDocTermOrdsinstancefield- Which field contains the strings.- Returns:
 - a 
DocTermOrdsinstance - Throws:
 java.io.IOException- If any error occurs.
 
- 
getCacheEntries
FieldCache.CacheEntry[] getCacheEntries()
EXPERT: 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.
 
- 
purgeAllCaches
void purgeAllCaches()
EXPERT: 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.
 
- 
purgeByCacheKey
void purgeByCacheKey(java.lang.Object coreCacheKey)
Expert: drops all cache entries associated with this readerIndexReader.getCoreCacheKey(). 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. 
- 
setInfoStream
void setInfoStream(java.io.PrintStream stream)
If non-null, FieldCacheImpl will warn whenever entries are created that are not sane according toFieldCacheSanityChecker. 
- 
getInfoStream
java.io.PrintStream getInfoStream()
counterpart ofsetInfoStream(PrintStream) 
 - 
 
 -