<commit_before>
var util = require('util'),
    thrift = require('helenus-thrift'),
    Cassandra = require('./cassandra/Cassandra'),
    ttype = require('./cassandra/cassandra_types'),
    Row = require('./row'),
    zlib = require('zlib'),
    Keyspace = require('./keyspace');

/**
 * A No-Operation function for default callbacks
 * @private
 * @constant
 * @memberOf Connection
 */
var NOOP = function(){};

/**
 * Default port for cassandra
 * @private
 * @constant
 * @memberOf Connection
 */
var DEFAULT_PORT = 9160;

/**
 * Default host
 * @private
 * @constant
 * @memberOf Connection
 */
var DEFAULT_HOST = 'localhost';

/**
 * Default Timeout
 * @private
 * @constant
 * @memberOf Connection
 */
var DEFAULT_TIMEOUT = 4000;

/**
 * Creates a JS Error from a Cassndra Error
 * @param {Object} err The cassandra error eg: { name:'Exception', why:'Some Reason' }
 * @private
 * @memberOf Connection
 */
function createError(err){
  //sometimes the message comes back as the field why and sometimes as the field message
  var error = new Error(err.why || err.message);
  error.name = 'Helenus' + err.name;
  Error.captureStackTrace(error, createError);
  return error;
}

/**
 * Escapes a string as required by CQL
 * @param {String} str
 * @private
 * @memberOf Connection
 * @returns {String} The sanitized string
 */
function cqlEscape(str){
  if(str instanceof Buffer){
    return str.toString('hex');
  } else {
    return str.toString().replace(/\'/img, '\'\'');
  }
}

/**
 * The Cassandra Connection
 *
 * @param {Object} options The options for the connection defaults to:
     {
       port: 9160,
       host: 'localhost'
       user: null,
       password: <PASSWORD>,
       keyspace: null,
       timeout: 1000
     }
 * @constructor
 * @exec
 */
var Connection = function(options){
  if(!options.port && options.host && options.host.indexOf(':') > -1){
    var split = options.host.split(':');
    options.host = split[0];
    options.port = split[1];
  }

  /**
   * The port to connect to
   * @default 9160
   */
  this.port = options.port || DEFAULT_PORT;

  /**
   * The host to connect to
   * @default localhost
   */
  this.host = options.host || DEFAULT_HOST;

  /**
   * The timeout for the connection
   * @default 3000
   */
  this.timeout = options.timeout || DEFAULT_TIMEOUT;

  /**
  * The username to authenticate with
  */
  this.user = options.user;

  /**
   * The password to connect with
   */
  this.password = <PASSWORD>;

  /**
   * The keyspace to authenticate to
   */
  this.keyspace = options.keyspace;

  /**
   * The CQL version.
  *
   * - Cassandra 1.0 supports CQL 2.0.0
   * - Cassandra 1.1 supports CQL 2.0.0 and 3.0.0 (with 2.0.0 the default)
   * - Cassandra 1.2 will have CQL 3.0.0 as the default
   *
   * Cassandra will support choosing the CQL version for a while,
   * @see https://issues.apache.org/jira/browse/CASSANDRA-3990
   */
  this.cqlVersion = options.cqlVersion;
<commit_msg>Set CQL version explicitly and always<commit_after>
var util = require('util'),
    thrift = require('helenus-thrift'),
    Cassandra = require('./cassandra/Cassandra'),
    ttype = require('./cassandra/cassandra_types'),
    Row = require('./row'),
    zlib = require('zlib'),
    Keyspace = require('./keyspace');

/**
 * A No-Operation function for default callbacks
 * @private
 * @constant
 * @memberOf Connection
 */
var NOOP = function(){};

/**
 * Default port for cassandra
 * @private
 * @constant
 * @memberOf Connection
 */
var DEFAULT_PORT = 9160;

/**
 * Default host
 * @private
 * @constant
 * @memberOf Connection
 */
var DEFAULT_HOST = 'localhost';

/**
 * Default Timeout
 * @private
 * @constant
 * @memberOf Connection
 */
var DEFAULT_TIMEOUT = 4000;

/**
 * Creates a JS Error from a Cassndra Error
 * @param {Object} err The cassandra error eg: { name:'Exception', why:'Some Reason' }
 * @private
 * @memberOf Connection
 */
function createError(err){
  //sometimes the message comes back as the field why and sometimes as the field message
  var error = new Error(err.why || err.message);
  error.name = 'Helenus' + err.name;
  Error.captureStackTrace(error, createError);
  return error;
}

/**
 * Escapes a string as required by CQL
 * @param {String} str
 * @private
 * @memberOf Connection
 * @returns {String} The sanitized string
 */
function cqlEscape(str){
  if(str instanceof Buffer){
    return str.toString('hex');
  } else {
    return str.toString().replace(/\'/img, '\'\'');
  }
}

/**
 * The Cassandra Connection
 *
 * @param {Object} options The options for the connection defaults to:
     {
       port: 9160,
       host: 'localhost'
       user: null,
       password: <PASSWORD>,
       keyspace: null,
       timeout: 1000
     }
 * @constructor
 * @exec
 */
var Connection = function(options){
  if(!options.port && options.host && options.host.indexOf(':') > -1){
    var split = options.host.split(':');
    options.host = split[0];
    options.port = split[1];
  }

  /**
   * The port to connect to
   * @default 9160
   */
  this.port = options.port || DEFAULT_PORT;

  /**
   * The host to connect to
   * @default localhost
   */
  this.host = options.host || DEFAULT_HOST;

  /**
   * The timeout for the connection
   * @default 3000
   */
  this.timeout = options.timeout || DEFAULT_TIMEOUT;

  /**
  * The username to authenticate with
  */
  this.user = options.user;

  /**
   * The password to connect with
   */
  this.password = <PASSWORD>;

  /**
   * The keyspace to authenticate to
   */
  this.keyspace = options.keyspace;

  /**
   * The CQL version.
  *
   * - Cassandra 1.0 supports CQL 2.0.0
   * - Cassandra 1.1 supports CQL 2.0.0 and 3.0.0 (with 2.0.0 the default)
   * - Cassandra 1.2 will have CQL 3.0.0 as the default
   *
   * Cassandra will support choosing the CQL version for a while,
   * @see https://issues.apache.org/jira/browse/CASSANDRA-3990
   */
  this.cqlVersion = options.cqlVersion || '2.0.0';

{'fraction_non_alphanumeric': 0.14153327716933445, 'fraction_numerical': 0.018028643639427126, 'mean_word_length': 2.89501312335958, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 2, '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': '609277', 'n_tokens_mistral': 1976, 'n_tokens_neox': 1881, 'n_words': 546}