

# Operators

Operators transform one or more DataStreams into a new DataStream. Programs can combine multiple transformations into sophisticated dataflow topologies.

This section gives a description of the basic transformations, the effective physical partitioning after applying those as well as insights into Flink’s operator chaining.

# DataStream Transformations

| Transformation | Description |
| --- | --- |
| **Map**
DataStream → DataStream | Takes one element and produces one element. A map function that doubles the values of the input stream:



```
DataStream&lt;Integer&gt; dataStream = //...
dataStream.map(new MapFunction&lt;Integer, Integer&gt;() {
    @Override
    public Integer map(Integer value) throws Exception {
        return 2 * value;
    }
}); 
```



 |
| **FlatMap**
DataStream → DataStream | Takes one element and produces zero, one, or more elements. A flatmap function that splits sentences to words:



```
dataStream.flatMap(new FlatMapFunction&lt;String, String&gt;() {
    @Override
    public void flatMap(String value, Collector&lt;String&gt; out)
        throws Exception {
        for(String word: value.split(" ")){
            out.collect(word);
        }
    }
}); 
```



 |
| **Filter**
DataStream → DataStream | Evaluates a boolean function for each element and retains those for which the function returns true. A filter that filters out zero values:



```
dataStream.filter(new FilterFunction&lt;Integer&gt;() {
    @Override
    public boolean filter(Integer value) throws Exception {
        return value != 0;
    }
}); 
```



 |
