Skip to content

Commit

Permalink
Merge pull request #2 from xebialabs/dai/kryo-5
Browse files Browse the repository at this point in the history
Update to use the newer Kryo 5.5.0
  • Loading branch information
mayur9991 authored Aug 13, 2024
2 parents f69dfa0 + 5d5b14b commit b8fe269
Show file tree
Hide file tree
Showing 98 changed files with 1,014 additions and 1,026 deletions.
23 changes: 1 addition & 22 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,6 @@ jobs:
distribution: "temurin"
java-version: "17"
- run: 'sbt "; +scalafmtCheckAll; scalafmtSbtCheck" "; scalafixEnable; scalafix --check; test:scalafix --check"'
mimaReport:
runs-on: ubuntu-latest
steps:
- uses: "actions/checkout@v3"
- uses: actions/setup-java@v3
with:
cache: "sbt"
distribution: "temurin"
java-version: ${{matrix.java}}
- run: 'sbt "++${{matrix.scala}} mimaReportBinaryIssues"'
strategy:
matrix:
java:
- "8"
- "11"
- "17"
scala:
- "2.11.12"
- "2.12.17"
test:
runs-on: ubuntu-latest
steps:
Expand All @@ -44,12 +25,10 @@ jobs:
strategy:
matrix:
java:
- "8"
- "11"
- "17"
scala:
- "2.12.17"
- "2.13.8"
- "2.13.13"
testWithCoverageReport:
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Release Drafter
on:
push:
branches:
- develop
- dai/develop

jobs:
update_release_draft:
Expand Down
12 changes: 5 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Release
on:
push:
branches: [develop]
branches: [dai/develop]
tags: ["*"]
jobs:
publish:
Expand All @@ -13,11 +13,9 @@ jobs:
cache: "sbt"
distribution: "temurin"
java-version: "17"
- uses: olafurpg/setup-gpg@v3
- name: Publish ${{ github.ref }}
run: sbt ci-release
run: sbt publish
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
NEXUS_HOST: "nexus.xebialabs.com"
NEXUS_USERNAME: ${{ secrets.NEXUS_CI_USER }}
NEXUS_PASSWORD: ${{ secrets.NEXUS_CI_USER_PWD }}
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,5 @@ project/build/target/
project/plugins/target/
project/plugins/lib_managed/
project/plugins/src_managed/

