public static byte[] ToBinary <K>(Windowed <K> timeKey, ISerDes <K> serializer, String topic) { byte[] bytes = serializer.Serialize(timeKey.Key, new Confluent.Kafka.SerializationContext(Confluent.Kafka.MessageComponentType.Key, topic)); ByteBuffer buf = ByteBuffer.Build(bytes.Length + TIMESTAMP_SIZE); buf.Put(bytes); buf.PutLong(timeKey.Window.StartMs); return(buf.ToArray()); }
/// <summary> /// Serialize an <see cref="Windowed{K}"/> instance to byte array /// </summary> /// <param name="data">Instance to serialize</param> /// <param name="context">serialization context</param> /// <returns>Return an array of byte</returns> public override byte[] Serialize(Windowed <T> data, SerializationContext context) { if (data == null) { return(null); } var bytesKey = innerSerdes.Serialize(data.Key, context); var bytes = WindowKeyHelper.ToStoreKeyBinary(bytesKey, data.Window.StartMs, 0); return(bytes.Get); }
/// <summary> /// Serialize an <see cref="Windowed{K}"/> instance to byte array /// </summary> /// <param name="data">Instance to serialize</param> /// <param name="context">serialization context</param> /// <returns>Return an array of byte</returns> public override byte[] Serialize(Windowed <T> data, SerializationContext context) { if (data == null) { return(null); } using var mStream = new MemoryStream(); using (var bufferStream = new BufferedStream(mStream)) { bufferStream.Write(innerSerdes.Serialize(data.Key, context)); bufferStream.Write(BitConverter.GetBytes(data.Window.StartMs)); } return(mStream.ToArray()); }
public static Bytes ToStoreKeyBinary <K>(Windowed <K> timeKey, int seqnum, ISerDes <K> keySerdes) { byte[] serializedKey = keySerdes.Serialize(timeKey.Key, new Confluent.Kafka.SerializationContext()); return(ToStoreKeyBinary(serializedKey, timeKey.Window.StartMs, seqnum)); }
public static Bytes ToStoreKeyBinary(Windowed <Bytes> timeKey, int seqnum) { byte[] bytes = timeKey.Key.Get; return(ToStoreKeyBinary(bytes, timeKey.Window.StartMs, seqnum)); }
public static Windowed <K> FromStoreKey <K>(Windowed <Bytes> windowedKey, ISerDes <K> keySerdes, String topic) { K key = keySerdes.Deserialize(windowedKey.Key.Get, new Confluent.Kafka.SerializationContext(Confluent.Kafka.MessageComponentType.Key, topic)); return(new Windowed <K>(key, windowedKey.Window)); }
private Windowed <K> WindowedKey(Windowed <Bytes> bytesKey) { K key = keySerdes.Deserialize(bytesKey.Key.Get, new Confluent.Kafka.SerializationContext()); return(new Windowed <K>(key, bytesKey.Window)); }
private Windowed <K> WindowedKey(Windowed <Bytes> bytesKey) { K key = funcSerdesKey(bytesKey.Key.Get); return(new Windowed <K>(key, bytesKey.Window)); }
public ValueAndTimestamp <V> Get(Windowed <K> key) { return(store.Fetch(key.Key, key.Window.StartMs)); }
private Windowed <K> WindowedKey(Windowed <Bytes> bytesKey) { K key = keySerdes.Deserialize(bytesKey.Key.Get); return(new Windowed <K>(key, bytesKey.Window)); }