[ 
https://issues.apache.org/jira/browse/LUCENE-5702?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14202739#comment-14202739
 ] 

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):
{code:java}
      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;
      }
{code}

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: https://issues.apache.org/jira/browse/LUCENE-5702
>             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
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to