本文整理汇总了Java中org.apache.lucene.util.SmallFloat类的典型用法代码示例。如果您正苦于以下问题:Java SmallFloat类的具体用法?Java SmallFloat怎么用?Java SmallFloat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SmallFloat类属于org.apache.lucene.util包,在下文中一共展示了SmallFloat类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: payloadBoost
import org.apache.lucene.util.SmallFloat; //导入依赖的package包/类
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;
}
示例2: collect
import org.apache.lucene.util.SmallFloat; //导入依赖的package包/类
@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());
}
}
}
示例3: AllTokenStream
import org.apache.lucene.util.SmallFloat; //导入依赖的package包/类
AllTokenStream(TokenStream input, float boost) {
super(input);
payloadAttribute = addAttribute(PayloadAttribute.class);
payloadSpare.bytes[0] = SmallFloat.floatToByte315(boost);
}
示例4: encodeNormValue
import org.apache.lucene.util.SmallFloat; //导入依赖的package包/类
/** Encodes the length to a byte via SmallFloat. */
protected byte encodeNormValue(float boost, float length) {
return SmallFloat.floatToByte315((boost / (float) Math.sqrt(length)));
}
示例5: encodeNormValue
import org.apache.lucene.util.SmallFloat; //导入依赖的package包/类
@Override
protected byte encodeNormValue(float boost, int fieldLength) {
return SmallFloat.floatToByte315(boost / (float) fieldLength);
}
示例6: encodeNormValue
import org.apache.lucene.util.SmallFloat; //导入依赖的package包/类
/** Encodes the length to a byte via SmallFloat. */
private static byte encodeNormValue(float boost, float length) {
return SmallFloat.floatToByte315((boost / (float) Math.sqrt(length)));
}
开发者ID:sebastian-hofstaetter,项目名称:ir-generalized-translation-models,代码行数:5,代码来源:LeafReaderOverride.java
示例7: encodeNormValue
import org.apache.lucene.util.SmallFloat; //导入依赖的package包/类
/** Encodes a normalization factor for storage in an index. */
public final long encodeNormValue(final float floatVal) {
return SmallFloat.floatToByte315(floatVal);
}
示例8: score
import org.apache.lucene.util.SmallFloat; //导入依赖的package包/类
public float score(int key) {
if (key < this.scores.length) {
return SmallFloat.byte315ToFloat(this.scores[key]);
}
return 0;
}
示例9: encodeNormValue
import org.apache.lucene.util.SmallFloat; //导入依赖的package包/类
/**
* 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);
}
示例10: encodeNormValue
import org.apache.lucene.util.SmallFloat; //导入依赖的package包/类
/** 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));
}
示例11: encodeNormValue
import org.apache.lucene.util.SmallFloat; //导入依赖的package包/类
/**
* 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);
}
示例12: encodeNormValue
import org.apache.lucene.util.SmallFloat; //导入依赖的package包/类
/**
* 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);
}
示例13: encodeNormValue
import org.apache.lucene.util.SmallFloat; //导入依赖的package包/类
/** 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);
}
示例14: encodeNormValue
import org.apache.lucene.util.SmallFloat; //导入依赖的package包/类
/**
* 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));
}