@Override public boolean incrementToken() throws IOException { if (input.incrementToken()) { char[] termBuffer = termAtt.buffer(); String termText = new String(termBuffer, 0, termAtt.length()); collator.getRawCollationKey(termText, reusableKey); int encodedLength = IndexableBinaryStringTools.getEncodedLength( reusableKey.bytes, 0, reusableKey.size); if (encodedLength > termBuffer.length) { termAtt.resizeBuffer(encodedLength); } termAtt.setLength(encodedLength); IndexableBinaryStringTools.encode(reusableKey.bytes, 0, reusableKey.size, termAtt.buffer(), 0, encodedLength); return true; } else { return false; } }
@Override public boolean incrementToken() throws IOException { if (input.incrementToken()) { byte[] collationKey = collator.getCollationKey(termAtt.toString()).toByteArray(); int encodedLength = IndexableBinaryStringTools.getEncodedLength( collationKey, 0, collationKey.length); termAtt.resizeBuffer(encodedLength); termAtt.setLength(encodedLength); IndexableBinaryStringTools.encode(collationKey, 0, collationKey.length, termAtt.buffer(), 0, encodedLength); return true; } else { return false; } }
/** * Convenience method to perform the same function as CollationKeyFilter. * * @param keyBits the result from * collator.getCollationKey(original).toByteArray() * @return The encoded collation key for the original String * @deprecated only for testing deprecated filters */ @Deprecated protected String encodeCollationKey(byte[] keyBits) { // Ensure that the backing char[] array is large enough to hold the encoded // Binary String int encodedLength = IndexableBinaryStringTools.getEncodedLength(keyBits, 0, keyBits.length); char[] encodedBegArray = new char[encodedLength]; IndexableBinaryStringTools.encode(keyBits, 0, keyBits.length, encodedBegArray, 0, encodedLength); return new String(encodedBegArray); }