在Scala中使用SinkFunction创建我自己的水槽

在Scala中使用SinkFunction创建我自己的水槽,scala,apache-flink,Scala,Apache Flink,我想使用scala for Flink创建自己的接收器,为此我需要扩展接口 但是我不能重写下面的invoke方法 default void invoke(IN value, Context context) throws Exception { invoke(value); } 这是我的代码: class MySinkFunction(schema: String) extends SinkFunction[List[GenericRecord]] { override def

我想使用scala for Flink创建自己的接收器,为此我需要扩展接口

但是我不能重写下面的invoke方法

default void invoke(IN value, Context context) throws Exception {
    invoke(value);
}
这是我的代码:

class MySinkFunction(schema: String) extends SinkFunction[List[GenericRecord]] {
    override def invoke(elements: List[GenericRecord], context: Context) { ... }
这会产生以下错误:

Type Context takes type parameters
如果我更改代码以添加任何类型参数:

class MySinkFunction(schema: String) extends SinkFunction[List[GenericRecord]] {
    override def invoke(elements: List[GenericRecord], context: Context[Xpto]) { ... }
错误消息不同:

Method `invoke` overrides nothing.
我是Scala的新手,有没有什么东西可以修复我所缺少的

我在scala中看到的所有方法都使用以下不推荐的方法:

/**
 * @deprecated Use {@link #invoke(Object, Context)}.
 */
@Deprecated
default void invoke(IN value) throws Exception {}
并使用以下方法实现:

...

@Public // Interface might be extended in the future with additional methods.
interface Context<T> {

    /** Returns the current processing time. */
    long currentProcessingTime();

    /** Returns the current event-time watermark. */
    long currentWatermark();

    /**
     * Returns the timestamp of the current input record or {@code null} if the element does not
     * have an assigned timestamp.
     */
    Long timestamp();
}
。。。
@Public//接口将来可能会使用其他方法进行扩展。
接口上下文{
/**返回当前处理时间*/
长currentProcessingTime();
/**返回当前事件时间水印*/
长当前水印();
/**
*返回当前输入记录的时间戳或{@code null}(如果元素未返回)
*具有指定的时间戳。
*/
长时间戳();
}

这个
放错位置了吗,因为它没有用在Function.Context中的任何地方?

在这种情况下,您只需使用:

override def invoke(elements: List[GenericRecord], context: SinkFunction.Context[_]) { ... }

而且它应该像一个符咒一样工作。

谢谢,就这样!