public class StaticGroupData extends GroupData
Modifier and Type | Field and Description |
---|---|
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 and Description |
---|
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.
|
Modifier and Type | Method and Description |
---|---|
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
|
debugGroups, isDynamic, nDocHits, score
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
public StaticGroupData(IndexReader reader, String field) throws IOException
reader
- Where to read the term data fromfield
- Which field to readIOException
public static StaticGroupData getCachedData(IndexReader reader, String field) throws IOException
reader
- Where to read the data fromfield
- Which field to readIOException
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 vectorprivate 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)
public final int nextLink(int linkId)
public final int linkGroup(int linkId)
public final String field()
public final int nGroups()
public final String name(int groupId)
public final int parent(int groupId)
public final int nChildren(int groupId)
public final int child(int groupId)
public final int sibling(int groupId)
public final int compare(int group1, int group2)