com.sun.labs.minion.indexer.dictionary
Class FieldStore

java.lang.Object
  extended by com.sun.labs.minion.indexer.dictionary.FieldStore
Direct Known Subclasses:
DiskFieldStore, MemoryFieldStore

public class FieldStore
extends java.lang.Object

A common base class for MemoryFieldStore and DiskFieldStore.


Field Summary
protected static java.lang.String header
          The header for the old-style field store.
protected static java.lang.String logTag
          The log tag.
protected  MetaFile metaFile
          The meta file.
protected  SavedField[] savedFields
          The saved fields.
 
Constructor Summary
FieldStore()
           
 
Method Summary
 int[] getFieldArray(java.lang.String[] fieldNames)
          Gets an array of field IDs suitable for use in postings entry iterators.
 int getFieldID(FieldInfo f)
          Gets the ID for a given field info object.
 FieldInfo getFieldInfo(java.lang.String name)
          Gets the info for a given field name.
protected  FieldInfo getFieldInfo(java.lang.String name, java.util.EnumSet<FieldInfo.Attribute> attributes, FieldInfo.Type type)
          Gets the info for a given field name.
 java.lang.String getFieldName(int id)
          Gets the name associated with a field ID.
 FieldInfo.Type getFieldType(java.lang.String name)
          Gets the type of a saved field.
 float[] getMultArray(java.util.Map mult)
          Gets an array for field multipliers suitable for use in postings iterators.
 float[] getMultArray(java.lang.String[] fieldNames, float[] mult)
          Gets an array of field multipliers suitable for use in postings entry iterators.
 int getNFields()
          Gets the number of currently defined fields.
 int[] getVectoredFields()
          Gets an array of the vectored fields.
 boolean isSavedField(java.lang.String name)
          Determines whether a given field name is a saved field or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

metaFile

protected MetaFile metaFile
The meta file.


savedFields

protected SavedField[] savedFields
The saved fields.


logTag

protected static java.lang.String logTag
The log tag.


header

protected static java.lang.String header
The header for the old-style field store.

Constructor Detail

FieldStore

public FieldStore()
Method Detail

getFieldInfo

public FieldInfo getFieldInfo(java.lang.String name)
Gets the info for a given field name.

Parameters:
name - the field name.
Returns:
The new field information object, or null if there is no such field.

getFieldInfo

protected FieldInfo getFieldInfo(java.lang.String name,
                                 java.util.EnumSet<FieldInfo.Attribute> attributes,
                                 FieldInfo.Type type)
Gets the info for a given field name. This will add the named field to the mapping and assign it an ID if it doesn't have one already.

Parameters:
name - the field name.
attributes - The field attributes.
type - the field type.
Returns:
The new field information object, or null if there was some problem with the meta file.

getNFields

public int getNFields()
Gets the number of currently defined fields.


getFieldID

public int getFieldID(FieldInfo f)
Gets the ID for a given field info object.

Parameters:
f - The FieldInfo object.

getFieldName

public java.lang.String getFieldName(int id)
Gets the name associated with a field ID.

Parameters:
id - The field ID of interest.
Returns:
The name, or null if the id is out of range for this field store.

getFieldType

public FieldInfo.Type getFieldType(java.lang.String name)
Gets the type of a saved field.

Parameters:
name - the name of the field for which we want the type
Returns:
The saved field type, or 0 if the named field does not exist or is not a saved field.

getFieldArray

public int[] getFieldArray(java.lang.String[] fieldNames)
Gets an array of field IDs suitable for use in postings entry iterators.

Parameters:
fieldNames - The names of the fields that we're interested in. If null is given as a field value, then words that don't occur in any field are what we're interested in.
Returns:
an array of integers, as wide as the number of fields, with 1s in the elements for the provided fields, or null if the given array of field names is null.

getMultArray

public float[] getMultArray(java.lang.String[] fieldNames,
                            float[] mult)
Gets an array of field multipliers suitable for use in postings entry iterators.

Parameters:
fieldNames - The names of the fields that we're interested in. If a null field name is passed, that multiplier will be used for occurrences that are not in any field.
mult - The multipliers for the named fields, in the order that the fields are given in.
Returns:
an array as wide as the number of defined fields with the multipliers specified by field ID.

getMultArray

public float[] getMultArray(java.util.Map mult)
Gets an array for field multipliers suitable for use in postings iterators.


isSavedField

public boolean isSavedField(java.lang.String name)
Determines whether a given field name is a saved field or not.


getVectoredFields

public int[] getVectoredFields()
Gets an array of the vectored fields. The no-field field is always assumed to be vectored.