<commit_before># encoding: utf-8

module CassandraMigrations
  class Migration

    # Used to define a table in a migration of table creation or to
    # add columns to an existing table.
    #
    # An instance of this class is passed to the block of the method
    # +create_table+, available on every migration.
    #
    # This class is also internally used in the method +add_column+.
    
    class TableDefinition

      def initialize()
        @columns_name_type_hash = {}
        @primary_keys = []
      end
      
      def to_create_cql
        cql = []

        if !@columns_name_type_hash.empty?
          @columns_name_type_hash.each do |column_name, type|
            cql << "#{column_name} #{type}"
          end
        else
          raise Errors::MigrationDefinitionError, 'No columns defined for table.'
        end

        if !@primary_keys.empty?
          cql << "PRIMARY KEY(#{@primary_keys.join(', ')})"
        else
          raise Errors::MigrationDefinitionError, 'No primary key defined.'
        end
        
        cql.join(', ')
      end
      
      def to_add_column_cql
        cql = ""

        if @columns_name_type_hash.size == 1
          cql = "#{@columns_name_type_hash.keys.first} #{@columns_name_type_hash.values.first}"
        elsif @columns_name_type_hash.empty?
          raise Errors::MigrationDefinitionError, 'No column to add.'
        else
          raise Errors::MigrationDefinitionError, 'Only one column can be added at once.'
        end
        
        cql
      end
      
      def boolean(column_name, options={})
        @columns_name_type_hash[column_name.to_sym] = column_type_for(:boolean, options)
        define_primary_keys(column_name) if options[:primary_key]
      end
      
      def integer(column_name, options={})
        @columns_name_type_hash[column_name.to_sym] = column_type_for(:integer, options) 
        define_primary_keys(column_name) if options[:primary_key]
      end
      
      def float(column_name, options={})
        @columns_name_type_hash[column_name.to_sym] = column_type_for(:float, options) <commit_msg>Added C* double column type<commit_after># encoding: utf-8

module CassandraMigrations
  class Migration

    # Used to define a table in a migration of table creation or to
    # add columns to an existing table.
    #
    # An instance of this class is passed to the block of the method
    # +create_table+, available on every migration.
    #
    # This class is also internally used in the method +add_column+.
    
    class TableDefinition

      def initialize()
        @columns_name_type_hash = {}
        @primary_keys = []
      end
      
      def to_create_cql
        cql = []

        if !@columns_name_type_hash.empty?
          @columns_name_type_hash.each do |column_name, type|
            cql << "#{column_name} #{type}"
          end
        else
          raise Errors::MigrationDefinitionError, 'No columns defined for table.'
        end

        if !@primary_keys.empty?
          cql << "PRIMARY KEY(#{@primary_keys.join(', ')})"
        else
          raise Errors::MigrationDefinitionError, 'No primary key defined.'
        end
        
        cql.join(', ')
      end
      
      def to_add_column_cql
        cql = ""

        if @columns_name_type_hash.size == 1
          cql = "#{@columns_name_type_hash.keys.first} #{@columns_name_type_hash.values.first}"
        elsif @columns_name_type_hash.empty?
          raise Errors::MigrationDefinitionError, 'No column to add.'
        else
          raise Errors::MigrationDefinitionError, 'Only one column can be added at once.'
        end
        
        cql
      end
      
      def boolean(column_name, options={})
        @columns_name_type_hash[column_name.to_sym] = column_type_for(:boolean, options)
        define_primary_keys(column_name) if options[:primary_key]
      end
      
      def integer(column_name, options={})
        @columns_name_type_hash[column_name.to_sym] = column_type_for(:integer, options) 
        define_primary_keys(column_name) if options[:primary_key]
      end
      
      def float(column_name, options={})
        @columns_name_type_hash[column_name.to_sym] = column_type_for(:float, options) 
        define_primary_keys(column_name) if options[:primary_key]
      end
      
      def double(column_name, options={})
        options[:limit] = 8
        @columns_name_type_hash[column_name.to_sym] = column_type_for(:float, options) 
{'fraction_non_alphanumeric': 0.08745247148288973, 'fraction_numerical': 0.0011183180496533215, 'mean_word_length': 2.398176291793313, 'pattern_counts': {'":': 0, '<': 11, '<?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': '4736030', 'n_tokens_mistral': 1327, 'n_tokens_neox': 1308, 'n_words': 326}