test_class.declarator: vals = new String[]{"a", "c", "e"}
test_class.modifier: private
test_class.original_string: private String[] vals = new String[]{"a", "c", "e"};
test_class.type: String[]
test_class.var_name: vals
test_class.declarator: freqs
test_class.modifier: private
test_class.original_string: private int[] freqs;
test_class.type: int[]
test_class.var_name: freqs
test_class.declarator: dictionary = new TermStringList()
test_class.original_string: TermValueList<String> dictionary = new TermStringList();
test_class.type: TermValueList<String>
test_class.var_name: dictionary
test_class.file: sensei-core/src/test/java/com/senseidb/search/query/filters/TestSenseiTermFilter.java
test_class.identifier: TestSenseiTermFilter
test_case.body: @Test
    public void testGetValsByFrequency() {
  
      List<String> dummy = new ArrayList<String>();
      DocIdSetCardinality andCardinality = DocIdSetCardinality.one();
      String andVals[] = SenseiTermFilter.getValsByFrequency(vals, freqs, 26, andCardinality, dictionary, dummy, true);
      assertArrayEquals(andVals, new String[]{"e", "c", "a"});
      DocSetAssertions.assertRange(18, 22, 26, andCardinality);
  
      DocIdSetCardinality orCardinality = DocIdSetCardinality.zero();
      String orgVals[] = SenseiTermFilter.getValsByFrequency(vals, freqs, 26, orCardinality, dictionary, dummy, false);
      assertArrayEquals(orgVals, new String[]{"a", "c", "e"});
      DocSetAssertions.assertRange(26, 26, 26, orCardinality);
    }
test_case.class_method_signature: TestSenseiTermFilter.testGetValsByFrequency()
test_case.full_signature: @Test public void testGetValsByFrequency()
test_case.identifier: testGetValsByFrequency
test_case.invocations: one getValsByFrequency assertArrayEquals assertRange zero getValsByFrequency assertArrayEquals assertRange
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testGetValsByFrequency()
focal_class.declarator: serialVersionUID = 1L
focal_class.modifier: private static final
focal_class.original_string: private static final long serialVersionUID = 1L;
focal_class.type: long
focal_class.var_name: serialVersionUID
focal_class.declarator: logger = Logger.getLogger(SenseiTermFilter.class)
focal_class.modifier: private static
focal_class.original_string: private static Logger logger = Logger.getLogger(SenseiTermFilter.class);
focal_class.type: Logger
focal_class.var_name: logger
focal_class.declarator: _name
focal_class.modifier: private final
focal_class.original_string: private final String _name;
focal_class.type: String
focal_class.var_name: _name
focal_class.declarator: _vals
focal_class.modifier: private final
focal_class.original_string: private final String[] _vals;
focal_class.type: String[]
focal_class.var_name: _vals
focal_class.declarator: _not
focal_class.modifier: private final
focal_class.original_string: private final String[] _not;
focal_class.type: String[]
focal_class.var_name: _not
focal_class.declarator: _isAnd
focal_class.modifier: private final
focal_class.original_string: private final boolean _isAnd;
focal_class.type: boolean
focal_class.var_name: _isAnd
focal_class.declarator: _noAutoOptimize
focal_class.modifier: private final
focal_class.original_string: private final boolean _noAutoOptimize;
focal_class.type: boolean
focal_class.var_name: _noAutoOptimize
focal_class.declarator: DECREASING_CARDINALITY_COMPARATOR = new Comparator<Pair<String, DocIdSetCardinality>>() {
      @Override
      public int compare(Pair<String, DocIdSetCardinality> a, Pair<String, DocIdSetCardinality> b) {
        return -a.getSecond().compareTo(b.getSecond());
      }
    }
focal_class.modifier: private static final
focal_class.original_string: private static final Comparator<Pair<String, DocIdSetCardinality>> DECREASING_CARDINALITY_COMPARATOR = new Comparator<Pair<String, DocIdSetCardinality>>() {
      @Override
      public int compare(Pair<String, DocIdSetCardinality> a, Pair<String, DocIdSetCardinality> b) {
        return -a.getSecond().compareTo(b.getSecond());
      }
    };
