org.apache.lucene.search

Interface FieldCache

public interface FieldCache

Expert: Maintains caches of term values.

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

Since: lucene 1.4

Version: $Id: FieldCache.java 179605 2005-06-02 16:48:40Z cutting $

Author: Tim Jones (Nacimiento Software)

Nested Class Summary
static interfaceFieldCache.FloatParser
Interface to parse floats from document fields.
static interfaceFieldCache.IntParser
Interface to parse ints from document fields.
static classFieldCache.StringIndex
Expert: Stores term text values and document ordering data.
Field Summary
static FieldCacheDEFAULT
Expert: The cache used internally by sorting and range query classes.
static intSTRING_INDEX
Indicator for StringIndex values in the cache.
Method Summary
ObjectgetAuto(IndexReader reader, String field)
Checks the internal cache for an appropriate entry, and if none is found reads field to see if it contains integers, floats or strings, and then calls one of the other methods in this class to get the values.
Comparable[]getCustom(IndexReader reader, String field, SortComparator comparator)
Checks the internal cache for an appropriate entry, and if none is found reads the terms out of field and calls the given SortComparator to get the sort values.
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.
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.
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.
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.
FieldCache.StringIndexgetStringIndex(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.
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.

Field Detail

DEFAULT

public static FieldCache DEFAULT
Expert: The cache used internally by sorting and range query classes.

STRING_INDEX

public static final int STRING_INDEX
Indicator for StringIndex values in the cache.

Method Detail

getAuto

public Object getAuto(IndexReader reader, String field)
Checks the internal cache for an appropriate entry, and if none is found reads field to see if it contains integers, floats or strings, and then calls one of the other methods in this class to get the values. For string values, a StringIndex is returned. After calling this method, there is an entry in the cache for both type AUTO and the actual found type.

Parameters: reader Used to get field values. field Which field contains the values.

Returns: int[], float[] or StringIndex.

Throws: IOException If any error occurs.

getCustom

public Comparable[] getCustom(IndexReader reader, String field, SortComparator comparator)
Checks the internal cache for an appropriate entry, and if none is found reads the terms out of field and calls the given SortComparator to get the sort values. A hit in the cache will happen if reader, field, and comparator are the same (using equals()) as a previous call to this method.

Parameters: reader Used to get field values. field Which field contains the values. comparator Used to convert terms into something to sort by.

Returns: Array of sort objects, one for each document.

Throws: IOException If any error occurs.

getFloats

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

getFloats

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

getInts

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

getInts

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

getStringIndex

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

getStrings

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

Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved.