<commit_before>require 'pstore'

module Moneta
  module Adapters
    class PStore < ::PStore
      include Moneta::Defaults

      def initialize(options = {})
        options[:path] ||= File.join Dir.pwd, 'data.pstore'
        super options[:path]
      end

      def key?(key)
        transaction do
          @table.key? key_for(key)
        end
      end

      def [](key)
        transaction true do
          struct = super key_for(key)
          struct ? struct['value'] : nil
        end
      end

      def delete(key)
        struct = if @transaction
          super key_for(key)
        else
          transaction do
            super key_for(key)
          end
        end
        struct ? struct['value'] : nil
      end<commit_msg>Using PStore's built-in methods for ketting keys<commit_after>require 'pstore'

module Moneta
  module Adapters
    class PStore < ::PStore
      include Moneta::Defaults

      def initialize(options = {})
        options[:path] ||= File.join Dir.pwd, 'data.pstore'
        super options[:path]
      end

      def key?(key)
        transaction do
          root? key_for(key)
        end
      end

      def keys
        transaction true do
          roots
        end
      end

      def [](key)
        transaction true do
          struct = super key_for(key)
          struct ? struct['value'] : nil
        end
      end

      def delete(key)
        struct = if @transaction
          super key_for(key)
        else
          transaction do
            super key_for(key)
          end
        end
        struct ? struct['value'] : nil
      end
{'fraction_non_alphanumeric': 0.08089607965152458, 'fraction_numerical': 0.0, 'mean_word_length': 1.5443037974683544, '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': '6788970', 'n_tokens_mistral': 454, 'n_tokens_neox': 442, 'n_words': 131}