<commit_before>package net.sansa_stack.query.spark.ontop


import com.esotericsoftware.kryo.{Kryo, Serializer}
import com.esotericsoftware.kryo.io.{Input, Output}
import it.unibz.inf.ontop.com.google.common.collect.ImmutableList
import it.unibz.inf.ontop.model.term.ImmutableFunctionalTerm
import it.unibz.inf.ontop.model.term.functionsymbol.FunctionSymbol
import it.unibz.inf.ontop.model.term.impl.{GroundExpressionImpl, ImmutableFunctionalTermImpl, NonGroundExpressionImpl, NonGroundFunctionalTermImpl}

class ImmutableFunctionalTermSerializer(ontopSessionID: String)
  extends Serializer[ImmutableFunctionalTerm](false, true) {


  override def write(kryo: Kryo, output: Output, obj: ImmutableFunctionalTerm): Unit = {
    kryo.writeClassAndObject(output, obj.getFunctionSymbol)
    kryo.writeClassAndObject(output, obj.getTerms)
  }

  override def read(kryo: Kryo, input: Input, `type`: Class[ImmutableFunctionalTerm]): ImmutableFunctionalTerm = {

    val functionSymbol = kryo.readClassAndObject(input).asInstanceOf[FunctionSymbol]
    val terms = kryo.readClassAndObject(input).asInstanceOf[ImmutableList[it.unibz.inf.ontop.model.term.ImmutableTerm]]

    val termFactory = OntopConnection.configs(ontopSessionID).getTermFactory
    val term = termFactory.getImmutableFunctionalTerm(functionSymbol, terms)

    term
  }
}

object ImmutableFunctionalTermSerializer {
  def registerSerializers(kryo: Kryo, ontopSessionID: String): Unit = {
    val serializer = new ImmutableFunctionalTermSerializer(ontopSessionID)

    kryo.register(classOf[ImmutableFunctionalTermImpl], serializer)
    kryo.register(classOf[NonGroundFunctionalTermImpl], serializer)
    kryo.register(classOf[NonGroundExpressionImpl], serializer)
    kryo.register(classOf[GroundExpressionImpl], serializer)<commit_msg>registered more classes to serializer<commit_after>package net.sansa_stack.query.spark.ontop


import com.esotericsoftware.kryo.{Kryo, Serializer}
import com.esotericsoftware.kryo.io.{Input, Output}
import it.unibz.inf.ontop.com.google.common.collect.ImmutableList
import it.unibz.inf.ontop.model.term.ImmutableFunctionalTerm
import it.unibz.inf.ontop.model.term.functionsymbol.FunctionSymbol
import it.unibz.inf.ontop.model.term.impl.{GroundExpressionImpl, GroundFunctionalTermImpl, ImmutableFunctionalTermImpl, NonGroundExpressionImpl, NonGroundFunctionalTermImpl}

class ImmutableFunctionalTermSerializer(ontopSessionID: String)
  extends Serializer[ImmutableFunctionalTerm](false, true) {


  override def write(kryo: Kryo, output: Output, obj: ImmutableFunctionalTerm): Unit = {
    kryo.writeClassAndObject(output, obj.getFunctionSymbol)
    kryo.writeClassAndObject(output, obj.getTerms)
  }

  override def read(kryo: Kryo, input: Input, `type`: Class[ImmutableFunctionalTerm]): ImmutableFunctionalTerm = {

    val functionSymbol = kryo.readClassAndObject(input).asInstanceOf[FunctionSymbol]
    val terms = kryo.readClassAndObject(input).asInstanceOf[ImmutableList[it.unibz.inf.ontop.model.term.ImmutableTerm]]

    val termFactory = OntopConnection.configs(ontopSessionID).getTermFactory
    val term = termFactory.getImmutableFunctionalTerm(functionSymbol, terms)

    term
  }
}

object ImmutableFunctionalTermSerializer {
  def registerSerializers(kryo: Kryo, ontopSessionID: String): Unit = {
    val serializer = new ImmutableFunctionalTermSerializer(ontopSessionID)

    kryo.register(classOf[ImmutableFunctionalTermImpl], serializer)
    kryo.register(classOf[NonGroundFunctionalTermImpl], serializer)
    kryo.register(classOf[GroundFunctionalTermImpl], serializer)
    kryo.register(classOf[NonGroundExpressionImpl], serializer)
    kryo.register(classOf[GroundExpressionImpl], serializer)
{'fraction_non_alphanumeric': 0.09208749662435863, 'fraction_numerical': 0.0, 'mean_word_length': 6.9314775160599575, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '1122736', 'n_tokens_mistral': 1202, 'n_tokens_neox': 1175, 'n_words': 168}