use of org.apache.kafka.common.utils.Bytes in project kafka by apache.
the class CachingSessionStore method put.
@Override
public void put(final Windowed<K> key, AGG value) {
validateStoreOpen();
final Bytes binaryKey = SessionKeySerde.toBinary(key, keySerde.serializer());
final LRUCacheEntry entry = new LRUCacheEntry(serdes.rawValue(value), true, context.offset(), key.window().end(), context.partition(), context.topic());
cache.put(cacheName, binaryKey, entry);
}
use of org.apache.kafka.common.utils.Bytes in project kafka by apache.
the class CachingWindowStore method put.
@Override
public synchronized void put(final K key, final V value, final long timestamp) {
// since this function may not access the underlying inner store, we need to validate
// if store is open outside as well.
validateStoreOpen();
final Bytes keyBytes = WindowStoreUtils.toBinaryKey(key, timestamp, 0, serdes);
final LRUCacheEntry entry = new LRUCacheEntry(serdes.rawValue(value), true, context.offset(), timestamp, context.partition(), context.topic());
cache.put(name, keyBytes, entry);
}
use of org.apache.kafka.common.utils.Bytes in project kafka by apache.
the class SessionKeySerdeTest method shouldExtractKeyFromBinary.
@Test
public void shouldExtractKeyFromBinary() throws Exception {
final Bytes serialized = SessionKeySerde.toBinary(windowedKey, serde.serializer());
assertEquals(windowedKey, SessionKeySerde.from(serialized.get(), serde.deserializer()));
}
use of org.apache.kafka.common.utils.Bytes in project kafka by apache.
the class SessionKeySerdeTest method shouldExtractKeyBytesFromBinary.
@Test
public void shouldExtractKeyBytesFromBinary() throws Exception {
final Bytes serialized = SessionKeySerde.toBinary(windowedKey, serde.serializer());
assertArrayEquals(key.getBytes(), SessionKeySerde.extractKeyBytes(serialized.get()));
}
use of org.apache.kafka.common.utils.Bytes in project kafka by apache.
the class SessionKeySerdeTest method shouldExtractBytesKeyFromBinary.
@Test
public void shouldExtractBytesKeyFromBinary() throws Exception {
final Bytes bytesKey = Bytes.wrap(key.getBytes());
final Windowed<Bytes> windowedBytesKey = new Windowed<>(bytesKey, window);
final Bytes serialized = SessionKeySerde.bytesToBinary(windowedBytesKey);
assertEquals(windowedBytesKey, SessionKeySerde.fromBytes(serialized));
}
Aggregations