NumericDocValues singleton = DocValues.unwrapSingleton(sortedNumeric); if (singleton != null) {
/** Wraps a multi-valued SortedSetDocValues as a single-valued view, using the specified selector */ public static SortedDocValues wrap(SortedSetDocValues sortedSet, Type selector) { if (sortedSet.getValueCount() >= Integer.MAX_VALUE) { throw new UnsupportedOperationException("fields containing more than " + (Integer.MAX_VALUE-1) + " unique terms are unsupported"); } SortedDocValues singleton = DocValues.unwrapSingleton(sortedSet); if (singleton != null) { // it's actually single-valued in practice, but indexed as multi-valued, // so just sort on the underlying single-valued dv directly. // regardless of selector type, this optimization is safe! return singleton; } else { switch(selector) { case MIN: return new MinValue(sortedSet); case MAX: return new MaxValue(sortedSet); case MIDDLE_MIN: return new MiddleMinValue(sortedSet); case MIDDLE_MAX: return new MiddleMaxValue(sortedSet); default: throw new AssertionError(); } } }
return null; final NumericDocValues singleton = DocValues.unwrapSingleton(values); final TwoPhaseIterator iterator; if (singleton != null) {
/** * Returns whether the provided values *might* be multi-valued. There is no * guarantee that this method will return {@code false} in the single-valued case. */ public static boolean isMultiValued(SortedSetDocValues values) { return DocValues.unwrapSingleton(values) == null; }
final SortedDocValues singleton = DocValues.unwrapSingleton(values); final TwoPhaseIterator iterator; if (singleton != null) {
final NumericDocValues singleton = DocValues.unwrapSingleton(values); if (singleton != null) { return singleton;
final SortedDocValues singleton = DocValues.unwrapSingleton(values); if (singleton != null) { return singleton;
@Override protected NumericDocValues getKeys(LeafReaderContext context) { final SortedSetDocValues globalOrds = valuesSource.globalOrdinalsValues(context); final SortedDocValues singleValues = DocValues.unwrapSingleton(globalOrds); if (singleValues != null) { return new AbstractNumericDocValues() {
/** * 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); } }
values = DocValues.unwrapSingleton(sorted); if (values == null) { values = new AbstractNumericDocValues() {
grow(globalOrds.getValueCount()); final SortedDocValues singleValues = DocValues.unwrapSingleton(globalOrds); if (singleValues != null) { return new LeafBucketCollectorBase(sub, globalOrds) {
values = DocValues.unwrapSingleton(sorted); if (values == null) { values = new AbstractSortedDocValues() {
/** * 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); } } }
/** * Returns whether the provided values *might* be multi-valued. There is no * guarantee that this method will return {@code false} in the single-valued case. */ public static boolean isMultiValued(SortedSetDocValues values) { return DocValues.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(SortedSetDocValues values) { return DocValues.unwrapSingleton(values) == null; }
segmentDocCounts = context.bigArrays().grow(segmentDocCounts, 1 + segmentOrds.getValueCount()); assert sub == LeafBucketCollector.NO_OP_COLLECTOR; final SortedDocValues singleValues = DocValues.unwrapSingleton(segmentOrds); mapping = valuesSource.globalOrdinalsMapping(ctx); if (singleValues != null) {
/** * 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 Bits docsWithValue(LeafReaderContext context) { final RandomAccessOrds ordinals = ordinalsValues(context); if (DocValues.unwrapSingleton(ordinals) != null) { return DocValues.docsWithValue(DocValues.unwrapSingleton(ordinals), context.reader().maxDoc()); } else { return DocValues.docsWithValue(ordinals, context.reader().maxDoc()); } }