<commit_before>module DataObjects
  # Abstract class to read rows from a query result
  class Reader

    include Enumerable

    ##
    # Returns the array of field names
    #
    # Note, that relational databases may use upper case identifiers internally,
    # but that field names should always be downcased by Driver implementations.
    #
    # @return [Array<String>] the field names (in lower case)
    def fields
      raise NotImplementedError.new
    end

    ##
    # Returns the array of field values for the current row.
    #
    # Not legal after next! has returned false or before it's been called
    #
    # @return [Array] the values for the current row
    def values
      raise NotImplementedError.new
    end

    # Close the reader discarding any unread results.
    def close
      raise NotImplementedError.new
    end

    # Discard the current row (if any) and read the next one (returning true), or return nil if there is no further row.
    def next!
      raise NotImplementedError.new
    end

    # Return the number of fields in the result set.
    def field_count
      raise NotImplementedError.new
    end

    # Yield each row to the given block as a Hash
    def each
      begin
        while next!
          yield Hash[*fields.zip(values).flatten]
        end
      ensure
        close
      end
      self
    end

  end
end<commit_msg>Removed Hash[] idiom for creating row Hash for Reader#each<commit_after>module DataObjects
  # Abstract class to read rows from a query result
  class Reader

    include Enumerable

    ##
    # Returns the array of field names
    #
    # Note, that relational databases may use upper case identifiers internally,
    # but that field names should always be downcased by Driver implementations.
    #
    # @return [Array<String>] the field names (in lower case)
    def fields
      raise NotImplementedError.new
    end

    ##
    # Returns the array of field values for the current row.
    #
    # Not legal after next! has returned false or before it's been called
    #
    # @return [Array] the values for the current row
    def values
      raise NotImplementedError.new
    end

    # Close the reader discarding any unread results.
    def close
      raise NotImplementedError.new
    end

    # Discard the current row (if any) and read the next one (returning true), or return nil if there is no further row.
    def next!
      raise NotImplementedError.new
    end

    # Return the number of fields in the result set.
    def field_count
      raise NotImplementedError.new
    end

    # Yield each row to the given block as a Hash
    def each
      begin
        while next!
          row = {}
          fields.each_with_index { |field, index| row[field] = values[index] }
          yield row
        end
      ensure
        close
      end
      self
    end

  end
end
{'fraction_non_alphanumeric': 0.04591304347826087, 'fraction_numerical': 0.0, 'mean_word_length': 2.2793614595210947, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '5310898', 'n_tokens_mistral': 786, 'n_tokens_neox': 749, 'n_words': 349}