Skip to content

Commit 2a6f5bb

Browse files
committed
Update README
1 parent 7d456f1 commit 2a6f5bb

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

README.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,29 @@ OCaml (and dune), Rust (and cargo), and C++ (and CMake and Ninja).
1313

1414
A basic streaming word-count application can be written in functional-style as follows:
1515
```
16-
val wordcounts = lines
17-
.flatmap(_.split(" "))
18-
.keyby(_)
19-
.window(
20-
length = 10min,
21-
stride = 3min
22-
)
23-
.count()
16+
def main() =
17+
source(topic: "text")
18+
.flatmap(fun(line: String) = line.split(" "))
19+
.keyby(fun(word) = word)
20+
.window(length = 10min, step = 3min, aggregate = count)
21+
.sink(topic: "wordcount")
2422
```
2523

2624
The same code can also be written using a more declarative, relational-style, syntax. This concept is borrowed from [Morel](https://github.com/julianhyde/morel) and applied to streaming data.
2725

2826
```
29-
val wordcounts =
30-
from
31-
line in lines,
32-
word in line.split(" ")
33-
keyby word
34-
window
35-
length = 10min
36-
stride = 3min
37-
reduce count
38-
identity 1;
27+
def main() =
28+
from line: String in source(topic: "text"),
29+
word in line.split(" ") {
30+
group word
31+
window count as w {
32+
length 10min
33+
step 3min
34+
compute count
35+
}
36+
select {word, w.count}
37+
into sink(topic: "wordcount")
38+
}
3939
```
4040

4141
## Feature highlights

0 commit comments

Comments
 (0)