<commit_before>module Eternity
  class CollectionIndex

    extend Forwardable
    def_delegators :hash, :to_h, :to_primitive, :empty?, :dump, :restore, :destroy

    def initialize(options)
      @hash = Restruct::Hash.new options
    end

    def collection_name
      hash.key.sections.last
    end

    def [](id)
      return nil unless hash.key? id
      Blob.new :data, hash[id]
    end

    def insert(id, data)
      raise "#{collection_name.capitalize} #{id} already exists" if hash.key? id
      hash[id] = Blob.write :data, data
    end

    def update(id, data)
      raise "#{collection_name.capitalize} #{id} not found" unless hash.key? id
      hash[id] = Blob.write :data, data
    end

    def delete(id)
      raise "#{collection_name.capitalize} #{id} not found" unless hash.key? id
      hash.delete id
    end

    private

    attr_reader :hash

  end
end<commit_msg>Rename hash to index<commit_after>module Eternity
  class CollectionIndex

    extend Forwardable
    def_delegators :index, :to_h, :to_primitive, :empty?, :dump, :restore, :destroy

    def initialize(options)
      @index = Restruct::Hash.new options
    end

    def collection_name
      index.key.sections.last
    end

    def [](id)
      return nil unless index.key? id
      Blob.new :data, index[id]
    end

    def insert(id, data)
      raise "#{collection_name.capitalize} #{id} already exists" if index.key? id
      index[id] = Blob.write :data, data
    end

    def update(id, data)
      raise "#{collection_name.capitalize} #{id} not found" unless index.key? id
      index[id] = Blob.write :data, data
    end

    def delete(id)
      raise "#{collection_name.capitalize} #{id} not found" unless index.key? id
      index.delete id
    end

    def ids
      index.keys
    end

    private

    attr_reader :index

  end
end
{'fraction_non_alphanumeric': 0.10179640718562874, 'fraction_numerical': 0.0, 'mean_word_length': 2.6468253968253967, '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': '2209004', 'n_tokens_mistral': 612, 'n_tokens_neox': 582, 'n_words': 176}