| **KeyBy**
DataStream → KeyedStream | Logically partitions a stream into disjoint partitions. All records with the same key are assigned to the same partition. Internally, _keyBy()_ is implemented with hash partitioning. There are different ways to [specify keys](//ci.apache.org/projects/flink/flink-docs-release-1.7/dev/api_concepts.html#specifying-keys).This transformation returns a _KeyedStream_, which is, among other things, required to use [keyed state](//ci.apache.org/projects/flink/flink-docs-release-1.7/dev/stream/state/state.html#keyed-state).



```
dataStream.keyBy("someKey") // Key by field "someKey"
dataStream.keyBy(0) // Key by the first element of a Tuple 
```



Attention A type **cannot be a key** if:

1.  it is a POJO type but does not override the _hashCode()_ method and relies on the _Object.hashCode()_ implementation.
2.  it is an array of any type.

 |
| **Reduce**
KeyedStream → DataStream | A "rolling" reduce on a keyed data stream. Combines the current element with the last reduced value and emits the new value.

A reduce function that creates a stream of partial sums:



```
keyedStream.reduce(new ReduceFunction&lt;Integer&gt;() {
    @Override
    public Integer reduce(Integer value1, Integer value2)
    throws Exception {
        return value1 + value2;
    }
}); 
```



 |
| **Fold**
KeyedStream → DataStream | A "rolling" fold on a keyed data stream with an initial value. Combines the current element with the last folded value and emits the new value.

A fold function that, when applied on the sequence (1,2,3,4,5), emits the sequence "start-1", "start-1-2", "start-1-2-3", ...



```
DataStream&lt;String&gt; result =
  keyedStream.fold("start", new FoldFunction&lt;Integer, String&gt;() {
    @Override
    public String fold(String current, Integer value) {
        return current + "-" + value;
    }
  }); 
```



 |
| **Aggregations**
KeyedStream → DataStream | Rolling aggregations on a keyed data stream. The difference between min and minBy is that min returns the minimum value, whereas minBy returns the element that has the minimum value in this field (same for max and maxBy).



```
keyedStream.sum(0);
keyedStream.sum("key");
keyedStream.min(0);
keyedStream.min("key");
keyedStream.max(0);
keyedStream.max("key");
keyedStream.minBy(0);
keyedStream.minBy("key");
keyedStream.maxBy(0);
keyedStream.maxBy("key"); 
```



 |
| **Window**
KeyedStream → WindowedStream | Windows can be defined on already partitioned KeyedStreams. Windows group the data in each key according to some characteristic (e.g., the data that arrived within the last 5 seconds). See [windows](windows.html) for a complete description of windows.



```
dataStream.keyBy(0).window(TumblingEventTimeWindows.of(Time.seconds(5))); // Last 5 seconds of data 
```



 |
| **WindowAll**
DataStream → AllWindowedStream | Windows can be defined on regular DataStreams. Windows group all the stream events according to some characteristic (e.g., the data that arrived within the last 5 seconds). See [windows](windows.html) for a complete description of windows.**WARNING:** This is in many cases a **non-parallel** transformation. All records will be gathered in one task for the windowAll operator.



```
dataStream.windowAll(TumblingEventTimeWindows.of(Time.seconds(5))); // Last 5 seconds of data 
```



 |
| **Window Apply**
WindowedStream → DataStream
AllWindowedStream → DataStream | Applies a general function to the window as a whole. Below is a function that manually sums the elements of a window.**Note:** If you are using a windowAll transformation, you need to use an AllWindowFunction instead.



```
windowedStream.apply (new WindowFunction&lt;Tuple2&lt;String,Integer&gt;, Integer, Tuple, Window&gt;() {
    public void apply (Tuple tuple,
            Window window,
            Iterable&lt;Tuple2&lt;String, Integer&gt;&gt; values,
            Collector&lt;Integer&gt; out) throws Exception {
        int sum = 0;
        for (value t: values) {
            sum += t.f1;
        }
        out.collect (new Integer(sum));
    }
});

// applying an AllWindowFunction on non-keyed window stream
allWindowedStream.apply (new AllWindowFunction&lt;Tuple2&lt;String,Integer&gt;, Integer, Window&gt;() {
    public void apply (Window window,
            Iterable&lt;Tuple2&lt;String, Integer&gt;&gt; values,
            Collector&lt;Integer&gt; out) throws Exception {
        int sum = 0;
        for (value t: values) {
            sum += t.f1;
        }
        out.collect (new Integer(sum));
    }
}); 
```



 |
| **Window Reduce**
WindowedStream → DataStream | Applies a functional reduce function to the window and returns the reduced value.



```
windowedStream.reduce (new ReduceFunction&lt;Tuple2&lt;String,Integer&gt;&gt;() {
    public Tuple2&lt;String, Integer&gt; reduce(Tuple2&lt;String, Integer&gt; value1, Tuple2&lt;String, Integer&gt; value2) throws Exception {
        return new Tuple2&lt;String,Integer&gt;(value1.f0, value1.f1 + value2.f1);
    }
}); 
```



 |
| **Window Fold**
WindowedStream → DataStream | Applies a functional fold function to the window and returns the folded value. The example function, when applied on the sequence (1,2,3,4,5), folds the sequence into the string "start-1-2-3-4-5":



```
windowedStream.fold("start", new FoldFunction&lt;Integer, String&gt;() {
    public String fold(String current, Integer value) {
        return current + "-" + value;
    }
}); 
```



 |
| **Aggregations on windows**
WindowedStream → DataStream | Aggregates the contents of a window. The difference between min and minBy is that min returns the minimum value, whereas minBy returns the element that has the minimum value in this field (same for max and maxBy).



```
windowedStream.sum(0);
windowedStream.sum("key");
windowedStream.min(0);
windowedStream.min("key");
windowedStream.max(0);
windowedStream.max("key");
windowedStream.minBy(0);
windowedStream.minBy("key");
windowedStream.maxBy(0);
windowedStream.maxBy("key"); 
```



 |
| **Union**
DataStream* → DataStream | Union of two or more data streams creating a new stream containing all the elements from all the streams. Note: If you union a data stream with itself you will get each element twice in the resulting stream.



```
dataStream.union(otherStream1, otherStream2, ...); 
```



 |
| **Window Join**
DataStream,DataStream → DataStream | Join two data streams on a given key and a common window.



```
dataStream.join(otherStream)
    .where(&lt;key selector&gt;).equalTo(&lt;key selector&gt;)
    .window(TumblingEventTimeWindows.of(Time.seconds(3)))
    .apply (new JoinFunction () {...}); 
```



 |
| **Interval Join**
KeyedStream,KeyedStream → DataStream | Join two elements e1 and e2 of two keyed streams with a common key over a given time interval, so that e1.timestamp + lowerBound &lt;= e2.timestamp &lt;= e1.timestamp + upperBound



```
// this will join the two streams so that
// key1 == key2 && leftTs - 2 &lt; rightTs &lt; leftTs + 2
keyedStream.intervalJoin(otherKeyedStream)
    .between(Time.milliseconds(-2), Time.milliseconds(2)) // lower and upper bound
    .upperBoundExclusive(true) // optional
    .lowerBoundExclusive(true) // optional
    .process(new IntervalJoinFunction() {...}); 
```



 |
| **Window CoGroup**
DataStream,DataStream → DataStream | Cogroups two data streams on a given key and a common window.



```
dataStream.coGroup(otherStream)
    .where(0).equalTo(1)
    .window(TumblingEventTimeWindows.of(Time.seconds(3)))
    .apply (new CoGroupFunction () {...}); 
```



 |
| **Connect**
DataStream,DataStream → ConnectedStreams | "Connects" two data streams retaining their types. Connect allowing for shared state between the two streams.



```
DataStream&lt;Integer&gt; someStream = //...
DataStream&lt;String&gt; otherStream = //...

ConnectedStreams&lt;Integer, String&gt; connectedStreams = someStream.connect(otherStream); 
```



 |
| **CoMap, CoFlatMap**
ConnectedStreams → DataStream | Similar to map and flatMap on a connected data stream



```
connectedStreams.map(new CoMapFunction&lt;Integer, String, Boolean&gt;() {
    @Override
    public Boolean map1(Integer value) {
        return true;
    }

    @Override
    public Boolean map2(String value) {
        return false;
    }
});
connectedStreams.flatMap(new CoFlatMapFunction&lt;Integer, String, String&gt;() {

   @Override
   public void flatMap1(Integer value, Collector&lt;String&gt; out) {
       out.collect(value.toString());
   }

   @Override
   public void flatMap2(String value, Collector&lt;String&gt; out) {
       for (String word: value.split(" ")) {
         out.collect(word);
       }
   }
}); 
```



 |
| **Split**
DataStream → SplitStream | Split the stream into two or more streams according to some criterion.



```
SplitStream&lt;Integer&gt; split = someDataStream.split(new OutputSelector&lt;Integer&gt;() {
    @Override
    public Iterable&lt;String&gt; select(Integer value) {
        List&lt;String&gt; output = new ArrayList&lt;String&gt;();
        if (value % 2 == 0) {
            output.add("even");
        }
        else {
            output.add("odd");
        }
        return output;
    }
}); 
```



 |
| **Select**
SplitStream → DataStream | Select one or more streams from a split stream.



```
SplitStream&lt;Integer&gt; split;
DataStream&lt;Integer&gt; even = split.select("even");
DataStream&lt;Integer&gt; odd = split.select("odd");
DataStream&lt;Integer&gt; all = split.select("even","odd"); 
```



 |
| **Iterate**
DataStream → IterativeStream → DataStream | Creates a "feedback" loop in the flow, by redirecting the output of one operator to some previous operator. This is especially useful for defining algorithms that continuously update a model. The following code starts with a stream and applies the iteration body continuously. Elements that are greater than 0 are sent back to the feedback channel, and the rest of the elements are forwarded downstream. See [iterations](#iterations) for a complete description.



```
IterativeStream&lt;Long&gt; iteration = initialStream.iterate();
DataStream&lt;Long&gt; iterationBody = iteration.map (/*do something*/);
DataStream&lt;Long&gt; feedback = iterationBody.filter(new FilterFunction&lt;Long&gt;(){
    @Override
    public boolean filter(Long value) throws Exception {
        return value &gt; 0;
    }
});
iteration.closeWith(feedback);
DataStream&lt;Long&gt; output = iterationBody.filter(new FilterFunction&lt;Long&gt;(){
    @Override
    public boolean filter(Long value) throws Exception {
        return value &lt;= 0;
    }
}); 
```



 |
| **Extract Timestamps**
DataStream → DataStream | Extracts timestamps from records in order to work with windows that use event time semantics. See [Event Time](//ci.apache.org/projects/flink/flink-docs-release-1.7/dev/event_time.html).



```
stream.assignTimestamps (new TimeStampExtractor() {...}); 
```



 |

| Transformation | Description |
| --- | --- |
| **Map**
DataStream → DataStream | Takes one element and produces one element. A map function that doubles the values of the input stream:



```
dataStream.map { x =&gt; x * 2 } 
```



 |
| **FlatMap**
DataStream → DataStream | Takes one element and produces zero, one, or more elements. A flatmap function that splits sentences to words:



```
dataStream.flatMap { str =&gt; str.split(" ") } 
```



 |
| **Filter**
DataStream → DataStream | Evaluates a boolean function for each element and retains those for which the function returns true. A filter that filters out zero values:



```
dataStream.filter { _ != 0 } 
```



 |
| **KeyBy**
DataStream → KeyedStream | Logically partitions a stream into disjoint partitions, each partition containing elements of the same key. Internally, this is implemented with hash partitioning. See [keys](//ci.apache.org/projects/flink/flink-docs-release-1.7/dev/api_concepts.html#specifying-keys) on how to specify keys. This transformation returns a KeyedStream.



```
dataStream.keyBy("someKey") // Key by field "someKey" dataStream.keyBy(0) // Key by the first element of a Tuple 
```



 |
| **Reduce**
KeyedStream → DataStream | A "rolling" reduce on a keyed data stream. Combines the current element with the last reduced value and emits the new value.

A reduce function that creates a stream of partial sums:



```
keyedStream.reduce { _ + _ } 
```



&lt;/p&gt; |
| **Fold**
KeyedStream → DataStream | A "rolling" fold on a keyed data stream with an initial value. Combines the current element with the last folded value and emits the new value.

A fold function that, when applied on the sequence (1,2,3,4,5), emits the sequence "start-1", "start-1-2", "start-1-2-3", ...



```
val result: DataStream[String] =
    keyedStream.fold("start")((str, i) =&gt; { str + "-" + i }) 
```



 |
| **Aggregations**
KeyedStream → DataStream | Rolling aggregations on a keyed data stream. The difference between min and minBy is that min returns the minimum value, whereas minBy returns the element that has the minimum value in this field (same for max and maxBy).



```
keyedStream.sum(0)
keyedStream.sum("key")
keyedStream.min(0)
keyedStream.min("key")
keyedStream.max(0)
keyedStream.max("key")
keyedStream.minBy(0)
keyedStream.minBy("key")
keyedStream.maxBy(0)
keyedStream.maxBy("key") 
```



 |
| **Window**
KeyedStream → WindowedStream | Windows can be defined on already partitioned KeyedStreams. Windows group the data in each key according to some characteristic (e.g., the data that arrived within the last 5 seconds). See [windows](windows.html) for a description of windows.



```
dataStream.keyBy(0).window(TumblingEventTimeWindows.of(Time.seconds(5))) // Last 5 seconds of data 
```



 |
| **WindowAll**
DataStream → AllWindowedStream | Windows can be defined on regular DataStreams. Windows group all the stream events according to some characteristic (e.g., the data that arrived within the last 5 seconds). See [windows](windows.html) for a complete description of windows.**WARNING:** This is in many cases a **non-parallel** transformation. All records will be gathered in one task for the windowAll operator.



```
dataStream.windowAll(TumblingEventTimeWindows.of(Time.seconds(5))) // Last 5 seconds of data 
```



 |
| **Window Apply**
WindowedStream → DataStream
AllWindowedStream → DataStream | Applies a general function to the window as a whole. Below is a function that manually sums the elements of a window.**Note:** If you are using a windowAll transformation, you need to use an AllWindowFunction instead.



```
windowedStream.apply { WindowFunction }

// applying an AllWindowFunction on non-keyed window stream allWindowedStream.apply { AllWindowFunction } 
```



 |
| **Window Reduce**
WindowedStream → DataStream | Applies a functional reduce function to the window and returns the reduced value.



```
windowedStream.reduce { _ + _ } 
```



 |
| **Window Fold**
WindowedStream → DataStream | Applies a functional fold function to the window and returns the folded value. The example function, when applied on the sequence (1,2,3,4,5), folds the sequence into the string "start-1-2-3-4-5":



```
val result: DataStream[String] =
    windowedStream.fold("start", (str, i) =&gt; { str + "-" + i }) 
```



 |
| **Aggregations on windows**
WindowedStream → DataStream | Aggregates the contents of a window. The difference between min and minBy is that min returns the minimum value, whereas minBy returns the element that has the minimum value in this field (same for max and maxBy).



```
windowedStream.sum(0)
windowedStream.sum("key")
windowedStream.min(0)
windowedStream.min("key")
windowedStream.max(0)
windowedStream.max("key")
windowedStream.minBy(0)
windowedStream.minBy("key")
windowedStream.maxBy(0)
windowedStream.maxBy("key") 
```



 |
| **Union**
DataStream* → DataStream | Union of two or more data streams creating a new stream containing all the elements from all the streams. Note: If you union a data stream with itself you will get each element twice in the resulting stream.



```
dataStream.union(otherStream1, otherStream2, ...) 
```



 |
| **Window Join**
DataStream,DataStream → DataStream | Join two data streams on a given key and a common window.



```
dataStream.join(otherStream)
    .where(&lt;key selector&gt;).equalTo(&lt;key selector&gt;)
    .window(TumblingEventTimeWindows.of(Time.seconds(3)))
    .apply { ... } 
```



 |
| **Window CoGroup**
DataStream,DataStream → DataStream | Cogroups two data streams on a given key and a common window.



```
dataStream.coGroup(otherStream)
    .where(0).equalTo(1)
    .window(TumblingEventTimeWindows.of(Time.seconds(3)))
    .apply {} 
```



 |
| **Connect**
DataStream,DataStream → ConnectedStreams | "Connects" two data streams retaining their types, allowing for shared state between the two streams.



```
someStream : DataStream[Int] = ...
otherStream : DataStream[String] = ...

val connectedStreams = someStream.connect(otherStream) 
```



 |
| **CoMap, CoFlatMap**
ConnectedStreams → DataStream | Similar to map and flatMap on a connected data stream



```
connectedStreams.map(
    (_ : Int) =&gt; true,
    (_ : String) =&gt; false
)
connectedStreams.flatMap(
    (_ : Int) =&gt; true,
    (_ : String) =&gt; false
) 
```



 |
| **Split**
DataStream → SplitStream | Split the stream into two or more streams according to some criterion.



```
val split = someDataStream.split(
  (num: Int) =&gt;
    (num % 2) match {
      case 0 =&gt; List("even")
      case 1 =&gt; List("odd")
    }
) 
```



 |
| **Select**
SplitStream → DataStream | Select one or more streams from a split stream.



```
val even = split select "even"
val odd = split select "odd"
val all = split.select("even","odd") 
```



 |
| **Iterate**
DataStream → IterativeStream → DataStream | Creates a "feedback" loop in the flow, by redirecting the output of one operator to some previous operator. This is especially useful for defining algorithms that continuously update a model. The following code starts with a stream and applies the iteration body continuously. Elements that are greater than 0 are sent back to the feedback channel, and the rest of the elements are forwarded downstream. See [iterations](#iterations) for a complete description.



```
initialStream.iterate {
  iteration =&gt; {
    val iterationBody = iteration.map {/*do something*/}
    (iterationBody.filter(_ &gt; 0), iterationBody.filter(_ &lt;= 0))
  }
} 
```



 |
| **Extract Timestamps**
DataStream → DataStream | Extracts timestamps from records in order to work with windows that use event time semantics. See [Event Time](//ci.apache.org/projects/flink/flink-docs-release-1.7/dev/event_time.html).



```
stream.assignTimestamps { timestampExtractor } 
```



 |

Extraction from tuples, case classes and collections via anonymous pattern matching, like the following:



```
val data: DataStream[(Int, String, Double)] = // [...] data.map {
  case (id, name, temperature) => // [...] }
```



is not supported by the API out-of-the-box. To use this feature, you should use a [Scala API extension](//ci.apache.org/projects/flink/flink-docs-release-1.7/dev/scala_api_extensions.html).

The following transformations are available on data streams of Tuples:

| Transformation | Description |
| --- | --- |
| **Project**
DataStream → DataStream | Selects a subset of fields from the tuples



```
DataStream&lt;Tuple3&lt;Integer, Double, String&gt;&gt; in = // [...]
DataStream&lt;Tuple2&lt;String, Integer&gt;&gt; out = in.project(2,0);
```



 |

# Physical partitioning

Flink also gives low-level control (if desired) on the exact stream partitioning after a transformation, via the following functions.

| Transformation | Description |
| --- | --- |
| **Custom partitioning**
DataStream → DataStream | Uses a user-defined Partitioner to select the target task for each element.



```
dataStream.partitionCustom(partitioner, "someKey");
dataStream.partitionCustom(partitioner, 0); 
```



 |
| **Random partitioning**
DataStream → DataStream | Partitions elements randomly according to a uniform distribution.



```
dataStream.shuffle(); 
```



 |
| **Rebalancing (Round-robin partitioning)**
DataStream → DataStream | Partitions elements round-robin, creating equal load per partition. Useful for performance optimization in the presence of data skew.



```
dataStream.rebalance(); 
```



 |
| **Rescaling**
DataStream → DataStream | Partitions elements, round-robin, to a subset of downstream operations. This is useful if you want to have pipelines where you, for example, fan out from each parallel instance of a source to a subset of several mappers to distribute load but don't want the full rebalance that rebalance() would incur. This would require only local data transfers instead of transferring data over network, depending on other configuration values such as the number of slots of TaskManagers.The subset of downstream operations to which the upstream operation sends elements depends on the degree of parallelism of both the upstream and downstream operation. For example, if the upstream operation has parallelism 2 and the downstream operation has parallelism 6, then one upstream operation would distribute elements to three downstream operations while the other upstream operation would distribute to the other three downstream operations. If, on the other hand, the downstream operation has parallelism 2 while the upstream operation has parallelism 6 then three upstream operations would distribute to one downstream operation while the other three upstream operations would distribute to the other downstream operation.In cases where the different parallelisms are not multiples of each other one or several downstream operations will have a differing number of inputs from upstream operations.Please see this figure for a visualization of the connection pattern in the above example:![Checkpoint barriers in data streams](../img/rescale.svg)



```
dataStream.rescale(); 
```



 |
| **Broadcasting**
DataStream → DataStream | Broadcasts elements to every partition.



```
dataStream.broadcast(); 
```



 |

| Transformation | Description |
| --- | --- |
| **Custom partitioning**
DataStream → DataStream | Uses a user-defined Partitioner to select the target task for each element.



```
dataStream.partitionCustom(partitioner, "someKey")
dataStream.partitionCustom(partitioner, 0) 
```



 |
| **Random partitioning**
DataStream → DataStream | Partitions elements randomly according to a uniform distribution.



```
dataStream.shuffle() 
```



 |
| **Rebalancing (Round-robin partitioning)**
DataStream → DataStream | Partitions elements round-robin, creating equal load per partition. Useful for performance optimization in the presence of data skew.



```
dataStream.rebalance() 
```



 |
| **Rescaling**
DataStream → DataStream | Partitions elements, round-robin, to a subset of downstream operations. This is useful if you want to have pipelines where you, for example, fan out from each parallel instance of a source to a subset of several mappers to distribute load but don't want the full rebalance that rebalance() would incur. This would require only local data transfers instead of transferring data over network, depending on other configuration values such as the number of slots of TaskManagers.The subset of downstream operations to which the upstream operation sends elements depends on the degree of parallelism of both the upstream and downstream operation. For example, if the upstream operation has parallelism 2 and the downstream operation has parallelism 4, then one upstream operation would distribute elements to two downstream operations while the other upstream operation would distribute to the other two downstream operations. If, on the other hand, the downstream operation has parallelism 2 while the upstream operation has parallelism 4 then two upstream operations would distribute to one downstream operation while the other two upstream operations would distribute to the other downstream operations.In cases where the different parallelisms are not multiples of each other one or several downstream operations will have a differing number of inputs from upstream operations.&lt;/p&gt; Please see this figure for a visualization of the connection pattern in the above example: &lt;/p&gt;![Checkpoint barriers in data streams](../img/rescale.svg)



```
dataStream.rescale() 
```



 |
| **Broadcasting**
DataStream → DataStream | Broadcasts elements to every partition.



```
dataStream.broadcast() 
```



 |

# Task chaining and resource groups

Chaining two subsequent transformations means co-locating them within the same thread for better performance. Flink by default chains operators if this is possible (e.g., two subsequent map transformations). The API gives fine-grained control over chaining if desired:

Use `StreamExecutionEnvironment.disableOperatorChaining()` if you want to disable chaining in the whole job. For more fine grained control, the following functions are available. Note that these functions can only be used right after a DataStream transformation as they refer to the previous transformation. For example, you can use `someStream.map(...).startNewChain()`, but you cannot use `someStream.startNewChain()`.

A resource group is a slot in Flink, see [slots](//ci.apache.org/projects/flink/flink-docs-release-1.7/ops/config.html#configuring-taskmanager-processing-slots). You can manually isolate operators in separate slots if desired.

| Transformation | Description |
| --- | --- |
| Start new chain | Begin a new chain, starting with this operator. The two mappers will be chained, and filter will not be chained to the first mapper.



```
someStream.filter(...).map(...).startNewChain().map(...);
```



 |
| Disable chaining | Do not chain the map operator



```
someStream.map(...).disableChaining();
```



 |
| Set slot sharing group | Set the slot sharing group of an operation. Flink will put operations with the same slot sharing group into the same slot while keeping operations that don't have the slot sharing group in other slots. This can be used to isolate slots. The slot sharing group is inherited from input operations if all input operations are in the same slot sharing group. The name of the default slot sharing group is "default", operations can explicitly be put into this group by calling slotSharingGroup("default").



```
someStream.filter(...).slotSharingGroup("name");
```



 |

| Transformation | Description |
| --- | --- |
| Start new chain | Begin a new chain, starting with this operator. The two mappers will be chained, and filter will not be chained to the first mapper.



```
someStream.filter(...).map(...).startNewChain().map(...)
```



 |
| Disable chaining | Do not chain the map operator



```
someStream.map(...).disableChaining()
```



 |
| Set slot sharing group | Set the slot sharing group of an operation. Flink will put operations with the same slot sharing group into the same slot while keeping operations that don't have the slot sharing group in other slots. This can be used to isolate slots. The slot sharing group is inherited from input operations if all input operations are in the same slot sharing group. The name of the default slot sharing group is "default", operations can explicitly be put into this group by calling slotSharingGroup("default").



```
someStream.filter(...).slotSharingGroup("name")
```



 |

