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

WIP: Updated to use the newer Kryo 5 #514

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
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
17 changes: 3 additions & 14 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import com.typesafe.tools.mima.plugin.MimaPlugin.mimaDefaultSettings
val akkaVersion = "2.6.13"
val algebirdVersion = "0.13.7"
val bijectionVersion = "0.9.7"
val kryoVersion = "4.0.2"
val kryoVersion = "5.0.3"
val scroogeVersion = "21.2.0"
val asmVersion = "4.15"

Expand Down Expand Up @@ -40,7 +40,7 @@ val sharedSettings = mimaDefaultSettings ++ Seq(
"org.scalacheck" %% "scalacheck" % "1.15.2" % "test",
"org.scalatest" %% "scalatest" % "3.2.6" % "test",
"org.scalatestplus" %% "scalatestplus-scalacheck" % "3.1.0.0-RC2" % "test",
"com.esotericsoftware" % "kryo-shaded" % kryoVersion
"com.esotericsoftware.kryo" % "kryo5" % kryoVersion
),
parallelExecution in Test := true,
pomExtra := <url>https://github.com/twitter/chill</url>
Expand Down Expand Up @@ -92,7 +92,6 @@ lazy val chillAll = Project(
chill,
chillBijection,
chillScrooge,
chillStorm,
chillJava,
chillHadoop,
chillThrift,
Expand Down Expand Up @@ -122,7 +121,7 @@ lazy val noPublishSettings = Seq(
* with the current.
*/
val unreleasedModules = Set[String]("akka")
val javaOnly = Set[String]("storm", "java", "hadoop", "thrift", "protobuf")
val javaOnly = Set[String]("java", "hadoop", "thrift", "protobuf")
val binaryCompatVersion = "0.9.2"

def youngestForwardCompatible(subProj: String) =
Expand All @@ -139,7 +138,6 @@ 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"),
Expand Down Expand Up @@ -214,15 +212,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" % "1.0.6" % "provided"
)
.dependsOn(chillJava)

// This can only have java deps!
lazy val chillHadoop = module("hadoop")
.settings(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,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 @@ -38,7 +38,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 @@ -32,7 +32,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 @@ -27,7 +27,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
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@

package com.twitter.chill.hadoop;

import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.io.Output;
import com.esotericsoftware.kryo.kryo5.Kryo;
import com.esotericsoftware.kryo.kryo5.io.Output;
import com.esotericsoftware.kryo.kryo5.objenesis.strategy.StdInstantiatorStrategy;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.conf.Configured;
import org.apache.hadoop.io.serializer.Deserializer;
import org.apache.hadoop.io.serializer.Serialization;
import org.apache.hadoop.io.serializer.Serializer;
import org.objenesis.strategy.StdInstantiatorStrategy;

import com.twitter.chill.KryoPool;
import com.twitter.chill.KryoInstantiator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ limitations under the License.

package com.twitter.chill.hadoop

import com.esotericsoftware.kryo.Kryo

import org.objenesis.strategy.StdInstantiatorStrategy
import com.esotericsoftware.kryo.kryo5.Kryo
import com.esotericsoftware.kryo.kryo5.objenesis.strategy.StdInstantiatorStrategy;

import java.io.{ByteArrayOutputStream => BAOut, ByteArrayInputStream => BAIn}
import org.apache.hadoop.conf.Configuration
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.twitter.chill;

import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.kryo5.Kryo;

/** Register this class to be used with the default serializer for this class */
public class ClassRegistrar<T> implements IKryoRegistrar {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package com.twitter.chill;

import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.kryo5.Kryo;
import java.io.Serializable;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

package com.twitter.chill;

import com.esotericsoftware.kryo.Kryo;
import org.objenesis.strategy.InstantiatorStrategy;
import com.esotericsoftware.kryo.kryo5.Kryo;
import com.esotericsoftware.kryo.kryo5.objenesis.strategy.InstantiatorStrategy;
import java.io.Serializable;

/** Class to create a new Kryo instance.
Expand Down
6 changes: 3 additions & 3 deletions chill-java/src/main/java/com/twitter/chill/KryoPool.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

package com.twitter.chill;

import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
import com.esotericsoftware.kryo.kryo5.Kryo;
import com.esotericsoftware.kryo.kryo5.io.Input;
import com.esotericsoftware.kryo.kryo5.io.Output;

import java.io.OutputStream;
import java.io.ByteArrayOutputStream;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

package com.twitter.chill;

import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.Serializer;
import com.esotericsoftware.kryo.kryo5.Kryo;
import com.esotericsoftware.kryo.kryo5.Serializer;

/** Set the default serializers for subclasses of the given class
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

package com.twitter.chill;

import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.Serializer;
import com.esotericsoftware.kryo.util.Util;
import com.esotericsoftware.kryo.kryo5.Kryo;
import com.esotericsoftware.kryo.kryo5.Serializer;
import com.esotericsoftware.kryo.kryo5.util.Util;

/** Use reflection to instantiate a serializer.
* Used when serializer classes are written to config files
Expand Down
8 changes: 4 additions & 4 deletions chill-java/src/main/java/com/twitter/chill/SerDeState.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

package com.twitter.chill;

import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
import com.esotericsoftware.kryo.kryo5.Kryo;
import com.esotericsoftware.kryo.kryo5.io.Input;
import com.esotericsoftware.kryo.kryo5.io.Output;

import java.io.OutputStream;
import java.io.InputStream;
Expand All @@ -43,7 +43,7 @@ protected SerDeState(Kryo k, Input in, Output out) {
/** Call this when to reset the state to the initial state */
public void clear() {
input.setBuffer(EMPTY_BUFFER);
output.clear();
output.reset();
}

public void setInput(byte[] in) { input.setBuffer(in); }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

package com.twitter.chill;

import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.Serializer;
import com.esotericsoftware.kryo.kryo5.Kryo;
import com.esotericsoftware.kryo.kryo5.Serializer;

/** Set the default serializers for subclasses of the given class
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@

package com.twitter.chill;

import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.Serializer;
import com.esotericsoftware.kryo.kryo5.Kryo;
import com.esotericsoftware.kryo.kryo5.Serializer;

public class SingleRegistrar<T> implements IKryoRegistrar {
final Class<T> klass;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@

import java.lang.reflect.InvocationTargetException;

import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
import com.esotericsoftware.kryo.kryo5.Kryo;
import com.esotericsoftware.kryo.kryo5.io.Input;
import com.esotericsoftware.kryo.kryo5.io.Output;

/**
* This is the standard Config based KryoInstantiator.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
import com.twitter.chill.ReflectingRegistrar;
import com.twitter.chill.ReflectingDefaultRegistrar;

import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.Serializer;
import org.objenesis.strategy.InstantiatorStrategy;
import org.objenesis.strategy.StdInstantiatorStrategy;
import com.esotericsoftware.kryo.kryo5.Kryo;
import com.esotericsoftware.kryo.kryo5.Serializer;
import com.esotericsoftware.kryo.kryo5.objenesis.strategy.InstantiatorStrategy;
import com.esotericsoftware.kryo.kryo5.objenesis.strategy.StdInstantiatorStrategy;
import java.util.ArrayList;
import java.util.List;
import java.lang.reflect.InvocationTargetException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@
import java.util.HashMap;
import java.util.Map;

import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.Serializer;
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
import com.esotericsoftware.kryo.kryo5.Kryo;
import com.esotericsoftware.kryo.kryo5.Serializer;
import com.esotericsoftware.kryo.kryo5.io.Input;
import com.esotericsoftware.kryo.kryo5.io.Output;

/**
* A kryo {@link Serializer} for lists created via {@link Arrays#asList(Object...)}.
Expand Down Expand Up @@ -71,7 +71,7 @@ public ArraysAsListSerializer() {
}

@Override
public List<?> read(final Kryo kryo, final Input input, final Class<List<?>> type) {
public List<?> read(final Kryo kryo, final Input input, final Class<? extends List<?>> type) {
final int length = input.readInt(true);
Class<?> componentType = kryo.readClass(input).getType();
try {
Expand Down
Loading