Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Do not evaluate isClassArityUsageDisabled on every serialize/des… #157

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import org.apache.flink.api.common.typeutils.TypeSerializer
import org.apache.flink.api.java.typeutils.runtime.TupleSerializerBase
import org.apache.flink.core.memory.{DataInputView, DataOutputView}
import org.apache.flink.types.NullFieldException
import org.apache.flinkx.api.serializer.CaseClassSerializer.isClassArityUsageDisabled
import org.slf4j.{Logger, LoggerFactory}

import scala.util.{Failure, Success, Try}
Expand Down Expand Up @@ -77,14 +78,6 @@ abstract class CaseClassSerializer[T <: Product](
createInstance(fields.toArray)
}

private def isClassArityUsageDisabled =
sys.env
.get("DISABLE_CASE_CLASS_ARITY_USAGE")
.exists(v =>
Try(v.toBoolean)
.getOrElse(false)
)

def serialize(value: T, target: DataOutputView): Unit = {
if (arity > 0 && !isClassArityUsageDisabled)
target.writeInt(value.productArity)
Expand Down Expand Up @@ -124,3 +117,13 @@ abstract class CaseClassSerializer[T <: Product](
createInstance(fields.filter(_ != null))
}
}

object CaseClassSerializer {
private val isClassArityUsageDisabled =
sys.env
.get("DISABLE_CASE_CLASS_ARITY_USAGE")
.exists(v =>
Try(v.toBoolean)
.getOrElse(false)
)
}
Loading