focal_class.type: Comparator<Pair<String, DocIdSetCardinality>>
focal_class.var_name: DECREASING_CARDINALITY_COMPARATOR
focal_class.declarator: INCREASING_CARDINALITY_COMPARATOR = new Comparator<Pair<String, DocIdSetCardinality>> (){
      @Override
      public int compare(Pair<String, DocIdSetCardinality> a, Pair<String, DocIdSetCardinality> b) {
        return a.getSecond().compareTo(b.getSecond());
      }
    }
focal_class.modifier: public static final
focal_class.original_string: public static final Comparator<Pair<String, DocIdSetCardinality>> INCREASING_CARDINALITY_COMPARATOR = new Comparator<Pair<String, DocIdSetCardinality>> (){
      @Override
      public int compare(Pair<String, DocIdSetCardinality> a, Pair<String, DocIdSetCardinality> b) {
        return a.getSecond().compareTo(b.getSecond());
      }
    };
focal_class.type: Comparator<Pair<String, DocIdSetCardinality>>
focal_class.var_name: INCREASING_CARDINALITY_COMPARATOR
focal_class.file: sensei-core/src/main/java/com/senseidb/search/query/filters/SenseiTermFilter.java
focal_class.identifier: SenseiTermFilter
focal_class.class_method_signature: SenseiTermFilter.SenseiTermFilter(String name,String vals[],String[] not,boolean isAnd,boolean noAutoOptimize)
focal_class.full_signature: public  SenseiTermFilter(String name,String vals[],String[] not,boolean isAnd,boolean noAutoOptimize)
focal_class.identifier: SenseiTermFilter
focal_class.modifiers: public
focal_class.parameters: (String name,String vals[],String[] not,boolean isAnd,boolean noAutoOptimize)
focal_class.signature:  SenseiTermFilter(String name,String vals[],String[] not,boolean isAnd,boolean noAutoOptimize)
focal_class.class_method_signature: SenseiTermFilter.buildDefaultDocIdSets(final BoboIndexReader reader,
                                                  final String name,
                                                  final String[] vals,
                                                  boolean isAnd)
focal_class.full_signature: static DocIdSet buildDefaultDocIdSets(final BoboIndexReader reader,
                                                  final String name,
                                                  final String[] vals,
                                                  boolean isAnd)
focal_class.identifier: buildDefaultDocIdSets
focal_class.modifiers: static
focal_class.parameters: (final BoboIndexReader reader,
                                                  final String name,
                                                  final String[] vals,
                                                  boolean isAnd)
focal_class.return: DocIdSet
focal_class.signature: DocIdSet buildDefaultDocIdSets(final BoboIndexReader reader,
                                                  final String name,
                                                  final String[] vals,
                                                  boolean isAnd)
focal_class.class_method_signature: SenseiTermFilter.buildLuceneDefaultDocIdSet(final BoboIndexReader reader,
                                                       final String name,
                                                       final String[] vals,
                                                       String[] nots,
                                                       boolean isAnd)
focal_class.full_signature: private static DocIdSet buildLuceneDefaultDocIdSet(final BoboIndexReader reader,
                                                       final String name,
                                                       final String[] vals,
                                                       String[] nots,
                                                       boolean isAnd)
focal_class.identifier: buildLuceneDefaultDocIdSet
focal_class.modifiers: private static
focal_class.parameters: (final BoboIndexReader reader,
                                                       final String name,
                                                       final String[] vals,
                                                       String[] nots,
                                                       boolean isAnd)
focal_class.return: DocIdSet
focal_class.signature: DocIdSet buildLuceneDefaultDocIdSet(final BoboIndexReader reader,
                                                       final String name,
                                                       final String[] vals,
                                                       String[] nots,
                                                       boolean isAnd)
