public interface

FieldCache

org.apache.lucene.search.FieldCache

Class Overview

Expert: Maintains caches of term values.

Created: May 19, 2004 11:13:14 AM

Summary

Nested Classes
interface FieldCache.ByteParser Interface to parse bytes from document fields. 
class FieldCache.CacheEntry EXPERT: A unique Identifier/Description for each item in the FieldCache. 
class FieldCache.CreationPlaceholder  
interface FieldCache.DoubleParser Interface to parse doubles from document fields. 
interface FieldCache.FloatParser Interface to parse floats from document fields. 
interface FieldCache.IntParser Interface to parse ints from document fields. 
interface FieldCache.LongParser Interface to parse long from document fields. 
interface FieldCache.Parser Marker interface as super-interface to all parsers. 
interface FieldCache.ShortParser Interface to parse shorts from document fields. 
class FieldCache.StringIndex Expert: Stores term text values and document ordering data. 
Constants
int STRING_INDEX Indicator for StringIndex values in the cache.
Fields
public static final FieldCache DEFAULT Expert: The cache used internally by sorting and range query classes.
public static final FieldCache.ByteParser DEFAULT_BYTE_PARSER The default parser for byte values, which are encoded by toString(byte)
public static final FieldCache.DoubleParser DEFAULT_DOUBLE_PARSER The default parser for double values, which are encoded by toString(double)
public static final FieldCache.FloatParser DEFAULT_FLOAT_PARSER The default parser for float values, which are encoded by toString(float)
public static final FieldCache.IntParser DEFAULT_INT_PARSER The default parser for int values, which are encoded by toString(int)
public static final FieldCache.LongParser DEFAULT_LONG_PARSER The default parser for long values, which are encoded by toString(long)
public static final FieldCache.ShortParser DEFAULT_SHORT_PARSER The default parser for short values, which are encoded by toString(short)
public static final FieldCache.DoubleParser NUMERIC_UTILS_DOUBLE_PARSER A parser instance for double values encoded with NumericUtils, e.g.
public static final FieldCache.FloatParser NUMERIC_UTILS_FLOAT_PARSER A parser instance for float values encoded with NumericUtils, e.g.
public static final FieldCache.IntParser NUMERIC_UTILS_INT_PARSER A parser instance for int values encoded by intToPrefixCoded(int), e.g.
public static final FieldCache.LongParser NUMERIC_UTILS_LONG_PARSER A parser instance for long values encoded by longToPrefixCoded(long), e.g.
Public Methods
abstract byte[] getBytes(IndexReader reader, String field, FieldCache.ByteParser parser)
Checks the internal cache for an appropriate entry, and if none is found, reads the terms in field as bytes and returns an array of size reader.maxDoc() of the value each document has in the given field.
abstract byte[] getBytes(IndexReader reader, String field)
Checks the internal cache for an appropriate entry, and if none is found, reads the terms in field as a single byte and returns an array of size reader.maxDoc() of the value each document has in the given field.
abstract CacheEntry[] getCacheEntries()
EXPERT: Generates an array of CacheEntry objects representing all items currently in the FieldCache.
abstract double[] getDoubles(IndexReader reader, String field)
Checks the internal cache for an appropriate entry, and if none is found, reads the terms in field as integers and returns an array of size reader.maxDoc() of the value each document has in the given field.
abstract double[] getDoubles(IndexReader reader, String field, FieldCache.DoubleParser parser)
Checks the internal cache for an appropriate entry, and if none is found, reads the terms in field as doubles and returns an array of size reader.maxDoc() of the value each document has in the given field.
abstract float[] getFloats(IndexReader reader, String field)
Checks the internal cache for an appropriate entry, and if none is found, reads the terms in field as floats and returns an array of size reader.maxDoc() of the value each document has in the given field.
abstract float[] getFloats(IndexReader reader, String field, FieldCache.FloatParser parser)
Checks the internal cache for an appropriate entry, and if none is found, reads the terms in field as floats and returns an array of size reader.maxDoc() of the value each document has in the given field.
abstract PrintStream getInfoStream()
abstract int[] getInts(IndexReader reader, String field)
Checks the internal cache for an appropriate entry, and if none is found, reads the terms in field as integers and returns an array of size reader.maxDoc() of the value each document has in the given field.
abstract int[] getInts(IndexReader reader, String field, FieldCache.IntParser parser)
Checks the internal cache for an appropriate entry, and if none is found, reads the terms in field as integers and returns an array of size reader.maxDoc() of the value each document has in the given field.
abstract long[] getLongs(IndexReader reader, String field, FieldCache.LongParser parser)
Checks the internal cache for an appropriate entry, and if none is found, reads the terms in field as longs and returns an array of size reader.maxDoc() of the value each document has in the given field.
abstract long[] getLongs(IndexReader reader, String field)
Checks the internal cache for an appropriate entry, and if none is found, reads the terms in field as longs and returns an array of size reader.maxDoc() of the value each document has in the given field.
abstract short[] getShorts(IndexReader reader, String field, FieldCache.ShortParser parser)
Checks the internal cache for an appropriate entry, and if none is found, reads the terms in field as shorts and returns an array of size reader.maxDoc() of the value each document has in the given field.
abstract short[] getShorts(IndexReader reader, String field)
Checks the internal cache for an appropriate entry, and if none is found, reads the terms in field as shorts and returns an array of size reader.maxDoc() of the value each document has in the given field.
abstract FieldCache.StringIndex getStringIndex(IndexReader reader, String field)
Checks the internal cache for an appropriate entry, and if none is found reads the term values in field and returns an array of them in natural order, along with an array telling which element in the term array each document uses.
abstract String[] getStrings(IndexReader reader, String field)
Checks the internal cache for an appropriate entry, and if none is found, reads the term values in field and returns an array of size reader.maxDoc() containing the value each document has in the given field.
abstract void purge(IndexReader r)
Expert: drops all cache entries associated with this reader.
abstract void purgeAllCaches()

