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

IntFieldSource

public class IntFieldSource extends FieldCacheSource
Expert: obtains int field values from the {@link org.apache.lucene.search.FieldCache FieldCache} using getInts() and makes those values available as other numeric types, casting as needed.

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.

see
org.apache.lucene.search.function.FieldCacheSource for requirements on the field.
author
yonik

Fields Summary
private FieldCache$IntParser
parser
Constructors Summary
public IntFieldSource(String field)
Create a cached int field source with default string-to-int parser.

    this(field, null);
  
public IntFieldSource(String field, FieldCache$IntParser parser)
Create a cached int field source with a specific string-to-int parser.

    super(field);
    this.parser = parser;
  
Methods Summary
public booleancachedFieldSourceEquals(org.apache.lucene.search.function.FieldCacheSource o)

    if (o.getClass() !=  IntFieldSource.class) {
      return false;
    }
    IntFieldSource other = (IntFieldSource)o;
    return this.parser==null ? 
      other.parser==null :
      this.parser.getClass() == other.parser.getClass();
  
public intcachedFieldSourceHashCode()

    return parser==null ? 
      Integer.class.hashCode() : parser.getClass().hashCode();
  
public java.lang.Stringdescription()

    return "int(" + super.description() + ')";
  
public org.apache.lucene.search.function.DocValuesgetCachedFieldValues(org.apache.lucene.search.FieldCache cache, java.lang.String field, org.apache.lucene.index.IndexReader reader)

    final int[] arr = (parser==null) ?  
      cache.getInts(reader, field) : 
      cache.getInts(reader, field, parser);
    return new DocValues(reader.maxDoc()) {
      /*(non-Javadoc) @see org.apache.lucene.search.function.DocValues#floatVal(int) */
      public float floatVal(int doc) { 
        return (float) arr[doc]; 
      }
      /*(non-Javadoc) @see org.apache.lucene.search.function.DocValues#intVal(int) */
      public  int intVal(int doc) { 
        return arr[doc]; 
      }
      /*(non-Javadoc) @see org.apache.lucene.search.function.DocValues#toString(int) */
      public String toString(int doc) { 
        return  description() + '=" + intVal(doc);  
      }
      /*(non-Javadoc) @see org.apache.lucene.search.function.DocValues#getInnerArray() */
      Object getInnerArray() {
        return arr;
      }
    };