<commit_before>class Cassandra
  class DynamicComposite < Composite
    attr_accessor :types

    def initialize(*parts)
      return if parts.empty?

      options = {}
      if parts.last.is_a?(Hash)
        options = parts.pop
      end
      @column_slice = options[:slice]
      raise ArgumentError if @column_slice != nil && ![:before, :after].include?(@column_slice)

      if parts.length == 1 && parts[0].instance_of?(self.class)
        @column_slice = parts[0].column_slice
        @parts = parts[0].parts
        @types = parts[0].types
      elsif parts.length == 1 && parts[0].instance_of?(String) && @column_slice.nil? && try_packed_composite(parts[0])
        @hash = parts[0].hash
      else
        @types, @parts = parts.transpose
      end
    end

    def pack
      packed_parts = @parts.map do |part|
        [part.length].pack('n') + part + "\x00"
      end

      if @column_slice
        part = @parts[-1]
        packed_parts[-1] = [part.length].pack('n') + part + slice_end_of_component
      end

      packed_types = @types.map do |type|
        if type.length == 1
          [0x8000 | type.ord].pack('n')<commit_msg>Fix for lacking String#ord on Ruby 1.8.<commit_after>class Cassandra
  class DynamicComposite < Composite
    attr_accessor :types

    def initialize(*parts)
      return if parts.empty?

      options = {}
      if parts.last.is_a?(Hash)
        options = parts.pop
      end
      @column_slice = options[:slice]
      raise ArgumentError if @column_slice != nil && ![:before, :after].include?(@column_slice)

      if parts.length == 1 && parts[0].instance_of?(self.class)
        @column_slice = parts[0].column_slice
        @parts = parts[0].parts
        @types = parts[0].types
      elsif parts.length == 1 && parts[0].instance_of?(String) && @column_slice.nil? && try_packed_composite(parts[0])
        @hash = parts[0].hash
      else
        @types, @parts = parts.transpose
      end
    end

    def pack
      packed_parts = @parts.map do |part|
        [part.length].pack('n') + part + "\x00"
      end

      if @column_slice
        part = @parts[-1]
        packed_parts[-1] = [part.length].pack('n') + part + slice_end_of_component
      end

      packed_types = @types.map do |type|
        if type.length == 1
          [0x8000 | type[0].ord].pack('n')
{'fraction_non_alphanumeric': 0.13560051657339647, 'fraction_numerical': 0.017649591046061126, 'mean_word_length': 2.3927007299270073, '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': '2471975', 'n_tokens_mistral': 758, 'n_tokens_neox': 734, 'n_words': 163}