-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Variable #key won't be added to context after window nodes - tests fixed
If two or more window nodes are not separated by a union, then #key variable is created with null
- Loading branch information
Szymon Bogusz
committed
Jan 28, 2025
1 parent
9f5ee5a
commit eab62f6
Showing
5 changed files
with
91 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
...main/scala/pl/touk/nussknacker/engine/flink/util/transformer/aggregate/NoOpFunction.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package pl.touk.nussknacker.engine.flink.util.transformer.aggregate | ||
|
||
import org.apache.flink.api.common.functions.{OpenContext, RuntimeContext} | ||
import org.apache.flink.streaming.api.functions.windowing.ProcessWindowFunction | ||
import org.apache.flink.streaming.api.windowing.windows.TimeWindow | ||
import org.apache.flink.util.Collector | ||
import pl.touk.nussknacker.engine.api.runtimecontext.{ContextIdGenerator, EngineRuntimeContext} | ||
import pl.touk.nussknacker.engine.api.{Context => NkContext, ValueWithContext} | ||
import pl.touk.nussknacker.engine.flink.api.process.FlinkCustomNodeContext | ||
import pl.touk.nussknacker.engine.flink.util.keyed.KeyEnricher | ||
|
||
import java.lang | ||
|
||
class NoOpFunction(convertToEngineRuntimeContext: RuntimeContext => EngineRuntimeContext, nodeId: String) | ||
extends ProcessWindowFunction[AnyRef, ValueWithContext[AnyRef], String, TimeWindow] { | ||
|
||
@transient | ||
private var contextIdGenerator: ContextIdGenerator = _ | ||
|
||
override def open(openContext: OpenContext): Unit = { | ||
contextIdGenerator = convertToEngineRuntimeContext(getRuntimeContext).contextIdGenerator(nodeId) | ||
} | ||
|
||
override def process( | ||
key: String, | ||
context: ProcessWindowFunction[AnyRef, ValueWithContext[AnyRef], String, TimeWindow]#Context, | ||
values: lang.Iterable[AnyRef], | ||
out: Collector[ValueWithContext[AnyRef]] | ||
): Unit = { | ||
values.forEach({ value => | ||
out.collect( | ||
ValueWithContext(value, NkContext(contextIdGenerator.nextContextId())) | ||
) | ||
}) | ||
} | ||
|
||
} | ||
|
||
object NoOpFunction { | ||
def apply(fctx: FlinkCustomNodeContext): NoOpFunction = | ||
new NoOpFunction(fctx.convertToEngineRuntimeContext, fctx.nodeId) | ||
} |
Oops, something went wrong.