/** * Return a {@link SortedBinaryDocValues} that doesn't contain any value. */ public static SortedBinaryDocValues emptySortedBinary() { return singleton(DocValues.emptyBinary()); }
/** * Return a {@link SortedNumericDoubleValues} that doesn't contain any value. */ public static SortedNumericDoubleValues emptySortedNumericDoubles() { return singleton(emptyNumericDouble()); }
/** * Return a {@link SortedNumericDoubleValues} that doesn't contain any value. */ public static MultiGeoPointValues emptyMultiGeoPoints() { return singleton(emptyGeoPoint()); }
@Override public SortedBinaryDocValues getBytesValues() { try { final BinaryDocValues values = DocValues.getBinary(reader, field); return FieldData.singleton(values); } catch (IOException e) { throw new IllegalStateException("Cannot load doc values", e); } }
@Override protected SortedNumericDoubleValues getValues(LeafReaderContext context) throws IOException { leafScript = searchScript.newInstance(context); final NumericDoubleValues values = new NumericDoubleValues() { @Override public boolean advanceExact(int doc) throws IOException { leafScript.setDocument(doc); return true; } @Override public double doubleValue() { return leafScript.runAsDouble(); } }; return FieldData.singleton(values); } @Override
@Override protected SortedBinaryDocValues getValues(LeafReaderContext context) throws IOException { leafScript = searchScript.newInstance(context); final BinaryDocValues values = new AbstractBinaryDocValues() { final BytesRefBuilder spare = new BytesRefBuilder(); @Override public boolean advanceExact(int doc) throws IOException { leafScript.setDocument(doc); return true; } @Override public BytesRef binaryValue() { final Object run = leafScript.run(); CollectionUtils.ensureNoSelfReferences(run); spare.copyChars(run.toString()); return spare.get(); } }; return FieldData.singleton(values); } @Override
final GeoPointValues singleValues = FieldData.unwrapSingleton(geoPointValues); if (singleValues != null && fromPoints.length == 1) { return FieldData.singleton(new NumericDoubleValues() {
/** * 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) { return singleton(new DoubleCastedValues(singleton)); } 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)); } else { return new MultiHalfFloatValues(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)); } else { return new MultiFloatValues(raw); } } catch (IOException e) { throw new IllegalStateException("Cannot load doc values", e); } }
/** * Given a {@link SortedNumericDocValues}, return a {@link SortedNumericDoubleValues} * instance that will translate long values to doubles using * {@link org.apache.lucene.util.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); } return singleton(doubles); } else { if (values instanceof SortableLongBitsSortedNumericDocValues) { return ((SortableLongBitsSortedNumericDocValues) values).getDoubleValues(); } else { return new SortableLongBitsToSortedNumericDoubleValues(values); } } }
/** * Return a {@link SortedNumericDoubleValues} that doesn't contain any value. */ public static MultiGeoPointValues emptyMultiGeoPoints() { return singleton(emptyGeoPoint()); }
@Override public SortedBinaryDocValues getBytesValues() { try { final BinaryDocValues values = DocValues.getBinary(reader, field); return FieldData.singleton(values); } catch (IOException e) { throw new IllegalStateException("Cannot load doc values", e); } }
/** * Return a {@link SortedBinaryDocValues} that doesn't contain any value. */ public static SortedBinaryDocValues emptySortedBinary() { return singleton(DocValues.emptyBinary()); }
@Override public SortedBinaryDocValues getBytesValues() { try { final BinaryDocValues values = DocValues.getBinary(reader, field); final Bits docsWithField = DocValues.getDocsWithField(reader, field); return FieldData.singleton(values, docsWithField); } catch (IOException e) { throw new IllegalStateException("Cannot load doc values", e); } }
/** * Return a {@link SortedNumericDoubleValues} that doesn't contain any value. */ public static MultiGeoPointValues emptyMultiGeoPoints(int maxDoc) { return singleton(emptyGeoPoint(), new Bits.MatchNoBits(maxDoc)); }
/** * Return a {@link SortedBinaryDocValues} that doesn't contain any value. */ public static SortedBinaryDocValues emptySortedBinary(int maxDoc) { return singleton(DocValues.emptyBinary(), new Bits.MatchNoBits(maxDoc)); }
/** * Return a {@link SortedNumericDoubleValues} that doesn't contain any value. */ public static SortedNumericDoubleValues emptySortedNumericDoubles(int maxDoc) { return singleton(emptyNumericDouble(), new Bits.MatchNoBits(maxDoc)); }
/** * Return a {@link SortedNumericDoubleValues} that doesn't contain any value. */ public static SortedNumericDoubleValues emptySortedNumericDoubles(int maxDoc) { return singleton(emptyNumericDouble(), new Bits.MatchNoBits(maxDoc)); }
/** * 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) { return singleton(new DoubleCastedValues(singleton)); } else { return new SortedDoubleCastedValues(values); } }