@Override public NumericDocValues getNumeric(FieldInfo field) throws IOException { return reader.getNumericDocValues(field.name); }
private NumericDocValues getDocValues( String field ) { try { return currentContext.reader().getNumericDocValues( field ); } catch ( IOException e ) { throw new RuntimeException( "Fail to read numeric doc values field " + field + " from the document.", e ); } }
@Override SortedNumericDocValues getValues(LeafReader reader, String field) throws IOException { NumericDocValues values = reader.getNumericDocValues(field); if (values == null) { return null; } return DocValues.singleton(values); } };
@Override public NumericDocValues getNumericDocValues(final String field) throws IOException { return isMeta(field) ? in.getNumericDocValues(field) : null; }
@Override public NumericDocValues getNumericDocValues(String field) throws IOException { ensureOpen(); LeafReader reader = fieldToReader.get(field); return reader == null ? null : reader.getNumericDocValues(field); }
@Override public NumericDocValues getNumericDocValues(String field) throws IOException { ensureOpen(); return in.getNumericDocValues(field); }
private void loadNextValue( LeafReaderContext context, int docID ) { NumericDocValues docValues; if ( docValuesCache.containsKey( context ) ) { docValues = docValuesCache.get( context ); } else { try { docValues = context.reader().getNumericDocValues( field ); docValuesCache.put( context, docValues ); } catch ( IOException e ) { throw new RuntimeException( e ); } } if ( docValues != null ) { currentValue = docValues.get( docID ); } else { currentValue = -1; } } }
@Override public int nextDoc() throws IOException { while (true) { while (currentValues == null) { if (nextLeaf == leaves.size()) { docID = NO_MORE_DOCS; return docID; } currentLeaf = leaves.get(nextLeaf); currentValues = currentLeaf.reader().getNumericDocValues(field); nextLeaf++; } int newDocID = currentValues.nextDoc(); if (newDocID == NO_MORE_DOCS) { currentValues = null; continue; } else { docID = currentLeaf.docBase + newDocID; return docID; } } }
@Override public boolean advanceExact(int targetDocID) throws IOException { if (targetDocID < docID) { throw new IllegalArgumentException("can only advance beyond current document: on docID=" + docID + " but targetDocID=" + targetDocID); } int readerIndex = ReaderUtil.subIndex(targetDocID, leaves); if (readerIndex >= nextLeaf) { if (readerIndex == leaves.size()) { throw new IllegalArgumentException("Out of range: " + targetDocID); } currentLeaf = leaves.get(readerIndex); currentValues = currentLeaf.reader().getNumericDocValues(field); nextLeaf = readerIndex+1; } docID = targetDocID; if (currentValues == null) { return false; } return currentValues.advanceExact(targetDocID - currentLeaf.docBase); } @Override
/** * Returns NumericDocValues for the field, or {@link #emptyNumeric()} if it has none. * @return docvalues instance, or an empty instance if {@code field} does not exist in this reader. * @throws IllegalStateException if {@code field} exists, but was not indexed with docvalues. * @throws IllegalStateException if {@code field} has docvalues, but the type is not {@link DocValuesType#NUMERIC}. * @throws IOException if an I/O error occurs. */ public static NumericDocValues getNumeric(LeafReader reader, String field) throws IOException { NumericDocValues dv = reader.getNumericDocValues(field); if (dv == null) { checkField(reader, field, DocValuesType.NUMERIC); return emptyNumeric(); } else { return dv; } }
/** * @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 int advance(int targetDocID) throws IOException { if (targetDocID <= docID) { throw new IllegalArgumentException("can only advance beyond current document: on docID=" + docID + " but targetDocID=" + targetDocID); } int readerIndex = ReaderUtil.subIndex(targetDocID, leaves); if (readerIndex >= nextLeaf) { if (readerIndex == leaves.size()) { currentValues = null; docID = NO_MORE_DOCS; return docID; } currentLeaf = leaves.get(readerIndex); currentValues = currentLeaf.reader().getNumericDocValues(field); nextLeaf = readerIndex+1; if (currentValues == null) { return nextDoc(); } } int newDocID = currentValues.advance(targetDocID - currentLeaf.docBase); if (newDocID == NO_MORE_DOCS) { currentValues = null; return nextDoc(); } else { docID = currentLeaf.docBase + newDocID; return docID; } }
/** * Returns SortedNumericDocValues for the field, or {@link #emptySortedNumeric} if it has none. * @return docvalues instance, or an empty instance if {@code field} does not exist in this reader. * @throws IllegalStateException if {@code field} exists, but was not indexed with docvalues. * @throws IllegalStateException if {@code field} has docvalues, but the type is not {@link DocValuesType#SORTED_NUMERIC} * or {@link DocValuesType#NUMERIC}. * @throws IOException if an I/O error occurs. */ public static SortedNumericDocValues getSortedNumeric(LeafReader reader, String field) throws IOException { SortedNumericDocValues dv = reader.getSortedNumericDocValues(field); if (dv == null) { NumericDocValues single = reader.getNumericDocValues(field); if (single == null) { checkField(reader, field, DocValuesType.SORTED_NUMERIC, DocValuesType.NUMERIC); return emptySortedNumeric(reader.maxDoc()); } return singleton(single); } return dv; }
@Override public NumericDocValues getNumericDocValues(String field) throws IOException { final NumericDocValues oldDocValues = in.getNumericDocValues(field); if (oldDocValues == null) return null; CachedNumericDVs dvs; synchronized (cachedNumericDVs) { dvs = cachedNumericDVs.get(field); if (dvs == null) { FixedBitSet docsWithField = new FixedBitSet(maxDoc()); long[] values = new long[maxDoc()]; while (true) { int docID = oldDocValues.nextDoc(); if (docID == NO_MORE_DOCS) { break; } int newDocID = docMap.oldToNew(docID); docsWithField.set(newDocID); values[newDocID] = oldDocValues.longValue(); } dvs = new CachedNumericDVs(values, docsWithField); cachedNumericDVs.put(field, dvs); } } return new SortingNumericDocValues(dvs); }
break; case NUMERIC: iterator = reader.getNumericDocValues(field); break; case BINARY:
return null; } else if (size == 1) { return leaves.get(0).reader().getNumericDocValues(field);
CombinedDocValues(LeafReader leafReader) throws IOException { this.versionDV = Objects.requireNonNull(leafReader.getNumericDocValues(VersionFieldMapper.NAME), "VersionDV is missing"); this.seqNoDV = Objects.requireNonNull(leafReader.getNumericDocValues(SeqNoFieldMapper.NAME), "SeqNoDV is missing"); this.primaryTermDV = Objects.requireNonNull( leafReader.getNumericDocValues(SeqNoFieldMapper.PRIMARY_TERM_NAME), "PrimaryTermDV is missing"); this.tombstoneDV = leafReader.getNumericDocValues(SeqNoFieldMapper.TOMBSTONE_NAME); this.recoverySource = leafReader.getNumericDocValues(SourceFieldMapper.RECOVERY_SOURCE_NAME); }
switch(info.getDocValuesType()) { case NUMERIC: reader.getNumericDocValues(info.name); break; case BINARY:
private boolean assertDocSoftDeleted(LeafReader leafReader, int segmentDocId) throws IOException { final NumericDocValues ndv = leafReader.getNumericDocValues(Lucene.SOFT_DELETES_FIELD); if (ndv == null || ndv.advanceExact(segmentDocId) == false) { throw new IllegalStateException("DocValues for field [" + Lucene.SOFT_DELETES_FIELD + "] is not found"); } return ndv.longValue() == 1; }
/** * Initialize lookup for the provided segment */ PerThreadIDVersionAndSeqNoLookup(LeafReader reader, String uidField) throws IOException { this.uidField = uidField; final Terms terms = reader.terms(uidField); if (terms == null) { // If a segment contains only no-ops, it does not have _uid but has both _soft_deletes and _tombstone fields. final NumericDocValues softDeletesDV = reader.getNumericDocValues(Lucene.SOFT_DELETES_FIELD); final NumericDocValues tombstoneDV = reader.getNumericDocValues(SeqNoFieldMapper.TOMBSTONE_NAME); if (softDeletesDV == null || tombstoneDV == null) { throw new IllegalArgumentException("reader does not have _uid terms but not a no-op segment; " + "_soft_deletes [" + softDeletesDV + "], _tombstone [" + tombstoneDV + "]"); } termsEnum = null; } else { termsEnum = terms.iterator(); } if (reader.getNumericDocValues(VersionFieldMapper.NAME) == null) { throw new IllegalArgumentException("reader misses the [" + VersionFieldMapper.NAME + "] field; _uid terms [" + terms + "]"); } Object readerKey = null; assert (readerKey = reader.getCoreCacheHelper().getKey()) != null; this.readerKey = readerKey; }