List of usage examples for org.apache.lucene.util SmallFloat floatToByte315
public static byte floatToByte315(float f)
From source file:BM25LSimilarity.java
License:Apache License
/** * The default implementation encodes <code>boost / sqrt(length)</code> with * {@link SmallFloat#floatToByte315(float)}. This is compatible with * Lucene's default implementation. If you change this, then you should * change {@link #decodeNormValue(byte)} to match. *///from w w w . j a v a2 s . c om protected byte encodeNormValue(float boost, int fieldLength) { return SmallFloat.floatToByte315(boost / (float) Math.sqrt(fieldLength)); }
From source file:com.core.nlp.similarity.DefaultSimilarity.java
License:Apache License
/** * Encodes a normalization factor for storage in an index. * <p/>//w ww . j a v a 2 s . com * The encoding uses a three-bit mantissa, a five-bit exponent, and the * zero-exponent point at 15, thus representing values from around 7x10^9 to * 2x10^-9 with about one significant decimal digit of accuracy. Zero is also * represented. Negative numbers are rounded up to zero. Values too large to * represent are rounded down to the largest representable value. Positive * values too small to represent are rounded up to the smallest positive * representable value. * * @see org.apache.lucene.document.Field#setBoost(float) * @see org.apache.lucene.util.SmallFloat */ @Override public final long encodeNormValue(float f) { return SmallFloat.floatToByte315(f); }
From source file:elhuyar.bilakit.SimilarityCLIRFactory.java
License:Open Source License
/** * Encodes a normalization factor for storage in an index. * <p>/*from w w w . j ava 2 s .c o m*/ * The encoding uses a three-bit mantissa, a five-bit exponent, and the * zero-exponent point at 15, thus representing values from around 7x10^9 to * 2x10^-9 with about one significant decimal digit of accuracy. Zero is also * represented. Negative numbers are rounded up to zero. Values too large to * represent are rounded down to the largest representable value. Positive * values too small to represent are rounded up to the smallest positive * representable value. * * @see org.apache.lucene.document.Field#setBoost(float) * @see org.apache.lucene.util.SmallFloat */ public final long encodeNormValue(float f) { return SmallFloat.floatToByte315(f); }
From source file:org.codelibs.elasticsearch.common.lucene.all.AllTokenStream.java
License:Apache License
AllTokenStream(TokenStream input, float boost) { super(input); payloadAttribute = addAttribute(PayloadAttribute.class); payloadSpare.bytes[0] = SmallFloat.floatToByte315(boost); }
From source file:org.dice.solrenhancements.similarity.DiceDefaultSimilarity.java
License:Apache License
/** * Encodes a normalization factor for storage in an index. * <p>/*from www. j a va 2 s. c o m*/ * The encoding uses a three-bit mantissa, a five-bit exponent, and the * zero-exponent point at 15, thus representing values from around 7x10^9 to * 2x10^-9 with about one significant decimal digit of accuracy. Zero is also * represented. Negative numbers are rounded up to zero. Values too large to * represent are rounded down to the largest representable value. Positive * values too small to represent are rounded up to the smallest positive * representable value. * * @see org.apache.lucene.document.Field#setBoost(float) * @see org.apache.lucene.util.SmallFloat */ @Override public long encodeNormValue(float f) { return SmallFloat.floatToByte315(f); }
From source file:org.elasticsearch.index.similarity.ClosedSimilarity.java
/** The default implementation encodes <code>boost / sqrt(length)</code> * with {@link SmallFloat#floatToByte315(float)}. This is compatible with * Lucene's default implementation. If you change this, then you should * change {@link #decodeNormValue(byte)} to match. */ protected byte encodeNormValue(float boost, int fieldLength) { byte encValue = SmallFloat.floatToByte315(boost / (float) Math.sqrt(fieldLength)); log.info("Encoding value: Boost: " + boost + " fieldLEngth: " + fieldLength + " encByte: " + encValue); return encValue; }
From source file:org.meresco.lucene.search.join.ScoreSuperCollector.java
License:Open Source License
@Override public void collect(int doc) throws IOException { if (this.keyValues != null) { int value = (int) this.keyValues.get(doc); if (value > 0) { if (value >= this.scores.length) { this.scores = ScoreSuperCollector.resize(this.scores, (int) ((value + 1) * 1.25)); }/*from w ww . j a v a 2 s.co m*/ this.scores[value] = SmallFloat.floatToByte315(scorer.score()); } } }