@Override public SortedNumericDoubleValues doubleValues(LeafReaderContext context) { return indexFieldData.load(context).getDoubleValues(); } }
@Override public boolean isFloatingPoint() { return indexFieldData.getNumericType().isFloatingPoint(); }
@Override protected String getFieldName() { return fieldData.getFieldName(); }
@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; }
@Override public AtomicNumericFieldData loadDirect(LeafReaderContext context) throws Exception { return new ScaledFloatLeafFieldData(scaledFieldData.loadDirect(context), scalingFactor); }
@Override public void clear() { scaledFieldData.clear(); }
@Override public Index index() { return scaledFieldData.index(); }
@Override public AtomicNumericFieldData loadDirect(LeafReaderContext context) throws Exception { return new ScaledFloatLeafFieldData(scaledFieldData.loadDirect(context), scalingFactor); }
@Override public void clear() { scaledFieldData.clear(); }
@Override public Index index() { return scaledFieldData.index(); }
@Override public SortedBinaryDocValues bytesValues(LeafReaderContext context) { return indexFieldData.load(context).getBytesValues(); }
@Override public FieldComparator<?> newComparator(String fieldname, int numHits, int sortPos, boolean reversed) { assert indexFieldData == null || fieldname.equals(indexFieldData.getFieldName()); final float dMissingValue = (Float) missingObject(missingValue, reversed); // NOTE: it's important to pass null as a missing value in the constructor so that // the comparator doesn't check docsWithField since we replace missing values in select() return new FieldComparator.FloatComparator(numHits, null, null) { @Override protected NumericDocValues getNumericDocValues(LeafReaderContext context, String field) throws IOException { final SortedNumericDoubleValues values = indexFieldData.load(context).getDoubleValues(); final NumericDoubleValues selectedValues; if (nested == null) { selectedValues = FieldData.replaceMissing(sortMode.select(values), dMissingValue); } else { final BitSet rootDocs = nested.rootDocs(context); final DocIdSetIterator innerDocs = nested.innerDocs(context); final int maxChildren = nested.getNestedSort() != null ? nested.getNestedSort().getMaxChildren() : Integer.MAX_VALUE; selectedValues = sortMode.select(values, dMissingValue, rootDocs, innerDocs, context.reader().maxDoc(), maxChildren); } return selectedValues.getRawFloatValues(); } }; } }
/** * gets the field data type from the _indexFieldData object * @return */ private Constants.FIELD_DATA_TYPE getType() { final boolean numericField = (_indexFieldData instanceof IndexNumericFieldData); FIELD_DATA_TYPE type = FIELD_DATA_TYPE.STRING; if(numericField) { final IndexNumericFieldData<?> indexNumericFieldData = (IndexNumericFieldData<?>) _indexFieldData; if(indexNumericFieldData.getNumericType() == IndexNumericFieldData.NumericType.LONG) type = FIELD_DATA_TYPE.LONG; if(indexNumericFieldData.getNumericType() == IndexNumericFieldData.NumericType.INT) type = FIELD_DATA_TYPE.INT; } return type; }
@Override public AtomicNumericFieldData loadDirect(LeafReaderContext context) throws Exception { return new ScaledFloatLeafFieldData(scaledFieldData.loadDirect(context), scalingFactor); }
@Override public void clear() { scaledFieldData.clear(); }
@Override public Index index() { return scaledFieldData.index(); }
@Override public SortedNumericDocValues longValues(LeafReaderContext context) { return indexFieldData.load(context).getLongValues(); }
@Override public FieldComparator<?> newComparator(String fieldname, int numHits, int sortPos, boolean reversed) { assert indexFieldData == null || fieldname.equals(indexFieldData.getFieldName()); final Long dMissingValue = (Long) missingObject(missingValue, reversed); // NOTE: it's important to pass null as a missing value in the constructor so that // the comparator doesn't check docsWithField since we replace missing values in select() return new FieldComparator.LongComparator(numHits, null, null) { @Override protected NumericDocValues getNumericDocValues(LeafReaderContext context, String field) throws IOException { final SortedNumericDocValues values = indexFieldData.load(context).getLongValues(); final NumericDocValues selectedValues; if (nested == null) { selectedValues = FieldData.replaceMissing(sortMode.select(values), dMissingValue); } else { final BitSet rootDocs = nested.rootDocs(context); final DocIdSetIterator innerDocs = nested.innerDocs(context); final int maxChildren = nested.getNestedSort() != null ? nested.getNestedSort().getMaxChildren() : Integer.MAX_VALUE; selectedValues = sortMode.select(values, dMissingValue, rootDocs, innerDocs, context.reader().maxDoc(), maxChildren); } return selectedValues; } }; } }
scriptValues = data.getLegacyFieldValues(); } else if (indexFieldData instanceof IndexNumericFieldData) { if (((IndexNumericFieldData) indexFieldData).getNumericType().isFloatingPoint()) { doubleValues = ((AtomicNumericFieldData) data).getDoubleValues(); } else {
protected SortedNumericDoubleValues getValues(LeafReaderContext context) throws IOException { return indexFieldData.load(context).getDoubleValues(); }