@Override public void collect(Value value) { // Make sure we don't aggregate something else if (value == null || value.get().length == 0) { return; } TermWeight.Info info; try { info = TermWeight.Info.parseFrom(value.get()); } catch (InvalidProtocolBufferException e) { log.error("Value passed to aggregator was not of type TermWeight.Info", e); return; } // Add each offset into the list maintaining sorted order TermWeightPosition.Builder builder = new TermWeightPosition.Builder(); for (int i = 0; i < info.getTermOffsetCount(); i++) { builder.setTermWeightOffsetInfo(info, i); offsets.add(builder.build()); builder.reset(); } }
for (int i = 0; i < twInfo.getTermOffsetCount(); i++) { position.setTermWeightOffsetInfo(twInfo, i); offsets.put(twZone, position.build());
public Builder setTermWeightOffsetInfo(TermWeight.Info info, int i) { setOffset(info.getTermOffset(i)); // Only pull the previous skips if the counts match the offsets // offsets, skips, and scores are linked by index so array lengths must match if (info.getTermOffsetCount() == info.getPrevSkipsCount()) { setPrevSkips(info.getPrevSkips(i)); } // Only pull the scores if the counts match the offsets if (info.getTermOffsetCount() == info.getScoreCount()) { setScore(info.getScore(i)); } setZeroOffsetMatch(info.getZeroOffsetMatch()); return this; }