class ActiveRecord::Base

Public Class Methods

bulk_insert(columns, data) click to toggle source
# File lib/arjdbc/vertica/adapter.rb, line 15
def self.bulk_insert(columns, data)
  connection.bulk_insert(self.table_name, self.primary_key, self.sequence_name, columns, data)
end
bulk_insert_records(*records) click to toggle source
# File lib/arjdbc/vertica/adapter.rb, line 19
def self.bulk_insert_records(*records)
  records.flatten!
  data = []
  column_names_without_id = column_names.reject { |name| name == self.primary_key }

  records.each do |record|
    values = []
    column_names_without_id.each do |column_name|
      if ::ArJdbc::Vertica::TIMESTAMP_COLUMNS.include?("#{column_name}")
        # Set the Timestampt if it is not already set
        values << (record.__send__("#{column_name}") || ::ArJdbc::Vertica.current_time)
      else
        values << record.__send__("#{column_name}")
      end
    end
    data << values
  end

  bulk_insert(column_names_without_id, data)
end
jdbcvertica5_connection(config)
Alias for: vertica5_connection
jdbcvertica6_connection(config)
Alias for: vertica5_connection
jdbcvertica7_connection(config)
Alias for: vertica5_connection
jdbcvertica8_connection(config)
Alias for: vertica5_connection
parse_port_from_host(host) click to toggle source
# File lib/arjdbc/vertica/connection_methods.rb, line 2
def self.parse_port_from_host(host)
  # looking for vertica_host_1:2098
  return nil unless host.include?(":")
  host.split(":").last
end
sequence_name() click to toggle source
# File lib/arjdbc/vertica/adapter.rb, line 11
def self.sequence_name
  "#{self.table_name}_#{self.primary_key || 'id'}_seq"
end
trim_port_from_host(host) click to toggle source
# File lib/arjdbc/vertica/connection_methods.rb, line 8
def self.trim_port_from_host(host)
  return host unless host.include?(":")
  host_parts = host.split(":")
  host_parts.pop
  host_parts.join(":")
end
vertica5_connection(config) click to toggle source
# File lib/arjdbc/vertica/connection_methods.rb, line 15
def self.vertica5_connection(config)
  current_host = nil
  current_port = nil

  if config[:hosts] && config[:hosts].is_a?(Array)
    current_host = config[:hosts].sample
    current_port = parse_port_from_host(current_host)
    current_host = trim_port_from_host(current_host)
  end

  current_host ||= config[:host]
  current_port ||= config[:port]
  config[:url] = "jdbc:vertica://#{current_host}:#{current_port}/#{config[:database]}"
  config[:driver] = "com.vertica.jdbc.Driver"
  config[:prepared_statements] = false
  config[:connection_alive_sql] = "SELECT 1;"
  config[:adapter_class] = ::ActiveRecord::ConnectionAdapters::VerticaAdapter

  jdbc_connection(config)
end
vertica6_connection(config)
Alias for: vertica5_connection
vertica7_connection(config)
Alias for: vertica5_connection
vertica8_connection(config)

connection methods should be the same

Alias for: vertica5_connection