You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@lucene.apache.org by "Adrien Grand (Jira)" <ji...@apache.org> on 2019/12/05 12:57:00 UTC
[jira] [Commented] (LUCENE-9081) Make DocValuesIterator public
[ https://issues.apache.org/jira/browse/LUCENE-9081?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16988769#comment-16988769 ]
Adrien Grand commented on LUCENE-9081:
--------------------------------------
I looked into the classes mentioned on SOLR-12964. I think we don't actually need to make it public? The base class looks like this:
{code}
public abstract class DocValuesAcc extends SlotAcc {
SchemaField sf;
public DocValuesAcc(FacetContext fcontext, SchemaField sf) throws IOException {
super(fcontext);
this.sf = sf;
}
@Override
public void collect(int doc, int slot, IntFunction<SlotContext> slotContext) throws IOException {
int valuesDocID = docIdSetIterator().docID();
if (valuesDocID < doc) {
valuesDocID = docIdSetIterator().advance(doc);
}
if (valuesDocID > doc) {
// missing
return;
}
assert valuesDocID == doc;
collectValues(doc, slot);
}
protected abstract void collectValues(int doc, int slot) throws IOException;
protected abstract DocIdSetIterator docIdSetIterator();
}
{code}
And I think the reason for this is to avoid repeating the boilerplate of advancing the iterator in all sub aggs. But advanceExact addresses this issue too as advancing the iterator becomes a single incantation rather than 6 lines that call advance and check the docID. So we could alternatively remove this default implementation of collect and call advanceExact from concrete implementations. Here is a subset of what the diff would look like to show the idea
{code:none}
diff --git a/solr/core/src/java/org/apache/solr/search/facet/CountValsAgg.java b/solr/core/src/java/org/apache/solr/search/facet/CountValsAgg.java
index eebe9fc..e999064 100644
--- a/solr/core/src/java/org/apache/solr/search/facet/CountValsAgg.java
+++ b/solr/core/src/java/org/apache/solr/search/facet/CountValsAgg.java
@@ -88,8 +88,10 @@ public class CountValsAgg extends SimpleAggValueSource {
}
@Override
- protected void collectValues(int doc, int slot) throws IOException {
- result[slot]+=values.docValueCount();
+ public void collect(int doc, int slot, IntFunction<SlotContext> slotContext) throws IOException {
+ if (values.advanceExact(doc)) {
+ result[slot]+=values.docValueCount();
+ }
}
}
diff --git a/solr/core/src/java/org/apache/solr/search/facet/DocValuesAcc.java b/solr/core/src/java/org/apache/solr/search/facet/DocValuesAcc.java
index e3740e7..90507e3 100644
--- a/solr/core/src/java/org/apache/solr/search/facet/DocValuesAcc.java
+++ b/solr/core/src/java/org/apache/solr/search/facet/DocValuesAcc.java
@@ -41,23 +41,6 @@ public abstract class DocValuesAcc extends SlotAcc {
this.sf = sf;
}
- @Override
- public void collect(int doc, int slot, IntFunction<SlotContext> slotContext) throws IOException {
- int valuesDocID = docIdSetIterator().docID();
- if (valuesDocID < doc) {
- valuesDocID = docIdSetIterator().advance(doc);
- }
- if (valuesDocID > doc) {
- // missing
- return;
- }
- assert valuesDocID == doc;
- collectValues(doc, slot);
- }
-
- protected abstract void collectValues(int doc, int slot) throws IOException;
-
- protected abstract DocIdSetIterator docIdSetIterator();
}
/**
@@ -98,10 +81,6 @@ abstract class SortedNumericDVAcc extends DocValuesAcc {
values = DocValues.getSortedNumeric(readerContext.reader(), sf.getName());
}
- @Override
- protected DocIdSetIterator docIdSetIterator() {
- return values;
- }
}
abstract class LongSortedNumericDVAcc extends SortedNumericDVAcc {
{code}
> Make DocValuesIterator public
> -----------------------------
>
> Key: LUCENE-9081
> URL: https://issues.apache.org/jira/browse/LUCENE-9081
> Project: Lucene - Core
> Issue Type: Task
> Reporter: Munendra S N
> Priority: Minor
>
> This is spinoff from SOLR-12964 where it was agreed to that {{DocValuesIterator}} should be made public. I came across same issue while working on SOLR-11706 and SOLR-13912
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@lucene.apache.org
For additional commands, e-mail: issues-help@lucene.apache.org