-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from NickBurkard/master
Support Scala 2.13 & Flink 1.15
- Loading branch information
Showing
38 changed files
with
1,767 additions
and
175 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
sbt.version = 1.5.5 | ||
sbt.version = 1.6.1 |
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.10.0-RC1") | ||
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.10") | ||
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.5.2") | ||
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.7") | ||
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2") | ||
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2") | ||
addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.10.0-RC1") | ||
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.10") | ||
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.5.2") | ||
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.7") | ||
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2") | ||
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.2") | ||
addSbtPlugin("io.github.davidgregory084" % "sbt-tpolecat" % "0.1.20") |
110 changes: 110 additions & 0 deletions
110
src/main/java/io/findify/flinkadt/api/serializer/ScalaCaseClassSerializerSnapshot.java
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,110 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.findify.flinkadt.api.serializer; | ||
|
||
import org.apache.flink.annotation.Internal; | ||
import org.apache.flink.api.common.typeutils.CompositeTypeSerializerSnapshot; | ||
import org.apache.flink.api.common.typeutils.TypeSerializer; | ||
import org.apache.flink.api.common.typeutils.TypeSerializerConfigSnapshot; | ||
import org.apache.flink.api.common.typeutils.TypeSerializerSnapshot; | ||
import org.apache.flink.core.memory.DataInputView; | ||
import org.apache.flink.core.memory.DataOutputView; | ||
import org.apache.flink.util.InstantiationUtil; | ||
|
||
import java.io.IOException; | ||
import java.util.Objects; | ||
|
||
import static org.apache.flink.util.Preconditions.checkNotNull; | ||
import static org.apache.flink.util.Preconditions.checkState; | ||
|
||
/** {@link TypeSerializerSnapshot} for {@link ScalaCaseClassSerializer}. */ | ||
@Internal | ||
public final class ScalaCaseClassSerializerSnapshot<T extends scala.Product> | ||
extends CompositeTypeSerializerSnapshot<T, ScalaCaseClassSerializer<T>> { | ||
|
||
private static final int VERSION = 2; | ||
|
||
private Class<T> type; | ||
|
||
/** Used via reflection. */ | ||
@SuppressWarnings("unused") | ||
public ScalaCaseClassSerializerSnapshot() { | ||
super(ScalaCaseClassSerializer.class); | ||
} | ||
|
||
/** | ||
* Used for delegating schema compatibility checks from serializers that were previously using | ||
* {@code TupleSerializerConfigSnapshot}. Type is the {@code outerSnapshot} information, that is | ||
* required to perform {@link #internalResolveSchemaCompatibility(TypeSerializer, | ||
* TypeSerializerSnapshot[])}. | ||
* | ||
* <p>This is used in {@link | ||
* ScalaCaseClassSerializer#resolveSchemaCompatibilityViaRedirectingToNewSnapshotClass(TypeSerializerConfigSnapshot)}. | ||
*/ | ||
@Internal | ||
ScalaCaseClassSerializerSnapshot(Class<T> type) { | ||
super(ScalaCaseClassSerializer.class); | ||
this.type = checkNotNull(type, "type can not be NULL"); | ||
} | ||
|
||
/** Used for the snapshot path. */ | ||
public ScalaCaseClassSerializerSnapshot(ScalaCaseClassSerializer<T> serializerInstance) { | ||
super(serializerInstance); | ||
this.type = checkNotNull(serializerInstance.getTupleClass(), "tuple class can not be NULL"); | ||
} | ||
|
||
@Override | ||
protected int getCurrentOuterSnapshotVersion() { | ||
return VERSION; | ||
} | ||
|
||
@Override | ||
protected TypeSerializer<?>[] getNestedSerializers( | ||
ScalaCaseClassSerializer<T> outerSerializer) { | ||
return outerSerializer.getFieldSerializers(); | ||
} | ||
|
||
@Override | ||
protected ScalaCaseClassSerializer<T> createOuterSerializerWithNestedSerializers( | ||
TypeSerializer<?>[] nestedSerializers) { | ||
checkState(type != null, "type can not be NULL"); | ||
return new ScalaCaseClassSerializer<>(type, nestedSerializers); | ||
} | ||
|
||
@Override | ||
protected void writeOuterSnapshot(DataOutputView out) throws IOException { | ||
checkState(type != null, "type can not be NULL"); | ||
out.writeUTF(type.getName()); | ||
} | ||
|
||
@Override | ||
protected void readOuterSnapshot( | ||
int readOuterSnapshotVersion, DataInputView in, ClassLoader userCodeClassLoader) | ||
throws IOException { | ||
this.type = InstantiationUtil.resolveClassByName(in, userCodeClassLoader); | ||
} | ||
|
||
@Override | ||
protected CompositeTypeSerializerSnapshot.OuterSchemaCompatibility | ||
resolveOuterSchemaCompatibility(ScalaCaseClassSerializer<T> newSerializer) { | ||
return (Objects.equals(type, newSerializer.getTupleClass())) | ||
? OuterSchemaCompatibility.COMPATIBLE_AS_IS | ||
: OuterSchemaCompatibility.INCOMPATIBLE; | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
src/main/java/io/findify/flinkadt/api/serializer/ScalaEitherSerializerSnapshot.java
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,69 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.findify.flinkadt.api.serializer; | ||
|
||
import org.apache.flink.api.common.typeutils.CompositeTypeSerializerSnapshot; | ||
import org.apache.flink.api.common.typeutils.TypeSerializer; | ||
|
||
import scala.util.Either; | ||
|
||
/** | ||
* Configuration snapshot for serializers of Scala's {@link Either} type, containing configuration | ||
* snapshots of the Left and Right serializers. | ||
*/ | ||
public class ScalaEitherSerializerSnapshot<L, R> | ||
extends CompositeTypeSerializerSnapshot<Either<L, R>, EitherSerializer<L, R>> { | ||
|
||
private static final int CURRENT_VERSION = 1; | ||
|
||
/** Constructor for read instantiation. */ | ||
public ScalaEitherSerializerSnapshot() { | ||
super(EitherSerializer.class); | ||
} | ||
|
||
/** Constructor to create the snapshot for writing. */ | ||
public ScalaEitherSerializerSnapshot(EitherSerializer<L, R> eitherSerializer) { | ||
super(eitherSerializer); | ||
} | ||
|
||
@Override | ||
public int getCurrentOuterSnapshotVersion() { | ||
return CURRENT_VERSION; | ||
} | ||
|
||
@Override | ||
protected EitherSerializer<L, R> createOuterSerializerWithNestedSerializers( | ||
TypeSerializer<?>[] nestedSerializers) { | ||
@SuppressWarnings("unchecked") | ||
TypeSerializer<L> leftSerializer = (TypeSerializer<L>) nestedSerializers[0]; | ||
|
||
@SuppressWarnings("unchecked") | ||
TypeSerializer<R> rightSerializer = (TypeSerializer<R>) nestedSerializers[1]; | ||
|
||
return new EitherSerializer<>(leftSerializer, rightSerializer); | ||
} | ||
|
||
@Override | ||
protected TypeSerializer<?>[] getNestedSerializers(EitherSerializer<L, R> outerSerializer) { | ||
return new TypeSerializer<?>[] { | ||
outerSerializer.getLeftSerializer(), outerSerializer.getRightSerializer() | ||
}; | ||
} | ||
} | ||
|
60 changes: 60 additions & 0 deletions
60
src/main/java/io/findify/flinkadt/api/serializer/ScalaOptionSerializerSnapshot.java
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,60 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package io.findify.flinkadt.api.serializer; | ||
|
||
import org.apache.flink.api.common.typeutils.CompositeTypeSerializerSnapshot; | ||
import org.apache.flink.api.common.typeutils.TypeSerializer; | ||
import org.apache.flink.api.common.typeutils.TypeSerializerSnapshot; | ||
|
||
import scala.Option; | ||
|
||
/** A {@link TypeSerializerSnapshot} for the Scala {@link OptionSerializer}. */ | ||
public final class ScalaOptionSerializerSnapshot<E> | ||
extends CompositeTypeSerializerSnapshot<Option<E>, OptionSerializer<E>> { | ||
|
||
private static final int VERSION = 2; | ||
|
||
@SuppressWarnings("WeakerAccess") | ||
public ScalaOptionSerializerSnapshot() { | ||
super(OptionSerializer.class); | ||
} | ||
|
||
public ScalaOptionSerializerSnapshot(OptionSerializer<E> serializerInstance) { | ||
super(serializerInstance); | ||
} | ||
|
||
@Override | ||
protected int getCurrentOuterSnapshotVersion() { | ||
return VERSION; | ||
} | ||
|
||
@Override | ||
protected TypeSerializer<?>[] getNestedSerializers(OptionSerializer<E> outerSerializer) { | ||
return new TypeSerializer[] {outerSerializer.elemSerializer()}; | ||
} | ||
|
||
@Override | ||
protected OptionSerializer<E> createOuterSerializerWithNestedSerializers( | ||
TypeSerializer<?>[] nestedSerializers) { | ||
@SuppressWarnings("unchecked") | ||
TypeSerializer<E> nestedSerializer = (TypeSerializer<E>) nestedSerializers[0]; | ||
return new OptionSerializer<>(nestedSerializer); | ||
} | ||
} | ||
|
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
Oops, something went wrong.