@Override public int compare(BytesRef left, BytesRef right) { // Make shallow copy in case decode changes the BytesRef: leftScratch.bytes = left.bytes; leftScratch.offset = left.offset; leftScratch.length = left.length; rightScratch.bytes = right.bytes; rightScratch.offset = right.offset; rightScratch.length = right.length; long leftCost = decode(leftScratch, input); long rightCost = decode(rightScratch, input); if (hasPayloads) { decodePayload(leftScratch, input); decodePayload(rightScratch, input); } if (hasContexts) { decodeContexts(leftScratch, input); decodeContexts(rightScratch, input); } int cmp = comparator.compare(leftScratch, rightScratch); if (cmp != 0) { return cmp; } return Long.compare(leftCost, rightCost); } };
contexts = decodeContexts(bytes, input);