<commit_before># -- coding: utf-8

require "logger"
require "cgi"
require "socket"
require "base64"
require "net/http"
require "kyototycoon/serializer.rb"
require "kyototycoon/serializer/default.rb"
require "kyototycoon/serializer/msgpack.rb"
require "kyototycoon/tsvrpc.rb"
require "kyototycoon/tsvrpc/skinny.rb"

class KyotoTycoon
  attr_accessor :colenc, :connect_timeout, :servers
  attr_reader :serializer, :logger, :db

  DEFAULT_HOST = '0.0.0.0'
  DEFAULT_PORT = 1978

  def self.configure(name, host=DEFAULT_HOST, port=DEFAULT_PORT, &block)
    @configure ||= {}
    if @configure[name]
      raise "'#{name}' is registered"
    end
    @configure[name] = lambda{
      kt = KyotoTycoon.new(host, port)
      block.call(kt)
      kt
    }
  end
  
  def self.create(name)
    if @configure[name].nil?
      raise "undefined configure: '#{name}'"
    end
    @configure[name].call
  end

  def initialize(host=DEFAULT_HOST, port=DEFAULT_PORT)
    @servers = [[host, port]]
    @serializer = KyotoTycoon::Serializer::Default
    @logger = Logger.new(nil)
    @colenc = :U
    @connect_timeout = 0.5
  end

  def serializer= (adaptor=:default)
    klass = KyotoTycoon::Serializer.get(adaptor)
    @serializer = klass
  end

  def db= (db)
    @db = db
  end

  def logger= (logger)
    if logger.class != Logger
      logger = Logger.new(logger)
    end
    @logger = logger
  end<commit_msg>default KT#colenc is :B(base64 encoding)<commit_after># -- coding: utf-8

require "logger"
require "cgi"
require "socket"
require "base64"
require "net/http"
require "kyototycoon/serializer.rb"
require "kyototycoon/serializer/default.rb"
require "kyototycoon/serializer/msgpack.rb"
require "kyototycoon/tsvrpc.rb"
require "kyototycoon/tsvrpc/skinny.rb"

class KyotoTycoon
  attr_accessor :colenc, :connect_timeout, :servers
  attr_reader :serializer, :logger, :db

  DEFAULT_HOST = '0.0.0.0'
  DEFAULT_PORT = 1978

  def self.configure(name, host=DEFAULT_HOST, port=DEFAULT_PORT, &block)
    @configure ||= {}
    if @configure[name]
      raise "'#{name}' is registered"
    end
    @configure[name] = lambda{
      kt = KyotoTycoon.new(host, port)
      block.call(kt)
      kt
    }
  end
  
  def self.create(name)
    if @configure[name].nil?
      raise "undefined configure: '#{name}'"
    end
    @configure[name].call
  end

  def initialize(host=DEFAULT_HOST, port=DEFAULT_PORT)
    @servers = [[host, port]]
    @serializer = KyotoTycoon::Serializer::Default
    @logger = Logger.new(nil)
    @colenc = :B
    @connect_timeout = 0.5
  end

  def serializer= (adaptor=:default)
    klass = KyotoTycoon::Serializer.get(adaptor)
    @serializer = klass
  end

  def db= (db)
    @db = db
  end

  def logger= (logger)
    if logger.class != Logger
      logger = Logger.new(logger)
    end
    @logger = logger
  end
{'fraction_non_alphanumeric': 0.12690535271180434, 'fraction_numerical': 0.009925558312655087, 'mean_word_length': 3.458135860979463, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '7417041', 'n_tokens_mistral': 1051, 'n_tokens_neox': 1016, 'n_words': 223}