本文整理汇总了Java中org.apache.kafka.streams.kstream.ValueTransformerSupplier类的典型用法代码示例。如果您正苦于以下问题:Java ValueTransformerSupplier类的具体用法?Java ValueTransformerSupplier怎么用?Java ValueTransformerSupplier使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ValueTransformerSupplier类属于org.apache.kafka.streams.kstream包,在下文中一共展示了ValueTransformerSupplier类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: transformValues
import org.apache.kafka.streams.kstream.ValueTransformerSupplier; //导入依赖的package包/类
@Override
public <V1> KStream<K, V1> transformValues(ValueTransformerSupplier<? super V, ? extends V1> valueTransformerSupplier, String... stateStoreNames) {
Objects.requireNonNull(valueTransformerSupplier, "valueTransformSupplier can't be null");
String name = topology.newName(TRANSFORMVALUES_NAME);
topology.addProcessor(name, new KStreamTransformValues<>(valueTransformerSupplier), this.name);
topology.connectProcessorAndStateStores(name, stateStoreNames);
return new KStreamImpl<>(topology, name, sourceNodes, this.repartitionRequired);
}
示例2: KStreamTransformValues
import org.apache.kafka.streams.kstream.ValueTransformerSupplier; //导入依赖的package包/类
public KStreamTransformValues(ValueTransformerSupplier<V, R> valueTransformerSupplier) {
this.valueTransformerSupplier = valueTransformerSupplier;
}
示例3: testTransform
import org.apache.kafka.streams.kstream.ValueTransformerSupplier; //导入依赖的package包/类
@Test
public void testTransform() {
KStreamBuilder builder = new KStreamBuilder();
ValueTransformerSupplier<Number, Integer> valueTransformerSupplier =
new ValueTransformerSupplier<Number, Integer>() {
public ValueTransformer<Number, Integer> get() {
return new ValueTransformer<Number, Integer>() {
private int total = 0;
@Override
public void init(ProcessorContext context) {
}
@Override
public Integer transform(Number value) {
total += value.intValue();
return total;
}
@Override
public Integer punctuate(long timestamp) {
return null;
}
@Override
public void close() {
}
};
}
};
final int[] expectedKeys = {1, 10, 100, 1000};
KStream<Integer, Integer> stream;
MockProcessorSupplier<Integer, Integer> processor = new MockProcessorSupplier<>();
stream = builder.stream(intSerde, intSerde, topicName);
stream.transformValues(valueTransformerSupplier).process(processor);
driver = new KStreamTestDriver(builder);
for (int expectedKey : expectedKeys) {
driver.process(topicName, expectedKey, expectedKey * 10);
}
assertEquals(4, processor.processed.size());
String[] expected = {"1:10", "10:110", "100:1110", "1000:11110"};
for (int i = 0; i < expected.length; i++) {
assertEquals(expected[i], processor.processed.get(i));
}
}
示例4: transformValues
import org.apache.kafka.streams.kstream.ValueTransformerSupplier; //导入依赖的package包/类
/**
* @param <R>
* @param valueTransformerSupplier
* @param stateStoreNames
* @return
* @see org.apache.kafka.streams.kstream.KStream#transformValues(org.apache.kafka.streams.kstream.ValueTransformerSupplier, java.lang.String[])
*/
public <R> KStream<K, R> transformValues(ValueTransformerSupplier<V, R> valueTransformerSupplier,
String... stateStoreNames) {
return delegate.transformValues(valueTransformerSupplier, stateStoreNames);
}