<commit_before>module ReQL
  struct Maxval
  end

  struct Minval
  end

  abstract struct AbstractValue
  end

  struct Datum < AbstractValue
  end

  abstract struct AbstractValue
    abstract def value : Type

    include Comparable(Object)

    alias Type = Array(Datum) | Set(Datum) | Bool | Float64 | Hash(String, Datum) | Int64 | Int32 | String | Nil | Maxval | Minval | Bytes | Time

    # Comparison

    def <=>(other : AbstractValue)
      self <=> other.value
    end

    def <=>(other)
      a = value
      b = other

      if type_order(a) != type_order(b)
        return type_order(a) <=> type_order(b)
      end

      a = a.to_a if a.is_a? Set
      b = b.to_a if b.is_a? Set

      case {a, b}
      when {Maxval, Maxval}  ; return 0
      when {Minval, Minval}  ; return 0
      when {Nil, Nil}        ; return 0
      when {String, String}  ; return a <=> b
      when {Float64, Float64}; return a <=> b
      when {Float64, Int64}  ; return a <=> b.to_f64
      when {Float64, Int32}  ; return a <=> b.to_f64
      when {Int64, Float64}  ; return a.to_f64 <=> b
      when {Int64, Int64}    ; return a <=> b
      when {Int64, Int32}    ; return a <=> b.to_i64
      when {Int32, Float64}  ; return a.to_f64 <=> b
      when {Int32, Int64}    ; return a.to_i64 <=> b
      when {Int32, Int32}    ; return a <=> b
      when {Time, Time}      ; return a <=> b
      when {Bool, Bool}
        return 0 if a == b
        return 1 if a && !b
        return -1
      when {Array, Array}
        a.each_with_index do |a_val, i|
          return 1 if i >= b.size
          cmp = a_val <=> b[i]<commit_msg>Fix comparison of NaNs. Assume they are equal for now, we need a strict ordering<commit_after>module ReQL
  struct Maxval
  end

  struct Minval
  end

  abstract struct AbstractValue
  end

  struct Datum < AbstractValue
  end

  abstract struct AbstractValue
    abstract def value : Type

    include Comparable(Object)

    alias Type = Array(Datum) | Set(Datum) | Bool | Float64 | Hash(String, Datum) | Int64 | Int32 | String | Nil | Maxval | Minval | Bytes | Time

    # Comparison

    def <=>(other : AbstractValue)
      self <=> other.value
    end

    def <=>(other) : Int32
      a = value
      b = other

      if type_order(a) != type_order(b)
        return type_order(a) <=> type_order(b)
      end

      a = a.to_a if a.is_a? Set
      b = b.to_a if b.is_a? Set

      case {a, b}
      when {Maxval, Maxval}  ; return 0
      when {Minval, Minval}  ; return 0
      when {Nil, Nil}        ; return 0
      when {String, String}  ; return a <=> b
      when {Float64, Float64}; return a <=> b || 0
      when {Float64, Int64}  ; return a <=> b.to_f64 || 0
      when {Float64, Int32}  ; return a <=> b.to_f64 || 0
      when {Int64, Float64}  ; return a.to_f64 <=> b || 0
      when {Int64, Int64}    ; return a <=> b
      when {Int64, Int32}    ; return a <=> b.to_i64
      when {Int32, Float64}  ; return a.to_f64 <=> b || 0
      when {Int32, Int64}    ; return a.to_i64 <=> b
      when {Int32, Int32}    ; return a <=> b
      when {Time, Time}      ; return a <=> b
      when {Bool, Bool}
        return 0 if a == b
        return 1 if a && !b
        return -1
      when {Array, Array}
        a.each_with_index do |a_val, i|
          return 1 if i >= b.size
          cmp = a_val <=> b[i]
{'fraction_non_alphanumeric': 0.11699581089168162, 'fraction_numerical': 0.03859964093357271, 'mean_word_length': 1.9955197132616487, 'pattern_counts': {'":': 0, '<': 37, '<?xml version=': 0, '>': 37, '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': '1348340', 'n_tokens_mistral': 1272, 'n_tokens_neox': 1163, 'n_words': 389}