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

ByteFieldSource

public class ByteFieldSource extends FieldCacheSource
Expert: obtains single byte field values from the {@link org.apache.lucene.search.FieldCache FieldCache} using getBytes() 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.

Fields Summary
private FieldCache$ByteParser
parser
Constructors Summary
public ByteFieldSource(String field)
Create a cached byte field source with default string-to-byte parser.

    this(field, null);
  
public ByteFieldSource(String field, FieldCache$ByteParser parser)
Create a cached byte field source with a specific string-to-byte parser.

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

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

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

    return "byte(" + 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 byte[] arr = (parser==null) ?  
      cache.getBytes(reader, field) : 
      cache.getBytes(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;
      }
    };