<commit_before>require 'sequel'

module EQ::QueueAdapter
  class SequelAdapter
    module Decorator
      def size
        db[:jobs].count
      end
    end
    include Decorator

    attr_reader :db
    def initialize
      @db = Sequel.sqlite
      create_table_if_not_exists!
    end

    def push payload
      db[:jobs].insert :payload => payload.to_sequel_blob
    end

    def pop
      db.transaction do
        job = db[:jobs].order(:id.desc).limit(1).first
        if job
          db[:jobs].where(:id => job[:id]).delete
          job[:payload]
        end
      end
    end

  private

    def create_table_if_not_exists!
      db.create_table? :jobs do
        primary_key :id
        Blob :payload
      end
    end
  end
end<commit_msg>enhanced sequel adapter<commit_after>require 'sequel'

module EQ::QueueAdapter
  class SequelAdapter
    module Decorator
      def size
        db[:jobs].count
      end
    end
    include Decorator

    attr_reader :db
    def initialize
      @db = Sequel.sqlite
      create_table_if_not_exists!
    end

    def push payload
      db[:jobs].insert :payload => payload.to_sequel_blob
    end

    # TODO this must be a lock & delete, not a pop!!
    def pop
      db.transaction do
        job = db[:jobs].order(:id.desc).limit(1).first
        if job
          db[:jobs].where(:id => job[:id]).delete
          job[:payload]
        end
      end
    end

  private

    def create_table_if_not_exists!
      db.create_table? :jobs do
        primary_key :id
        Blob :payload
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.07987220447284345, 'fraction_numerical': 0.0012779552715654952, 'mean_word_length': 1.9603024574669188, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6068195', 'n_tokens_mistral': 505, 'n_tokens_neox': 478, 'n_words': 127}