<commit_before>;   Copyright (c) <NAME>. All rights reserved.
;   The use and distribution terms for this software are covered by the
;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
;   which can be found in the file LICENSE at the root of this distribution.
;   By using this software in any fashion, you are agreeing to be bound by
;   the terms of this license.
;   You must not remove this notice, or any other, from this software.


(ns keypin.type.record
  (:require
    [keypin.internal :as i]
    [keypin.type :as t])
  (:import
    [java.util Map]
    [clojure.lang Associative IDeref ILookup IPersistentCollection IPersistentMap Named Seqable]
    [keypin.type KeyAttributes]))


(defrecord StoreState [^Map    store-data
                       ^String store-name
                       ^long   updated-at
                       ])


(deftype DynamicStore [state-agent  ; an agent holding current state
                       update-data  ; (fn ^StoreState []) to potentially update state
                       ]
  IDeref
  (deref [_]      (update-data))
  t/IStore
  (lookup [_ kd]  (t/lookup (update-data) kd))
  ILookup
  (valAt [_ k]    (get (update-data) k))
  (valAt [_ k nf] (get (update-data) k nf))
  Seqable
  (seq   [_]      (seq (update-data)))
  IPersistentCollection
  (count [_]      (count (update-data)))
  (cons  [_ _]    (throw (UnsupportedOperationException. "cons is not supported on this type")))
  (empty [_]      (let [ss (->StoreState {} "empty" (i/now-millis))]
                    (DynamicStore. (agent ss) (constantly ss))))
  (equiv [_ obj]  (.equiv ^IPersistentMap (update-data) obj))
  Associative
  (containsKey  [_ k]   (contains? (update-data) k))
  (entryAt      [_ k]   (.entryAt ^IPersistentMap (update-data) k))
  (assoc        [_ _ _] (throw (UnsupportedOperationException. "assoc is not supported on this type"))))<commit_msg>omit unused import<commit_after>;   Copyright (c) <NAME>. All rights reserved.
;   The use and distribution terms for this software are covered by the
;   Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
;   which can be found in the file LICENSE at the root of this distribution.
;   By using this software in any fashion, you are agreeing to be bound by
;   the terms of this license.
;   You must not remove this notice, or any other, from this software.


(ns keypin.type.record
  (:require
    [keypin.internal :as i]
    [keypin.type :as t])
  (:import
    [java.util Map]
    [clojure.lang Associative IDeref ILookup IPersistentCollection IPersistentMap Seqable]
    [keypin.type KeyAttributes]))


(defrecord StoreState [^Map    store-data
                       ^String store-name
                       ^long   updated-at
                       ])


(deftype DynamicStore [state-agent  ; an agent holding current state
                       update-data  ; (fn ^StoreState []) to potentially update state
                       ]
  IDeref
  (deref [_]      (update-data))
  t/IStore
  (lookup [_ kd]  (t/lookup (update-data) kd))
  ILookup
  (valAt [_ k]    (get (update-data) k))
  (valAt [_ k nf] (get (update-data) k nf))
  Seqable
  (seq   [_]      (seq (update-data)))
  IPersistentCollection
  (count [_]      (count (update-data)))
  (cons  [_ _]    (throw (UnsupportedOperationException. "cons is not supported on this type")))
  (empty [_]      (let [ss (->StoreState {} "empty" (i/now-millis))]
                    (DynamicStore. (agent ss) (constantly ss))))
  (equiv [_ obj]  (.equiv ^IPersistentMap (update-data) obj))
  Associative
  (containsKey  [_ k]   (contains? (update-data) k))
  (entryAt      [_ k]   (.entryAt ^IPersistentMap (update-data) k))
  (assoc        [_ _ _] (throw (UnsupportedOperationException. "assoc is not supported on this type"))))
{'fraction_non_alphanumeric': 0.11474980351061043, 'fraction_numerical': 0.002095886822111606, 'mean_word_length': 2.5682242990654207, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '6929594', 'n_tokens_mistral': 1234, 'n_tokens_neox': 1168, 'n_words': 386}