scriptValues = data.getLegacyFieldValues(); } else if (indexFieldData instanceof IndexNumericFieldData) { if (((IndexNumericFieldData) indexFieldData).getNumericType().isFloatingPoint()) { doubleValues = ((AtomicNumericFieldData) data).getDoubleValues(); } else {
/** * Instantiates a new reusable {@link BytesRefTermStream} based on the field type. */ public static BytesRefTermStream get(IndexReader reader, IndexFieldData indexFieldData) { if (indexFieldData instanceof IndexNumericFieldData) { IndexNumericFieldData numFieldData = (IndexNumericFieldData) indexFieldData; switch (numFieldData.getNumericType()) { case INT: return new IntegerBytesRefTermStream(reader, numFieldData); case LONG: return new LongBytesRefTermStream(reader, numFieldData); default: throw new UnsupportedOperationException("Streaming numeric type '" + numFieldData.getNumericType().name() + "' is unsupported"); } } else { return new BytesBytesRefTermStream(reader, indexFieldData); } }
/** * @return number of bytes per term, based on the NumericValue.requiredBits() */ @Override public long bytesPerValue(BytesRef term) { // Estimate about about 0.8 (8 / 10) compression ratio for // numbers, but at least 4 bytes return Math.max(type.requiredBits() / 10, 4); }
assert !getNumericType().isFloatingPoint(); boolean success = false; try (OrdinalsBuilder builder = new OrdinalsBuilder(-1, reader.maxDoc(), acceptableTransientOverheadRatio)) { BytesRef term; while ((term = iter.next()) != null) { final long value = numericType.toLong(term); valuesBuilder.add(value);
scriptValues = data.getScriptValues(); } else if (indexFieldData instanceof IndexNumericFieldData) { if (((IndexNumericFieldData) indexFieldData).getNumericType().isFloatingPoint()) { doubleValues = ((AtomicNumericFieldData) data).getDoubleValues(); } else {
assert !numericType.isFloatingPoint(); source = new LongValuesComparatorSource(this, missingValue, sortMode, nested); break; assert !numericType.isFloatingPoint(); sortField = new SortedNumericSortField(fieldName, SortField.Type.LONG, reverse, selectorType); break;
assert !numericType.isFloatingPoint(); source = new LongValuesComparatorSource(this, missingValue, sortMode, nested); break; assert !numericType.isFloatingPoint(); sortField = new SortedNumericSortField(fieldName, SortField.Type.LONG, reverse, selectorType); break;
try { final BinaryDocValues values = DocValues.getBinary(context.reader(), fieldNames.indexName()); if (numericType.isFloatingPoint()) { return new AtomicDoubleFieldData(-1) {
assert !numericType.isFloatingPoint(); source = new LongValuesComparatorSource(this, missingValue, sortMode, nested); break; assert !numericType.isFloatingPoint(); sortField = new SortedNumericSortField(fieldName, SortField.Type.LONG, reverse, selectorType); break;
@Override public DocIdSet getDocIdSet(LeafReaderContext context) throws IOException { final NumericTermsSet termsSet = this.getTermsSet(); // make sure there are terms to filter on if (termsSet == null || termsSet.isEmpty()) return null; IndexNumericFieldData numericFieldData = (IndexNumericFieldData) fieldData; if (!numericFieldData.getNumericType().isFloatingPoint()) { final SortedNumericDocValues values = numericFieldData.load(context).getLongValues(); // load fielddata return new DocValuesDocIdSet(context.reader().maxDoc(), context.reader().getLiveDocs()) { @Override protected boolean matchDoc(int doc) { values.setDocument(doc); final int numVals = values.count(); for (int i = 0; i < numVals; i++) { if (termsSet.contains(values.valueAt(i))) { return true; } } return false; } }; } // only get here if wrong fielddata type in which case // no docs will match so we just return null. return null; }
/** * Instantiates a new reusable {@link NumericTermStream} based on the field type. */ public static NumericTermStream get(IndexReader reader, IndexFieldData indexFieldData) { if (indexFieldData instanceof IndexNumericFieldData) { IndexNumericFieldData numFieldData = (IndexNumericFieldData) indexFieldData; if (!numFieldData.getNumericType().isFloatingPoint()) { return new LongTermStream(reader, numFieldData); } else { throw new UnsupportedOperationException("Streaming floating points is unsupported"); } } else { return new HashTermStream(reader, indexFieldData); } }
public double toDouble(BytesRef indexForm) { return (double) toLong(indexForm); }
@Override public boolean isFloatingPoint() { return indexFieldData.getNumericType().isFloatingPoint(); }
@Override public boolean isFloatingPoint() { return indexFieldData.getNumericType().isFloatingPoint(); }
@Override public long toLong(BytesRef indexForm) { return INT.toLong(indexForm); }
@Override public void toIndexForm(Number number, BytesRefBuilder bytes) { INT.toIndexForm(number, bytes); }
@Override public boolean isFloatingPoint() { return indexFieldData.getNumericType().isFloatingPoint(); }
@Override public void toIndexForm(Number number, BytesRefBuilder bytes) { INT.toIndexForm(number, bytes); }
@Override public long toLong(BytesRef indexForm) { return INT.toLong(indexForm); }
@Override public boolean isFloatingPoint() { return indexFieldData.getNumericType().isFloatingPoint(); }