focal_class.class_method_signature: SenseiTermFilter.planString(String type, String[] vals, String[] nots, List<String> optimizedVals, List<String> optimizedNots)
focal_class.full_signature: public String planString(String type, String[] vals, String[] nots, List<String> optimizedVals, List<String> optimizedNots)
focal_class.identifier: planString
focal_class.modifiers: public
focal_class.parameters: (String type, String[] vals, String[] nots, List<String> optimizedVals, List<String> optimizedNots)
focal_class.return: String
focal_class.signature: String planString(String type, String[] vals, String[] nots, List<String> optimizedVals, List<String> optimizedNots)
focal_class.class_method_signature: SenseiTermFilter.getSenseiDocIdSet(IndexReader reader)
focal_class.full_signature: @Override public SenseiDocIdSet getSenseiDocIdSet(IndexReader reader)
focal_class.identifier: getSenseiDocIdSet
focal_class.modifiers: @Override public
focal_class.parameters: (IndexReader reader)
focal_class.return: SenseiDocIdSet
focal_class.signature: SenseiDocIdSet getSenseiDocIdSet(IndexReader reader)
focal_class.class_method_signature: SenseiTermFilter.getValsByFrequency(String[] vals, int[] freqs, int maxDoc, DocIdSetCardinality total, TermValueList valArray, List<String> optimizedOut, boolean isAnd)
focal_class.full_signature: static String[] getValsByFrequency(String[] vals, int[] freqs, int maxDoc, DocIdSetCardinality total, TermValueList valArray, List<String> optimizedOut, boolean isAnd)
focal_class.identifier: getValsByFrequency
focal_class.modifiers: static
focal_class.parameters: (String[] vals, int[] freqs, int maxDoc, DocIdSetCardinality total, TermValueList valArray, List<String> optimizedOut, boolean isAnd)
focal_class.return: String[]
focal_class.signature: String[] getValsByFrequency(String[] vals, int[] freqs, int maxDoc, DocIdSetCardinality total, TermValueList valArray, List<String> optimizedOut, boolean isAnd)
focal_class.superclass: extends SenseiFilter
focal_method.body: static String[] getValsByFrequency(String[] vals, int[] freqs, int maxDoc, DocIdSetCardinality total, TermValueList valArray, List<String> optimizedOut, boolean isAnd) {
      List<Pair<String, DocIdSetCardinality>> valsAndFreqs = new ArrayList<Pair<String, DocIdSetCardinality>>(vals.length);
  
      for (String val : vals) {
        int i = valArray.indexOf(val);
  
        if (i >=0) {
          DocIdSetCardinality docIdSetCardinality = DocIdSetCardinality.exact(((double) freqs[i]) / (maxDoc + 1));
          if (isAnd) {
            if (docIdSetCardinality.isOne()) {
              optimizedOut.add(val);
              continue;
            }
            total.andWith(docIdSetCardinality);
          } else {
            if (docIdSetCardinality.isZero()) {
              optimizedOut.add(val);
              continue;
            }
            total.orWith(docIdSetCardinality);
          }
          valsAndFreqs.add(new Pair<String, DocIdSetCardinality>(valArray.get(i), docIdSetCardinality));
        }
      }
  
      // Lowest cardinality docs go first to optimize the AND case, last for the OR case.
      Collections.sort(valsAndFreqs, isAnd ? INCREASING_CARDINALITY_COMPARATOR : DECREASING_CARDINALITY_COMPARATOR);
  
      String[] sortedVals = new String[valsAndFreqs.size()];
      int i = 0;
      while (i < sortedVals.length) {
        sortedVals[i] = valsAndFreqs.get(i).getFirst();
        ++i;
      }
      return sortedVals;
    }
focal_method.class_method_signature: SenseiTermFilter.getValsByFrequency(String[] vals, int[] freqs, int maxDoc, DocIdSetCardinality total, TermValueList valArray, List<String> optimizedOut, boolean isAnd)
focal_method.full_signature: static String[] getValsByFrequency(String[] vals, int[] freqs, int maxDoc, DocIdSetCardinality total, TermValueList valArray, List<String> optimizedOut, boolean isAnd)
focal_method.identifier: getValsByFrequency
focal_method.invocations: indexOf exact isOne add andWith isZero add orWith add get sort size getFirst get
focal_method.modifiers: static
focal_method.parameters: (String[] vals, int[] freqs, int maxDoc, DocIdSetCardinality total, TermValueList valArray, List<String> optimizedOut, boolean isAnd)
focal_method.return: String[]
focal_method.signature: String[] getValsByFrequency(String[] vals, int[] freqs, int maxDoc, DocIdSetCardinality total, TermValueList valArray, List<String> optimizedOut, boolean isAnd)