|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ObjectGroupData
StaticGroupData
public class StaticGroupData
This class contains the mapping, for a given field, from documents to one or more term values in that document.
Field Summary | |
---|---|
private static WeakHashMap |
cache
Cached data. |
private int[] |
docs
Array of document IDs |
private String |
field
The particular field we have data from |
private int[] |
groupChildren
The first child of each group, or -1 for none. |
private int[] |
groupParents
The parent of each group, or -1 for none |
private String[] |
groups
Array of group names |
private int[] |
groupSiblings
The next sibling of each group, or -1 for none. |
private int[] |
links
Array of links: 0..docs.length is either positive to indicate a single group for this doc, or negative to indicate a link later in the array to a list of groups. docs.length..links.length holds the extra groups; each entry is a group number, negative to mean end of the groups for a single doc. |
Constructor Summary | |
---|---|
StaticGroupData(IndexReader reader,
String field)
Read in the term data for a given field, and build up the various arrays of document to group info, and hierarchical relationships between the groups. |
Method Summary | |
---|---|
private Integer |
addTermKey(String termText,
Vector groupVec,
HashMap groupMap,
HashMap childMap)
Add the given term to the group vector and map. |
private void |
buildHierarchy(HashMap childMap)
Based on a hierarchy data map, build the parent, child, and sibling relationship arrays that make all this info easy to find and fast to traverse. |
private void |
buildLinks(HashMap docMap)
Perform the final build step, forming the 'docs' and 'links' arrays. |
int |
child(int groupId)
Get the first child of the given group, or -1 if it has no children |
int |
compare(int group1,
int group2)
Compare two groups for sort order |
String |
field()
Get the name of the grouping field |
int |
findGroup(String name)
Locate a group by name and return its index, or -1 if not found |
int |
firstLink(int docId)
Return the ID of the first link for the given document, or -1 if there are no links for that document. |
static StaticGroupData |
getCachedData(IndexReader reader,
String field)
Retrieves GroupData for a given field from a given reader. |
int |
linkGroup(int linkId)
Returns the group number of the specified link |
String |
name(int groupId)
Get the name of a group given its number |
int |
nChildren(int groupId)
Get the number of children a group has |
int |
nextLink(int linkId)
Return the ID of the link after the specified one, or -1 if no more |
int |
nGroups()
Get the total number of groups |
int |
parent(int groupId)
Get the parent of the given group, or -1 if group is the root |
int |
sibling(int groupId)
Get the sibling of the given group, or -1 if no more |
Methods inherited from class GroupData |
---|
debugGroups, isDynamic, nDocHits, score |
Methods inherited from class Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private String field
private int[] docs
private int[] links
private String[] groups
private int[] groupParents
private int[] groupChildren
private int[] groupSiblings
private static WeakHashMap cache
Constructor Detail |
---|
public StaticGroupData(IndexReader reader, String field) throws IOException
reader
- Where to read the term data fromfield
- Which field to read
IOException
Method Detail |
---|
public static StaticGroupData getCachedData(IndexReader reader, String field) throws IOException
reader
- Where to read the data fromfield
- Which field to read
IOException
private Integer addTermKey(String termText, Vector groupVec, HashMap groupMap, HashMap childMap)
termText
- Term to addgroupVec
- Vector of groups in sort ordergroupMap
- Mapping of terms to group numberschildMap
- Mapping of parent key to child vector
private void buildHierarchy(HashMap childMap)
childMap
- Map of parent key to vector of child keysprivate void buildLinks(HashMap docMap)
docMap
- Map of document ID to vector of group IDspublic final int firstLink(int docId)
firstLink
in class GroupData
docId
- document to look for
public final int nextLink(int linkId)
nextLink
in class GroupData
public final int linkGroup(int linkId)
linkGroup
in class GroupData
public final String field()
field
in class GroupData
public final int nGroups()
nGroups
in class GroupData
public final String name(int groupId)
name
in class GroupData
public final int parent(int groupId)
parent
in class GroupData
public final int nChildren(int groupId)
nChildren
in class GroupData
public final int child(int groupId)
child
in class GroupData
public final int sibling(int groupId)
sibling
in class GroupData
public final int compare(int group1, int group2)
compare
in class GroupData
public final int findGroup(String name)
findGroup
in class GroupData
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |