Class KeyValue<K,​V>


  • @Public
    @Stable
    public class KeyValue<K,​V>
    extends java.lang.Object
    A simple KeyValue class.
    • Constructor Detail

      • KeyValue

        public KeyValue​(K key,
                        V value)
    • Method Detail

      • getKey

        public K getKey()
      • getValue

        public V getValue()
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object
      • equals

        public boolean equals​(java.lang.Object obj)
        Overrides:
        equals in class java.lang.Object
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.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 encode
        keyWriter - a writer to encode key object
        value - value object to encode
        valueWriter - 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 bytes
        decoder - the decoder to decode encoded key/value bytes
        Returns:
        the decoded key/value pair