lucene-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "David Smiley (JIRA)" <>
Subject [jira] [Commented] (LUCENE-5702) Per-segment comparator API
Date Fri, 07 Nov 2014 21:38:34 GMT


David Smiley commented on LUCENE-5702:

bq. Maybe you could extend an existing FieldComparator to pull a NumericDocValues instance
differently (or IntValues/LongValues/... on 4.x) like SortedNumericSortField does?

I considered that but FieldComparator.LongComparator's constructor is package private, so
that's a deal-breaker.  In trunk (and 5x?) it's public.

In addition, to handle a more generic case, it's problematic because there's a FieldCache/DV
lookup *and* a Bits docsWithField lookup (and this logic is annoyingly repeated several times).
 See the snippet below.  In my case, I'm sorting indirectly by looking up values in another
document and so I need to map the current doc id to a target id.  I certainly don't want that
to happen twice for the same document (both the FieldCache/DV lookup *and* the docsWithField
call).  The following logic could be extracted into a method that a subclass could override,
like hypothetical method getValue(doc):
      long v2 = currentReaderValues.get(doc);
      // Test for v2 == 0 to save Bits.get method call for
      // the common case (doc has value and value is non-zero):
      if (docsWithField != null && v2 == 0 && !docsWithField.get(doc)) {
        v2 = missingValue;

Two examples of a FieldComparator instances in Lucene that could benefit from some re-usable
base classes are ExpressionComparator and ValueSourceComparator.  There are probably others.

> Per-segment comparator API
> --------------------------
>                 Key: LUCENE-5702
>                 URL:
>             Project: Lucene - Core
>          Issue Type: New Feature
>            Reporter: Adrien Grand
>            Assignee: Adrien Grand
>            Priority: Minor
>             Fix For: Trunk
>         Attachments: LUCENE-5702.patch
> As a next step of LUCENE-5527, it would be nice to have per-segment comparators, and
maybe even change the default behavior of our top* comparators so that they merge top hits
in the end.

This message was sent by Atlassian JIRA

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message