Package org.apache.pulsar.common.schema
Class KeyValue<K,V>
- java.lang.Object
-
- org.apache.pulsar.common.schema.KeyValue<K,V>
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
KeyValue.KeyValueDecoder<K,V>
Decoder to decode key/value bytes.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <K,V>
KeyValue<K,V>decode(byte[] data, KeyValue.KeyValueDecoder<K,V> decoder)
Decode the value into a key/value pair.static <K,V>
byte[]encode(K key, Schema<K> keyWriter, V value, Schema<V> valueWriter)
Encode a key and value pair into a bytes array.boolean
equals(java.lang.Object obj)
K
getKey()
V
getValue()
int
hashCode()
java.lang.String
toString()
-
-
-
Method Detail
-
getKey
public K getKey()
-
getValue
public V getValue()
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
encode
public static <K,V> byte[] encode(K key, Schema<K> keyWriter, V value, Schema<V> valueWriter)
Encode a key and value pair into a bytes array.- Parameters:
key
- key object to encodekeyWriter
- a writer to encode key objectvalue
- value object to encodevalueWriter
- a writer to encode value object- Returns:
- the encoded bytes array
-
decode
public static <K,V> KeyValue<K,V> decode(byte[] data, KeyValue.KeyValueDecoder<K,V> decoder)
Decode the value into a key/value pair.- Parameters:
data
- the encoded bytesdecoder
- the decoder to decode encoded key/value bytes- Returns:
- the decoded key/value pair
-
-