本文整理汇总了Java中org.apache.lucene.analysis.payloads.PayloadHelper.decodeInt方法的典型用法代码示例。如果您正苦于以下问题:Java PayloadHelper.decodeInt方法的具体用法?Java PayloadHelper.decodeInt怎么用?Java PayloadHelper.decodeInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.lucene.analysis.payloads.PayloadHelper
的用法示例。
在下文中一共展示了PayloadHelper.decodeInt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: position
import org.apache.lucene.analysis.payloads.PayloadHelper; //导入方法依赖的package包/类
private int position(int doc, BytesRef term) {
int maxPosition = 20;
try {
Terms terms = context.reader().getTermVector(doc, weight.field);
TermsEnum termsEnum = terms.iterator();
if (!termsEnum.seekExact(term)) {
Loggers.getLogger(this.getClass()).error("seekExact failed, returning default position = " +
maxPosition + " for field = " + weight.field);
return maxPosition;
}
PostingsEnum dpEnum = termsEnum.postings(null, PostingsEnum.ALL);
dpEnum.nextDoc();
dpEnum.nextPosition();
BytesRef payload = dpEnum.getPayload();
if (payload == null) {
Loggers.getLogger(this.getClass()).error("getPayload failed, returning default position = " +
maxPosition + " for field = " + weight.field);
return maxPosition;
}
return PayloadHelper.decodeInt(payload.bytes, payload.offset);
} catch (Exception ex) {
Loggers.getLogger(this.getClass()).error("Unexpected exception, returning default position = " +
maxPosition + " for field = " + weight.field, ex);
return maxPosition;
}
}
示例2: payloadAsInt
import org.apache.lucene.analysis.payloads.PayloadHelper; //导入方法依赖的package包/类
public int payloadAsInt(int defaultMissing) {
if (payload != null && payload.length != 0) {
return PayloadHelper.decodeInt(payload.bytes, payload.offset);
} else {
return defaultMissing;
}
}