/.bsp
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
[![Latest version](https://index.scala-lang.org/twitter/chill/chill/latest.svg?color=orange)](https://index.scala-lang.org/twitter/chill/chill)
[![Chat](https://badges.gitter.im/twitter/chill.svg)](https://gitter.im/twitter/chill?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

IMPORTANT: This is Digital.ai fork of twitter/chill. Please do not use it in your projects unless you are Digital.ai employee.

Extensions for the [Kryo serialization library](https://github.com/EsotericSoftware/kryo) including
serializers and a set of classes to ease configuration of Kryo in systems like Hadoop, Storm,
Akka, etc.
Expand Down
84 changes: 28 additions & 56 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import com.typesafe.tools.mima.plugin.MimaPlugin.mimaDefaultSettings

val akkaVersion = "2.6.20"
val algebirdVersion = "0.13.9"
val bijectionVersion = "0.9.7"
val kryoVersion = "4.0.2"
val kryoVersion = "5.6.0"
val scroogeVersion = "21.2.0"
val asmVersion = "4.16"
val protobufVersion = "3.22.2"
Expand All @@ -18,11 +16,12 @@ def scalaVersionSpecificFolders(srcBaseDir: java.io.File, scalaVersion: String):
}

val sharedSettings = Seq(
organization := "com.twitter",
scalaVersion := "2.11.12",
crossScalaVersions := Seq("2.11.12", "2.12.17", "2.13.8"),
organization := "com.xebialabs.chill",
scalaVersion := "2.13.13",
crossScalaVersions := Seq("2.11.12", "2.12.17", "2.13.13"),
scalacOptions ++= Seq("-unchecked", "-deprecation"),
scalacOptions ++= {
val credentialsFile = Path.userHome / ".sbt" / ".chill-credentials"
scalaVersion.value match {
case v if v.startsWith("2.11") => Seq("-Ywarn-unused", "-Ywarn-unused-import", "-target:jvm-1.8")
case _ => Seq("-Ywarn-unused", "-release", "8")
Expand Down Expand Up @@ -53,10 +52,10 @@ val sharedSettings = Seq(
"org.scalacheck" %% "scalacheck" % "1.15.2" % "test",
"org.scalatest" %% "scalatest" % "3.2.15" % "test",
"org.scalatestplus" %% "scalatestplus-scalacheck" % "3.1.0.0-RC2" % "test",
"com.esotericsoftware" % "kryo-shaded" % kryoVersion
"com.esotericsoftware" % "kryo5" % kryoVersion
),
Test / parallelExecution := true,
pomExtra := <url>https://github.com/twitter/chill</url>
pomExtra := <url>https://github.com/xebialabs/chill</url>
<licenses>
<license>
<name>Apache 2</name>
Expand Down Expand Up @@ -98,14 +97,12 @@ lazy val chillAll = Project(
).settings(sharedSettings)
.settings(noPublishSettings)
.settings(
mimaPreviousArtifacts := Set.empty,
crossScalaVersions := Nil
)
.aggregate(
chill,
chillBijection,
chillScrooge,
chillStorm,
chillJava,
chillHadoop,
chillThrift,
Expand All @@ -123,49 +120,15 @@ lazy val noPublishSettings = Seq(
publishArtifact := false
)

/**
* This returns the youngest jar we released that is compatible with the current.
*/
val unreleasedModules = Set[String]("akka")
val javaOnly = Set[String]("storm", "java", "hadoop", "thrift", "protobuf")
val binaryCompatVersion = "0.9.2"

def youngestForwardCompatible(subProj: String) =
Some(subProj)
.filterNot(unreleasedModules.contains)
.map { s =>
if (javaOnly.contains(s))
"com.twitter" % ("chill-" + s) % binaryCompatVersion
else
"com.twitter" %% ("chill-" + s) % binaryCompatVersion
}

val ignoredABIProblems = {
import com.typesafe.tools.mima.core._
import com.typesafe.tools.mima.core.ProblemFilters._
Seq(
exclude[MissingTypesProblem]("com.twitter.chill.storm.BlizzardKryoFactory"),
exclude[MissingTypesProblem]("com.twitter.chill.InnerClosureFinder"),
exclude[IncompatibleResultTypeProblem]("com.twitter.chill.InnerClosureFinder.visitMethod"),
exclude[IncompatibleResultTypeProblem]("com.twitter.chill.FieldAccessFinder.visitMethod"),
exclude[MissingClassProblem]("com.twitter.chill.FieldAccessFinder"),
exclude[MissingTypesProblem]("com.twitter.chill.FieldAccessFinder"),
exclude[DirectMissingMethodProblem]("com.twitter.chill.FieldAccessFinder.this"),
exclude[IncompatibleResultTypeProblem]("com.twitter.chill.Tuple1*Serializer.read"),
exclude[IncompatibleMethTypeProblem]("com.twitter.chill.Tuple1*Serializer.write"),
exclude[IncompatibleResultTypeProblem]("com.twitter.chill.Tuple2*Serializer.read"),
exclude[IncompatibleMethTypeProblem]("com.twitter.chill.Tuple2*Serializer.write")
)
}
val javaOnly = Set[String]("java", "hadoop", "thrift", "protobuf")

def module(name: String) = {
val id = "chill-%s".format(name)
Project(id = id, base = file(id))
.settings(sharedSettings)
.settings(
Keys.name := id,
mimaPreviousArtifacts := youngestForwardCompatible(name).toSet,
mimaBinaryIssueFilters ++= ignoredABIProblems,
// Disable cross publishing for java artifacts
publishArtifact :=
(if (javaOnly.contains(name) && scalaVersion.value.startsWith("2.11")) false else true)
Expand All @@ -180,8 +143,6 @@ lazy val chill = Project(
).settings(sharedSettings)
.settings(
name := "chill",
mimaPreviousArtifacts := Set("com.twitter" %% "chill" % binaryCompatVersion),
mimaBinaryIssueFilters ++= ignoredABIProblems,
libraryDependencies += "org.apache.xbean" % "xbean-asm7-shaded" % asmVersion
)
.dependsOn(chillJava)
Expand Down Expand Up @@ -216,15 +177,6 @@ lazy val chillJava = module("java").settings(
autoScalaLibrary := false
)

// This can only have java deps!
lazy val chillStorm = module("storm")
.settings(
crossPaths := false,
autoScalaLibrary := false,
libraryDependencies += "org.apache.storm" % "storm-core" % "2.4.0" % "provided"
)
.dependsOn(chillJava)

// This can only have java deps!
lazy val chillHadoop = module("hadoop")
.settings(
Expand Down Expand Up @@ -284,3 +236,23 @@ lazy val chillAlgebird = module("algebird")
)
)
.dependsOn(chill)

ThisBuild / dynverSeparator := "-"
ThisBuild / dynverSonatypeSnapshots := true
ThisBuild / publishMavenStyle := true

ThisBuild / publishTo := {
val nexus = "https://nexus.xebialabs.com/nexus/content/"
if (isSnapshot.value)
Some("snapshots".at(nexus + "repositories/snapshots"))
else
Some("releases".at(nexus + "repositories/releases"))
}

inThisBuild(
List(
scalaVersion := "2.13.13",
semanticdbEnabled := true,
semanticdbVersion := scalafixSemanticdb.revision
)
)
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ package com.twitter.chill.akka
*/
import akka.actor.{ActorPath, ActorRef, ExtendedActorSystem}
import akka.serialization.Serialization
import com.esotericsoftware.kryo.{Kryo, Serializer}
import com.esotericsoftware.kryo.io.{Input, Output}
import com.esotericsoftware.kryo.kryo5.{Kryo, Serializer}
import com.esotericsoftware.kryo.kryo5.io.{Input, Output}

import com.twitter.chill.{toRich, IKryoRegistrar}

Expand All @@ -34,7 +34,7 @@ class ActorRefSerializer(system: ExtendedActorSystem) extends Serializer[ActorRe
kryo.forSubclass[ActorRef](this)
}

override def read(kryo: Kryo, input: Input, typ: Class[ActorRef]): ActorRef = {
override def read(kryo: Kryo, input: Input, typ: Class[_ <: ActorRef]): ActorRef = {
val path = ActorPath.fromString(input.readString())
system.provider.resolveActorRef(path)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ limitations under the License.
*/
package com.twitter.chill.algebird

import com.esotericsoftware.kryo.Kryo
import com.esotericsoftware.kryo.serializers.FieldSerializer
import com.esotericsoftware.kryo.kryo5.Kryo
import com.esotericsoftware.kryo.kryo5.serializers.FieldSerializer

import com.twitter.chill.IKryoRegistrar

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ limitations under the License.
*/
package com.twitter.chill.algebird

import com.esotericsoftware.kryo.Kryo
import com.esotericsoftware.kryo.{Serializer => KSerializer}
import com.esotericsoftware.kryo.io.{Input, Output}
import com.esotericsoftware.kryo.kryo5.Kryo
import com.esotericsoftware.kryo.kryo5.{Serializer => KSerializer}
import com.esotericsoftware.kryo.kryo5.io.{Input, Output}

import com.twitter.algebird.{AveragedValue, DecayedValue, HLL, HyperLogLog, HyperLogLogMonoid, Moments, QTree}

Expand All @@ -29,7 +29,7 @@ class AveragedValueSerializer extends KSerializer[AveragedValue] {
out.writeLong(s.count, true)
out.writeDouble(s.value)
}
def read(kser: Kryo, in: Input, cls: Class[AveragedValue]): AveragedValue =
def read(kser: Kryo, in: Input, cls: Class[_ <: AveragedValue]): AveragedValue =
AveragedValue(in.readLong(true), in.readDouble)
}

Expand All @@ -42,7 +42,7 @@ class MomentsSerializer extends KSerializer[Moments] {
out.writeDouble(s.m3)
out.writeDouble(s.m4)
}
def read(kser: Kryo, in: Input, cls: Class[Moments]): Moments =
def read(kser: Kryo, in: Input, cls: Class[_ <: Moments]): Moments =
Moments(in.readLong(true), in.readDouble, in.readDouble, in.readDouble, in.readDouble)
}

Expand All @@ -52,7 +52,7 @@ class DecayedValueSerializer extends KSerializer[DecayedValue] {
out.writeDouble(s.value)
out.writeDouble(s.scaledTime)
}
def read(kser: Kryo, in: Input, cls: Class[DecayedValue]): DecayedValue =
def read(kser: Kryo, in: Input, cls: Class[_ <: DecayedValue]): DecayedValue =
DecayedValue(in.readDouble, in.readDouble)
}

Expand All @@ -63,7 +63,7 @@ class HLLSerializer extends KSerializer[HLL] {
out.writeInt(bytes.size, true)
out.writeBytes(bytes)
}
def read(kser: Kryo, in: Input, cls: Class[HLL]): HLL =
def read(kser: Kryo, in: Input, cls: Class[_ <: HLL]): HLL =
HyperLogLog.fromBytes(in.readBytes(in.readInt(true)))
}

Expand All @@ -72,15 +72,15 @@ class HLLMonoidSerializer extends KSerializer[HyperLogLogMonoid] {
val hllMonoids: MMap[Int, HyperLogLogMonoid] = MMap[Int, HyperLogLogMonoid]()
def write(kser: Kryo, out: Output, mon: HyperLogLogMonoid): Unit =
out.writeInt(mon.bits, true)
def read(kser: Kryo, in: Input, cls: Class[HyperLogLogMonoid]): HyperLogLogMonoid = {
def read(kser: Kryo, in: Input, cls: Class[_ <: HyperLogLogMonoid]): HyperLogLogMonoid = {
val bits = in.readInt(true)
hllMonoids.getOrElseUpdate(bits, new HyperLogLogMonoid(bits))
}
}

class QTreeSerializer extends KSerializer[QTree[Any]] {
setImmutable(true)
override def read(kryo: Kryo, input: Input, cls: Class[QTree[Any]]): QTree[Any] = {
override def read(kryo: Kryo, input: Input, cls: Class[_ <: QTree[Any]]): QTree[Any] = {
val (v1, v2, v3) = (input.readLong(), input.readInt(), input.readLong())
val v4 = kryo.readClassAndObject(input)
val v5 = kryo.readClassAndObject(input).asInstanceOf[Option[QTree[Any]]]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.twitter.chill.avro;

import avro.FiscalRecord;
import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.Serializer;
import com.esotericsoftware.kryo.kryo5.Kryo;
import com.esotericsoftware.kryo.kryo5.Serializer;
import com.esotericsoftware.kryo.kryo5.objenesis.strategy.StdInstantiatorStrategy;
import com.twitter.chill.KryoInstantiator;
import com.twitter.chill.KryoPool;
import org.apache.avro.Schema;
Expand All @@ -11,7 +12,6 @@
import org.apache.avro.generic.GenericRecordBuilder;
import org.junit.Before;
import org.junit.Test;
import org.objenesis.strategy.StdInstantiatorStrategy;
import scala.reflect.ClassTag;

import static org.junit.Assert.assertEquals;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ limitations under the License.

package com.twitter.chill

import com.twitter.bijection.Injection
import com.twitter.bijection.{Bijection, Bufferable, ImplicitBijection, Injection}

import scala.reflect.ClassTag
Expand All @@ -32,7 +31,7 @@ object BijectionEnrichedKryo {
)(implicit bij: ImplicitBijection[A, B], cmf: ClassTag[B]): KSerializer[A] =
new KSerializer[A] {
def write(k: Kryo, out: Output, obj: A): Unit = kser.write(k, out, bij(obj))
def read(k: Kryo, in: Input, cls: Class[A]): A =
def read(k: Kryo, in: Input, cls: Class[_ <: A]): A =
bij.invert(kser.read(k, in, cmf.runtimeClass.asInstanceOf[Class[B]]))
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class InjectiveSerializer[T] private (injection: Injection[T, Array[Byte]])
out.writeBytes(bytes)
}

def read(kser: Kryo, in: Input, cls: Class[T]): T = {
def read(kser: Kryo, in: Input, cls: Class[_ <: T]): T = {
val bytes = new Array[Byte](in.readInt(true))
in.readBytes(bytes)
injection.invert(bytes).get
Expand Down
Loading

0 comments on commit b8fe269

Please sign in to comment.