com.atlassian.jira.issue.search.parameters.lucene.sort
Class JiraLuceneFieldFinder

java.lang.Object
  extended by com.atlassian.jira.issue.search.parameters.lucene.sort.JiraLuceneFieldFinder

public class JiraLuceneFieldFinder
extends Object

This used to be a cache of values but it was found that it consumed a hell of a lot of memory for no benefit (JRA-10111). So the cache.put was never called.

This has been refactored into a "finder" of terms values for fields within documents.


Constructor Summary
JiraLuceneFieldFinder()
           
 
Method Summary
 boolean doesFieldContainTerm(org.apache.lucene.index.IndexReader reader, String field, String term)
          This method checks if a field contains a term.
 Object[] getCustom(org.apache.lucene.index.IndexReader reader, String field, MappedSortComparator mappedSortComparator)
          This is used to retrieve values from the Lucence index.
static JiraLuceneFieldFinder getInstance()
           
 Collection<String>[] getMatches(org.apache.lucene.index.IndexReader reader, String field)
          For each document in the index, it returns an array of string collections for each matching term.
 void getMatches(org.apache.lucene.index.IndexReader reader, String field, MatchHandler handler)
          For each document that has at least one value defined for the specified field, invokes MatchHandler.handleMatchedDocument(int, String) with the document index and the field value as the argument.
 List<String> getTermValuesForField(org.apache.lucene.index.IndexReader reader, String field)
          This method is used to retrieve term values form the Lucene index.
 List<String>[] getUniqueMatches(org.apache.lucene.index.IndexReader reader, String field)
          For each document in the index, it returns an array of string collections for each matching term.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JiraLuceneFieldFinder

public JiraLuceneFieldFinder()
Method Detail

getInstance

public static JiraLuceneFieldFinder getInstance()

getCustom

public Object[] getCustom(org.apache.lucene.index.IndexReader reader,
                          String field,
                          MappedSortComparator mappedSortComparator)
                   throws IOException
This is used to retrieve values from the Lucence index. It returns an array that is the same size as the number of documents in the reader and will have all null values if the field is not present, otherwise it has the values of the field within the document.

Parameters:
reader - the Lucence index reader
field - the name of the field to find
mappedSortComparator - the MappedSortComparator that we are acting on behalf of
Returns:
an non null array of values, which may contain null values.
Throws:
IOException - if things dont play out well.

getTermValuesForField

public List<String> getTermValuesForField(org.apache.lucene.index.IndexReader reader,
                                          String field)
                                   throws IOException
This method is used to retrieve term values form the Lucene index. It returns a list of the text representation of the terms that are present in a field - this list will be empty if a field has no terms.

Parameters:
reader - the Lucence index reader
field - the name of the field to find
Returns:
a List of strings that represent the term values for a specified field
Throws:
IOException

doesFieldContainTerm

public boolean doesFieldContainTerm(org.apache.lucene.index.IndexReader reader,
                                    String field,
                                    String term)
                             throws IOException
This method checks if a field contains a term.

Parameters:
reader - the Lucence index reader
field - the name of the field to test
term - the term you are looking for in the field
Returns:
a boolean indicating ehether the field contains this term
Throws:
IOException

getMatches

public Collection<String>[] getMatches(org.apache.lucene.index.IndexReader reader,
                                       String field)
                                throws IOException
For each document in the index, it returns an array of string collections for each matching term. Uses the DefaultMatchHandler.

Parameters:
reader - the index to read
field - the field to check the documents for
Returns:
an array of string collections for each term for each document
Throws:
IOException - if things dont play out well.

getUniqueMatches

@ExperimentalApi
public List<String>[] getUniqueMatches(org.apache.lucene.index.IndexReader reader,
                                                       String field)
                                throws IOException
For each document in the index, it returns an array of string collections for each matching term. Uses the SingleValueMatchHandler, so any collections that are returned are guaranteed to contain exactly one (possibly null) value in them.

Parameters:
reader - the index to read
field - the field to check the documents for
Returns:
an array of string collections for each term for each document
Throws:
IOException - if things dont play out well.

getMatches

@ExperimentalApi
public void getMatches(org.apache.lucene.index.IndexReader reader,
                                       String field,
                                       MatchHandler handler)
                throws IOException
For each document that has at least one value defined for the specified field, invokes MatchHandler.handleMatchedDocument(int, String) with the document index and the field value as the argument.

Parameters:
reader - the index to read
field - the field to check the documents for
handler - a handler that will be invoked for each matching term
Throws:
IOException - if things dont play out well.


Copyright © 2002-2012 Atlassian. All Rights Reserved.