use of org.apache.kafka.common.utils.Bytes in project apache-kafka-on-k8s by banzaicloud.
the class WindowKeySchemaTest method shouldExtractBytesKeyFromBinary.
@Test
public void shouldExtractBytesKeyFromBinary() {
final Windowed<Bytes> windowedBytesKey = new Windowed<>(Bytes.wrap(key.getBytes()), window);
final Bytes serialized = WindowKeySchema.toStoreKeyBinary(windowedBytesKey, 0);
assertEquals(windowedBytesKey, WindowKeySchema.fromStoreKey(serialized.get(), endTime - startTime));
}
use of org.apache.kafka.common.utils.Bytes in project apache-kafka-on-k8s by banzaicloud.
the class WindowKeySchemaTest method shouldExtractStartTimeFromBinary.
@Test
public void shouldExtractStartTimeFromBinary() {
final Bytes serialized = WindowKeySchema.toStoreKeyBinary(windowedKey, 0, stateSerdes);
assertEquals(startTime, WindowKeySchema.extractStoreTimestamp(serialized.get()));
}
use of org.apache.kafka.common.utils.Bytes in project apache-kafka-on-k8s by banzaicloud.
the class WindowKeySchemaTest method testLowerBoundWithMonZeroTimestamp.
@Test
public void testLowerBoundWithMonZeroTimestamp() {
Bytes lower = windowKeySchema.lowerRange(Bytes.wrap(new byte[] { 0xA, 0xB, 0xC }), 42);
assertThat(lower, equalTo(WindowKeySchema.toStoreKeyBinary(new byte[] { 0xA, 0xB, 0xC }, 0, 0)));
}
use of org.apache.kafka.common.utils.Bytes in project apache-kafka-on-k8s by banzaicloud.
the class WindowKeySchemaTest method shouldExtractKeyFromBinary.
@Test
public void shouldExtractKeyFromBinary() {
final Bytes serialized = WindowKeySchema.toStoreKeyBinary(windowedKey, 0, stateSerdes);
assertEquals(windowedKey, WindowKeySchema.fromStoreKey(serialized.get(), endTime - startTime, stateSerdes));
}
use of org.apache.kafka.common.utils.Bytes in project apache-kafka-on-k8s by banzaicloud.
the class WindowKeySchemaTest method testLowerBoundMatchesTrailingZeros.
@Test
public void testLowerBoundMatchesTrailingZeros() {
Bytes lower = windowKeySchema.lowerRange(Bytes.wrap(new byte[] { 0xA, 0xB, 0xC }), Long.MAX_VALUE - 1);
assertThat("appending zeros to key should still be in range", lower.compareTo(WindowKeySchema.toStoreKeyBinary(new byte[] { 0xA, 0xB, 0xC, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, Long.MAX_VALUE - 1, 0)) < 0);
assertThat(lower, equalTo(WindowKeySchema.toStoreKeyBinary(new byte[] { 0xA, 0xB, 0xC }, 0, 0)));
}
Aggregations