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


Java Initializer类代码示例

本文整理汇总了Java中org.apache.kafka.streams.kstream.Initializer的典型用法代码示例。如果您正苦于以下问题:Java Initializer类的具体用法?Java Initializer怎么用?Java Initializer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Initializer类属于org.apache.kafka.streams.kstream包,在下文中一共展示了Initializer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: aggregate

import org.apache.kafka.streams.kstream.Initializer; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public <W extends Window, T> KTable<Windowed<K>, T> aggregate(final Initializer<T> initializer,
                                                              final Aggregator<? super K, ? super V, T> aggregator,
                                                              final Windows<W> windows,
                                                              final StateStoreSupplier<WindowStore> storeSupplier) {
    Objects.requireNonNull(initializer, "initializer can't be null");
    Objects.requireNonNull(aggregator, "aggregator can't be null");
    Objects.requireNonNull(windows, "windows can't be null");
    Objects.requireNonNull(storeSupplier, "storeSupplier can't be null");
    return (KTable<Windowed<K>, T>) doAggregate(
            new KStreamWindowAggregate<>(windows, storeSupplier.name(), initializer, aggregator),
            AGGREGATE_NAME,
            storeSupplier
    );
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:17,代码来源:KGroupedStreamImpl.java

示例2: aggregate

import org.apache.kafka.streams.kstream.Initializer; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public SchemaKTable aggregate(final Initializer initializer,
                              final UdafAggregator aggregator,
                              final WindowExpression windowExpression,
                              final Serde<GenericRow> topicValueSerDe,
                              final String storeName) {
  final KTable aggKtable;
  if (windowExpression != null) {
    final Materialized<String, GenericRow, ?> materialized
        = Materialized.<String, GenericRow, WindowStore<Bytes, byte[]>>as(storeName)
        .withKeySerde(Serdes.String())
        .withValueSerde(topicValueSerDe);

    final KsqlWindowExpression ksqlWindowExpression = windowExpression.getKsqlWindowExpression();
    aggKtable = ksqlWindowExpression.applyAggregate(kgroupedStream, initializer, aggregator, materialized);
  } else {
    aggKtable = kgroupedStream.aggregate(initializer, aggregator, Materialized.with(Serdes.String(), topicValueSerDe));
  }
  return new SchemaKTable(schema, aggKtable, keyField, sourceSchemaKStreams, windowExpression != null,
                          SchemaKStream.Type.AGGREGATE, functionRegistry, schemaRegistryClient);

}
 
开发者ID:confluentinc,项目名称:ksql,代码行数:23,代码来源:SchemaKGroupedStream.java

示例3: shouldCreateTumblingWindowAggregate

import org.apache.kafka.streams.kstream.Initializer; //导入依赖的package包/类
@Test
public void shouldCreateTumblingWindowAggregate() {
  final KGroupedStream stream = EasyMock.createNiceMock(KGroupedStream.class);
  final TimeWindowedKStream windowedKStream = EasyMock.createNiceMock(TimeWindowedKStream.class);
  final UdafAggregator aggregator = EasyMock.createNiceMock(UdafAggregator.class);
  final TumblingWindowExpression windowExpression = new TumblingWindowExpression(10, TimeUnit.SECONDS);
  final Initializer initializer = () -> 0;
  final Materialized<String, GenericRow, WindowStore<Bytes, byte[]>> store = Materialized.as("store");

  EasyMock.expect(stream.windowedBy(TimeWindows.of(10000L))).andReturn(windowedKStream);
  EasyMock.expect(windowedKStream.aggregate(same(initializer), same(aggregator), same(store))).andReturn(null);
  EasyMock.replay(stream, windowedKStream);

  windowExpression.applyAggregate(stream, initializer, aggregator, store);
  EasyMock.verify(stream, windowedKStream);
}
 
开发者ID:confluentinc,项目名称:ksql,代码行数:17,代码来源:TumblingWindowExpressionTest.java

示例4: shouldCreateHoppingWindowAggregate

import org.apache.kafka.streams.kstream.Initializer; //导入依赖的package包/类
@Test
public void shouldCreateHoppingWindowAggregate() {
  final KGroupedStream stream = EasyMock.createNiceMock(KGroupedStream.class);
  final TimeWindowedKStream windowedKStream = EasyMock.createNiceMock(TimeWindowedKStream.class);
  final UdafAggregator aggregator = EasyMock.createNiceMock(UdafAggregator.class);
  final HoppingWindowExpression windowExpression = new HoppingWindowExpression(10, TimeUnit.SECONDS, 4, TimeUnit.MILLISECONDS);
  final Initializer initializer = () -> 0;
  final Materialized<String, GenericRow, WindowStore<Bytes, byte[]>> store = Materialized.as("store");

  EasyMock.expect(stream.windowedBy(TimeWindows.of(10000L).advanceBy(4L))).andReturn(windowedKStream);
  EasyMock.expect(windowedKStream.aggregate(same(initializer), same(aggregator), same(store))).andReturn(null);
  EasyMock.replay(stream, windowedKStream);

  windowExpression.applyAggregate(stream, initializer, aggregator, store);
  EasyMock.verify(stream, windowedKStream);
}
 
开发者ID:confluentinc,项目名称:ksql,代码行数:17,代码来源:HoppingWindowExpressionTest.java

示例5: aggregate

import org.apache.kafka.streams.kstream.Initializer; //导入依赖的package包/类
@Override
public <T> KTable<K, T> aggregate(final Initializer<T> initializer,
                                  final Aggregator<? super K, ? super V, T> adder,
                                  final Aggregator<? super K, ? super V, T> subtractor,
                                  final Serde<T> aggValueSerde,
                                  final String queryableStoreName) {
    determineIsQueryable(queryableStoreName);
    return aggregate(initializer, adder, subtractor, keyValueStore(keySerde, aggValueSerde, getOrCreateName(queryableStoreName, AGGREGATE_NAME)));
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:10,代码来源:KGroupedTableImpl.java

示例6: KStreamSessionWindowAggregate

import org.apache.kafka.streams.kstream.Initializer; //导入依赖的package包/类
KStreamSessionWindowAggregate(final SessionWindows windows,
                              final String storeName,
                              final Initializer<T> initializer,
                              final Aggregator<? super K, ? super V, T> aggregator,
                              final Merger<? super K, T> sessionMerger) {
    this.windows = windows;
    this.storeName = storeName;
    this.initializer = initializer;
    this.aggregator = aggregator;
    this.sessionMerger = sessionMerger;
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:12,代码来源:KStreamSessionWindowAggregate.java

示例7: init

import org.apache.kafka.streams.kstream.Initializer; //导入依赖的package包/类
public Initializer<Long> init() {
    return new Initializer<Long>() {
        @Override
        public Long apply() {
            return 0L;
        }
    };
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:9,代码来源:SmokeTestUtil.java

示例8: applyAggregate

import org.apache.kafka.streams.kstream.Initializer; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public KTable applyAggregate(final KGroupedStream groupedStream,
                             final Initializer initializer,
                             final UdafAggregator aggregator,
                             final Materialized<String, GenericRow, ?> materialized) {
  return groupedStream.windowedBy(SessionWindows.with(sizeUnit.toMillis(gap)))
      .aggregate(initializer, aggregator, aggregator.getMerger(),
          materialized);
}
 
开发者ID:confluentinc,项目名称:ksql,代码行数:11,代码来源:SessionWindowExpression.java

示例9: applyAggregate

import org.apache.kafka.streams.kstream.Initializer; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public KTable applyAggregate(final KGroupedStream groupedStream,
                             final Initializer initializer,
                             final UdafAggregator aggregator,
                             final Materialized<String, GenericRow, ?> materialized) {
  return groupedStream.windowedBy(TimeWindows.of(sizeUnit.toMillis(size)))
      .aggregate(initializer, aggregator, materialized);

}
 
开发者ID:confluentinc,项目名称:ksql,代码行数:11,代码来源:TumblingWindowExpression.java

示例10: applyAggregate

import org.apache.kafka.streams.kstream.Initializer; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Override
public KTable applyAggregate(KGroupedStream groupedStream, Initializer initializer, UdafAggregator aggregator, Materialized<String, GenericRow, ?> materialized) {
  return groupedStream.windowedBy(TimeWindows.of(
      sizeUnit.toMillis(size))
      .advanceBy(
          advanceByUnit.toMillis(advanceBy)))
      .aggregate(initializer, aggregator, materialized);
}
 
开发者ID:confluentinc,项目名称:ksql,代码行数:10,代码来源:HoppingWindowExpression.java

示例11: KStreamWindowAggregate

import org.apache.kafka.streams.kstream.Initializer; //导入依赖的package包/类
public KStreamWindowAggregate(Windows<W> windows, String storeName, Initializer<T> initializer, Aggregator<? super K, ? super V, T> aggregator) {
    this.windows = windows;
    this.storeName = storeName;
    this.initializer = initializer;
    this.aggregator = aggregator;
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:7,代码来源:KStreamWindowAggregate.java

示例12: KTableAggregate

import org.apache.kafka.streams.kstream.Initializer; //导入依赖的package包/类
public KTableAggregate(String storeName, Initializer<T> initializer, Aggregator<? super K, ? super V, T> add, Aggregator<? super K, ? super V, T> remove) {
    this.storeName = storeName;
    this.initializer = initializer;
    this.add = add;
    this.remove = remove;
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:7,代码来源:KTableAggregate.java

示例13: KStreamAggregate

import org.apache.kafka.streams.kstream.Initializer; //导入依赖的package包/类
public KStreamAggregate(String storeName, Initializer<T> initializer, Aggregator<? super K, ? super V, T> aggregator) {
    this.storeName = storeName;
    this.initializer = initializer;
    this.aggregator = aggregator;
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:6,代码来源:KStreamAggregate.java

示例14: before

import org.apache.kafka.streams.kstream.Initializer; //导入依赖的package包/类
@Before
public void before() throws InterruptedException {
    testNo++;
    builder = new KStreamBuilder();
    createTopics();
    streamsConfiguration = new Properties();
    final String applicationId = "kgrouped-stream-test-" + testNo;
    streamsConfiguration.put(StreamsConfig.APPLICATION_ID_CONFIG, applicationId);
    streamsConfiguration
        .put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, CLUSTER.bootstrapServers());
    streamsConfiguration.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
    streamsConfiguration.put(StreamsConfig.STATE_DIR_CONFIG, TestUtils.tempDirectory().getPath());
    streamsConfiguration.put(StreamsConfig.CACHE_MAX_BYTES_BUFFERING_CONFIG, 0);
    streamsConfiguration.put(IntegrationTestUtils.INTERNAL_LEAVE_GROUP_ON_CLOSE, true);
    streamsConfiguration.put(StreamsConfig.COMMIT_INTERVAL_MS_CONFIG, 100);

    final KeyValueMapper<Integer, String, String> mapper = MockKeyValueMapper.SelectValueMapper();
    stream = builder.stream(Serdes.Integer(), Serdes.String(), streamOneInput);
    groupedStream = stream
        .groupBy(
            mapper,
            Serdes.String(),
            Serdes.String());

    reducer = new Reducer<String>() {
        @Override
        public String apply(final String value1, final String value2) {
            return value1 + ":" + value2;
        }
    };
    initializer = new Initializer<Integer>() {
        @Override
        public Integer apply() {
            return 0;
        }
    };
    aggregator = new Aggregator<String, String, Integer>() {
        @Override
        public Integer apply(final String aggKey, final String value, final Integer aggregate) {
            return aggregate + value.length();
        }
    };
}
 
开发者ID:YMCoding,项目名称:kafka-0.11.0.0-src-with-comment,代码行数:44,代码来源:KStreamAggregationIntegrationTest.java

示例15: applyAggregate

import org.apache.kafka.streams.kstream.Initializer; //导入依赖的package包/类
public abstract KTable applyAggregate(final KGroupedStream groupedStream,
final Initializer initializer,
final UdafAggregator aggregator,
final Materialized<String, GenericRow, ?> materialized);
 
开发者ID:confluentinc,项目名称:ksql,代码行数:5,代码来源:KsqlWindowExpression.java


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