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:
java.lang.Appendable
,java.lang.CharSequence
,java.lang.Cloneable
,CharTermAttribute
,TermToBytesRefAttribute
,Attribute
public class CollatedTermAttributeImpl extends CharTermAttributeImpl
Extension ofCharTermAttributeImpl
that encodes the term text as a binary Unicode collation key instead of as UTF-8 bytes.
-
-
Constructor Summary
Constructors Constructor Description CollatedTermAttributeImpl(java.text.Collator collator)
Create a new CollatedTermAttributeImpl
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
fillBytesRef()
Updates 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, toString
-
Methods inherited from class org.apache.lucene.util.AttributeImpl
reflectAsString
-
-
-
-
Method Detail
-
fillBytesRef
public int fillBytesRef()
Description copied from interface:TermToBytesRefAttribute
Updates the bytesTermToBytesRefAttribute.getBytesRef()
to contain this term's final encoding, and returns its hashcode.- Specified by:
fillBytesRef
in interfaceTermToBytesRefAttribute
- Overrides:
fillBytesRef
in 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()
.
-
-