final NumericDocValues singleton = DocValues.unwrapSingleton(values); if (singleton != null) { final Bits docsWithField = DocValues.unwrapSingletonBits(values); if (docsWithField == null || missingValue == 0) { return singleton;
final NumericDocValues singleton = DocValues.unwrapSingleton(values); if (singleton != null) { final Bits docsWithField = DocValues.unwrapSingletonBits(values); if (docsWithField == null || missingValue == 0) { return singleton;
final NumericDocValues singleton = DocValues.unwrapSingleton(values); if (singleton != null) { final Bits docsWithField = DocValues.unwrapSingletonBits(values); if (docsWithField == null || missingValue == 0) { return singleton;
/** * Wrap the provided {@link SortedNumericDocValues} instance to cast all values to doubles. */ public static SortedNumericDoubleValues castToDouble(final SortedNumericDocValues values) { final NumericDocValues singleton = DocValues.unwrapSingleton(values); if (singleton != null) { final Bits docsWithField = DocValues.unwrapSingletonBits(values); return singleton(new DoubleCastedValues(singleton), docsWithField); } else { return new SortedDoubleCastedValues(values); } }
@Override public SortedNumericDoubleValues getDoubleValues() { try { SortedNumericDocValues raw = DocValues.getSortedNumeric(reader, field); NumericDocValues single = DocValues.unwrapSingleton(raw); if (single != null) { return FieldData.singleton(new SingleHalfFloatValues(single), DocValues.unwrapSingletonBits(raw)); } else { return new MultiHalfFloatValues(raw); } } catch (IOException e) { throw new IllegalStateException("Cannot load doc values", e); } }
/** * Wrap the provided {@link SortedNumericDocValues} instance to cast all values to doubles. */ public static SortedNumericDoubleValues castToDouble(final SortedNumericDocValues values) { final NumericDocValues singleton = DocValues.unwrapSingleton(values); if (singleton != null) { final Bits docsWithField = DocValues.unwrapSingletonBits(values); return singleton(new DoubleCastedValues(singleton), docsWithField); } else { return new SortedDoubleCastedValues(values); } }
/** * Wrap the provided {SortedNumericDocValues} instance to cast all values to doubles. */ public static SortedNumericDoubleValues castToDouble(final SortedNumericDocValues values) { final NumericDocValues singleton = DocValues.unwrapSingleton(values); if (singleton != null) { final Bits docsWithField = DocValues.unwrapSingletonBits(values); return singleton(new DoubleCastedValues(singleton), docsWithField); } else { return new SortedDoubleCastedValues(values); } }
@Override public SortedNumericDoubleValues getDoubleValues() { try { SortedNumericDocValues raw = DocValues.getSortedNumeric(reader, field); NumericDocValues single = DocValues.unwrapSingleton(raw); if (single != null) { return FieldData.singleton(new SingleFloatValues(single), DocValues.unwrapSingletonBits(raw)); } else { return new MultiFloatValues(raw); } } catch (IOException e) { throw new IllegalStateException("Cannot load doc values", e); } }
@Override public SortedNumericDoubleValues getDoubleValues() { try { SortedNumericDocValues raw = DocValues.getSortedNumeric(reader, field); NumericDocValues single = DocValues.unwrapSingleton(raw); if (single != null) { return FieldData.singleton(new SingleFloatValues(single), DocValues.unwrapSingletonBits(raw)); } else { return new MultiFloatValues(raw); } } catch (IOException e) { throw new IllegalStateException("Cannot load doc values", e); } }
@Override public SortedNumericDoubleValues getDoubleValues() { final SortedNumericDocValues values = scaledFieldData.getLongValues(); final NumericDocValues singleValues = DocValues.unwrapSingleton(values); if (singleValues != null) { return FieldData.singleton(new NumericDoubleValues() { @Override public double get(int docID) { return singleValues.get(docID) * scalingFactorInverse; } }, DocValues.unwrapSingletonBits(values)); } else { return new SortedNumericDoubleValues() { @Override public double valueAt(int index) { return values.valueAt(index) * scalingFactorInverse; } @Override public void setDocument(int doc) { values.setDocument(doc); } @Override public int count() { return values.count(); } }; } }
/** * Given a {@link SortedNumericDocValues}, return a {@link SortedNumericDoubleValues} * instance that will translate long values to doubles using * {@link NumericUtils#sortableLongToDouble(long)}. */ public static SortedNumericDoubleValues sortableLongBitsToDoubles(SortedNumericDocValues values) { final NumericDocValues singleton = DocValues.unwrapSingleton(values); if (singleton != null) { final NumericDoubleValues doubles; if (singleton instanceof SortableLongBitsNumericDocValues) { doubles = ((SortableLongBitsNumericDocValues) singleton).getDoubleValues(); } else { doubles = new SortableLongBitsToNumericDoubleValues(singleton); } final Bits docsWithField = DocValues.unwrapSingletonBits(values); return singleton(doubles, docsWithField); } else { if (values instanceof SortableLongBitsSortedNumericDocValues) { return ((SortableLongBitsSortedNumericDocValues) values).getDoubleValues(); } else { return new SortableLongBitsToSortedNumericDoubleValues(values); } } }
/** * Given a {SortedNumericDocValues}, return a {SortedNumericDoubleValues} * instance that will translate long values to doubles using * {NumericUtils#sortableLongToDouble(long)}. */ public static SortedNumericDoubleValues sortableLongBitsToDoubles(SortedNumericDocValues values) { final NumericDocValues singleton = DocValues.unwrapSingleton(values); if (singleton != null) { final NumericDoubleValues doubles; if (singleton instanceof SortableLongBitsNumericDocValues) { doubles = ((SortableLongBitsNumericDocValues) singleton).getDoubleValues(); } else { doubles = new SortableLongBitsToNumericDoubleValues(singleton); } final Bits docsWithField = DocValues.unwrapSingletonBits(values); return singleton(doubles, docsWithField); } else { if (values instanceof SortableLongBitsSortedNumericDocValues) { return ((SortableLongBitsSortedNumericDocValues) values).getDoubleValues(); } else { return new SortableLongBitsToSortedNumericDoubleValues(values); } } }
/** * Given a {@link SortedNumericDocValues}, return a {@link SortedNumericDoubleValues} * instance that will translate long values to doubles using * {@link NumericUtils#sortableLongToDouble(long)}. */ public static SortedNumericDoubleValues sortableLongBitsToDoubles(SortedNumericDocValues values) { final NumericDocValues singleton = DocValues.unwrapSingleton(values); if (singleton != null) { final NumericDoubleValues doubles; if (singleton instanceof SortableLongBitsNumericDocValues) { doubles = ((SortableLongBitsNumericDocValues) singleton).getDoubleValues(); } else { doubles = new SortableLongBitsToNumericDoubleValues(singleton); } final Bits docsWithField = DocValues.unwrapSingletonBits(values); return singleton(doubles, docsWithField); } else { if (values instanceof SortableLongBitsSortedNumericDocValues) { return ((SortableLongBitsSortedNumericDocValues) values).getDoubleValues(); } else { return new SortableLongBitsToSortedNumericDoubleValues(values); } } }
@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()); } } }
@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()); } } }
@Override public Bits docsWithValue(LeafReaderContext context) throws IOException { if (isFloatingPoint()) { final SortedNumericDoubleValues values = doubleValues(context); if (org.codelibs.elasticsearch.index.fielddata.FieldData.unwrapSingleton(values) != null) { return org.codelibs.elasticsearch.index.fielddata.FieldData.unwrapSingletonBits(values); } else { return org.codelibs.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()); } } }