@Override public int hashCode() { return node.hashCode(); }
@Override public int hashCode() { return node.hashCode(); }
@Override public final boolean incrementToken() throws IOException { if (!input.incrementToken()) { return false; } final int nodeHash = nodeAtt.node().hashCode(); if (lastNodeHash != nodeHash) { // new node lastPosition = 0; lastNodeHash = nodeHash; } lastPosition += posIncrAtt.getPositionIncrement(); if (lastPosition > 0) { posAtt.setPosition(lastPosition - 1); } else { posAtt.setPosition(lastPosition); } return true; }
@Override public final boolean incrementToken() throws IOException { if (!input.incrementToken()) { return false; } final int nodeHash = nodeAtt.node().hashCode(); if (lastNodeHash != nodeHash) { // new node lastPosition = 0; lastNodeHash = nodeHash; } lastPosition += posIncrAtt.getPositionIncrement(); if (lastPosition > 0) { posAtt.setPosition(lastPosition - 1); } else { posAtt.setPosition(lastPosition); } return true; }
@Override public void addPosition(final int position, final BytesRef payload, final int startOffset, final int endOffset) throws IOException { assert indexOptions == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS; // we always receive node ids in the payload assert payload != null; // decode payload sirenPayload.decode(payload); final IntsRef node = sirenPayload.getNode(); // check if we received the same node // TODO: we pay the cost of decoding the node before testing the equality // we could instead directly compute the node hash based on the byte array final int nodeHash = node.hashCode(); if (lastNodeHash != nodeHash) { // if different node // add term freq for previous node if not first payload. if (lastNodeHash != Long.MAX_VALUE) { this.addTermFreqInNode(); } // add new node this.addNode(node); } lastNodeHash = nodeHash; // add position this.addPosition(sirenPayload.getPosition()); }
@Override public void addPosition(final int position, final BytesRef payload, final int startOffset, final int endOffset) throws IOException { assert indexOptions == IndexOptions.DOCS_AND_FREQS_AND_POSITIONS; // we always receive node ids in the payload assert payload != null; // decode payload sirenPayload.decode(payload); final IntsRef node = sirenPayload.getNode(); // check if we received the same node // TODO: we pay the cost of decoding the node before testing the equality // we could instead directly compute the node hash based on the byte array final int nodeHash = node.hashCode(); if (lastNodeHash != nodeHash) { // if different node // add term freq for previous node if not first payload. if (lastNodeHash != Long.MAX_VALUE) { this.addTermFreqInNode(); } // add new node this.addNode(node); } lastNodeHash = nodeHash; // add position this.addPosition(sirenPayload.getPosition()); }