public Iterable<ScoredMatch> decode(Iterable<RawMatch> rawMatches, final double boostedNorm) {
try {
final TermPositions payloads = reader.termPositions(payloadTerm);
return Iterables.transform(rawMatches, new Function<RawMatch, ScoredMatch>() {
private byte[] data = new byte[256];
private ScoredMatch match = new ScoredMatch(0, new DocId(data, 0, 0));
@Override
public ScoredMatch apply(RawMatch rawMatch) {
int rawId = rawMatch.getRawId();
try {
if (payloads.skipTo(rawId) && payloads.doc() == rawId) {
payloads.nextPosition();
int size = payloads.getPayloadLength();
if (size > data.length) {
data = new byte[size];
}
payloads.getPayload(data, 0);
match.getDocId().update(data, 0, size);
match.setScore(rawMatch.getBoostedScore() / boostedNorm);
return match;
} else {
throw new IllegalArgumentException("rawId:" + rawId + " doesn't exist. Payloads.doc():" + payloads.doc());
}
} catch (IOException e) {