use of org.apache.samza.serializers.IntegerSerde in project samza by apache.
the class TestExpandingInputDescriptor method testAPIUsage.
public void testAPIUsage() {
// does not assert anything, but acts as a compile-time check on expected descriptor type parameters
// and validates that the method calls can be chained.
ExampleExpandingSystemDescriptor expandingSystem = new ExampleExpandingSystemDescriptor("expandingSystem");
ExampleExpandingInputDescriptor<Long> input1 = expandingSystem.getInputDescriptor("input1", new IntegerSerde());
ExampleExpandingOutputDescriptor<Integer> output1 = expandingSystem.getOutputDescriptor("output1", new IntegerSerde());
input1.shouldBootstrap().withOffsetDefault(SystemStreamMetadata.OffsetType.NEWEST).withPriority(1).shouldResetOffset().withStreamConfigs(Collections.emptyMap());
output1.withStreamConfigs(Collections.emptyMap());
}
use of org.apache.samza.serializers.IntegerSerde in project samza by apache.
the class TestGenericInputDescriptor method testISDObjectsWithOverrides.
@Test
public void testISDObjectsWithOverrides() {
GenericSystemDescriptor mySystem = new GenericSystemDescriptor("input-system", "factory.class.name").withSystemConfigs(Collections.emptyMap()).withDefaultStreamConfigs(Collections.emptyMap());
IntegerSerde streamSerde = new IntegerSerde();
GenericInputDescriptor<Integer> isd = mySystem.getInputDescriptor("input-stream", streamSerde);
assertEquals(streamSerde, isd.getSerde());
assertFalse(isd.getTransformer().isPresent());
}
use of org.apache.samza.serializers.IntegerSerde in project samza by apache.
the class TestSimpleInputDescriptor method testAPIUsage.
@Test
public void testAPIUsage() {
// does not assert anything, but acts as a compile-time check on expected descriptor type parameters
// and validates that the method calls can be chained.
ExampleSimpleSystemDescriptor kafkaSystem = new ExampleSimpleSystemDescriptor("kafka-system").withSystemConfigs(Collections.emptyMap());
ExampleSimpleInputDescriptor<Integer> input1 = kafkaSystem.getInputDescriptor("input1", new IntegerSerde());
ExampleSimpleOutputDescriptor<Integer> output1 = kafkaSystem.getOutputDescriptor("output1", new IntegerSerde());
input1.shouldBootstrap().withOffsetDefault(SystemStreamMetadata.OffsetType.NEWEST).withPriority(1).shouldResetOffset().withStreamConfigs(Collections.emptyMap());
output1.withStreamConfigs(Collections.emptyMap());
}
use of org.apache.samza.serializers.IntegerSerde in project samza by apache.
the class TestWindowOperator method testTumblingAggregatingWindowsDiscardingMode.
@Test
public void testTumblingAggregatingWindowsDiscardingMode() throws Exception {
when(this.context.getTaskContext().getStore("jobName-jobId-window-w1")).thenReturn(new TestInMemoryStore<>(new TimeSeriesKeySerde(new IntegerSerde()), new IntegerSerde()));
OperatorSpecGraph sgb = this.getAggregateTumblingWindowStreamGraph(AccumulationMode.DISCARDING, Duration.ofSeconds(1), Triggers.repeat(Triggers.count(2))).getOperatorSpecGraph();
List<WindowPane<Integer, Integer>> windowPanes = new ArrayList<>();
TestClock testClock = new TestClock();
StreamOperatorTask task = new StreamOperatorTask(sgb, testClock);
task.init(this.context);
MessageCollector messageCollector = envelope -> windowPanes.add((WindowPane<Integer, Integer>) envelope.getMessage());
integers.forEach(n -> task.processAsync(new IntegerEnvelope(n), messageCollector, taskCoordinator, taskCallback));
testClock.advanceTime(Duration.ofSeconds(1));
task.window(messageCollector, taskCoordinator);
Assert.assertEquals(windowPanes.size(), 5);
Assert.assertEquals(windowPanes.get(0).getMessage(), new Integer(2));
Assert.assertEquals(windowPanes.get(1).getMessage(), new Integer(2));
Assert.assertEquals(windowPanes.get(2).getMessage(), new Integer(2));
Assert.assertEquals(windowPanes.get(3).getMessage(), new Integer(2));
Assert.assertEquals(windowPanes.get(4).getMessage(), new Integer(1));
}
use of org.apache.samza.serializers.IntegerSerde in project samza by apache.
the class TestTimestampedValueSerde method testEmptyValueSerialization.
@Test
public void testEmptyValueSerialization() {
byte[] expectedBytes = new byte[8];
ByteBuffer.wrap(expectedBytes).putLong(1234L);
TimestampedValueSerde<Integer> timestampedValueSerde = new TimestampedValueSerde<>(new IntegerSerde());
TimestampedValue<Integer> timestampedValue = new TimestampedValue<>(null, 1234L);
assertTrue(Arrays.equals(expectedBytes, timestampedValueSerde.toBytes(timestampedValue)));
}
Aggregations