Java 类org.apache.lucene.util.SmallFloat 实例源码

项目:elasticsearch_my    文件:AllTermQuery.java   
float payloadBoost() throws IOException {
    if (doc != docID()) {
        final int freq = postings.freq();
        payloadBoost = 0;
        for (int i = 0; i < freq; ++i) {
            postings.nextPosition();
            final BytesRef payload = postings.getPayload();
            float boost;
            if (payload == null) {
                boost = 1;
            } else if (payload.length == 1) {
                boost = SmallFloat.byte315ToFloat(payload.bytes[payload.offset]);
            } else if (payload.length == 4) {
                // TODO: for bw compat only, remove this in 6.0
                boost = PayloadHelper.decodeFloat(payload.bytes, payload.offset);
            } else {
                throw new IllegalStateException("Payloads are expected to have a length of 1 or 4 but got: "
                    + payload);
            }
            payloadBoost += boost;
        }
        payloadBoost /= freq;
        doc = docID();
    }
    return payloadBoost;
}
项目:meresco-lucene    文件:ScoreSuperCollector.java   
@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));
            }
            this.scores[value] = SmallFloat.floatToByte315(scorer.score());
        }
    }
}
项目:elasticsearch_my    文件:AllTokenStream.java   
AllTokenStream(TokenStream input, float boost) {
    super(input);
    payloadAttribute = addAttribute(PayloadAttribute.class);
    payloadSpare.bytes[0] = SmallFloat.floatToByte315(boost);
}
项目:lams    文件:SimilarityBase.java   
/** Encodes the length to a byte via SmallFloat. */
protected byte encodeNormValue(float boost, float length) {
  return SmallFloat.floatToByte315((boost / (float) Math.sqrt(length)));
}
项目:elasticsearch-similarity-plugin    文件:SimpleSimilarity.java   
@Override
protected byte encodeNormValue(float boost, int fieldLength) {
    return SmallFloat.floatToByte315(boost / (float) fieldLength);
}
项目:ir-generalized-translation-models    文件:LeafReaderOverride.java   
/** Encodes the length to a byte via SmallFloat. */
private static byte encodeNormValue(float boost, float length) {
    return SmallFloat.floatToByte315((boost / (float) Math.sqrt(length)));
}
项目:DoSeR-Disambiguation    文件:FuzzyLabelSimilarity.java   
/** Encodes a normalization factor for storage in an index. */
public final long encodeNormValue(final float floatVal) {
    return SmallFloat.floatToByte315(floatVal);
}
项目:search    文件:SimilarityBase.java   
/** Encodes the length to a byte via SmallFloat. */
protected byte encodeNormValue(float boost, float length) {
  return SmallFloat.floatToByte315((boost / (float) Math.sqrt(length)));
}
项目:DoSeR    文件:FuzzyLabelSimilarity.java   
/** Encodes a normalization factor for storage in an index. */
public final long encodeNormValue(final float floatVal) {
    return SmallFloat.floatToByte315(floatVal);
}
项目:NYBC    文件:SimilarityBase.java   
/** Encodes the length to a byte via SmallFloat. */
protected byte encodeNormValue(float boost, float length) {
  return SmallFloat.floatToByte315((boost / (float) Math.sqrt(length)));
}
项目:read-open-source-code    文件:SimilarityBase.java   
/** Encodes the length to a byte via SmallFloat. */
protected byte encodeNormValue(float boost, float length) {
  return SmallFloat.floatToByte315((boost / (float) Math.sqrt(length)));
}
项目:read-open-source-code    文件:SimilarityBase.java   
/** Encodes the length to a byte via SmallFloat. */
protected byte encodeNormValue(float boost, float length) {
  return SmallFloat.floatToByte315((boost / (float) Math.sqrt(length)));
}
项目:read-open-source-code    文件:SimilarityBase.java   
/** Encodes the length to a byte via SmallFloat. */
protected byte encodeNormValue(float boost, float length) {
  return SmallFloat.floatToByte315((boost / (float) Math.sqrt(length)));
}
项目:meresco-lucene    文件:ScoreSuperCollector.java   
public float score(int key) {
    if (key < this.scores.length) {
        return SmallFloat.byte315ToFloat(this.scores[key]);
    }
    return 0;
}
项目:Maskana-Gestor-de-Conocimiento    文件:SimilarityBase.java   
/** Encodes the length to a byte via SmallFloat. */
protected byte encodeNormValue(float boost, float length) {
  return SmallFloat.floatToByte315((boost / (float) Math.sqrt(length)));
}
项目:lams    文件:DefaultSimilarity.java   
/**
 * Encodes a normalization factor for storage in an index.
 * <p>
 * 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);
}
项目:lams    文件:BM25Similarity.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) {
  return SmallFloat.floatToByte315(boost / (float) Math.sqrt(fieldLength));
}
项目:linden    文件:LindenSimilarity.java   
/**
 * Encodes a normalization factor for storage in an index.
 * <p>
 * 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);
}
项目:lucene4ir    文件:BM25Similarity.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) {
  return SmallFloat.floatToByte315(boost / (float) Math.sqrt(fieldLength));
}
项目:search    文件:DefaultSimilarity.java   
/**
 * Encodes a normalization factor for storage in an index.
 * <p>
 * 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);
}
项目:search    文件:BM25Similarity.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) {
  return SmallFloat.floatToByte315(boost / (float) Math.sqrt(fieldLength));
}
项目:SolrPlugins    文件:DiceDefaultSimilarity.java   
/**
 * Encodes a normalization factor for storage in an index.
 * <p>
 * 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);
}
项目:NYBC    文件:BM25Similarity.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) {
  return SmallFloat.floatToByte315(boost / (float) Math.sqrt(fieldLength));
}
项目:NYBC    文件:TFIDFSimilarity.java   
/** Encodes a normalization factor for storage in an index.
*
* <p>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 byte encodeNormValue(float f) {
  return SmallFloat.floatToByte315(f);
}
项目:read-open-source-code    文件:DefaultSimilarity.java   
/**
 * Encodes a normalization factor for storage in an index.
 * <p>
 * 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);
}
项目:read-open-source-code    文件:BM25Similarity.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) {
  return SmallFloat.floatToByte315(boost / (float) Math.sqrt(fieldLength));
}
项目:read-open-source-code    文件:DefaultSimilarity.java   
/**
 * Encodes a normalization factor for storage in an index.
 * <p>
 * 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);
}
项目:read-open-source-code    文件:BM25Similarity.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) {
  return SmallFloat.floatToByte315(boost / (float) Math.sqrt(fieldLength));
}
项目:read-open-source-code    文件:DefaultSimilarity.java   
/**
 * Encodes a normalization factor for storage in an index.
 * <p>
 * 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);
}
项目:read-open-source-code    文件:BM25Similarity.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) {
  return SmallFloat.floatToByte315(boost / (float) Math.sqrt(fieldLength));
}
项目:information-retrieval-adventure    文件:BM25FSimilarity.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) {
  return SmallFloat.floatToByte315(boost / (float) Math.sqrt(fieldLength));
}
项目:Maskana-Gestor-de-Conocimiento    文件:DefaultSimilarity.java   
/**
 * Encodes a normalization factor for storage in an index.
 * <p>
 * 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);
}
项目:Maskana-Gestor-de-Conocimiento    文件:BM25Similarity.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) {
  return SmallFloat.floatToByte315(boost / (float) Math.sqrt(fieldLength));
}