void reset(FieldInfo field) { if (remapper != null) { // field numbers are not aligned, we need to remap to the new field number currentField = remapper.fieldInfo(field.name); } else { currentField = field; } binaryValue = null; stringValue = null; numericValue = null; }
@Override public FieldInfo fieldInfo(int fieldNumber) { FieldInfo res = super.fieldInfo(fieldNumber); if (!filteredNames.contains(res.name)) { throw new IllegalArgumentException("The field named '" + res.name + "' numbered '" + fieldNumber + "' is not " + "accessible in the current merge context, available ones are: " + filteredNames); } return res; } }
@Override public FieldInfo fieldInfo(String fieldName) { if (!filteredNames.contains(fieldName)) { // Throw IAE to be consistent with fieldInfo(int) which throws it as well on invalid numbers throw new IllegalArgumentException("The field named '" + fieldName + "' is not accessible in the current " + "merge context, available ones are: " + filteredNames); } return super.fieldInfo(fieldName); }
EmptyFilterLeafReader(final LeafReader delegate) { super(delegate); final FieldInfos infos = delegate.getFieldInfos(); final List<FieldInfo> lfi = new ArrayList<FieldInfo>(metaFields.size()); for(String metaField: metaFields) { final FieldInfo _fi = infos.fieldInfo(metaField); if(_fi != null) { lfi.add(_fi); } } fi = lfi.toArray(new FieldInfo[0]); }
@Override public Collection<Accountable> getChildResources() { List<Accountable> resources = new ArrayList<>(); for(Map.Entry<Integer,BKDReader> ent : readers.entrySet()) { resources.add(Accountables.namedAccountable(readState.fieldInfos.fieldInfo(ent.getKey()).name, ent.getValue())); } return Collections.unmodifiableList(resources); }
@Override public String next() { if (!hasNext()) { throw new NoSuchElementException(); } final int fieldNum = fieldNums[fieldNumOffs[i++]]; return fieldInfos.fieldInfo(fieldNum).name; } @Override
private static void checkField(LeafReader in, String field, DocValuesType... expected) { FieldInfo fi = in.getFieldInfos().fieldInfo(field); if (fi != null) { DocValuesType actual = fi.getDocValuesType(); throw new IllegalStateException("unexpected docvalues type " + actual + " for field '" + field + "' " + (expected.length == 1 ? "(expected=" + expected[0] : "(expected one of " + Arrays.toString(expected)) + "). " + "Re-index with correct docvalues type."); } }
@Override SortedNumericDocValues getValues(LeafReader reader, String field) throws IOException { FieldInfo info = reader.getFieldInfos().fieldInfo(field); if (info == null) { // Queries have some optimizations when one sub scorer returns null rather // than a scorer that does not match any documents return null; } return DocValues.getSortedNumeric(reader, field); } };
@Override public Terms terms(final String field) throws IOException { Terms terms = in.terms(field); if (terms == null) { return null; } else { return new SortingTerms(terms, infos.fieldInfo(field).getIndexOptions(), docMap); } }
/** * Returns {@code true} if the specified docvalues fields have not been updated */ public static boolean isCacheable(LeafReaderContext ctx, String... fields) { for (String field : fields) { FieldInfo fi = ctx.reader().getFieldInfos().fieldInfo(field); if (fi != null && fi.getDocValuesGen() > -1) return false; } return true; } }
/** * @return the {@code NumericDocValues} for a given field * @throws IllegalArgumentException if this field is not indexed with numeric doc values */ public NumericDocValues readDocValues( String field ) { try { NumericDocValues dv = context.reader().getNumericDocValues( field ); if ( dv == null ) { FieldInfo fi = context.reader().getFieldInfos().fieldInfo( field ); DocValuesType actual = null; if ( fi != null ) { actual = fi.getDocValuesType(); } throw new IllegalStateException( "The field '" + field + "' is not indexed properly, expected NumericDV, but got '" + actual + "'" ); } return dv; } catch ( IOException e ) { throw new RuntimeException( e ); } } }
@Override public NumericDocValues getNormValues(String field) throws IOException { ensureOpen(); FieldInfo fi = getFieldInfos().fieldInfo(field); if (fi == null || !fi.hasNorms()) { // Field does not exist or does not index norms return null; } return norms.getNorms(fi); }
@Override public LeafFieldComparator getLeafComparator(LeafReaderContext context) throws IOException { LeafReader reader = context.reader(); FieldInfo info = reader.getFieldInfos().fieldInfo(field); if (info != null) { LatLonDocValuesField.checkCompatible(info); } currentDocs = DocValues.getSortedNumeric(reader, field); valuesDocID = -1; return this; }
@Override public Terms terms(String field) throws IOException { Terms terms = super.terms(field); return terms==null ? null : new SortingTerms(terms, in.getFieldInfos().fieldInfo(field).getIndexOptions(), docMap); }
@Override public SortedNumericDocValues getSortedNumericDocValues(String field) throws IOException { ensureOpen(); FieldInfo fi = getFieldInfos().fieldInfo(field); if (fi == null) { // Field does not exist return null; } if (fi.getDocValuesType() != DocValuesType.SORTED_NUMERIC) { // Field was not indexed with doc values return null; } return docValues.getSortedNumeric(fi); }
@Override public SortedSetDocValues getSortedSetDocValues(String field) throws IOException { ensureOpen(); FieldInfo fi = getFieldInfos().fieldInfo(field); if (fi == null) { // Field does not exist return null; } if (fi.getDocValuesType() != DocValuesType.SORTED_SET) { // Field was not indexed with doc values return null; } return docValues.getSortedSet(fi); }
@Override public SortedDocValues getSortedDocValues(String field) throws IOException { ensureOpen(); FieldInfo fi = getFieldInfos().fieldInfo(field); if (fi == null) { // Field does not exist return null; } if (fi.getDocValuesType() != DocValuesType.SORTED) { // Field was not indexed with doc values return null; } return docValues.getSorted(fi); }
@Override public final NumericDocValues getNormValues(String field) throws IOException { ensureOpen(); FieldInfo fi = getFieldInfos().fieldInfo(field); if (fi == null || fi.hasNorms() == false) { // Field does not exist or does not index norms return null; } return getNormsReader().getNorms(fi); }
@Override public final PointValues getPointValues(String field) throws IOException { ensureOpen(); FieldInfo fi = getFieldInfos().fieldInfo(field); if (fi == null || fi.getPointDataDimensionCount() == 0) { // Field does not exist or does not index points return null; } return getPointsReader().getValues(field); }
@Override public Scorer scorer(LeafReaderContext context) throws IOException { FieldInfos fieldInfos = context.reader().getFieldInfos(); FieldInfo fieldInfo = fieldInfos.fieldInfo(field); if (fieldInfo == null || fieldInfo.hasNorms() == false) { return null; } LeafReader reader = context.reader(); DocIdSetIterator iterator = reader.getNormValues(field); return new ConstantScoreScorer(this, score(), iterator); }