You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sh...@apache.org on 2016/12/18 20:15:02 UTC
lucene-solr:branch_6x: LUCENE-7590: move docsWithField to
DocValuesStats
Repository: lucene-solr
Updated Branches:
refs/heads/branch_6x 47bb32c3b -> 73b6a29f2
LUCENE-7590: move docsWithField to DocValuesStats
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/73b6a29f
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/73b6a29f
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/73b6a29f
Branch: refs/heads/branch_6x
Commit: 73b6a29f2d89e2f1ce86b57ad0acec7d157f7e21
Parents: 47bb32c
Author: Shai Erera <sh...@apache.org>
Authored: Sun Dec 18 22:11:14 2016 +0200
Committer: Shai Erera <sh...@apache.org>
Committed: Sun Dec 18 22:14:36 2016 +0200
----------------------------------------------------------------------
.../apache/lucene/search/DocValuesStats.java | 45 +++++---------------
1 file changed, 11 insertions(+), 34 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/73b6a29f/lucene/misc/src/java/org/apache/lucene/search/DocValuesStats.java
----------------------------------------------------------------------
diff --git a/lucene/misc/src/java/org/apache/lucene/search/DocValuesStats.java b/lucene/misc/src/java/org/apache/lucene/search/DocValuesStats.java
index 99b81fa..f97af20 100644
--- a/lucene/misc/src/java/org/apache/lucene/search/DocValuesStats.java
+++ b/lucene/misc/src/java/org/apache/lucene/search/DocValuesStats.java
@@ -32,6 +32,7 @@ public abstract class DocValuesStats<T> {
private int missing = 0;
private int count = 0;
+ private Bits docsWithField;
protected final String field;
@@ -49,7 +50,7 @@ public abstract class DocValuesStats<T> {
* the field. Implementations should update the statistics based on the value of the current document.
*
* @param doc
- * the document to read the value of for udpating statistics.
+ * the document to read the value of for updating statistics.
* @param count
* the updated number of documents with value for this field.
*/
@@ -59,13 +60,13 @@ public abstract class DocValuesStats<T> {
* Initializes this object with the given reader context. Returns whether stats can be computed for this segment (i.e.
* it does have the requested DocValues field).
*/
- protected abstract boolean init(LeafReaderContext context) throws IOException;
-
- /** Returns whether the given document has a value for the requested DocValues field. */
- protected abstract boolean hasValue(int doc) throws IOException;
+ protected boolean init(LeafReaderContext context) throws IOException {
+ docsWithField = context.reader().getDocsWithField(field);
+ return docsWithField == null;
+ }
final void accumulate(int doc) throws IOException {
- if (hasValue(doc)) {
+ if (docsWithField.get(doc)) {
++count;
doAccumulate(doc, count);
} else {
@@ -109,7 +110,6 @@ public abstract class DocValuesStats<T> {
protected double variance = 0.0;
protected NumericDocValues ndv;
- protected Bits docsWithField;
protected NumericDocValuesStats(String field, T initialMin, T initialMax) {
super(field, initialMin, initialMax);
@@ -117,16 +117,11 @@ public abstract class DocValuesStats<T> {
@Override
protected final boolean init(LeafReaderContext context) throws IOException {
+ super.init(context);
ndv = context.reader().getNumericDocValues(field);
- docsWithField = context.reader().getDocsWithField(field);
return ndv != null;
}
- @Override
- protected final boolean hasValue(int doc) throws IOException {
- return docsWithField.get(doc);
- }
-
/** The mean of all values of the field. */
public final double mean() {
return mean;
@@ -217,7 +212,6 @@ public abstract class DocValuesStats<T> {
protected double variance = 0.0;
protected SortedNumericDocValues sndv;
- protected Bits docsWithField;
protected SortedNumericDocValuesStats(String field, T initialMin, T initialMax) {
super(field, initialMin, initialMax);
@@ -225,16 +219,11 @@ public abstract class DocValuesStats<T> {
@Override
protected final boolean init(LeafReaderContext context) throws IOException {
+ super.init(context);
sndv = context.reader().getSortedNumericDocValues(field);
- docsWithField = context.reader().getDocsWithField(field);
return sndv != null;
}
- @Override
- protected final boolean hasValue(int doc) throws IOException {
- return docsWithField.get(doc);
- }
-
/** The mean of all values of the field. */
public final double mean() {
return mean;
@@ -352,7 +341,6 @@ public abstract class DocValuesStats<T> {
public static class SortedDocValuesStats extends DocValuesStats<BytesRef> {
protected SortedDocValues sdv;
- protected Bits docsWithField;
protected SortedDocValuesStats(String field) {
super(field, null, null);
@@ -360,17 +348,12 @@ public abstract class DocValuesStats<T> {
@Override
protected final boolean init(LeafReaderContext context) throws IOException {
+ super.init(context);
sdv = context.reader().getSortedDocValues(field);
- docsWithField = context.reader().getDocsWithField(field);
return sdv != null;
}
@Override
- protected final boolean hasValue(int doc) throws IOException {
- return docsWithField.get(doc);
- }
-
- @Override
protected void doAccumulate(int doc, int count) throws IOException {
BytesRef val = sdv.get(doc);
if (max == null || val.compareTo(max) > 0) {
@@ -386,7 +369,6 @@ public abstract class DocValuesStats<T> {
public static class SortedSetDocValuesStats extends DocValuesStats<BytesRef> {
protected SortedSetDocValues ssdv;
- protected Bits docsWithField;
protected SortedSetDocValuesStats(String field) {
super(field, null, null);
@@ -394,17 +376,12 @@ public abstract class DocValuesStats<T> {
@Override
protected final boolean init(LeafReaderContext context) throws IOException {
+ super.init(context);
ssdv = context.reader().getSortedSetDocValues(field);
- docsWithField = context.reader().getDocsWithField(field);
return ssdv != null;
}
@Override
- protected final boolean hasValue(int doc) throws IOException {
- return docsWithField.get(doc);
- }
-
- @Override
protected void doAccumulate(int doc, int count) throws IOException {
ssdv.setDocument(doc);
long ord;