<commit_before>require 'dry-equalizer'

require 'rom/schema/attribute'
require 'rom/schema/dsl'
require 'rom/association_set'

module ROM
  # Relation schema
  #
  # Schemas hold detailed information about relation tuples, including their
  # primitive types (String, Integer, Hash, etc. or custom classes), as well as
  # various meta information like primary/foreign key and literally any other
  # information that a given database adapter may need.
  #
  # Adapters can extend this class and it can be used in adapter-specific relations.
  # In example rom-sql extends schema with Association DSL and many additional
  # SQL-specific APIs in schema types.
  #
  # Schemas are used for projecting canonical relations into other relations and
  # every relation object maintains its schema. This means that we always have
  # all information about relation tuples, even when a relation was projected and
  # diverged from its canonical form.
  #
  # Furthermore schema attributes know their source relations, which makes it
  # possible to merge schemas from multiple relations and maintain information
  # about the source relations. In example when two relations are joined, their
  # schemas are merged, and we know which attributes belong to which relation.
  #
  # @api public
  class Schema
    EMPTY_ASSOCIATION_SET = AssociationSet.new(EMPTY_HASH).freeze

    DEFAULT_INFERRER = proc { [EMPTY_ARRAY, EMPTY_ARRAY].freeze }

    MissingAttributesError = Class.new(StandardError) do
      def initialize(name, attributes)
        super("missing attributes in #{name.inspect} schema: #{attributes.map(&:inspect).join(', ')}")
      end
    end

    AttributeAlreadyDefinedError = Class.new(StandardError)

    include Dry::Equalizer(:name, :attributes)
    include Enumerable

    attr_reader :name, :attributes, :inferrer, :associations_dsl


    include Dry::Equalizer(:name, :attributes, :associations)
    include Enumerable

    # @!attribute [r] name
    #   @return [Symbol] The name of this schema
    attr_reader :name

    # @!attribute [r] attributes
    #   @return [Array] Array with schema attributes
    attr_reader :attributes

    # @!attribute [r] associations
    #   @return [AssociationSet] Optional association set (this is adapter-specific)
    attr_reader :associations

    # @!attribute [r] inferrer
    #   @return [#call] An optional inferrer object used in `finalize!`
    attr_reader :inferrer
<commit_msg>Remove redundant code from schema<commit_after>require 'dry-equalizer'

require 'rom/schema/attribute'
require 'rom/schema/dsl'
require 'rom/association_set'

module ROM
  # Relation schema
  #
  # Schemas hold detailed information about relation tuples, including their
  # primitive types (String, Integer, Hash, etc. or custom classes), as well as
  # various meta information like primary/foreign key and literally any other
  # information that a given database adapter may need.
  #
  # Adapters can extend this class and it can be used in adapter-specific relations.
  # In example rom-sql extends schema with Association DSL and many additional
  # SQL-specific APIs in schema types.
  #
  # Schemas are used for projecting canonical relations into other relations and
  # every relation object maintains its schema. This means that we always have
  # all information about relation tuples, even when a relation was projected and
  # diverged from its canonical form.
  #
  # Furthermore schema attributes know their source relations, which makes it
  # possible to merge schemas from multiple relations and maintain information
  # about the source relations. In example when two relations are joined, their
  # schemas are merged, and we know which attributes belong to which relation.
  #
  # @api public
  class Schema
    EMPTY_ASSOCIATION_SET = AssociationSet.new(EMPTY_HASH).freeze

    DEFAULT_INFERRER = proc { [EMPTY_ARRAY, EMPTY_ARRAY].freeze }

    MissingAttributesError = Class.new(StandardError) do
      def initialize(name, attributes)
        super("missing attributes in #{name.inspect} schema: #{attributes.map(&:inspect).join(', ')}")
      end
    end

    AttributeAlreadyDefinedError = Class.new(StandardError)

    include Dry::Equalizer(:name, :attributes, :associations)
    include Enumerable

    # @!attribute [r] name
    #   @return [Symbol] The name of this schema
    attr_reader :name

    # @!attribute [r] attributes
    #   @return [Array] Array with schema attributes
    attr_reader :attributes

    # @!attribute [r] associations
    #   @return [AssociationSet] Optional association set (this is adapter-specific)
    attr_reader :associations

    # @!attribute [r] inferrer
    #   @return [#call] An optional inferrer object used in `finalize!`
    attr_reader :inferrer

{'fraction_non_alphanumeric': 0.0721779269827948, 'fraction_numerical': 0.0, 'mean_word_length': 3.9144329896907215, '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': '4082605', 'n_tokens_mistral': 1289, 'n_tokens_neox': 1241, 'n_words': 506}