<commit_before>/*
 *  @author <NAME>
 *
 *  Copyright 2014 University of Zurich
 *
 *  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.signalcollect.configuration

import com.esotericsoftware.kryo.Kryo
import com.esotericsoftware.kryo.serializers.DeflateSerializer
import com.esotericsoftware.kryo.Serializer
import com.signalcollect.interfaces.Request
import com.signalcollect.messaging.Command
import com.signalcollect.messaging.AkkaProxy
import com.signalcollect.messaging.Incrementor
import com.signalcollect.factory.messagebus._
import com.signalcollect.factory.mapper.DefaultMapperFactory
import com.signalcollect.worker.AkkaWorker
import com.signalcollect.WorkerCreator
import com.signalcollect.factory.worker.DefaultAkkaWorker

class KryoInit {

  def customize(kryo: Kryo): Unit = {
    kryo.setReferences(true) // Required for cycle between edges and vertices.
    kryo.setCopyReferences(false)
    register(kryo)
  }

  protected def register(kryo: Kryo): Unit = {
    try {
      def register(s: String) {
        kryo.register(Class.forName(s))
      }
      def registerClass(c: Class[_]) {
        kryo.register(c)
      }
      register("scala.Some")
      register("scala.None$")
      register("com.signalcollect.interfaces.SignalMessage")
      register("com.signalcollect.interfaces.BulkSignal")
      register("com.signalcollect.interfaces.BulkSignalNoSourceIds")
      register("com.signalcollect.interfaces.AddVertex")
      register("com.signalcollect.interfaces.AddEdge")
      register("com.signalcollect.WorkerCreator")
      register("com.signalcollect.configuration.GraphConfiguration")
      register("com.signalcollect.nodeprovisioning.local.LocalNodeProvisioner")
      register("com.signalcollect.factory.scheduler.Throughput$")
      register("java.lang.Class")
      register("java.lang.Object")
      register("akka.actor.RepointableActorRef")
      register("scala.collection.convert.Wrappers$JMapWrapper")
      register("com.signalcollect.interfaces.EdgeId")
      register("com.signalcollect.interfaces.WorkerStatus")
      register("com.signalcollect.interfaces.NodeStatus")
      register("com.signalcollect.interfaces.Heartbeat")
      register("com.signalcollect.interfaces.WorkerStatistics")
      register("com.signalcollect.interfaces.NodeStatistics")
      register("com.signalcollect.interfaces.SentMessagesStats")
      register("scala.collection.mutable.HashMap")
      register("scala.collection.immutable.HashMap$HashTrieMap")
      register("scala.collection.immutable.Map$EmptyMap$")
      register("scala.collection.immutable.Map$Map1")
      register("scala.collection.immutable.Map$Map2")
      register("scala.collection.immutable.Map$Map3")
      register("scala.collection.immutable.Map$Map4")
      register("scala.collection.immutable.HashSet$HashTrieSet")
      register("scala.collection.immutable.Set$EmptySet$")
      register("scala.collection.immutable.Set$Set1")
      register("scala.collection.immutable.Set$Set2")
      register("scala.collection.immutable.Set$Set3")
      register("scala.collection.immutable.Set$Set4")
      register("scala.collection.immutable.Nil$")
      register("scala.collection.immutable.$colon$colon")
      register("scala.collection.immutable.Vector")
      register("akka.dispatch.NullMessage$")
      register("akka.actor.SystemGuardian$RegisterTerminationHook$")
      register("akka.actor.ReceiveTimeout$")
      register("com.signalcollect.WorkerCreator$$anonfun$create$1")
      register("scala.reflect.ManifestFactory$$anon$1")
      register("com.signalcollect.factory.storage.MemoryEfficientStorage$")
      register("com.signalcollect.factory.worker.DefaultAkkaWorker$")
      register("com.signalcollect.coordinator.OnIdle")
      register("com.signalcollect.worker.ScheduleOperations$")
      register("akka.actor.Terminated")
      register("akka.actor.LocalActorRef")
      register("akka.actor.SystemGuardian$TerminationHookDone$")
      register("com.signalcollect.configuration.EventBased$")
      register("com.signalcollect.configuration.Pinned$")
      register("com.signalcollect.interfaces.Request")
      register("com.signalcollect.messaging.Command")
      register("com.signalcollect.messaging.Incrementor$$anonfun$1")
      register("com.signalcollect.coordinator.DefaultCoordinator$$anonfun$1")
      register("com.signalcollect.DefaultGraph$$anonfun$11")
      register("com.signalcollect.factory.messagebus.AkkaMessageBusFactory$")
      register("com.signalcollect.factory.mapper.DefaultMapperFactory$")
      register("com.signalcollect.factory.messagebus.BulkAkkaMessageBusFactory")
      registerClass(classOf[Array[Int]])
      registerClass(classOf[Array[Long]])
      registerClass(classOf[Array[Float]])
      registerClass(classOf[Array[Double]])
      registerClass(classOf[Array[Boolean]])
      registerClass(classOf[Array[String]])
      registerClass(classOf[Array[Object]])
      registerClass(classOf[Array[java.lang.StackTraceElement]])
      registerClass(classOf[Array[Object]])
      registerClass(classOf[Array[Array[Int]]])
      registerClass(classOf[Array[Array[Long]]])
      registerClass(classOf[Array[Array[Float]]])
      registerClass(classOf[Array[Array[Double]]])
      registerClass(classOf[Array[Array[Boolean]]])
      registerClass(classOf[Array[Array[String]]])
      registerClass(classOf[Array[Array[Object]]])
    } catch {
      case t: Throwable => t.printStackTrace
    }
    //registerWithCompression(kryo, classOf[Array[Array[Int]]])
  }

  protected def registerWithCompression(kryo: Kryo, c: Class[_]) {<commit_msg>Supporting Short, removed support for exceptions.<commit_after>/*
 *  @author <NAME>
 *
 *  Copyright 2014 University of Zurich
 *
 *  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.signalcollect.configuration

import com.esotericsoftware.kryo.Kryo
import com.esotericsoftware.kryo.serializers.DeflateSerializer
import com.esotericsoftware.kryo.Serializer
import com.signalcollect.interfaces.Request
import com.signalcollect.messaging.Command
import com.signalcollect.messaging.AkkaProxy
import com.signalcollect.messaging.Incrementor
import com.signalcollect.factory.messagebus._
import com.signalcollect.factory.mapper.DefaultMapperFactory
import com.signalcollect.worker.AkkaWorker
import com.signalcollect.WorkerCreator
import com.signalcollect.factory.worker.DefaultAkkaWorker

class KryoInit {

  def customize(kryo: Kryo): Unit = {
    kryo.setReferences(true) // Required for cycle between edges and vertices.
    kryo.setCopyReferences(false)
    register(kryo)
  }

  protected def register(kryo: Kryo): Unit = {
    try {
      def register(s: String) {
        kryo.register(Class.forName(s))
      }
      def registerClass(c: Class[_]) {
        kryo.register(c)
      }
      register("scala.Some")
      register("scala.None$")
      register("com.signalcollect.interfaces.SignalMessage")
      register("com.signalcollect.interfaces.BulkSignal")
      register("com.signalcollect.interfaces.BulkSignalNoSourceIds")
      register("com.signalcollect.interfaces.AddVertex")
      register("com.signalcollect.interfaces.AddEdge")
      register("com.signalcollect.WorkerCreator")
      register("com.signalcollect.configuration.GraphConfiguration")
      register("com.signalcollect.nodeprovisioning.local.LocalNodeProvisioner")
      register("com.signalcollect.factory.scheduler.Throughput$")
      register("java.lang.Class")
      register("java.lang.Object")
      register("akka.actor.RepointableActorRef")
      register("scala.collection.convert.Wrappers$JMapWrapper")
      register("com.signalcollect.interfaces.EdgeId")
      register("com.signalcollect.interfaces.WorkerStatus")
      register("com.signalcollect.interfaces.NodeStatus")
      register("com.signalcollect.interfaces.Heartbeat")
      register("com.signalcollect.interfaces.WorkerStatistics")
      register("com.signalcollect.interfaces.NodeStatistics")
      register("com.signalcollect.interfaces.SentMessagesStats")
      register("scala.collection.mutable.HashMap")
      register("scala.collection.immutable.HashMap$HashTrieMap")
      register("scala.collection.immutable.Map$EmptyMap$")
      register("scala.collection.immutable.Map$Map1")
      register("scala.collection.immutable.Map$Map2")
      register("scala.collection.immutable.Map$Map3")
      register("scala.collection.immutable.Map$Map4")
      register("scala.collection.immutable.HashSet$HashTrieSet")
      register("scala.collection.immutable.Set$EmptySet$")
      register("scala.collection.immutable.Set$Set1")
      register("scala.collection.immutable.Set$Set2")
      register("scala.collection.immutable.Set$Set3")
      register("scala.collection.immutable.Set$Set4")
      register("scala.collection.immutable.Nil$")
      register("scala.collection.immutable.$colon$colon")
      register("scala.collection.immutable.Vector")
      register("akka.dispatch.NullMessage$")
      register("akka.actor.SystemGuardian$RegisterTerminationHook$")
      register("akka.actor.ReceiveTimeout$")
      register("com.signalcollect.WorkerCreator$$anonfun$create$1")
      register("scala.reflect.ManifestFactory$$anon$1")
      register("com.signalcollect.factory.storage.MemoryEfficientStorage$")
      register("com.signalcollect.factory.worker.DefaultAkkaWorker$")
      register("com.signalcollect.coordinator.OnIdle")
      register("com.signalcollect.worker.ScheduleOperations$")
      register("akka.actor.Terminated")
      register("akka.actor.LocalActorRef")
      register("akka.actor.SystemGuardian$TerminationHookDone$")
      register("com.signalcollect.configuration.EventBased$")
      register("com.signalcollect.configuration.Pinned$")
      register("com.signalcollect.interfaces.Request")
      register("com.signalcollect.messaging.Command")
      register("com.signalcollect.messaging.Incrementor$$anonfun$1")
      register("com.signalcollect.coordinator.DefaultCoordinator$$anonfun$1")
      register("com.signalcollect.DefaultGraph$$anonfun$11")
      register("com.signalcollect.factory.messagebus.AkkaMessageBusFactory$")
      register("com.signalcollect.factory.mapper.DefaultMapperFactory$")
      register("com.signalcollect.factory.messagebus.BulkAkkaMessageBusFactory")
      registerClass(classOf[Array[Int]])
      registerClass(classOf[Array[Long]])
      registerClass(classOf[Array[Short]])
      registerClass(classOf[Array[Float]])
      registerClass(classOf[Array[Double]])
      registerClass(classOf[Array[Boolean]])
      registerClass(classOf[Array[String]])
      registerClass(classOf[Array[Object]])
      registerClass(classOf[Array[AnyRef]])
      registerClass(classOf[Array[Array[Int]]])
      registerClass(classOf[Array[Array[Long]]])
      registerClass(classOf[Array[Array[Short]]])
      registerClass(classOf[Array[Array[Float]]])
      registerClass(classOf[Array[Array[Double]]])
      registerClass(classOf[Array[Array[Boolean]]])
      registerClass(classOf[Array[Array[String]]])
      registerClass(classOf[Array[Array[Object]]])
      registerClass(classOf[Array[Array[AnyRef]]])
    } catch {
      case t: Throwable => t.printStackTrace
    }
    //registerWithCompression(kryo, classOf[Array[Array[Int]]])
  }

  protected def registerWithCompression(kryo: Kryo, c: Class[_]) {
{'fraction_non_alphanumeric': 0.12024242424242425, 'fraction_numerical': 0.0035555555555555557, 'mean_word_length': 4.658893461362597, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6986111', 'n_tokens_mistral': 3565, 'n_tokens_neox': 3531, 'n_words': 469}