Skip to content
Merged
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
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.typesafe.tools.mima.plugin.MimaPlugin.mimaDefaultSettings
import scala.collection.JavaConverters._
import scalariform.formatter.preferences._

val kryoVersion = "3.0.3"
val kryoVersion = "4.0.0"
val bijectionVersion = "0.9.0"
val algebirdVersion = "0.12.0"

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
Copyright 2012 Twitter, Inc.

Licensed 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 com.twitter.chill

import scala.reflect.ClassTag

class ClassTagSerializer[T] extends KSerializer[ClassTag[T]] {
Copy link
Collaborator

@johnynek johnynek Aug 24, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why remove the old one? This will break people, no?


def write(kser: Kryo, out: Output, obj: ClassTag[T]) {
kser.writeObject(out, obj.runtimeClass)
}

def read(kser: Kryo, in: Input, cls: Class[ClassTag[T]]): ClassTag[T] = {
val clazz = kser.readObject(in, classOf[Class[T]])
ClassTag(clazz)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ManifestSerializer[T] extends KSerializer[Manifest[T]] {
out.writeInt(idxOpt.get + 1, true)
} else {
out.writeInt(0, true)
kser.writeObject(out, obj.erasure)
kser.writeObject(out, obj.runtimeClass)
//write the type arguments:
val targs = obj.typeArguments
out.writeInt(targs.size, true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ import com.twitter.chill.java.PackageRegistrar
import _root_.java.io.Serializable

import scala.collection.JavaConverters._
import scala.reflect.ClassTag

/**
* This class has a no-arg constructor, suitable for use with reflection instantiation
Expand Down Expand Up @@ -193,7 +194,7 @@ class AllScalaRegistrar extends IKryoRegistrar {
def read(k: Kryo, in: Input, cls: Class[Symbol]) = Symbol(in.readString)
})
.forSubclass[Regex](new RegexSerializer)
.forClass[ClassManifest[Any]](new ClassManifestSerializer[Any])
.forClass[ClassTag[Any]](new ClassTagSerializer[Any])
.forSubclass[Manifest[Any]](new ManifestSerializer[Any])
.forSubclass[scala.Enumeration#Value](new EnumerationSerializer)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class WrappedArraySerializer[T] extends KSerializer[WrappedArray[T]] {
def write(kser: Kryo, out: Output, obj: WrappedArray[T]) {
// Write the class-manifest, we don't use writeClass because it
// uses the registration system, and this class might not be registered
kser.writeObject(out, obj.elemManifest.runtimeClass)
kser.writeObject(out, obj.elemTag.runtimeClass)
kser.writeClassAndObject(out, obj.array)
}

Expand Down