<commit_before>package org.smoothbuild.io.cache.value.read;

import org.smoothbuild.io.cache.hash.HashedDb;
import org.smoothbuild.io.cache.hash.Unmarshaller;
import org.smoothbuild.io.cache.value.instance.CachedBlob;
import org.smoothbuild.io.cache.value.instance.CachedFile;
import org.smoothbuild.io.fs.base.Path;
import org.smoothbuild.lang.type.SFile;

import com.google.common.hash.HashCode;

public class ReadFile implements ReadValue<SFile> {
  private final HashedDb hashedDb;

  public ReadFile(HashedDb hashedDb) {
    this.hashedDb = hashedDb;
  }

  @Override
  public SFile read(HashCode hash) {
    try (Unmarshaller unmarshaller = new Unmarshaller(hashedDb, hash);) {
      HashCode blobHash = unmarshaller.readHash();
      Path path = unmarshaller.readPath();
      // TODO copy pasted from BlobReader
      CachedBlob blob = new CachedBlob(hashedDb, blobHash);

      return new CachedFile(path, blob, hash);
    }
  }
}<commit_msg>removed TODO<commit_after>package org.smoothbuild.io.cache.value.read;

import org.smoothbuild.io.cache.hash.HashedDb;
import org.smoothbuild.io.cache.hash.Unmarshaller;
import org.smoothbuild.io.cache.value.instance.CachedBlob;
import org.smoothbuild.io.cache.value.instance.CachedFile;
import org.smoothbuild.io.fs.base.Path;
import org.smoothbuild.lang.type.SFile;

import com.google.common.hash.HashCode;

public class ReadFile implements ReadValue<SFile> {
  private final HashedDb hashedDb;

  public ReadFile(HashedDb hashedDb) {
    this.hashedDb = hashedDb;
  }

  @Override
  public SFile read(HashCode hash) {
    try (Unmarshaller unmarshaller = new Unmarshaller(hashedDb, hash);) {
      HashCode blobHash = unmarshaller.readHash();
      Path path = unmarshaller.readPath();
      CachedBlob blob = new CachedBlob(hashedDb, blobHash);

      return new CachedFile(path, blob, hash);
    }
  }
}
{'fraction_non_alphanumeric': 0.10543302850995159, 'fraction_numerical': 0.0, 'mean_word_length': 4.344827586206897, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6984990', 'n_tokens_mistral': 627, 'n_tokens_neox': 616, 'n_words': 120}