or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

async-operations.mddata-sources.mdfunction-interfaces.mdindex.mdkeyed-streams.mdoutput-operations.mdscala-extensions.mdstream-composition.mdstream-environment.mdstream-partitioning.mdstream-transformations.mdwindow-operations.mdwindowing.md

function-interfaces.mddocs/

0

# Function Interfaces and User-Defined Functions

1

2

Type-safe interfaces for implementing custom processing logic including window functions, process functions, and rich functions with lifecycle management.

3

4

## Window Function Interfaces

5

6

```scala { .api }

7

trait WindowFunction[IN, OUT, KEY, W <: Window] {

8

def apply(key: KEY, window: W, input: Iterable[IN], out: Collector[OUT]): Unit

9

}

10

11

abstract class ProcessWindowFunction[IN, OUT, KEY, W <: Window] {

12

def process(key: KEY, context: Context, elements: Iterable[IN], out: Collector[OUT]): Unit

13

def clear(context: Context): Unit

14

}

15

16

trait AllWindowFunction[IN, OUT, W <: Window] {

17

def apply(window: W, input: Iterable[IN], out: Collector[OUT]): Unit

18

}

19

```

20

21

## Rich Function Interfaces

22

23

```scala { .api }

24

abstract class RichWindowFunction[IN, OUT, KEY, W <: Window] extends WindowFunction[IN, OUT, KEY, W]

25

abstract class RichProcessWindowFunction[IN, OUT, KEY, W <: Window] extends ProcessWindowFunction[IN, OUT, KEY, W]

26

abstract class RichAllWindowFunction[IN, OUT, W <: Window] extends AllWindowFunction[IN, OUT, W]

27

```

28

29

## Async Function Interface

30

31

```scala { .api }

32

trait AsyncFunction[IN, OUT] {

33

def asyncInvoke(input: IN, collector: AsyncCollector[OUT]): Unit

34

}

35

```

36

37

Function interfaces provide type-safe contracts for implementing custom processing logic with access to runtime context, state, and timers.