目前正在基于Rust语言构建一款流式引擎框架,在完成第一版的开发工作后,计划将其开源,希望能为技术爱好者们提供一个共同学习和交流的平台。
在此想先和大家探讨一下,下面展示的用法是否符合大家的预期和使用习惯呢?
期待听到大家的反馈与建议!
// Build and execute the streaming pipeline
DataStream::new(source)
// Split text into words
.map(|line| {
line.split_whitespace()
.map(|s| s.to_lowercase())
.collect::<Vec<_>>()
})
// Parallelize the processing
.parallel(2)
// Create tumbling windows of 1 second
.window(WindowConfig::tumbling(Duration::from_millis(1000)))
// Count words in each window
.aggregate(HashMap::new(), |mut counts, words| {
for word in words {
*counts.entry(word).or_insert(0) += 1;
}
counts
})
// Write results to sink
.sink(sink.clone())
.await?;
1
共 2 条评论, 1 页
评论区
写评论哈哈,可以,慢慢抄
--
👇
taoistwar: 抄最新版的flink就行
抄最新版的flink就行