/** * Return a {@link NumericDoubleValues} instance that can be used to sort documents * with this mode and the provided values. When a document has no value, * <code>missingValue</code> is returned. * * Allowed Modes: SUM, AVG, MEDIAN, MIN, MAX */ public NumericDoubleValues select(final SortedNumericDoubleValues values) { final NumericDoubleValues singleton = FieldData.unwrapSingleton(values); if (singleton != null) { return singleton; } else { return new NumericDoubleValues() { private double value; @Override public boolean advanceExact(int target) throws IOException { if (values.advanceExact(target)) { value = pick(values); return true; } return false; } @Override public double doubleValue() throws IOException { return this.value; } }; } }
/** * Wrap the provided {@link SortedNumericDoubleValues} instance to cast all values to longs. */ public static SortedNumericDocValues castToLong(final SortedNumericDoubleValues values) { final NumericDoubleValues singleton = unwrapSingleton(values); if (singleton != null) { final Bits docsWithField = unwrapSingletonBits(values); return DocValues.singleton(new LongCastedValues(singleton), docsWithField); } else { return new SortedLongCastedValues(values); } }
/** * Wrap the provided {@link SortedNumericDoubleValues} instance to cast all values to longs. */ public static SortedNumericDocValues castToLong(final SortedNumericDoubleValues values) { final NumericDoubleValues singleton = unwrapSingleton(values); if (singleton != null) { final Bits docsWithField = unwrapSingletonBits(values); return DocValues.singleton(new LongCastedValues(singleton), docsWithField); } else { return new SortedLongCastedValues(values); } }
final BinaryDocValues singleton = FieldData.unwrapSingleton(values); if (singleton != null) { if (missingValue == null) {
@Override public Bits docsWithValue(LeafReaderContext context) { final MultiGeoPointValues geoPoints = geoPointValues(context); if (org.elasticsearch.index.fielddata.FieldData.unwrapSingleton(geoPoints) != null) { return org.elasticsearch.index.fielddata.FieldData.unwrapSingletonBits(geoPoints); } else { return org.elasticsearch.index.fielddata.FieldData.docsWithValue(geoPoints, context.reader().maxDoc()); } }
final MultiGeoPointValues geoPointValues, final GeoPoint... fromPoints) { final GeoPointValues singleValues = FieldData.unwrapSingleton(geoPointValues); if (singleValues != null && fromPoints.length == 1) { return FieldData.singleton(new NumericDoubleValues() {
@Override public Bits docsWithValue(LeafReaderContext context) throws IOException { final SortedBinaryDocValues bytes = bytesValues(context); if (org.elasticsearch.index.fielddata.FieldData.unwrapSingleton(bytes) != null) { return org.elasticsearch.index.fielddata.FieldData.unwrapSingletonBits(bytes); } else { return org.elasticsearch.index.fielddata.FieldData.docsWithValue(bytes, context.reader().maxDoc()); } }
/** * Wrap the provided {@link SortedNumericDoubleValues} instance to cast all values to longs. */ public static SortedNumericDocValues castToLong(final SortedNumericDoubleValues values) { final NumericDoubleValues singleton = unwrapSingleton(values); if (singleton != null) { return DocValues.singleton(new LongCastedValues(singleton)); } else { return new SortedLongCastedValues(values); } }
@Override public Bits docsWithValue(LeafReaderContext context) { final MultiGeoPointValues geoPoints = geoPointValues(context); if (org.elasticsearch.index.fielddata.FieldData.unwrapSingleton(geoPoints) != null) { return org.elasticsearch.index.fielddata.FieldData.unwrapSingletonBits(geoPoints); } else { return org.elasticsearch.index.fielddata.FieldData.docsWithValue(geoPoints, context.reader().maxDoc()); } }
/** * Given a {@link SortedNumericDoubleValues}, return a * {@link SortedNumericDocValues} instance that will translate double values * to sortable long bits using * {@link org.apache.lucene.util.NumericUtils#doubleToSortableLong(double)}. */ public static SortedNumericDocValues toSortableLongBits(SortedNumericDoubleValues values) { final NumericDoubleValues singleton = unwrapSingleton(values); if (singleton != null) { final NumericDocValues longBits; if (singleton instanceof SortableLongBitsToNumericDoubleValues) { longBits = ((SortableLongBitsToNumericDoubleValues) singleton).getLongValues(); } else { longBits = new SortableLongBitsNumericDocValues(singleton); } return DocValues.singleton(longBits); } else { if (values instanceof SortableLongBitsToSortedNumericDoubleValues) { return ((SortableLongBitsToSortedNumericDoubleValues) values).getLongValues(); } else { return new SortableLongBitsSortedNumericDocValues(values); } } }
@Override public Bits docsWithValue(LeafReaderContext context) throws IOException { final SortedBinaryDocValues bytes = bytesValues(context); if (org.elasticsearch.index.fielddata.FieldData.unwrapSingleton(bytes) != null) { return org.elasticsearch.index.fielddata.FieldData.unwrapSingletonBits(bytes); } else { return org.elasticsearch.index.fielddata.FieldData.docsWithValue(bytes, context.reader().maxDoc()); } }
/** * Returns whether the provided values *might* be multi-valued. There is no * guarantee that this method will return <tt>false</tt> in the single-valued case. */ public static boolean isMultiValued(SortedBinaryDocValues values) { return unwrapSingleton(values) != null; }
@Override public Bits docsWithValue(LeafReaderContext context) throws IOException { if (isFloatingPoint()) { final SortedNumericDoubleValues values = doubleValues(context); if (org.elasticsearch.index.fielddata.FieldData.unwrapSingleton(values) != null) { return org.elasticsearch.index.fielddata.FieldData.unwrapSingletonBits(values); } else { return org.elasticsearch.index.fielddata.FieldData.docsWithValue(values, context.reader().maxDoc()); } } else { final SortedNumericDocValues values = longValues(context); if (DocValues.unwrapSingleton(values) != null) { return DocValues.unwrapSingletonBits(values); } else { return DocValues.docsWithValue(values, context.reader().maxDoc()); } } }
/** * Returns whether the provided values *might* be multi-valued. There is no * guarantee that this method will return <tt>false</tt> in the single-valued case. */ public static boolean isMultiValued(MultiGeoPointValues values) { return unwrapSingleton(values) == null; }
/** * Returns whether the provided values *might* be multi-valued. There is no * guarantee that this method will return <tt>false</tt> in the single-valued case. */ public static boolean isMultiValued(SortedNumericDoubleValues values) { return unwrapSingleton(values) == null; }
/** * Returns whether the provided values *might* be multi-valued. There is no * guarantee that this method will return <tt>false</tt> in the single-valued case. */ public static boolean isMultiValued(MultiGeoPointValues values) { return unwrapSingleton(values) == null; }
/** * Returns whether the provided values *might* be multi-valued. There is no * guarantee that this method will return <tt>false</tt> in the single-valued case. */ public static boolean isMultiValued(SortedNumericDoubleValues values) { return unwrapSingleton(values) == null; }
/** * Returns whether the provided values *might* be multi-valued. There is no * guarantee that this method will return <tt>false</tt> in the single-valued case. */ public static boolean isMultiValued(SortedBinaryDocValues values) { return unwrapSingleton(values) != null; }
/** * Wrap the provided {@link SortedNumericDoubleValues} instance to cast all values to longs. */ public static SortedNumericDocValues castToLong(final SortedNumericDoubleValues values) { final NumericDoubleValues singleton = unwrapSingleton(values); if (singleton != null) { return DocValues.singleton(new LongCastedValues(singleton)); } else { return new SortedLongCastedValues(values); } }
/** * Wrap the provided {@link SortedNumericDoubleValues} instance to cast all values to longs. */ public static SortedNumericDocValues castToLong(final SortedNumericDoubleValues values) { final NumericDoubleValues singleton = unwrapSingleton(values); if (singleton != null) { return DocValues.singleton(new LongCastedValues(singleton)); } else { return new SortedLongCastedValues(values); } }