<commit_before>package io.vivarium.net.common.messages;

import java.io.IOException;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRawValue;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

import io.vivarium.net.UUIDDeserializer;
import io.vivarium.net.UUIDSerializer;
import io.vivarium.util.UUID;

public class SendResource extends Message
{
    @JsonSerialize(using = UUIDSerializer.class)
    @JsonDeserialize(using = UUIDDeserializer.class)
    final public UUID resourceID;
    final public JsonNode jsonData;

    @JsonRawValue
    public String getJsonData()
    {
        // default raw value: null or "[]"
        return jsonData == null ? null : jsonData.toString();
    }

    @SuppressWarnings("unused") // Used for Jackson deserialization
    private SendResource()
    {
        resourceID = null;
        jsonData = null;
    }

    @JsonCreator
    public SendResource(@JsonProperty("resourceID") UUID resourceID, @JsonProperty("jsonData") String jsonString)
    {
        try
        {
            this.jsonData = new ObjectMapper().readTree(jsonString);
        }
        catch (IOException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new IllegalArgumentException("Unable to parse JSON");
        }
        this.resourceID = resourceID;
    }

    public SendResource(UUID resourceID, JsonNode jsonData)
    {
        this.resourceID = resourceID;
        this.jsonData = jsonData;
    }
}<commit_msg>[2] Fix to SendResource message for client/server/worker communication<commit_after>package io.vivarium.net.common.messages;

import java.io.IOException;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRawValue;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;

import io.vivarium.net.UUIDDeserializer;
import io.vivarium.net.UUIDSerializer;
import io.vivarium.util.UUID;

public class SendResource extends Message
{
    @JsonSerialize(using = UUIDSerializer.class)
    @JsonDeserialize(using = UUIDDeserializer.class)
    final public UUID resourceID;
    final public JsonNode jsonData;

    @JsonRawValue
    public String getJsonData()
    {
        // default raw value: null or "[]"
        return jsonData == null ? null : jsonData.toString();
    }

    @SuppressWarnings("unused") // Used for Jackson deserialization
    private SendResource()
    {
        resourceID = null;
        jsonData = null;
    }

    public SendResource(UUID resourceID, String jsonString)
    {
        try
        {
            this.jsonData = new ObjectMapper().readTree(jsonString);
        }
        catch (IOException e)
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
            throw new IllegalArgumentException("Unable to parse JSON");
        }
        this.resourceID = resourceID;
    }

    @JsonCreator
    public SendResource(@JsonProperty("resourceID") UUID resourceID, @JsonProperty("jsonData") JsonNode jsonData)
    {
        this.resourceID = resourceID;
        this.jsonData = jsonData;
    }
}
{'fraction_non_alphanumeric': 0.09254641174840676, 'fraction_numerical': 0.0002770850651149903, 'mean_word_length': 3.168591224018476, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 14}, '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': '2564226', 'n_tokens_mistral': 1025, 'n_tokens_neox': 974, 'n_words': 213}