<commit_before>(ns icecap.store.mem
  "An in-memory store."
  (:require [clojure.core.async :as a]
            [icecap.store.api :refer :all]))

(defn mem-store
  "Create an in-memory store."
  []
  (let [store (atom {})]
    (reify Store
      (create! [_ index blob]
        (swap! store assoc index blob)
        (a/to-chan []))
      (retrieve [_ index]
        (let [v (@store index)
              vs (if (nil? v) [] [v])]
          (a/to-chan vs)))
      (delete! [_ index]
        (swap! store dissoc index)
        (a/to-chan [])))))<commit_msg>Encode before storing in memory<commit_after>(ns icecap.store.mem
  "An in-memory store."
  (:require [clojure.core.async :as a]
            [icecap.store.api :refer :all]
            [icecap.codec :refer [safebase64-encode]]))

(defn mem-store
  "Create an in-memory store."
  []
  (let [store (atom {})]
    (reify Store
      (create! [_ index blob]
        (let [index (safebase64-encode index)]
          (swap! store assoc index blob)
          (a/to-chan [])))
      (retrieve [_ index]
        (let [index (safebase64-encode index)
              v (@store index)
              vs (if (nil? v) [] [v])]
          (a/to-chan vs)))
      (delete! [_ index]
        (let [index (safebase64-encode index)]
          (swap! store dissoc index)
          (a/to-chan []))))))
{'fraction_non_alphanumeric': 0.16265060240963855, 'fraction_numerical': 0.006024096385542169, 'mean_word_length': 1.9932432432432432, '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': '4478607', 'n_tokens_mistral': 468, 'n_tokens_neox': 451, 'n_words': 122}