org.cdlib.xtf.textEngine
Class NumericFieldData

Object
  extended by NumericFieldData

public class NumericFieldData
extends Object

Holds numeric data for a field from a Lucene index. Data is cached for a given index reader, to speed access after the initial load.

Author:
Martin Haye

Field Summary
private static WeakHashMap cache
          Cached data.
private  IntList docs
          Document IDs containing values for the field
private  LongList values
          Associated numeric value for each document
 
Constructor Summary
private NumericFieldData(IndexReader reader, String field)
          Load data from the given field of the reader, and parse the values as numbers.
 
Method Summary
 int doc(int index)
           
 int docPos(int docId)
           
 int findDocIndex(int docId)
           
static NumericFieldData getCachedData(IndexReader reader, String field)
          Retrieves tags for a given field from a given reader.
static long parseVal(String str)
          Parse the numeric characters of a string, ignoring all non-digits
 int size()
           
 long value(int index)
           
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cache

private static WeakHashMap cache
Cached data. If the reader goes away, our cache will too.


docs

private IntList docs
Document IDs containing values for the field


values

private LongList values
Associated numeric value for each document

Constructor Detail

NumericFieldData

private NumericFieldData(IndexReader reader,
                         String field)
                  throws IOException
Load data from the given field of the reader, and parse the values as numbers.

Throws:
IOException
Method Detail

getCachedData

public static NumericFieldData getCachedData(IndexReader reader,
                                             String field)
                                      throws IOException
Retrieves tags for a given field from a given reader. Maintains a cache so that if the same fields are requested again for this reader, we don't have to re-read the tags.

Parameters:
reader - Where to read the tags from
field - Which field to read
Returns:
FRBR tags for the specified field
Throws:
IOException

parseVal

public static long parseVal(String str)
Parse the numeric characters of a string, ignoring all non-digits


size

public final int size()

doc

public final int doc(int index)

value

public final long value(int index)

findDocIndex

public final int findDocIndex(int docId)

docPos

public final int docPos(int docId)