use of org.apache.kafka.common.utils.Bytes in project apache-kafka-on-k8s by banzaicloud.
the class SessionKeySchemaTest method testUpperBoundWithLargeTimestamps.
@Test
public void testUpperBoundWithLargeTimestamps() {
Bytes upper = sessionKeySchema.upperRange(Bytes.wrap(new byte[] { 0xA, 0xB, 0xC }), Long.MAX_VALUE);
assertThat("shorter key with max timestamp should be in range", upper.compareTo(Bytes.wrap(SessionKeySchema.toBinary(new Windowed<>(Bytes.wrap(new byte[] { 0xA }), new SessionWindow(Long.MAX_VALUE, Long.MAX_VALUE))))) >= 0);
assertThat("shorter key with max timestamp should be in range", upper.compareTo(Bytes.wrap(SessionKeySchema.toBinary(new Windowed<>(Bytes.wrap(new byte[] { 0xA, 0xB }), new SessionWindow(Long.MAX_VALUE, Long.MAX_VALUE))))) >= 0);
assertThat(upper, equalTo(Bytes.wrap(SessionKeySchema.toBinary(new Windowed<>(Bytes.wrap(new byte[] { 0xA }), new SessionWindow(Long.MAX_VALUE, Long.MAX_VALUE))))));
}
use of org.apache.kafka.common.utils.Bytes in project apache-kafka-on-k8s by banzaicloud.
the class SessionKeySchemaTest method testUpperBoundWithKeyBytesLargerThanFirstTimestampByte.
@Test
public void testUpperBoundWithKeyBytesLargerThanFirstTimestampByte() {
Bytes upper = sessionKeySchema.upperRange(Bytes.wrap(new byte[] { 0xA, (byte) 0x8F, (byte) 0x9F }), Long.MAX_VALUE);
assertThat("shorter key with max timestamp should be in range", upper.compareTo(Bytes.wrap(SessionKeySchema.toBinary(new Windowed<>(Bytes.wrap(new byte[] { 0xA, (byte) 0x8F }), new SessionWindow(Long.MAX_VALUE, Long.MAX_VALUE))))) >= 0);
assertThat(upper, equalTo(Bytes.wrap(SessionKeySchema.toBinary(new Windowed<>(Bytes.wrap(new byte[] { 0xA, (byte) 0x8F, (byte) 0x9F }), new SessionWindow(Long.MAX_VALUE, Long.MAX_VALUE))))));
}
use of org.apache.kafka.common.utils.Bytes in project apache-kafka-on-k8s by banzaicloud.
the class SessionKeySchemaTest method testLowerBoundWithZeroTimestamp.
@Test
public void testLowerBoundWithZeroTimestamp() {
Bytes lower = sessionKeySchema.lowerRange(Bytes.wrap(new byte[] { 0xA, 0xB, 0xC }), 0);
assertThat(lower, equalTo(Bytes.wrap(SessionKeySchema.toBinary(new Windowed<>(Bytes.wrap(new byte[] { 0xA, 0xB, 0xC }), new SessionWindow(0, 0))))));
}
use of org.apache.kafka.common.utils.Bytes in project apache-kafka-on-k8s by banzaicloud.
the class SessionKeySchemaTest method shouldFetchExactKeysSkippingLongerKeys.
@Test
public void shouldFetchExactKeysSkippingLongerKeys() {
final Bytes key = Bytes.wrap(new byte[] { 0 });
final List<Integer> result = getValues(sessionKeySchema.hasNextCondition(key, key, 0, Long.MAX_VALUE));
assertThat(result, equalTo(Arrays.asList(2, 4)));
}
use of org.apache.kafka.common.utils.Bytes in project apache-kafka-on-k8s by banzaicloud.
the class SessionKeySchemaTest method testUpperBoundWithZeroTimestamp.
@Test
public void testUpperBoundWithZeroTimestamp() {
Bytes upper = sessionKeySchema.upperRange(Bytes.wrap(new byte[] { 0xA, 0xB, 0xC }), 0);
assertThat(upper, equalTo(Bytes.wrap(SessionKeySchema.toBinary(new Windowed<>(Bytes.wrap(new byte[] { 0xA, 0xB, 0xC }), new SessionWindow(0, 0))))));
}
Aggregations