org.cdlib.xtf.textEngine.facet
Class FRBRData

Object
  extended by FRBRData

public class FRBRData
extends Object

Keeps a large in-memory table of the title, author, and other info for each document.

Author:
Martin Haye

Field Summary
private static WeakHashMap cache
          Cached data.
 IntMultiMap docTags
           
static int FIRST_TYPE
           
static int LAST_TYPE
           
 IntMultiMap tagDocs
           
 TagArray tags
           
static int TYPE_AUTHOR
           
static int TYPE_DATE
           
static int TYPE_ID
           
static int TYPE_TITLE
           
 
Constructor Summary
private FRBRData(IndexReader reader, String[] fields)
          Read tags for a given set of fields from the given reader.
 
Method Summary
private  int addTag(String term, int type)
          Add a tag for the given term and type.
private  int calcType(String field)
          Calculate the type of a given field, based on the field name.
static FRBRData getCachedTags(IndexReader reader, String[] fields)
          Retrieves tags for a given set of fields from a given reader.
private  int readField(IndexReader reader, String field, int type)
          Read all the term->document mappings from a given field, and add them to the tag array, and docTags mapping.
 
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.


FIRST_TYPE

public static final int FIRST_TYPE
See Also:
Constant Field Values

TYPE_TITLE

public static final int TYPE_TITLE
See Also:
Constant Field Values

TYPE_AUTHOR

public static final int TYPE_AUTHOR
See Also:
Constant Field Values

TYPE_DATE

public static final int TYPE_DATE
See Also:
Constant Field Values

TYPE_ID

public static final int TYPE_ID
See Also:
Constant Field Values

LAST_TYPE

public static final int LAST_TYPE
See Also:
Constant Field Values

tags

public final TagArray tags

docTags

public final IntMultiMap docTags

tagDocs

public final IntMultiMap tagDocs
Constructor Detail

FRBRData

private FRBRData(IndexReader reader,
                 String[] fields)
          throws IOException
Read tags for a given set of fields from the given reader. Do not construct directly, but rather use getCachedTags(IndexReader, String[]).

Throws:
IOException
Method Detail

getCachedTags

public static FRBRData getCachedTags(IndexReader reader,
                                     String[] fields)
                              throws IOException
Retrieves tags for a given set of fields 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
fields - Which fields to read
Returns:
FRBR tags for the specified fields
Throws:
IOException

readField

private int readField(IndexReader reader,
                      String field,
                      int type)
               throws IOException
Read all the term->document mappings from a given field, and add them to the tag array, and docTags mapping.

Returns:
number of tags added
Throws:
IOException

addTag

private int addTag(String term,
                   int type)
Add a tag for the given term and type.

Parameters:
term - Term to parse and add
type - Type to add the tag under

calcType

private int calcType(String field)
              throws IOException
Calculate the type of a given field, based on the field name.

Throws:
IOException