CPN ML:如何从列表中获取包含特定元素的产品

时间:2018-03-29 20:26:49

标签: ml cpn-tools

我试图使用参数a和bs创建一个函数,这将检查列表bs是否包含第一个元素是a的产品。 如果列表bs包含第一个元素为a的产品,则返回该产品。

该函数提供了与文件相关的非描述性错误" evalloop.sml"。

public void dump( String kafka_topic ) {

    // Serializers/deserializers (serde) for key and value types
    final Serde<Long> long_serde = Serdes.Long();
    final Serde< TsdbObject > tsdb_object_serde = 
        Serdes.serdeFrom( new TsdbObject.TsdbObjectSerializer(), 
                          new TsdbObject.TsdbObjectDeserializer() );

    StreamsBuilder streams_builder = new StreamsBuilder();
    KStream< Long, TsdbObject > kstream = 
        streams_builder.stream( kafka_topic, Consumed.with( long_serde, tsdb_object_serde ) );

    // Add final operator, to print results to stdout:
    Printed< Long, TsdbObject > printed = Printed.toSysOut();
    kstream.print( printed );

    Map<String, Object> kstreams_props = new HashMap<>();
    kstreams_props.put(StreamsConfig.APPLICATION_ID_CONFIG, "DumpKafkaTopic");
    kstreams_props.put(StreamsConfig.BOOTSTRAP_SERVERS_CONFIG, "localhost:9092");

    // make sure to consume the complete topic via "auto.offset.reset = earliest"
    kstreams_props.put( ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");

    StreamsConfig kstreams_config = new StreamsConfig(kstreams_props);

    KafkaStreams kstreams = new KafkaStreams( streams_builder.build(), kstreams_config );
    System.out.println( "Starting DumpKafkaTopic stream " );

    kstreams.start();

    // Add shutdown hook to respond to SIGTERM and gracefully close Kafka Streams (from https://www.confluent.io/blog/data-reprocessing-with-kafka-streams-resetting-a-streams-application/)
    Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println( "Stopping DumpKafkaTopic stream " );
                kstreams.close();
            }
        }));                
}

0 个答案:

没有答案