<commit_before>package com.zakgof.velvetdb.serialize;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;

import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
import com.zakgof.serialize.ISerializer;

public class KryoSerializer implements ISerializer {

  private Kryo kryo;

  public KryoSerializer() {
    this(new Kryo());
  }

  public KryoSerializer(Kryo kryo) {
    this.kryo = kryo;
  }

  public <T> byte[] serialize(T object, Class<T> clazz) {
    ByteArrayOutputStream bas = new ByteArrayOutputStream();
    Output output = new Output(bas);
    kryo.writeObject(output, object);
    output.flush();
    return bas.toByteArray();
  }

  public <T> T deserialize(InputStream stream, Class<T> clazz) {
    Input input = new Input(stream);
    T object = kryo.readObject(input, clazz);
    return object;
  }
  
  public Kryo getKryo() {
    return kryo;
  }

}<commit_msg>Formatting<commit_after>package com.zakgof.velvetdb.serialize;

import java.io.ByteArrayOutputStream;
import java.io.InputStream;

import com.esotericsoftware.kryo.Kryo;
import com.esotericsoftware.kryo.io.Input;
import com.esotericsoftware.kryo.io.Output;
import com.zakgof.serialize.ISerializer;

public class KryoSerializer implements ISerializer {

    private Kryo kryo;

    public KryoSerializer() {
        this(new Kryo());
    }

    public KryoSerializer(Kryo kryo) {
        this.kryo = kryo;
    }

    @Override
    public <T> byte[] serialize(T object, Class<T> clazz) {
        ByteArrayOutputStream bas = new ByteArrayOutputStream();
        Output output = new Output(bas);
        kryo.writeObject(output, object);
        output.flush();
        return bas.toByteArray();
    }

    @Override
    public <T> T deserialize(InputStream stream, Class<T> clazz) {
        Input input = new Input(stream);
        T object = kryo.readObject(input, clazz);
        return object;
    }

    public Kryo getKryo() {
        return kryo;
    }

}
{'fraction_non_alphanumeric': 0.10661401776900296, 'fraction_numerical': 0.0, 'mean_word_length': 3.4065217391304348, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '5741884', 'n_tokens_mistral': 704, 'n_tokens_neox': 687, 'n_words': 148}