Interface SerializablePredicate
- All Known Implementing Classes:
SerializablePredicate.All, SerializablePredicate.KeyEquals, SerializablePredicate.KeyStartsWith, SerializablePredicate.ValueContains, SerializablePredicate.ValueEquals
public sealed interface SerializablePredicate
permits SerializablePredicate.All, SerializablePredicate.KeyEquals, SerializablePredicate.ValueEquals, SerializablePredicate.KeyStartsWith, SerializablePredicate.ValueContains
Wire-serializable predicate for
MessageType.CQC_SUBSCRIBE.
A sealed hierarchy of lightweight predicates that can be shipped client -> server over the
binary protocol. Both sides implement the same matching semantics against raw
String map keys / values, so the server can evaluate the predicate locally to
filter map change events and only push matched entries to the subscribing client.
Wire format
[1-byte kind][kind-specific body] ALL => [0x01] KEY_EQUALS(s) => [0x02][int len][utf8 bytes of s] VALUE_EQUALS(s) => [0x03][int len][utf8 bytes of s] KEY_STARTS_WITH(s) => [0x04][int len][utf8 bytes of s] VALUE_CONTAINS(s) => [0x05][int len][utf8 bytes of s]
Rationale
Shipping a full SQL parser orBiPredicate<K,V> over the wire is out of scope
for the initial CQC wire support. This minimal set covers the common continuous-query
patterns (filter by key prefix, substring match, exact match) while keeping the encoding
small, deterministic, and language-agnostic.- Since:
- 2.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classMatches every entry.static final recordMatches entries whose key equals the operand.static final recordMatches entries whose key starts with the operand.static final recordMatches entries whose value contains the operand as a substring.static final recordMatches entries whose value equals the operand. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final bytestatic final bytestatic final bytestatic final bytestatic final bytestatic final intMaximum encoded predicate size accepted over the wire (8 KiB).static final intMaximum allowed length of a string operand in the encoded form. -
Method Summary
Modifier and TypeMethodDescriptionstatic SerializablePredicateall()Match every entry.static SerializablePredicatedecode(byte[] bytes) Decode a predicate from wire bytes produced byencode().byte[]encode()Encode this predicate into a newly-allocated byte array.static SerializablePredicateMatch entries whose key equalsvalue.static SerializablePredicatekeyStartsWith(String prefix) Match entries whose key starts withprefix.booleanTest whether the predicate matches the given entry.static SerializablePredicatevalueContains(String substring) Match entries whose value containssubstring.static SerializablePredicatevalueEquals(String value) Match entries whose value equalsvalue.
-
Field Details
-
MAX_ENCODED_BYTES
static final int MAX_ENCODED_BYTESMaximum encoded predicate size accepted over the wire (8 KiB).- See Also:
-
MAX_OPERAND_BYTES
static final int MAX_OPERAND_BYTESMaximum allowed length of a string operand in the encoded form.- See Also:
-
KIND_ALL
static final byte KIND_ALL- See Also:
-
KIND_KEY_EQUALS
static final byte KIND_KEY_EQUALS- See Also:
-
KIND_VALUE_EQUALS
static final byte KIND_VALUE_EQUALS- See Also:
-
KIND_KEY_STARTS_WITH
static final byte KIND_KEY_STARTS_WITH- See Also:
-
KIND_VALUE_CONTAINS
static final byte KIND_VALUE_CONTAINS- See Also:
-
-
Method Details
-
test
-
encode
byte[] encode()Encode this predicate into a newly-allocated byte array. -
all
Match every entry. -
keyEquals
Match entries whose key equalsvalue. -
valueEquals
Match entries whose value equalsvalue. -
keyStartsWith
Match entries whose key starts withprefix. -
valueContains
Match entries whose value containssubstring. -
decode
Decode a predicate from wire bytes produced byencode().- Parameters:
bytes- the wire payload- Returns:
- the decoded predicate
- Throws:
IllegalArgumentException- ifbytesis malformed, truncated, or exceeds size limits
-