EXPERT: Instructs the FieldCache to forcibly expunge all entries from the underlying caches.

abstract void setInfoStream(PrintStream stream)
If non-null, FieldCacheImpl will warn whenever entries are created that are not sane according to FieldCacheSanityChecker.

Constants

public static final int STRING_INDEX

Indicator for StringIndex values in the cache.

Constant Value: -1 (0xffffffff)

Fields

public static final FieldCache DEFAULT

Expert: The cache used internally by sorting and range query classes.

public static final FieldCache.ByteParser DEFAULT_BYTE_PARSER

The default parser for byte values, which are encoded by toString(byte)

public static final FieldCache.DoubleParser DEFAULT_DOUBLE_PARSER

The default parser for double values, which are encoded by toString(double)

public static final FieldCache.FloatParser DEFAULT_FLOAT_PARSER

The default parser for float values, which are encoded by toString(float)

public static final FieldCache.IntParser DEFAULT_INT_PARSER

The default parser for int values, which are encoded by toString(int)

public static final FieldCache.LongParser DEFAULT_LONG_PARSER

The default parser for long values, which are encoded by toString(long)

public static final FieldCache.ShortParser DEFAULT_SHORT_PARSER

The default parser for short values, which are encoded by toString(short)

public static final FieldCache.DoubleParser NUMERIC_UTILS_DOUBLE_PARSER

A parser instance for double values encoded with NumericUtils, e.g. when indexed via NumericField/NumericTokenStream.

public static final FieldCache.FloatParser NUMERIC_UTILS_FLOAT_PARSER

A parser instance for float values encoded with NumericUtils, e.g. when indexed via NumericField/NumericTokenStream.

public static final FieldCache.IntParser NUMERIC_UTILS_INT_PARSER

A parser instance for int values encoded by intToPrefixCoded(int), e.g. when indexed via NumericField/NumericTokenStream.

public static final FieldCache.LongParser NUMERIC_UTILS_LONG_PARSER

A parser instance for long values encoded by longToPrefixCoded(long), e.g. when indexed via NumericField/NumericTokenStream.

Public Methods

public abstract byte[] getBytes (IndexReader reader, String field, FieldCache.ByteParser parser)

Checks the internal cache for an appropriate entry, and if none is found, reads the terms in field as bytes and returns an array of size reader.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.
Returns
  • The values in the given field for each document.
Throws
IOException If any error occurs.

public abstract byte[] getBytes (IndexReader reader, String field)

Checks the internal cache for an appropriate entry, and if none is found, reads the terms in field as a single byte and returns an array of size reader.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.
Returns
  • The values in the given field for each document.
Throws
IOException If any error occurs.

public abstract 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 IndexReader associated with it has garbage collected will prevent the Value itself from being garbage collected when the Cache drops the WeakRefrence.

EXPERIMENTAL API: This API is considered extremely advanced and experimental. It may be removed or altered w/o warning in future releases of Lucene.

public abstract double[] getDoubles (IndexReader reader, String field)

