Package org.apache.lucene.search

Examples of org.apache.lucene.search.FieldComparator$TermOrdValComparator


      for (SortField sortField: sortFields) {
        int type = sortField.getType();
        if (type==SortField.SCORE || type==SortField.DOC) continue;

        FieldComparator comparator = null;
        FieldComparator comparators[] = (readers==null) ? null : new FieldComparator[readers.length];

        String fieldname = sortField.getField();
        FieldType ft = fieldname==null ? null : req.getSchema().getFieldTypeNoEx(fieldname);

        DocList docList = rb.getResults().docList;
View Full Code Here


            this.isReverse = new boolean[orderings.length];
            for (int i = 0; i < orderings.length; i++) {
                idx[i] = names.indexOf(orderings[i].getSelectorName());
                SortField sf = orderings[i].getSortField();
                if (sf.getComparatorSource() != null) {
                    FieldComparator c = sf.getComparatorSource().newComparator(sf.getField(), numHits, 0, false);
                    assert c instanceof FieldComparatorBase;
                    comparators[i] = new ScoreDocComparator((FieldComparatorBase) c);
                    comparators[i].setNextReader(reader, 0);
                }
                isReverse[i] = sf.getReverse();
View Full Code Here

            this.isReverse = new boolean[orderings.length];
            for (int i = 0; i < orderings.length; i++) {
                idx[i] = names.indexOf(orderings[i].getSelectorName());
                SortField sf = orderings[i].getSortField();
                if (sf.getComparatorSource() != null) {
                    FieldComparator c = sf.getComparatorSource().newComparator(sf.getField(), numHits, 0, false);
                    assert c instanceof FieldComparatorBase;
                    comparators[i] = new ScoreDocComparator((FieldComparatorBase) c);
                    comparators[i].setNextReader(reader, 0);
                }
                isReverse[i] = sf.getReverse();
View Full Code Here

        this.base = base;
    }

    @Override
    public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException {
        FieldComparator comparator = base.newComparator(fieldname, numHits, sortPos, reversed);
        assert comparator instanceof FieldComparatorBase;

        return new FieldComparatorDecorator((FieldComparatorBase) comparator) {
            @Override
            protected Comparable sortValue(int doc) {
View Full Code Here

        this.base = base;
    }

    @Override
    public FieldComparator newComparator(String fieldname, int numHits, int sortPos, boolean reversed) throws IOException {
        FieldComparator comparator = base.newComparator(fieldname, numHits, sortPos, reversed);
        assert comparator instanceof FieldComparatorBase;

        return new FieldComparatorDecorator((FieldComparatorBase) comparator) {
            @Override
            protected Comparable sortValue(int doc) {
View Full Code Here

      return;
    }

    // Update existing group:
    for (int compIDX = 0;; compIDX++) {
      final FieldComparator fc = comparators[compIDX];
      fc.copy(spareSlot, doc);

      final int c = reversed[compIDX] * fc.compare(group.comparatorSlot, spareSlot);
      if (c < 0) {
        // Definitely not competitive.
        return;
      } else if (c > 0) {
        // Definitely competitive; set remaining comparators:
        for (int compIDX2=compIDX+1; compIDX2<comparators.length; compIDX2++) {
          comparators[compIDX2].copy(spareSlot, doc);
        }
        break;
      } else if (compIDX == compIDXEnd) {
        // Here c=0. If we're at the last comparator, this doc is not
        // competitive, since docs are visited in doc Id order, which means
        // this doc cannot compete with any other document in the queue.
        return;
      }
    }

    // Remove before updating the group since lookup is done via comparators
    // TODO: optimize this

    final CollectedSearchGroup prevLast;
    if (orderedGroups != null) {
      prevLast = orderedGroups.last();
      orderedGroups.remove(group);
      assert orderedGroups.size() == topNGroups-1;
    } else {
      prevLast = null;
    }

    group.topDoc = docBase + doc;

    // Swap slots
    final int tmp = spareSlot;
    spareSlot = group.comparatorSlot;
    group.comparatorSlot = tmp;

    // Re-add the changed group
    if (orderedGroups != null) {
      orderedGroups.add(group);
      assert orderedGroups.size() == topNGroups;
      final CollectedSearchGroup newLast = orderedGroups.last();
      // If we changed the value of the last group, or changed which group was last, then update bottom:
      if (group == newLast || prevLast != newLast) {
        for (FieldComparator fc : comparators) {
          fc.setBottom(newLast.comparatorSlot);
        }
      }
    }
  }
View Full Code Here

  private void buildSortedSet() {
    final Comparator<CollectedSearchGroup> comparator = new Comparator<CollectedSearchGroup>() {
      public int compare(CollectedSearchGroup o1, CollectedSearchGroup o2) {
        for (int compIDX = 0;; compIDX++) {
          FieldComparator fc = comparators[compIDX];
          final int c = reversed[compIDX] * fc.compare(o1.comparatorSlot, o2.comparatorSlot);
          if (c != 0) {
            return c;
          } else if (compIDX == compIDXEnd) {
            return o1.topDoc - o2.topDoc;
          }
        }
      }
    };

    orderedGroups = new TreeSet<CollectedSearchGroup>(comparator);
    orderedGroups.addAll(groupMap.values());
    assert orderedGroups.size() > 0;

    for (FieldComparator fc : comparators) {
      fc.setBottom(orderedGroups.last().comparatorSlot);
    }
  }
View Full Code Here

      for (SortField sortField : sortFields) {
        int type = sortField.getType();
        if (type == SortField.SCORE || type == SortField.DOC)
          continue;

        FieldComparator comparator = null;
        FieldComparator comparators[] = (readers == null) ? null : new FieldComparator[readers.length];

        String fieldname = sortField.getField();
        FieldType ft = fieldname == null ? null : req.getSchema().getFieldTypeNoEx(fieldname);

        DocSlice docList = (DocSlice)rb.getResults().docList;
View Full Code Here

TOP

Related Classes of org.apache.lucene.search.FieldComparator$TermOrdValComparator

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.