Uploaded image for project: 'Jira Data Center'
  1. Jira Data Center
  2. JRASERVER-27988

SAP Lucene Sorting Optimization - numHits

    XMLWordPrintable

Details

    • We collect Jira feedback from various sources, and we evaluate what we've collected when planning our product roadmap. To understand how this piece of feedback will be reviewed, see our Implementation of New Features Policy.

    Description

      NOTE: This suggestion is for JIRA Server. Using JIRA Cloud? See the corresponding suggestion.

      Package: com.atlassian.jira.issue.search.parameters.lucene.sort

      Usage Scenario: The method newComparator returns an object of the internal class InternalFieldComparator. The InternalFieldComparator method is responsible for extracting Lucene field values from documents and storing them in slots (method copy) and for doing comparisions on the values stored in the slots (compare, compareBottom)

      Current Implementation: The constructor of InternalFieldComparator creates an array that has the maximal needed size (parameter numHits).

      values = new Object[numHits];
      

      If numHits is relatively small number, this is okay. However, if the maximum hit count is unlimited (Integer.MAX_VALUE), the caller passes the total number of Lucene index documents to numHits. In our case this is around 700.000. So in this case 700.000 x 8 Byte = 5.3 MB are allocated even if the actual hit count number is far less (e.g. 20).

      One Alternative Implementation: Use a Vector instead of an array. The vector capacity can grow dynamically. In most cases the searches on Lucene return a limited number of hits (< 4000). The need of the vector capacity to grow is therefore limited.

      private final Vector<Object> values;InternalFieldComparator2(int numHits, String fieldP, final LuceneFieldSorter sorter){  values = new Vector<Object>();  ...}public void copy(int slot, int doc)
      {
        if (slot >= values.size()) 
        {    values.setSize(slot + 1);        
        }  ...
      }
      

      Attachments

        Issue Links

          Activity

            People

              tcampbell Trevor Campbell (Inactive)
              rbal Rick
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: