def initialize(connect_type=:local, host=nil, port=nil, path='./',
ext='.tbl', memo_blob_path='./', delay_index_creation=false)
@connect_type = connect_type
@host = host
@port = port
@path = path
@ext = ext
@memo_blob_path = memo_blob_path
@delay_index_creation = delay_index_creation
yield self if block_given?
class << self
private(:connect_type=, :host=, :path=, :ext=, :memo_blob_path=,
:delay_index_creation=)
end
raise ArgumentError, 'Invalid connection type specified' unless (
[:local, :client, :server].include?(@connect_type))
raise "Must specify hostname or IP address!" if \
@connect_type == :client and @host.nil?
raise "Must specify port number!" if @connect_type == :client and \
@port.nil?
raise "Invalid path!" if @path.nil?
raise "Invalid extension!" if @ext.nil?
raise "Invalid memo/blob path!" if @memo_blob_path.nil?
@table_hash = {}
if client?
DRb.start_service()
@server = DRbObject.new(nil, 'druby://%s:%d' % [@host, @port])
@engine = @server.engine
@path = @server.path
@ext = @server.ext
@memo_blob_path = @server.memo_blob_path
else
@engine = KBEngine.create_called_from_database_instance(self)
end
if @delay_index_creation
else
@engine.tables.each do |tbl|
@table_hash[tbl] = \
KBTable.create_called_from_database_instance(self, tbl,
File.join(@path, tbl.to_s + @ext))
end
end
end