<commit_before>module Cequel

  #
  # Handle to a Cassandra keyspace.
  #
  class Keyspace

    #
    # @api private
    # @see Cequel.connect
    #
    def initialize(configuration={})
      configure(configuration)
    end

    def connection=(connection)
      @connection = connection
    end

    def configure(configuration = {})
      @configuration = configuration
      @hosts = configuration[:host] || configuration[:hosts]
      @thrift_options = configuration[:thrift].try(:symbolize_keys) || {}
      @keyspace = configuration[:keyspace]
      # reset the connections
      clear_active_connections!
    end

    def logger=(logger)
      @logger = logger
    end

    def logger
      @logger
    end

    def slowlog=(slowlog)
      @slowlog = slowlog
    end

    def slowlog
      @slowlog
    end

    def slowlog_threshold=(slowlog_threshold)
      @slowlog_threshold = slowlog_threshold
    end

    def slowlog_threshold
      @slowlog_threshold
    end

    def connection_pool
      return @connection_pool if defined? @connection_pool
      if @configuration[:pool]
        options = {
          :size => configuration[:pool],
          :timeout => configuration[:pool_timeout]
        }
        @connection_pool = ConnectionPool.new(:size => 10, :timeout => 5) do
          build_connection
        end
      else
        @connection_pool = nil
      end
    end

    def connection
      @connection ||= build_connection
    end

    def clear_active_connections!
      remove_instance_variable(:@connection) if defined? @connection
      remove_instance_variable(:@connection_pool) if defined? @connection_pool<commit_msg>use parameters for pooling<commit_after>module Cequel

  #
  # Handle to a Cassandra keyspace.
  #
  class Keyspace

    #
    # @api private
    # @see Cequel.connect
    #
    def initialize(configuration={})
      configure(configuration)
    end

    def connection=(connection)
      @connection = connection
    end

    def configure(configuration = {})
      @configuration = configuration
      @hosts = configuration[:host] || configuration[:hosts]
      @thrift_options = configuration[:thrift].try(:symbolize_keys) || {}
      @keyspace = configuration[:keyspace]
      # reset the connections
      clear_active_connections!
    end

    def logger=(logger)
      @logger = logger
    end

    def logger
      @logger
    end

    def slowlog=(slowlog)
      @slowlog = slowlog
    end

    def slowlog
      @slowlog
    end

    def slowlog_threshold=(slowlog_threshold)
      @slowlog_threshold = slowlog_threshold
    end

    def slowlog_threshold
      @slowlog_threshold
    end

    def connection_pool
      return @connection_pool if defined? @connection_pool
      if @configuration[:pool]
        options = {
          :size => @configuration[:pool] || 10,
          :timeout => @configuration[:pool_timeout] || 5
        }
        @connection_pool = ConnectionPool.new(options) do
          build_connection
        end
      else
        @connection_pool = nil
      end
    end

    def connection
      @connection ||= build_connection
    end

    def clear_active_connections!
      remove_instance_variable(:@connection) if defined? @connection
      remove_instance_variable(:@connection_pool) if defined? @connection_pool
{'fraction_non_alphanumeric': 0.08139183055975795, 'fraction_numerical': 0.001815431164901664, 'mean_word_length': 2.5358288770053474, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '7183527', 'n_tokens_mistral': 927, 'n_tokens_neox': 877, 'n_words': 215}