当前位置: 首页>>代码示例>>Java>>正文


Java ValueTransformerSupplier类代码示例

本文整理汇总了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);
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:11,代码来源:KStreamImpl.java

示例2: KStreamTransformValues

import org.apache.kafka.streams.kstream.ValueTransformerSupplier; //导入依赖的package包/类
public KStreamTransformValues(ValueTransformerSupplier<V, R> valueTransformerSupplier) {
    this.valueTransformerSupplier = valueTransformerSupplier;
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:4,代码来源:KStreamTransformValues.java

示例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));
    }
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:54,代码来源:KStreamTransformValuesTest.java

示例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);
}
 
开发者ID:nickman,项目名称:HeliosStreams,代码行数:12,代码来源:KStreamExt.java


注:本文中的org.apache.kafka.streams.kstream.ValueTransformerSupplier类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。