<commit_before>module Redstruct
  module Types
    class Hash < Redstruct::Types::Struct
      include Redstruct::Utils::Coercion

      def [](key)
        return self.connection.hget(@key, key)
      end

      def []=(key, value)
        self.connection.hset(@key, key, value)
      end

      def set(key, value, overwrite: true)
        if overwrite
          self[key] = value
        else
          self.connection.hsetnx(@key, key, value)
        end
      end

      def get(*keys)
        return self[keys.first] if keys.size == 1
        return self.connection.mapped_hmget(@key, *keys)
      end

      def update(hash)
        self.connection.mapped_hmset(@key, hash)
      end

      def delete(*keys)
        return self.connection.hdel(@key, keys)
      end

      def key?(key)
        return coerce_bool(self.connection.hexists(@key, key))
      end

      def incr(key, increment: 1)
        if increment.is_a?(Float)
          self.connection.hincrbyfloat(@key, key, increment.to_f)
        else
          self.connection.hincrby(@key, key, increment)
        end
      end

      def decr(key, increment: 1)
        return incr(key, (-increment))
      end

      def to_h
        return self.connection.hgetall(@key)
      end

      def keys
        return self.connection.hkeys(@key)
      end

      def values
        return self.connection.hvals(@key)
      end

      def size
        return self.connection.hlen(@key)<commit_msg>do not overload #delete method, which deletes the whole object<commit_after>module Redstruct
  module Types
    class Hash < Redstruct::Types::Struct
      include Redstruct::Utils::Coercion

      def [](key)
        return self.connection.hget(@key, key)
      end

      def []=(key, value)
        self.connection.hset(@key, key, value)
      end

      def set(key, value, overwrite: true)
        if overwrite
          self[key] = value
        else
          self.connection.hsetnx(@key, key, value)
        end
      end

      def get(*keys)
        return self[keys.first] if keys.size == 1
        return self.connection.mapped_hmget(@key, *keys)
      end

      def update(hash)
        self.connection.mapped_hmset(@key, hash)
      end

      def remove(*keys)
        return self.connection.hdel(@key, keys)
      end

      def key?(key)
        return coerce_bool(self.connection.hexists(@key, key))
      end

      def incr(key, increment: 1)
        if increment.is_a?(Float)
          self.connection.hincrbyfloat(@key, key, increment.to_f)
        else
          self.connection.hincrby(@key, key, increment)
        end
      end

      def decr(key, increment: 1)
        return incr(key, -increment)
      end

      def to_h
        return self.connection.hgetall(@key)
      end

      def keys
        return self.connection.hkeys(@key)
      end

      def values
        return self.connection.hvals(@key)
      end

      def size
        return self.connection.hlen(@key)
{'fraction_non_alphanumeric': 0.09922375970300372, 'fraction_numerical': 0.0020249746878164025, 'mean_word_length': 1.9404761904761905, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7219590', 'n_tokens_mistral': 920, 'n_tokens_neox': 885, 'n_words': 222}