Class CollatedTermAttributeImpl
java.lang.Object
org.apache.lucene.util.AttributeImpl
org.apache.lucene.analysis.tokenattributes.CharTermAttributeImpl
org.apache.lucene.collation.tokenattributes.CollatedTermAttributeImpl
- All Implemented Interfaces:
Appendable,CharSequence,Cloneable,CharTermAttribute,TermToBytesRefAttribute,Attribute
Extension of
CharTermAttributeImpl that encodes the term
text as a binary Unicode collation key instead of as UTF-8 bytes.-
Constructor Summary
ConstructorsConstructorDescriptionCollatedTermAttributeImpl(Collator collator) Create a new CollatedTermAttributeImpl -
Method Summary
Modifier and TypeMethodDescriptionintUpdates the bytesTermToBytesRefAttribute.getBytesRef()to contain this term's final encoding, and returns its hashcode.Methods inherited from class org.apache.lucene.analysis.tokenattributes.CharTermAttributeImpl
append, append, append, append, append, append, buffer, charAt, clear, clone, copyBuffer, copyTo, equals, getBytesRef, hashCode, length, reflectWith, resizeBuffer, setEmpty, setLength, subSequence, toStringMethods inherited from class org.apache.lucene.util.AttributeImpl
reflectAsStringMethods inherited from interface java.lang.CharSequence
chars, codePoints, isEmpty
-
Constructor Details
-
CollatedTermAttributeImpl
Create a new CollatedTermAttributeImpl- Parameters:
collator- Collation key generator
-
-
Method Details
-
fillBytesRef
public int fillBytesRef()Description copied from interface:TermToBytesRefAttributeUpdates the bytesTermToBytesRefAttribute.getBytesRef()to contain this term's final encoding, and returns its hashcode.- Specified by:
fillBytesRefin interfaceTermToBytesRefAttribute- Overrides:
fillBytesRefin classCharTermAttributeImpl- Returns:
- the hashcode as defined by
BytesRef.hashCode():int hash = 0; for (int i = termBytes.offset; i < termBytes.offset+termBytes.length; i++) { hash = 31*hash + termBytes.bytes[i]; }Implement this for performance reasons, if your code can calculate the hash on-the-fly. If this is not the case, just returntermBytes.hashCode().
-