summaryrefslogtreecommitdiff
path: root/core/src/main/java/org/elasticsearch/index/fielddata/NumericDoubleValues.java
diff options
context:
space:
mode:
Diffstat (limited to 'core/src/main/java/org/elasticsearch/index/fielddata/NumericDoubleValues.java')
-rw-r--r--core/src/main/java/org/elasticsearch/index/fielddata/NumericDoubleValues.java53
1 files changed, 34 insertions, 19 deletions
diff --git a/core/src/main/java/org/elasticsearch/index/fielddata/NumericDoubleValues.java b/core/src/main/java/org/elasticsearch/index/fielddata/NumericDoubleValues.java
index 2cbbb0064f..0d78d3c790 100644
--- a/core/src/main/java/org/elasticsearch/index/fielddata/NumericDoubleValues.java
+++ b/core/src/main/java/org/elasticsearch/index/fielddata/NumericDoubleValues.java
@@ -20,43 +20,58 @@
package org.elasticsearch.index.fielddata;
import org.apache.lucene.index.NumericDocValues;
+import org.apache.lucene.search.DoubleValues;
+
+import java.io.IOException;
/**
* A per-document numeric value.
*/
-public abstract class NumericDoubleValues {
+public abstract class NumericDoubleValues extends DoubleValues {
/** Sole constructor. (For invocation by subclass
* constructors, typically implicit.) */
protected NumericDoubleValues() {}
-
- /**
- * Returns the numeric value for the specified document ID. This must return
- * <tt>0d</tt> if the given doc ID has no value.
- * @param docID document ID to lookup
- * @return numeric value
- */
- public abstract double get(int docID);
// TODO: this interaction with sort comparators is really ugly...
/** Returns numeric docvalues view of raw double bits */
public NumericDocValues getRawDoubleValues() {
- return new NumericDocValues() {
- @Override
- public long get(int docID) {
- return Double.doubleToRawLongBits(NumericDoubleValues.this.get(docID));
- }
+ return new AbstractNumericDocValues() {
+ private int docID = -1;
+ @Override
+ public boolean advanceExact(int target) throws IOException {
+ docID = target;
+ return NumericDoubleValues.this.advanceExact(target);
+ }
+ @Override
+ public long longValue() throws IOException {
+ return Double.doubleToRawLongBits(NumericDoubleValues.this.doubleValue());
+ }
+ @Override
+ public int docID() {
+ return docID;
+ }
};
}
// yes... this is doing what the previous code was doing...
/** Returns numeric docvalues view of raw float bits */
public NumericDocValues getRawFloatValues() {
- return new NumericDocValues() {
- @Override
- public long get(int docID) {
- return Float.floatToRawIntBits((float)NumericDoubleValues.this.get(docID));
- }
+ return new AbstractNumericDocValues() {
+ private int docID = -1;
+ @Override
+ public boolean advanceExact(int target) throws IOException {
+ docID = target;
+ return NumericDoubleValues.this.advanceExact(target);
+ }
+ @Override
+ public long longValue() throws IOException {
+ return Float.floatToRawIntBits((float)NumericDoubleValues.this.doubleValue());
+ }
+ @Override
+ public int docID() {
+ return docID;
+ }
};
}
}