Interface MapRecord<S,K,V>

Type Parameters:
K - the field type of the backing map.
V - the value type of the backing map.
All Superinterfaces:
Iterable<Map.Entry<K,V>>, Record<S,Map<K,V>>
All Known Subinterfaces:
ByteBufferRecord, ByteRecord, StringRecord

public interface MapRecord<S,K,V> extends Record<S,Map<K,V>>, Iterable<Map.Entry<K,V>>
A Record within the stream backed by a collection of field/value pairs.
Since:
2.2
Author:
Christoph Strobl, Mark Paluch, Romain Beghi
  • Method Details

    • create

      static <S, K, V> MapRecord<S,K,V> create(S stream, Map<K,V> map)
      Creates a new MapRecord associated with the stream key and value.
      Parameters:
      stream - the stream key.
      map - the value.
      Returns:
      the ObjectRecord holding the stream key and value.
    • withId

      MapRecord<S,K,V> withId(RecordId id)
      Description copied from interface: Record
      Create a new instance of Record with the given RecordId.
      Specified by:
      withId in interface Record<S,K>
      Parameters:
      id - must not be null.
      Returns:
      new instance of Record.
    • withStreamKey

      <SK> MapRecord<SK,K,V> withStreamKey(SK key)
      Description copied from interface: Record
      Create a new instance of Record with the given key to store the record at.
      Specified by:
      withStreamKey in interface Record<S,K>
      Parameters:
      key - the Redis key identifying the stream.
      Returns:
      new instance of Record.
    • mapEntries

      default <HK, HV> MapRecord<S,HK,HV> mapEntries(Function<Map.Entry<K,V>,Map.Entry<HK,HV>> mapFunction)
      Apply the given mapFunction to each and every entry in the backing collection to create a new MapRecord.
      Type Parameters:
      HK - the field type of the new backing collection.
      HV - the value type of the new backing collection.
      Parameters:
      mapFunction - must not be null.
      Returns:
      new instance of MapRecord.
    • map

      default <SK, HK, HV> MapRecord<SK,HK,HV> map(Function<MapRecord<S,K,V>,MapRecord<SK,HK,HV>> mapFunction)
      Map this MapRecord by applying the mapping Function.
      Parameters:
      mapFunction - function to apply to this MapRecord element.
      Returns:
      the mapped MapRecord.
    • serialize

      default ByteRecord serialize(@Nullable RedisSerializer<?> serializer)
      Serialize key and field/value pairs with the given RedisSerializer. An already assigned id is carried over to the new instance.
      Parameters:
      serializer - can be null if the Record only holds binary data.
      Returns:
      new ByteRecord holding the serialized values.
    • serialize

      default ByteRecord serialize(@Nullable RedisSerializer<? super S> streamSerializer, @Nullable RedisSerializer<? super K> fieldSerializer, @Nullable RedisSerializer<? super V> valueSerializer)
      Serialize key with the streamSerializer, field names with the fieldSerializer and values with the valueSerializer. An already assigned id is carried over to the new instance.
      Parameters:
      streamSerializer - can be null if the key is binary.
      fieldSerializer - can be null if the fields are binary.
      valueSerializer - can be null if the values are binary.
      Returns:
      new ByteRecord holding the serialized values.
    • toObjectRecord

      default <OV> ObjectRecord<S,OV> toObjectRecord(HashMapper<? super OV,? super K,? super V> mapper)
      Apply the given HashMapper to the backing value to create a new MapRecord. An already assigned id is carried over to the new instance.
      Type Parameters:
      OV - type of the value backing the ObjectRecord.
      Parameters:
      mapper - must not be null.
      Returns:
      new instance of ObjectRecord.