# File lib/activerdf_rdflite/rdflite.rb, line 34
34:         def initialize(params = {})
35:                 $activerdflog.info "initialised rdflite with params #{params.to_s}"
36: 
37:                 @reads = true
38:                 @writes = true
39: 
40:                 # if no file-location given, we use in-memory store
41:                 file = params[:location] || ':memory:'
42:                 @db = SQLite3::Database.new(file) 
43: 
44:                 # disable keyword search by default, enable only if ferret is found
45:                 @keyword_search = params[:keyword].nil? ? false : params[:keyword]
46:                 @keyword_search &= @@have_ferret
47: 
48:                 @reasoning = params[:reasoning] || false
49: 
50:                 if keyword_search?
51:                         # we initialise the ferret index, either as a file or in memory
52:                         infos = Ferret::Index::FieldInfos.new
53: 
54:                         # we setup the fields not to store object's contents
55:                         infos.add_field(:subject, :store => :yes, :index => :no, :term_vector => :no)
56:                         infos.add_field(:object, :store => :no) #, :index => :omit_norms)
57: 
58:                         @ferret = if params[:location]
59:                                                                         Ferret::I.new(:path => params[:location] + '.ferret', :field_infos => infos)
60:                                                                 else
61:                                                                         Ferret::I.new(:field_infos => infos)
62:                                                                 end
63:                 end
64: 
65:                 # turn off filesystem synchronisation for speed
66:                 @db.synchronous = 'off'
67: 
68:                 # create triples table. ignores duplicated triples
69:                 @db.execute('create table if not exists triple(s,p,o,c, unique(s,p,o,c) on conflict ignore)')
70: 
71:                 create_indices(params)
72:                 @db
73:         end