break field data value iterator into two callback types, one with support for missing, and one without
This commit is contained in:
parent
c9838d5c75
commit
58c606d6d9
|
@ -94,8 +94,14 @@ public abstract class NumericFieldData<Doc extends NumericDocFieldData> extends
|
|||
|
||||
public abstract void forEachValueInDoc(int docId, DoubleValueInDocProc proc);
|
||||
|
||||
public abstract void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc);
|
||||
|
||||
public static interface DoubleValueInDocProc {
|
||||
void onValue(int docId, double value);
|
||||
}
|
||||
|
||||
public static interface MissingDoubleValueInDocProc {
|
||||
void onValue(int docId, double value);
|
||||
|
||||
void onMissing(int docId);
|
||||
}
|
||||
|
|
|
@ -95,6 +95,15 @@ public class MultiValueByteFieldData extends ByteFieldData {
|
|||
}
|
||||
|
||||
@Override public void forEachValueInDoc(int docId, DoubleValueInDocProc proc) {
|
||||
for (int[] ordinal : ordinals) {
|
||||
int loc = ordinal[docId];
|
||||
if (loc != 0) {
|
||||
proc.onValue(docId, values[loc]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc) {
|
||||
boolean found = false;
|
||||
for (int[] ordinal : ordinals) {
|
||||
int loc = ordinal[docId];
|
||||
|
|
|
@ -71,6 +71,14 @@ public class SingleValueByteFieldData extends ByteFieldData {
|
|||
}
|
||||
|
||||
@Override public void forEachValueInDoc(int docId, DoubleValueInDocProc proc) {
|
||||
int loc = ordinals[docId];
|
||||
if (loc == 0) {
|
||||
return;
|
||||
}
|
||||
proc.onValue(docId, values[loc]);
|
||||
}
|
||||
|
||||
@Override public void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc) {
|
||||
int loc = ordinals[docId];
|
||||
if (loc == 0) {
|
||||
proc.onMissing(docId);
|
||||
|
|
|
@ -84,6 +84,15 @@ public class MultiValueDoubleFieldData extends DoubleFieldData {
|
|||
}
|
||||
|
||||
@Override public void forEachValueInDoc(int docId, DoubleValueInDocProc proc) {
|
||||
for (int[] ordinal : ordinals) {
|
||||
int loc = ordinal[docId];
|
||||
if (loc != 0) {
|
||||
proc.onValue(docId, values[loc]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc) {
|
||||
boolean found = false;
|
||||
for (int[] ordinal : ordinals) {
|
||||
int loc = ordinal[docId];
|
||||
|
|
|
@ -64,6 +64,14 @@ public class SingleValueDoubleFieldData extends DoubleFieldData {
|
|||
}
|
||||
|
||||
@Override public void forEachValueInDoc(int docId, DoubleValueInDocProc proc) {
|
||||
int loc = ordinals[docId];
|
||||
if (loc == 0) {
|
||||
return;
|
||||
}
|
||||
proc.onValue(docId, values[loc]);
|
||||
}
|
||||
|
||||
@Override public void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc) {
|
||||
int loc = ordinals[docId];
|
||||
if (loc == 0) {
|
||||
proc.onMissing(docId);
|
||||
|
|
|
@ -95,6 +95,15 @@ public class MultiValueFloatFieldData extends FloatFieldData {
|
|||
}
|
||||
|
||||
@Override public void forEachValueInDoc(int docId, DoubleValueInDocProc proc) {
|
||||
for (int[] ordinal : ordinals) {
|
||||
int loc = ordinal[docId];
|
||||
if (loc != 0) {
|
||||
proc.onValue(docId, values[loc]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc) {
|
||||
boolean found = false;
|
||||
for (int[] ordinal : ordinals) {
|
||||
int loc = ordinal[docId];
|
||||
|
|
|
@ -71,6 +71,14 @@ public class SingleValueFloatFieldData extends FloatFieldData {
|
|||
}
|
||||
|
||||
@Override public void forEachValueInDoc(int docId, DoubleValueInDocProc proc) {
|
||||
int loc = ordinals[docId];
|
||||
if (loc == 0) {
|
||||
return;
|
||||
}
|
||||
proc.onValue(docId, values[loc]);
|
||||
}
|
||||
|
||||
@Override public void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc) {
|
||||
int loc = ordinals[docId];
|
||||
if (loc == 0) {
|
||||
proc.onMissing(docId);
|
||||
|
|
|
@ -95,6 +95,15 @@ public class MultiValueIntFieldData extends IntFieldData {
|
|||
}
|
||||
|
||||
@Override public void forEachValueInDoc(int docId, DoubleValueInDocProc proc) {
|
||||
for (int[] ordinal : ordinals) {
|
||||
int loc = ordinal[docId];
|
||||
if (loc != 0) {
|
||||
proc.onValue(docId, values[loc]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc) {
|
||||
boolean found = false;
|
||||
for (int[] ordinal : ordinals) {
|
||||
int loc = ordinal[docId];
|
||||
|
|
|
@ -71,6 +71,14 @@ public class SingleValueIntFieldData extends IntFieldData {
|
|||
}
|
||||
|
||||
@Override public void forEachValueInDoc(int docId, DoubleValueInDocProc proc) {
|
||||
int loc = ordinals[docId];
|
||||
if (loc == 0) {
|
||||
return;
|
||||
}
|
||||
proc.onValue(docId, values[loc]);
|
||||
}
|
||||
|
||||
@Override public void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc) {
|
||||
int loc = ordinals[docId];
|
||||
if (loc == 0) {
|
||||
proc.onMissing(docId);
|
||||
|
|
|
@ -111,6 +111,15 @@ public class MultiValueLongFieldData extends LongFieldData {
|
|||
}
|
||||
|
||||
@Override public void forEachValueInDoc(int docId, DoubleValueInDocProc proc) {
|
||||
for (int[] ordinal : ordinals) {
|
||||
int loc = ordinal[docId];
|
||||
if (loc != 0) {
|
||||
proc.onValue(docId, values[loc]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc) {
|
||||
boolean found = false;
|
||||
for (int[] ordinal : ordinals) {
|
||||
int loc = ordinal[docId];
|
||||
|
|
|
@ -81,6 +81,14 @@ public class SingleValueLongFieldData extends LongFieldData {
|
|||
}
|
||||
|
||||
@Override public void forEachValueInDoc(int docId, DoubleValueInDocProc proc) {
|
||||
int loc = ordinals[docId];
|
||||
if (loc == 0) {
|
||||
return;
|
||||
}
|
||||
proc.onValue(docId, values[loc]);
|
||||
}
|
||||
|
||||
@Override public void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc) {
|
||||
int loc = ordinals[docId];
|
||||
if (loc == 0) {
|
||||
proc.onMissing(docId);
|
||||
|
|
|
@ -95,6 +95,15 @@ public class MultiValueShortFieldData extends ShortFieldData {
|
|||
}
|
||||
|
||||
@Override public void forEachValueInDoc(int docId, DoubleValueInDocProc proc) {
|
||||
for (int[] ordinal : ordinals) {
|
||||
int loc = ordinal[docId];
|
||||
if (loc != 0) {
|
||||
proc.onValue(docId, values[loc]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc) {
|
||||
boolean found = false;
|
||||
for (int[] ordinal : ordinals) {
|
||||
int loc = ordinal[docId];
|
||||
|
|
|
@ -71,6 +71,14 @@ public class SingleValueShortFieldData extends ShortFieldData {
|
|||
}
|
||||
|
||||
@Override public void forEachValueInDoc(int docId, DoubleValueInDocProc proc) {
|
||||
int loc = ordinals[docId];
|
||||
if (loc == 0) {
|
||||
return;
|
||||
}
|
||||
proc.onValue(docId, values[loc]);
|
||||
}
|
||||
|
||||
@Override public void forEachValueInDoc(int docId, MissingDoubleValueInDocProc proc) {
|
||||
int loc = ordinals[docId];
|
||||
if (loc == 0) {
|
||||
proc.onMissing(docId);
|
||||
|
|
|
@ -101,8 +101,6 @@ public class CountAndTotalHistogramFacetCollector extends AbstractFacetCollector
|
|||
|
||||
private final TLongDoubleHashMap totals = new TLongDoubleHashMap();
|
||||
|
||||
private int missing;
|
||||
|
||||
public HistogramProc(long interval) {
|
||||
this.interval = interval;
|
||||
}
|
||||
|
@ -113,10 +111,6 @@ public class CountAndTotalHistogramFacetCollector extends AbstractFacetCollector
|
|||
totals.adjustOrPutValue(bucket, value, value);
|
||||
}
|
||||
|
||||
@Override public void onMissing(int docId) {
|
||||
missing++;
|
||||
}
|
||||
|
||||
public TLongLongHashMap counts() {
|
||||
return counts;
|
||||
}
|
||||
|
|
|
@ -100,8 +100,6 @@ public class CountHistogramFacetCollector extends AbstractFacetCollector {
|
|||
|
||||
private final TLongLongHashMap counts = CacheRecycler.popLongLongMap();
|
||||
|
||||
private int missing;
|
||||
|
||||
public HistogramProc(long interval) {
|
||||
this.interval = interval;
|
||||
}
|
||||
|
@ -111,10 +109,6 @@ public class CountHistogramFacetCollector extends AbstractFacetCollector {
|
|||
counts.adjustOrPutValue(bucket, 1, 1);
|
||||
}
|
||||
|
||||
@Override public void onMissing(int docId) {
|
||||
missing++;
|
||||
}
|
||||
|
||||
public TLongLongHashMap counts() {
|
||||
return counts;
|
||||
}
|
||||
|
|
|
@ -115,8 +115,6 @@ public class KeyValueScriptHistogramFacetCollector extends AbstractFacetCollecto
|
|||
|
||||
private final TLongDoubleHashMap totals = new TLongDoubleHashMap();
|
||||
|
||||
private int missing;
|
||||
|
||||
public HistogramProc(long interval, SearchScript valueScript) {
|
||||
this.interval = interval;
|
||||
this.valueScript = valueScript;
|
||||
|
@ -131,10 +129,6 @@ public class KeyValueScriptHistogramFacetCollector extends AbstractFacetCollecto
|
|||
totals.adjustOrPutValue(bucket, scriptValue, scriptValue);
|
||||
}
|
||||
|
||||
@Override public void onMissing(int docId) {
|
||||
missing++;
|
||||
}
|
||||
|
||||
public TLongLongHashMap counts() {
|
||||
return counts;
|
||||
}
|
||||
|
|
|
@ -101,8 +101,6 @@ public class KeyValueRangeFacetCollector extends AbstractFacetCollector {
|
|||
|
||||
private final RangeFacet.Entry[] entries;
|
||||
|
||||
private int missing;
|
||||
|
||||
NumericFieldData valueFieldData;
|
||||
|
||||
public RangeProc(RangeFacet.Entry[] entries) {
|
||||
|
@ -129,9 +127,5 @@ public class KeyValueRangeFacetCollector extends AbstractFacetCollector {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void onMissing(int docId) {
|
||||
missing++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -88,8 +88,6 @@ public class RangeFacetCollector extends AbstractFacetCollector {
|
|||
|
||||
private final RangeFacet.Entry[] entries;
|
||||
|
||||
private int missing;
|
||||
|
||||
public RangeProc(RangeFacet.Entry[] entries) {
|
||||
this.entries = entries;
|
||||
}
|
||||
|
@ -106,9 +104,5 @@ public class RangeFacetCollector extends AbstractFacetCollector {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void onMissing(int docId) {
|
||||
missing++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ public class StatisticalFacetCollector extends AbstractFacetCollector {
|
|||
return new InternalStatisticalFacet(facetName, statsProc.min(), statsProc.max(), statsProc.total(), statsProc.sumOfSquares(), statsProc.count());
|
||||
}
|
||||
|
||||
public static class StatsProc implements NumericFieldData.DoubleValueInDocProc {
|
||||
public static class StatsProc implements NumericFieldData.MissingDoubleValueInDocProc {
|
||||
|
||||
double min = Double.MAX_VALUE;
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ public class StatisticalFieldsFacetCollector extends AbstractFacetCollector {
|
|||
return new InternalStatisticalFacet(facetName, statsProc.min(), statsProc.max(), statsProc.total(), statsProc.sumOfSquares(), statsProc.count());
|
||||
}
|
||||
|
||||
public static class StatsProc implements NumericFieldData.DoubleValueInDocProc {
|
||||
public static class StatsProc implements NumericFieldData.MissingDoubleValueInDocProc {
|
||||
|
||||
double min = Double.MAX_VALUE;
|
||||
|
||||
|
|
Loading…
Reference in New Issue