Checks the internal cache for an appropriate entry, and if none is found, reads the terms in field as integers and returns an array of size reader.maxDoc() of the value each document has in the given field.

Parameters
reader Used to get field values.
field Which field contains the doubles.
Returns
  • The values in the given field for each document.
Throws
IOException If any error occurs.

public abstract double[] getDoubles (IndexReader reader, String field, FieldCache.DoubleParser parser)

Checks the internal cache for an appropriate entry, and if none is found, reads the terms in field as doubles and returns an array of size reader.maxDoc() of the value each document has in the given field.

Parameters
reader Used to get field values.
field Which field contains the doubles.
parser Computes integer for string values.
Returns
  • The values in the given field for each document.
Throws
IOException If any error occurs.

public abstract float[] getFloats (IndexReader reader, String field)

Checks the internal cache for an appropriate entry, and if none is found, reads the terms in field as floats and returns an array of size reader.maxDoc() of the value each document has in the given field.

Parameters
reader Used to get field values.
field Which field contains the floats.
Returns
  • The values in the given field for each document.
Throws
IOException If any error occurs.

public abstract float[] getFloats (IndexReader reader, String field, FieldCache.FloatParser parser)

Checks the internal cache for an appropriate entry, and if none is found, reads the terms in field as floats and returns an array of size reader.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.
Returns
  • The values in the given field for each document.
Throws
IOException If any error occurs.

public abstract PrintStream getInfoStream ()

public abstract int[] getInts (IndexReader reader, String field)

Checks the internal cache for an appropriate entry, and if none is found, reads the terms in field as integers and returns an array of size reader.maxDoc() of the value each document has in the given field.

Parameters
reader Used to get field values.
field Which field contains the integers.
Returns
  • The values in the given field for each document.
Throws
IOException If any error occurs.

public abstract int[] getInts (IndexReader reader, String field, FieldCache.IntParser parser)

Checks the internal cache for an appropriate entry, and if none is found, reads the terms in field as integers and returns an array of size reader.maxDoc() of the value each document has in the given field.

Parameters
reader Used to get field values.
field Which field contains the integers.
parser Computes integer for string values.
Returns
  • The values in the given field for each document.
Throws
IOException If any error occurs.

public abstract long[] getLongs (IndexReader reader, String field, FieldCache.LongParser parser)

Checks the internal cache for an appropriate entry, and if none is found, reads the terms in field as longs and returns an array of size reader.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 integer for string values.
Returns
  • The values in the given field for each document.
Throws
IOException If any error occurs.

public abstract long[] getLongs (IndexReader reader, String field)

Checks the internal cache for an appropriate entry, and if none is found, reads the terms in field as longs and returns an array of size reader.maxDoc() of the value each document has in the given field.

Parameters
reader Used to get field values.
field Which field contains the longs.
Returns
  • The values in the given field for each document.
Throws
IOException If any error occurs.

public abstract short[] getShorts (IndexReader reader, String field, FieldCache.ShortParser parser)

Checks the internal cache for an appropriate entry, and if none is found, reads the terms in field as shorts and returns an array of size reader.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.
Returns
  • The values in the given field for each document.
Throws
IOException If any error occurs.

public abstract short[] getShorts (IndexReader reader, String field)

Checks the internal cache for an appropriate entry, and if none is found, reads the terms in field as shorts and returns an array of size reader.maxDoc() of the value each document has in the given field.

Parameters
reader Used to get field values.
field Which field contains the shorts.
Returns
  • The values in the given field for each document.
Throws
IOException If any error occurs.

public abstract FieldCache.StringIndex getStringIndex (IndexReader reader, String field)

Checks the internal cache for an appropriate entry, and if none is found reads the term values in field and returns an array of them in natural order, along with an array telling which element in the term array each document uses.

Parameters
reader Used to get field values.
field Which field contains the strings.
Returns
  • Array of terms and index into the array for each document.
Throws
IOException If any error occurs.

public abstract String[] getStrings (IndexReader reader, String field)

Checks the internal cache for an appropriate entry, and if none is found, reads the term values in field and returns an array of size reader.maxDoc() containing the value each document has in the given field.

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.

public abstract void purge (IndexReader r)

Expert: drops all cache entries associated with this reader. NOTE: this reader 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.

public abstract 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.

EXPERIMENTAL API: This API is considered extremely advanced and experimental. It may be removed or altered w/o warning in future releases of Lucene.

public abstract void setInfoStream (PrintStream stream)

If non-null, FieldCacheImpl will warn whenever entries are created that are not sane according to FieldCacheSanityChecker.