@Override public boolean advanceExact(int target) throws IOException { return values.advanceExact(target); } };
@Override public boolean advanceExact(int target) throws IOException { return in.advanceExact(target); }
@Override public boolean advanceExact(int target) throws IOException { return in.advanceExact(target); }
@Override public boolean advanceExact(int target) throws IOException { return in.advanceExact(target); }
private int getValueForDoc(int doc) throws IOException { if (currentReaderValues.advanceExact(doc)) { return (int) currentReaderValues.longValue(); } else { return missingValue; } }
private float getValueForDoc(int doc) throws IOException { if (currentReaderValues.advanceExact(doc)) { return Float.intBitsToFloat((int) currentReaderValues.longValue()); } else { return missingValue; } }
private long getValueForDoc(int doc) throws IOException { if (currentReaderValues.advanceExact(doc)) { return currentReaderValues.longValue(); } else { return missingValue; } }
private double getValueForDoc(int doc) throws IOException { if (currentReaderValues.advanceExact(doc)) { return Double.longBitsToDouble(currentReaderValues.longValue()); } else { return missingValue; } }
@Override public float score(int doc, float freq) throws IOException { // if there are no norms, we act as if b=0 float norm; if (norms == null) { norm = k1; } else { if (norms.advanceExact(doc)) { norm = cache[((byte) norms.longValue()) & 0xFF]; } else { norm = cache[0]; } } return weightValue * freq / (freq + norm); }
float getLengthValue(int doc) throws IOException { if (norms == null) { return 1F; } if (norms.advanceExact(doc)) { return normCache[Byte.toUnsignedInt((byte) norms.longValue())]; } else { return 0; } }
@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().getNormValues(field); nextLeaf = readerIndex+1; } docID = targetDocID; if (currentValues == null) { return false; } return currentValues.advanceExact(targetDocID - currentLeaf.docBase); }
@Override public float score(int doc, float freq) throws IOException { final float raw = tf(freq) * weightValue; // compute tf(f)*weight if (norms == null) { return raw; } else { float normValue; if (norms.advanceExact(doc)) { normValue = normTable[(int) (norms.longValue() & 0xFF)]; } else { normValue = 0; } return raw * normValue; // normalize for field } }
@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
private Explanation explainTFNorm(int doc, Explanation freq, BM25Stats stats, NumericDocValues norms, float[] lengthCache) throws IOException { List<Explanation> subs = new ArrayList<>(); subs.add(freq); subs.add(Explanation.match(k1, "parameter k1")); if (norms == null) { subs.add(Explanation.match(0, "parameter b (norms omitted for field)")); return Explanation.match( (freq.getValue() * (k1 + 1)) / (freq.getValue() + k1), "tfNorm, computed as (freq * (k1 + 1)) / (freq + k1) from:", subs); } else { byte norm; if (norms.advanceExact(doc)) { norm = (byte) norms.longValue(); } else { norm = 0; } float doclen = lengthCache[norm & 0xff]; subs.add(Explanation.match(b, "parameter b")); subs.add(Explanation.match(stats.avgdl, "avgFieldLength")); subs.add(Explanation.match(doclen, "fieldLength")); return Explanation.match( (freq.getValue() * (k1 + 1)) / (freq.getValue() + k1 * (1 - b + b * doclen/stats.avgdl)), "tfNorm, computed as (freq * (k1 + 1)) / (freq + k1 * (1 - b + b * fieldLength / avgFieldLength)) from:", subs); } }
@Override public boolean advanceExact(int doc) throws IOException { return in.advanceExact(doc); } }
private Explanation explainField(int doc, Explanation freq, IDFStats stats, NumericDocValues norms, float[] normTable) throws IOException { Explanation tfExplanation = Explanation.match(tf(freq.getValue()), "tf(freq="+freq.getValue()+"), with freq of:", freq); float norm; if (norms == null) { norm = 1f; } else if (norms.advanceExact(doc) == false) { norm = 0f; } else { norm = normTable[(int) (norms.longValue() & 0xFF)]; } Explanation fieldNormExpl = Explanation.match( norm, "fieldNorm(doc=" + doc + ")"); return Explanation.match( tfExplanation.getValue() * stats.idf.getValue() * fieldNormExpl.getValue(), "fieldWeight in " + doc + ", product of:", tfExplanation, stats.idf, fieldNormExpl); }
boolean hasRecoverySource(int segmentDocId) throws IOException { if (recoverySource == null) { return false; } assert recoverySource.docID() < segmentDocId; return recoverySource.advanceExact(segmentDocId); } }
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; }
long docSeqNo(int segmentDocId) throws IOException { assert seqNoDV.docID() < segmentDocId; if (seqNoDV.advanceExact(segmentDocId) == false) { throw new IllegalStateException("DocValues for field [" + SeqNoFieldMapper.NAME + "] is not found"); } return seqNoDV.longValue(); }
/** Return the number of tokens that the current document has in the considered field. */ public int getLength() throws IOException { // the length is computed lazily so that similarities that do not use the length are // not penalized if (norms == null) { return 1; } else if (norms.advanceExact(docID)) { return SmallFloat.byte4ToInt((byte) norms.longValue()); } else { return 0; } }