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

FloatFieldSource

public class FloatFieldSource extends FieldCacheSource
Expert: obtains float field values from the {@link org.apache.lucene.search.FieldCache FieldCache} using getFloats() 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$FloatParser
parser
Constructors Summary
public FloatFieldSource(String field)
Create a cached float field source with default string-to-float parser.

    this(field, null);
  
public FloatFieldSource(String field, FieldCache$FloatParser parser)
Create a cached float field source with a specific string-to-float parser.

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

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

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

    return "float(" + 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 float[] arr = (parser==null) ?
      cache.getFloats(reader, field) :
      cache.getFloats(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 arr[doc];      
      }
      /*(non-Javadoc) @see org.apache.lucene.search.function.DocValues#toString(int) */
      public String toString(int doc) { 
        return  description() + '=" + arr[doc];  
      }
      /*(non-Javadoc) @see org.apache.lucene.search.function.DocValues#getInnerArray() */
      Object getInnerArray() {
        return arr;
      }
    };