FileDocCategorySizeDatePackage
FieldCacheSource.javaAPI DocApache Lucene 2.2.03950Sat Jun 16 22:20:34 BST 2007org.apache.lucene.search.function

FieldCacheSource

public abstract class FieldCacheSource extends ValueSource
Expert: A base class for ValueSource implementations that retrieve values for a single field from the {@link org.apache.lucene.search.FieldCache FieldCache}.

Fields used herein nust be indexed (doesn't matter if these fields are stored or not).

It is assumed that each such indexed field is untokenized, or at least has a single token in a document. For documents with multiple tokens of the same field, behavior is undefined (It is likely that current code would use the value of one of these tokens, but this is not guaranteed).

Document with no tokens in this field are assigned the Zero value.

WARNING: The status of the search.function package is experimental. The APIs introduced here might change in the future and will not be supported anymore in such a case.

author
yonik

Fields Summary
private String
field
private FieldCache
cache
Constructors Summary
public FieldCacheSource(String field)
Create a cached field source for the input field.


                
     
    this.field=field;
  
Methods Summary
public abstract booleancachedFieldSourceEquals(org.apache.lucene.search.function.FieldCacheSource other)
Check if equals to another {@link FieldCacheSource}, already knowing that cache and field are equal.

see
Object#equals(java.lang.Object)

public abstract intcachedFieldSourceHashCode()
Return a hash code of a {@link FieldCacheSource}, without the hash-codes of the field and the cache (those are taken care of elsewhere).

see
Object#hashCode()

public java.lang.Stringdescription()

    return field;
  
public final booleanequals(java.lang.Object o)

    if (!(o instanceof FieldCacheSource)) {
      return false;
    }
    FieldCacheSource other = (FieldCacheSource) o;
    return 
      this.cache == other.cache &&
      this.field.equals(other.field) && 
      cachedFieldSourceEquals(other);
  
public abstract org.apache.lucene.search.function.DocValuesgetCachedFieldValues(org.apache.lucene.search.FieldCache cache, java.lang.String field, org.apache.lucene.index.IndexReader reader)
Return cached DocValues for input field and reader.

param
cache FieldCache so that values of a field are loaded once per reader (RAM allowing)
param
field Field for which values are required.
see
ValueSource

public final org.apache.lucene.search.function.DocValuesgetValues(org.apache.lucene.index.IndexReader reader)

    return getCachedFieldValues(cache, field, reader);
  
public final inthashCode()

    return 
      cache.hashCode() + 
      field.hashCode() +
      cachedFieldSourceHashCode();