public class HashStriper extends Object implements SymbolStriper
Example: striper byhash16
splits the symbol universe into 16 stripes by hash.
HashStriper can be matched by the following regex: byhash([0-9]+)
,
where the matched group defines the number of stripes (must be a power of 2).
HashFilter
Modifier and Type | Field and Description |
---|---|
static String |
HASH_STRIPER_PREFIX |
Modifier | Constructor and Description |
---|---|
protected |
HashStriper(DataScheme scheme,
int stripeCount) |
Modifier and Type | Method and Description |
---|---|
BitSet |
getIntersectingStripes(QDFilter filter)
Returns bit set of
SymbolStriper.getStripeCount() size that specifies stripes that
intersect with the given filter. |
String |
getName()
Returns a string representation of this striper.
|
DataScheme |
getScheme()
Returns scheme that this striper works for.
|
protected int |
getShift() |
int |
getStripeCount()
Returns the positive number of stripes that this striper splits into.
|
QDFilter |
getStripeFilter(int stripeIndex)
Returns
filter corresponding for the given stripe index. |
int |
getStripeIndex(char[] chars,
int offset,
int length)
Returns the index of the stripe that the given symbol (represented as character array) falls into.
|
int |
getStripeIndex(int cipher,
String symbol)
Returns the index of the stripe that the given cipher-symbol pair falls into.
|
int |
getStripeIndex(String symbol)
Returns the index of the stripe that the given symbol falls into.
|
protected static int |
index(int hash,
int shift) |
String |
toString()
Returns a string representation of this striper.
|
static SymbolStriper |
valueOf(DataScheme scheme,
int stripeCount)
Constructs a symbol striper for a given number of hash stripes.
|
static HashStriper |
valueOf(DataScheme scheme,
String spec)
Parses a given specification as hash striper for a given scheme.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
definedValueOf
public static final String HASH_STRIPER_PREFIX
protected HashStriper(DataScheme scheme, int stripeCount)
public static HashStriper valueOf(DataScheme scheme, String spec)
valueOf
in interface SymbolStriper
scheme
- the scheme.spec
- the striper specification.NullPointerException
- if spec is null.FilterSyntaxException
- if spec is invalid.public static SymbolStriper valueOf(DataScheme scheme, int stripeCount)
MonoStriper.INSTANCE
striper will be returned.scheme
- the scheme.stripeCount
- the number of hash stripes.FilterSyntaxException
- if spec is invalid.public String getName()
SymbolStriper
SymbolStriperFactory
.getName
in interface SymbolStriper
public DataScheme getScheme()
SymbolStriper
null
if this striper works for any scheme.getScheme
in interface SymbolStriper
public int getStripeCount()
SymbolStriper
getStripeCount
in interface SymbolStriper
public int getStripeIndex(int cipher, String symbol)
SymbolStriper
Note that wildcard
symbol should not be submitted to this method,
since it should be accepted by all stripes therefore making stripes intersecting each other.
getStripeIndex
in interface SymbolStriper
cipher
- symbol ciphersymbol
- symbol stringQDFilter.accept(QDContract, DataRecord, int, String)
public int getStripeIndex(String symbol)
SymbolStriper
getStripeIndex
in interface SymbolStriper
symbol
- symbol string (not-null)SymbolStriper.getStripeIndex(int, String)
public int getStripeIndex(char[] chars, int offset, int length)
SymbolStriper
getStripeIndex
in interface SymbolStriper
chars
- array that is the source of the symboloffset
- the initial offsetlength
- the symbol's lengthSymbolStriper.getStripeIndex(int, String)
public QDFilter getStripeFilter(int stripeIndex)
SymbolStriper
filter
corresponding for the given stripe index.getStripeFilter
in interface SymbolStriper
stripeIndex
- stripe indexpublic BitSet getIntersectingStripes(QDFilter filter)
SymbolStriper
SymbolStriper.getStripeCount()
size that specifies stripes that
intersect with the given filter. If intersection cannot be calculated null
can be returned.getIntersectingStripes
in interface SymbolStriper
filter
- QD filter to check for intersectionSymbolStriper.getStripeCount()
size of intersecting stripes, or null
.public String toString()
SymbolStriper
toString
in interface SymbolStriper
toString
in class Object
SymbolStriper.getName()
protected int getShift()
protected static int index(int hash, int shift)
Copyright © 2002–2025 Devexperts LLC. All rights reserved.