Package org.jesterj.ingest.trie.analyzer
Class CharSequenceAnalyzer
- java.lang.Object
-
- org.jesterj.ingest.trie.KeyAnalyzer<java.lang.CharSequence>
-
- org.jesterj.ingest.trie.analyzer.CharSequenceAnalyzer
-
- All Implemented Interfaces:
java.io.Serializable,java.util.Comparator<java.lang.CharSequence>
public class CharSequenceAnalyzer extends KeyAnalyzer<java.lang.CharSequence>
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static intLENGTHThe number of bits perCharacter.-
Fields inherited from class org.jesterj.ingest.trie.KeyAnalyzer
EQUAL_BIT_KEY, NULL_BIT_KEY, OUT_OF_BOUNDS_BIT_KEY
-
-
Constructor Summary
Constructors Constructor Description CharSequenceAnalyzer()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intbitIndex(java.lang.CharSequence key, int offsetInBits, int lengthInBits, java.lang.CharSequence other, int otherOffsetInBits, int otherLengthInBits)Returns the n-th different bit between key and other.intbitsPerElement()Returns the number of bits per element in the key.intcompare(java.lang.CharSequence o1, java.lang.CharSequence o2)booleanisBitSet(java.lang.CharSequence key, int bitIndex, int lengthInBits)Returns whether or not a bit is set.booleanisPrefix(java.lang.CharSequence prefix, int offsetInBits, int lengthInBits, java.lang.CharSequence key)Determines whether or not the given prefix (from offset to length) is a prefix of the given key.intlengthInBits(java.lang.CharSequence key)Returns the length of the Key in bits.
-
-
-
Field Detail
-
LENGTH
public static final int LENGTH
The number of bits perCharacter.- See Also:
- Constant Field Values
-
-
Method Detail
-
bitsPerElement
public int bitsPerElement()
Description copied from class:KeyAnalyzerReturns the number of bits per element in the key. This is only useful for variable-length keys, such as Strings.- Specified by:
bitsPerElementin classKeyAnalyzer<java.lang.CharSequence>- Returns:
- the number of bits per element
-
lengthInBits
public int lengthInBits(java.lang.CharSequence key)
Description copied from class:KeyAnalyzerReturns the length of the Key in bits.- Specified by:
lengthInBitsin classKeyAnalyzer<java.lang.CharSequence>- Parameters:
key- the key- Returns:
- the bit length of the key
-
bitIndex
public int bitIndex(java.lang.CharSequence key, int offsetInBits, int lengthInBits, java.lang.CharSequence other, int otherOffsetInBits, int otherLengthInBits)Description copied from class:KeyAnalyzerReturns the n-th different bit between key and other. This starts the comparison in key at 'offsetInBits' and goes for 'lengthInBits' bits, and compares to the other key starting at 'otherOffsetInBits' and going for 'otherLengthInBits' bits.- Specified by:
bitIndexin classKeyAnalyzer<java.lang.CharSequence>- Parameters:
key- the key to useoffsetInBits- the bit offset in the keylengthInBits- the maximum key length in bits to useother- the other key to useotherOffsetInBits- the bit offset in the other keyotherLengthInBits- the maximum key length in bits for the other key- Returns:
- the bit index where the key and other first differ
-
isBitSet
public boolean isBitSet(java.lang.CharSequence key, int bitIndex, int lengthInBits)Description copied from class:KeyAnalyzerReturns whether or not a bit is set.- Specified by:
isBitSetin classKeyAnalyzer<java.lang.CharSequence>- Parameters:
key- the key to check, may not be nullbitIndex- the bit index to checklengthInBits- the maximum key length in bits to check- Returns:
trueif the bit is set in the given key andbitIndex<lengthInBits,falseotherwise.
-
isPrefix
public boolean isPrefix(java.lang.CharSequence prefix, int offsetInBits, int lengthInBits, java.lang.CharSequence key)Description copied from class:KeyAnalyzerDetermines whether or not the given prefix (from offset to length) is a prefix of the given key.- Specified by:
isPrefixin classKeyAnalyzer<java.lang.CharSequence>- Parameters:
prefix- the prefix to checkoffsetInBits- the bit offset in the keylengthInBits- the maximum key length in bits to usekey- the key to check- Returns:
trueif this is a valid prefix for the given key
-
compare
public int compare(java.lang.CharSequence o1, java.lang.CharSequence o2)- Specified by:
comparein interfacejava.util.Comparator<java.lang.CharSequence>- Overrides:
comparein classKeyAnalyzer<java.lang.CharSequence>
-
-